babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722
  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. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  410. * @param num the number to convert and pad
  411. * @param length the expected length of the string
  412. * @returns the padded string
  413. */
  414. static PadNumber(num: number, length: number): string;
  415. }
  416. }
  417. declare module "babylonjs/Misc/deepCopier" {
  418. /**
  419. * Class containing a set of static utilities functions for deep copy.
  420. */
  421. export class DeepCopier {
  422. /**
  423. * Tries to copy an object by duplicating every property
  424. * @param source defines the source object
  425. * @param destination defines the target object
  426. * @param doNotCopyList defines a list of properties to avoid
  427. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  428. */
  429. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  430. }
  431. }
  432. declare module "babylonjs/Misc/precisionDate" {
  433. /**
  434. * Class containing a set of static utilities functions for precision date
  435. */
  436. export class PrecisionDate {
  437. /**
  438. * Gets either window.performance.now() if supported or Date.now() else
  439. */
  440. static get Now(): number;
  441. }
  442. }
  443. declare module "babylonjs/Misc/devTools" {
  444. /** @hidden */
  445. export class _DevTools {
  446. static WarnImport(name: string): string;
  447. }
  448. }
  449. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  450. /**
  451. * Interface used to define the mechanism to get data from the network
  452. */
  453. export interface IWebRequest {
  454. /**
  455. * Returns client's response url
  456. */
  457. responseURL: string;
  458. /**
  459. * Returns client's status
  460. */
  461. status: number;
  462. /**
  463. * Returns client's status as a text
  464. */
  465. statusText: string;
  466. }
  467. }
  468. declare module "babylonjs/Misc/webRequest" {
  469. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  470. import { Nullable } from "babylonjs/types";
  471. /**
  472. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  473. */
  474. export class WebRequest implements IWebRequest {
  475. private _xhr;
  476. /**
  477. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  478. * i.e. when loading files, where the server/service expects an Authorization header
  479. */
  480. static CustomRequestHeaders: {
  481. [key: string]: string;
  482. };
  483. /**
  484. * Add callback functions in this array to update all the requests before they get sent to the network
  485. */
  486. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  487. private _injectCustomRequestHeaders;
  488. /**
  489. * Gets or sets a function to be called when loading progress changes
  490. */
  491. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  492. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  493. /**
  494. * Returns client's state
  495. */
  496. get readyState(): number;
  497. /**
  498. * Returns client's status
  499. */
  500. get status(): number;
  501. /**
  502. * Returns client's status as a text
  503. */
  504. get statusText(): string;
  505. /**
  506. * Returns client's response
  507. */
  508. get response(): any;
  509. /**
  510. * Returns client's response url
  511. */
  512. get responseURL(): string;
  513. /**
  514. * Returns client's response as text
  515. */
  516. get responseText(): string;
  517. /**
  518. * Gets or sets the expected response type
  519. */
  520. get responseType(): XMLHttpRequestResponseType;
  521. set responseType(value: XMLHttpRequestResponseType);
  522. /** @hidden */
  523. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  524. /** @hidden */
  525. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  526. /**
  527. * Cancels any network activity
  528. */
  529. abort(): void;
  530. /**
  531. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  532. * @param body defines an optional request body
  533. */
  534. send(body?: Document | BodyInit | null): void;
  535. /**
  536. * Sets the request method, request URL
  537. * @param method defines the method to use (GET, POST, etc..)
  538. * @param url defines the url to connect with
  539. */
  540. open(method: string, url: string): void;
  541. /**
  542. * Sets the value of a request header.
  543. * @param name The name of the header whose value is to be set
  544. * @param value The value to set as the body of the header
  545. */
  546. setRequestHeader(name: string, value: string): void;
  547. /**
  548. * Get the string containing the text of a particular header's value.
  549. * @param name The name of the header
  550. * @returns The string containing the text of the given header name
  551. */
  552. getResponseHeader(name: string): Nullable<string>;
  553. }
  554. }
  555. declare module "babylonjs/Misc/fileRequest" {
  556. import { Observable } from "babylonjs/Misc/observable";
  557. /**
  558. * File request interface
  559. */
  560. export interface IFileRequest {
  561. /**
  562. * Raised when the request is complete (success or error).
  563. */
  564. onCompleteObservable: Observable<IFileRequest>;
  565. /**
  566. * Aborts the request for a file.
  567. */
  568. abort: () => void;
  569. }
  570. }
  571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  572. /**
  573. * Define options used to create a render target texture
  574. */
  575. export class RenderTargetCreationOptions {
  576. /**
  577. * Specifies is mipmaps must be generated
  578. */
  579. generateMipMaps?: boolean;
  580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  581. generateDepthBuffer?: boolean;
  582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  583. generateStencilBuffer?: boolean;
  584. /** Defines texture type (int by default) */
  585. type?: number;
  586. /** Defines sampling mode (trilinear by default) */
  587. samplingMode?: number;
  588. /** Defines format (RGBA by default) */
  589. format?: number;
  590. }
  591. }
  592. declare module "babylonjs/Engines/constants" {
  593. /** Defines the cross module used constants to avoid circular dependncies */
  594. export class Constants {
  595. /** Defines that alpha blending is disabled */
  596. static readonly ALPHA_DISABLE: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  598. static readonly ALPHA_ADD: number;
  599. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  600. static readonly ALPHA_COMBINE: number;
  601. /** Defines that alpha blending is DEST - SRC * DEST */
  602. static readonly ALPHA_SUBTRACT: number;
  603. /** Defines that alpha blending is SRC * DEST */
  604. static readonly ALPHA_MULTIPLY: number;
  605. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  606. static readonly ALPHA_MAXIMIZED: number;
  607. /** Defines that alpha blending is SRC + DEST */
  608. static readonly ALPHA_ONEONE: number;
  609. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  610. static readonly ALPHA_PREMULTIPLIED: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  613. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  616. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  617. static readonly ALPHA_INTERPOLATE: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  620. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_SCREENMODE: number;
  623. /**
  624. * Defines that alpha blending is SRC + DST
  625. * Alpha will be set to SRC ALPHA + DST ALPHA
  626. */
  627. static readonly ALPHA_ONEONE_ONEONE: number;
  628. /**
  629. * Defines that alpha blending is SRC * DST ALPHA + DST
  630. * Alpha will be set to 0
  631. */
  632. static readonly ALPHA_ALPHATOCOLOR: number;
  633. /**
  634. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  635. */
  636. static readonly ALPHA_REVERSEONEMINUS: number;
  637. /**
  638. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  639. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  640. */
  641. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST
  644. * Alpha will be set to SRC ALPHA
  645. */
  646. static readonly ALPHA_ONEONE_ONEZERO: number;
  647. /**
  648. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  649. * Alpha will be set to DST ALPHA
  650. */
  651. static readonly ALPHA_EXCLUSION: number;
  652. /** Defines that alpha blending equation a SUM */
  653. static readonly ALPHA_EQUATION_ADD: number;
  654. /** Defines that alpha blending equation a SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  656. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  657. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  658. /** Defines that alpha blending equation a MAX operation */
  659. static readonly ALPHA_EQUATION_MAX: number;
  660. /** Defines that alpha blending equation a MIN operation */
  661. static readonly ALPHA_EQUATION_MIN: number;
  662. /**
  663. * Defines that alpha blending equation a DARKEN operation:
  664. * It takes the min of the src and sums the alpha channels.
  665. */
  666. static readonly ALPHA_EQUATION_DARKEN: number;
  667. /** Defines that the ressource is not delayed*/
  668. static readonly DELAYLOADSTATE_NONE: number;
  669. /** Defines that the ressource was successfully delay loaded */
  670. static readonly DELAYLOADSTATE_LOADED: number;
  671. /** Defines that the ressource is currently delay loading */
  672. static readonly DELAYLOADSTATE_LOADING: number;
  673. /** Defines that the ressource is delayed and has not started loading */
  674. static readonly DELAYLOADSTATE_NOTLOADED: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  676. static readonly NEVER: number;
  677. /** 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 */
  678. static readonly ALWAYS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  680. static readonly LESS: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  682. static readonly EQUAL: number;
  683. /** 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 */
  684. static readonly LEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  686. static readonly GREATER: number;
  687. /** 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 */
  688. static readonly GEQUAL: number;
  689. /** 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 */
  690. static readonly NOTEQUAL: number;
  691. /** Passed to stencilOperation to specify that stencil value must be kept */
  692. static readonly KEEP: number;
  693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  694. static readonly REPLACE: number;
  695. /** Passed to stencilOperation to specify that stencil value must be incremented */
  696. static readonly INCR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be decremented */
  698. static readonly DECR: number;
  699. /** Passed to stencilOperation to specify that stencil value must be inverted */
  700. static readonly INVERT: number;
  701. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  702. static readonly INCR_WRAP: number;
  703. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  704. static readonly DECR_WRAP: number;
  705. /** Texture is not repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  707. /** Texture is repeating outside of 0..1 UVs */
  708. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  709. /** Texture is repeating and mirrored */
  710. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  711. /** ALPHA */
  712. static readonly TEXTUREFORMAT_ALPHA: number;
  713. /** LUMINANCE */
  714. static readonly TEXTUREFORMAT_LUMINANCE: number;
  715. /** LUMINANCE_ALPHA */
  716. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  717. /** RGB */
  718. static readonly TEXTUREFORMAT_RGB: number;
  719. /** RGBA */
  720. static readonly TEXTUREFORMAT_RGBA: number;
  721. /** RED */
  722. static readonly TEXTUREFORMAT_RED: number;
  723. /** RED (2nd reference) */
  724. static readonly TEXTUREFORMAT_R: number;
  725. /** RG */
  726. static readonly TEXTUREFORMAT_RG: number;
  727. /** RED_INTEGER */
  728. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  729. /** RED_INTEGER (2nd reference) */
  730. static readonly TEXTUREFORMAT_R_INTEGER: number;
  731. /** RG_INTEGER */
  732. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  733. /** RGB_INTEGER */
  734. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  735. /** RGBA_INTEGER */
  736. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  737. /** UNSIGNED_BYTE */
  738. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  739. /** UNSIGNED_BYTE (2nd reference) */
  740. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  741. /** FLOAT */
  742. static readonly TEXTURETYPE_FLOAT: number;
  743. /** HALF_FLOAT */
  744. static readonly TEXTURETYPE_HALF_FLOAT: number;
  745. /** BYTE */
  746. static readonly TEXTURETYPE_BYTE: number;
  747. /** SHORT */
  748. static readonly TEXTURETYPE_SHORT: number;
  749. /** UNSIGNED_SHORT */
  750. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  751. /** INT */
  752. static readonly TEXTURETYPE_INT: number;
  753. /** UNSIGNED_INT */
  754. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  755. /** UNSIGNED_SHORT_4_4_4_4 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  757. /** UNSIGNED_SHORT_5_5_5_1 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  759. /** UNSIGNED_SHORT_5_6_5 */
  760. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  761. /** UNSIGNED_INT_2_10_10_10_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  763. /** UNSIGNED_INT_24_8 */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  765. /** UNSIGNED_INT_10F_11F_11F_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  767. /** UNSIGNED_INT_5_9_9_9_REV */
  768. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  769. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  770. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  771. /** nearest is mag = nearest and min = nearest and no mip */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** mag = nearest and min = nearest and mip = none */
  774. static readonly TEXTURE_NEAREST_NEAREST: number;
  775. /** Bilinear is mag = linear and min = linear and no mip */
  776. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  777. /** mag = linear and min = linear and mip = none */
  778. static readonly TEXTURE_LINEAR_LINEAR: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  781. /** Trilinear is mag = linear and min = linear and mip = linear */
  782. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  783. /** mag = nearest and min = nearest and mip = nearest */
  784. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = nearest */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  787. /** mag = nearest and min = linear and mip = linear */
  788. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  789. /** mag = nearest and min = linear and mip = none */
  790. static readonly TEXTURE_NEAREST_LINEAR: number;
  791. /** nearest is mag = nearest and min = nearest and mip = linear */
  792. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  793. /** mag = linear and min = nearest and mip = nearest */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = linear */
  796. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  797. /** Bilinear is mag = linear and min = linear and mip = nearest */
  798. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  799. /** mag = linear and min = nearest and mip = none */
  800. static readonly TEXTURE_LINEAR_NEAREST: number;
  801. /** Explicit coordinates mode */
  802. static readonly TEXTURE_EXPLICIT_MODE: number;
  803. /** Spherical coordinates mode */
  804. static readonly TEXTURE_SPHERICAL_MODE: number;
  805. /** Planar coordinates mode */
  806. static readonly TEXTURE_PLANAR_MODE: number;
  807. /** Cubic coordinates mode */
  808. static readonly TEXTURE_CUBIC_MODE: number;
  809. /** Projection coordinates mode */
  810. static readonly TEXTURE_PROJECTION_MODE: number;
  811. /** Skybox coordinates mode */
  812. static readonly TEXTURE_SKYBOX_MODE: number;
  813. /** Inverse Cubic coordinates mode */
  814. static readonly TEXTURE_INVCUBIC_MODE: number;
  815. /** Equirectangular coordinates mode */
  816. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  819. /** Equirectangular Fixed Mirrored coordinates mode */
  820. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  821. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  822. static readonly SCALEMODE_FLOOR: number;
  823. /** Defines that texture rescaling will look for the nearest power of 2 size */
  824. static readonly SCALEMODE_NEAREST: number;
  825. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  826. static readonly SCALEMODE_CEILING: number;
  827. /**
  828. * The dirty texture flag value
  829. */
  830. static readonly MATERIAL_TextureDirtyFlag: number;
  831. /**
  832. * The dirty light flag value
  833. */
  834. static readonly MATERIAL_LightDirtyFlag: number;
  835. /**
  836. * The dirty fresnel flag value
  837. */
  838. static readonly MATERIAL_FresnelDirtyFlag: number;
  839. /**
  840. * The dirty attribute flag value
  841. */
  842. static readonly MATERIAL_AttributesDirtyFlag: number;
  843. /**
  844. * The dirty misc flag value
  845. */
  846. static readonly MATERIAL_MiscDirtyFlag: number;
  847. /**
  848. * The all dirty flag value
  849. */
  850. static readonly MATERIAL_AllDirtyFlag: number;
  851. /**
  852. * Returns the triangle fill mode
  853. */
  854. static readonly MATERIAL_TriangleFillMode: number;
  855. /**
  856. * Returns the wireframe mode
  857. */
  858. static readonly MATERIAL_WireFrameFillMode: number;
  859. /**
  860. * Returns the point fill mode
  861. */
  862. static readonly MATERIAL_PointFillMode: number;
  863. /**
  864. * Returns the point list draw mode
  865. */
  866. static readonly MATERIAL_PointListDrawMode: number;
  867. /**
  868. * Returns the line list draw mode
  869. */
  870. static readonly MATERIAL_LineListDrawMode: number;
  871. /**
  872. * Returns the line loop draw mode
  873. */
  874. static readonly MATERIAL_LineLoopDrawMode: number;
  875. /**
  876. * Returns the line strip draw mode
  877. */
  878. static readonly MATERIAL_LineStripDrawMode: number;
  879. /**
  880. * Returns the triangle strip draw mode
  881. */
  882. static readonly MATERIAL_TriangleStripDrawMode: number;
  883. /**
  884. * Returns the triangle fan draw mode
  885. */
  886. static readonly MATERIAL_TriangleFanDrawMode: number;
  887. /**
  888. * Stores the clock-wise side orientation
  889. */
  890. static readonly MATERIAL_ClockWiseSideOrientation: number;
  891. /**
  892. * Stores the counter clock-wise side orientation
  893. */
  894. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  895. /**
  896. * Nothing
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_NothingTrigger: number;
  900. /**
  901. * On pick
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_OnPickTrigger: number;
  905. /**
  906. * On left pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnLeftPickTrigger: number;
  910. /**
  911. * On right pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnRightPickTrigger: number;
  915. /**
  916. * On center pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnCenterPickTrigger: number;
  920. /**
  921. * On pick down
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnPickDownTrigger: number;
  925. /**
  926. * On double pick
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnDoublePickTrigger: number;
  930. /**
  931. * On pick up
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnPickUpTrigger: number;
  935. /**
  936. * On pick out.
  937. * This trigger will only be raised if you also declared a OnPickDown
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnPickOutTrigger: number;
  941. /**
  942. * On long press
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnLongPressTrigger: number;
  946. /**
  947. * On pointer over
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnPointerOverTrigger: number;
  951. /**
  952. * On pointer out
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOutTrigger: number;
  956. /**
  957. * On every frame
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnEveryFrameTrigger: number;
  961. /**
  962. * On intersection enter
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnIntersectionEnterTrigger: number;
  966. /**
  967. * On intersection exit
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionExitTrigger: number;
  971. /**
  972. * On key down
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnKeyDownTrigger: number;
  976. /**
  977. * On key up
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyUpTrigger: number;
  981. /**
  982. * Billboard mode will only apply to Y axis
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  985. /**
  986. * Billboard mode will apply to all axes
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  989. /**
  990. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  991. */
  992. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  993. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  994. * Test order :
  995. * Is the bounding sphere outside the frustum ?
  996. * If not, are the bounding box vertices outside the frustum ?
  997. * It not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1000. /** Culling strategy : Bounding Sphere Only.
  1001. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1002. * It's also less accurate than the standard because some not visible objects can still be selected.
  1003. * Test : is the bounding sphere outside the frustum ?
  1004. * If not, then the cullable object is in the frustum.
  1005. */
  1006. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1007. /** Culling strategy : Optimistic Inclusion.
  1008. * This in an inclusion test first, then the standard exclusion test.
  1009. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1010. * 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.
  1011. * Anyway, it's as accurate as the standard strategy.
  1012. * Test :
  1013. * Is the cullable object bounding sphere center in the frustum ?
  1014. * If not, apply the default culling strategy.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1017. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1018. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1019. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1020. * 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.
  1021. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1022. * Test :
  1023. * Is the cullable object bounding sphere center in the frustum ?
  1024. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1025. */
  1026. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1027. /**
  1028. * No logging while loading
  1029. */
  1030. static readonly SCENELOADER_NO_LOGGING: number;
  1031. /**
  1032. * Minimal logging while loading
  1033. */
  1034. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1035. /**
  1036. * Summary logging while loading
  1037. */
  1038. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1039. /**
  1040. * Detailled logging while loading
  1041. */
  1042. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1043. }
  1044. }
  1045. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1046. import { Nullable } from "babylonjs/types";
  1047. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1048. /**
  1049. * This represents the required contract to create a new type of texture loader.
  1050. */
  1051. export interface IInternalTextureLoader {
  1052. /**
  1053. * Defines wether the loader supports cascade loading the different faces.
  1054. */
  1055. supportCascades: boolean;
  1056. /**
  1057. * This returns if the loader support the current file information.
  1058. * @param extension defines the file extension of the file being loaded
  1059. * @returns true if the loader can load the specified file
  1060. */
  1061. canLoad(extension: string): boolean;
  1062. /**
  1063. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1064. * @param data contains the texture data
  1065. * @param texture defines the BabylonJS internal texture
  1066. * @param createPolynomials will be true if polynomials have been requested
  1067. * @param onLoad defines the callback to trigger once the texture is ready
  1068. * @param onError defines the callback to trigger in case of error
  1069. */
  1070. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1071. /**
  1072. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1073. * @param data contains the texture data
  1074. * @param texture defines the BabylonJS internal texture
  1075. * @param callback defines the method to call once ready to upload
  1076. */
  1077. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1078. }
  1079. }
  1080. declare module "babylonjs/Engines/IPipelineContext" {
  1081. /**
  1082. * Class used to store and describe the pipeline context associated with an effect
  1083. */
  1084. export interface IPipelineContext {
  1085. /**
  1086. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1087. */
  1088. isAsync: boolean;
  1089. /**
  1090. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1091. */
  1092. isReady: boolean;
  1093. /** @hidden */
  1094. _getVertexShaderCode(): string | null;
  1095. /** @hidden */
  1096. _getFragmentShaderCode(): string | null;
  1097. /** @hidden */
  1098. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1099. }
  1100. }
  1101. declare module "babylonjs/Meshes/dataBuffer" {
  1102. /**
  1103. * Class used to store gfx data (like WebGLBuffer)
  1104. */
  1105. export class DataBuffer {
  1106. /**
  1107. * Gets or sets the number of objects referencing this buffer
  1108. */
  1109. references: number;
  1110. /** Gets or sets the size of the underlying buffer */
  1111. capacity: number;
  1112. /**
  1113. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1114. */
  1115. is32Bits: boolean;
  1116. /**
  1117. * Gets the underlying buffer
  1118. */
  1119. get underlyingResource(): any;
  1120. }
  1121. }
  1122. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1123. /** @hidden */
  1124. export interface IShaderProcessor {
  1125. attributeProcessor?: (attribute: string) => string;
  1126. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1127. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1128. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1129. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1130. lineProcessor?: (line: string, isFragment: boolean) => string;
  1131. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1133. }
  1134. }
  1135. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1136. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1137. /** @hidden */
  1138. export interface ProcessingOptions {
  1139. defines: string[];
  1140. indexParameters: any;
  1141. isFragment: boolean;
  1142. shouldUseHighPrecisionShader: boolean;
  1143. supportsUniformBuffers: boolean;
  1144. shadersRepository: string;
  1145. includesShadersStore: {
  1146. [key: string]: string;
  1147. };
  1148. processor?: IShaderProcessor;
  1149. version: string;
  1150. platformName: string;
  1151. lookForClosingBracketForUniformBuffer?: boolean;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1155. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1156. /** @hidden */
  1157. export class ShaderCodeNode {
  1158. line: string;
  1159. children: ShaderCodeNode[];
  1160. additionalDefineKey?: string;
  1161. additionalDefineValue?: string;
  1162. isValid(preprocessors: {
  1163. [key: string]: string;
  1164. }): boolean;
  1165. process(preprocessors: {
  1166. [key: string]: string;
  1167. }, options: ProcessingOptions): string;
  1168. }
  1169. }
  1170. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1171. /** @hidden */
  1172. export class ShaderCodeCursor {
  1173. private _lines;
  1174. lineIndex: number;
  1175. get currentLine(): string;
  1176. get canRead(): boolean;
  1177. set lines(value: string[]);
  1178. }
  1179. }
  1180. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1181. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1182. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1183. /** @hidden */
  1184. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1185. process(preprocessors: {
  1186. [key: string]: string;
  1187. }, options: ProcessingOptions): string;
  1188. }
  1189. }
  1190. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1191. /** @hidden */
  1192. export class ShaderDefineExpression {
  1193. isTrue(preprocessors: {
  1194. [key: string]: string;
  1195. }): boolean;
  1196. }
  1197. }
  1198. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1199. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1200. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1201. /** @hidden */
  1202. export class ShaderCodeTestNode extends ShaderCodeNode {
  1203. testExpression: ShaderDefineExpression;
  1204. isValid(preprocessors: {
  1205. [key: string]: string;
  1206. }): boolean;
  1207. }
  1208. }
  1209. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1210. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1211. /** @hidden */
  1212. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1213. define: string;
  1214. not: boolean;
  1215. constructor(define: string, not?: boolean);
  1216. isTrue(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1225. leftOperand: ShaderDefineExpression;
  1226. rightOperand: ShaderDefineExpression;
  1227. isTrue(preprocessors: {
  1228. [key: string]: string;
  1229. }): boolean;
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1233. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1234. /** @hidden */
  1235. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1236. leftOperand: ShaderDefineExpression;
  1237. rightOperand: ShaderDefineExpression;
  1238. isTrue(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. operand: string;
  1249. testValue: string;
  1250. constructor(define: string, operand: string, testValue: string);
  1251. isTrue(preprocessors: {
  1252. [key: string]: string;
  1253. }): boolean;
  1254. }
  1255. }
  1256. declare module "babylonjs/Offline/IOfflineProvider" {
  1257. /**
  1258. * Class used to enable access to offline support
  1259. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1260. */
  1261. export interface IOfflineProvider {
  1262. /**
  1263. * Gets a boolean indicating if scene must be saved in the database
  1264. */
  1265. enableSceneOffline: boolean;
  1266. /**
  1267. * Gets a boolean indicating if textures must be saved in the database
  1268. */
  1269. enableTexturesOffline: boolean;
  1270. /**
  1271. * Open the offline support and make it available
  1272. * @param successCallback defines the callback to call on success
  1273. * @param errorCallback defines the callback to call on error
  1274. */
  1275. open(successCallback: () => void, errorCallback: () => void): void;
  1276. /**
  1277. * Loads an image from the offline support
  1278. * @param url defines the url to load from
  1279. * @param image defines the target DOM image
  1280. */
  1281. loadImage(url: string, image: HTMLImageElement): void;
  1282. /**
  1283. * Loads a file from offline support
  1284. * @param url defines the URL to load from
  1285. * @param sceneLoaded defines a callback to call on success
  1286. * @param progressCallBack defines a callback to call when progress changed
  1287. * @param errorCallback defines a callback to call on error
  1288. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1289. */
  1290. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1291. }
  1292. }
  1293. declare module "babylonjs/Misc/filesInputStore" {
  1294. /**
  1295. * Class used to help managing file picking and drag'n'drop
  1296. * File Storage
  1297. */
  1298. export class FilesInputStore {
  1299. /**
  1300. * List of files ready to be loaded
  1301. */
  1302. static FilesToLoad: {
  1303. [key: string]: File;
  1304. };
  1305. }
  1306. }
  1307. declare module "babylonjs/Misc/retryStrategy" {
  1308. import { WebRequest } from "babylonjs/Misc/webRequest";
  1309. /**
  1310. * Class used to define a retry strategy when error happens while loading assets
  1311. */
  1312. export class RetryStrategy {
  1313. /**
  1314. * Function used to defines an exponential back off strategy
  1315. * @param maxRetries defines the maximum number of retries (3 by default)
  1316. * @param baseInterval defines the interval between retries
  1317. * @returns the strategy function to use
  1318. */
  1319. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1320. }
  1321. }
  1322. declare module "babylonjs/Misc/baseError" {
  1323. /**
  1324. * @ignore
  1325. * Application error to support additional information when loading a file
  1326. */
  1327. export abstract class BaseError extends Error {
  1328. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1329. }
  1330. }
  1331. declare module "babylonjs/Misc/fileTools" {
  1332. import { WebRequest } from "babylonjs/Misc/webRequest";
  1333. import { Nullable } from "babylonjs/types";
  1334. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1335. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1336. import { BaseError } from "babylonjs/Misc/baseError";
  1337. /** @ignore */
  1338. export class LoadFileError extends BaseError {
  1339. request?: WebRequest;
  1340. file?: File;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. * @param file defines the optional file
  1346. */
  1347. constructor(message: string, object?: WebRequest | File);
  1348. }
  1349. /** @ignore */
  1350. export class RequestFileError extends BaseError {
  1351. request: WebRequest;
  1352. /**
  1353. * Creates a new LoadFileError
  1354. * @param message defines the message of the error
  1355. * @param request defines the optional web request
  1356. */
  1357. constructor(message: string, request: WebRequest);
  1358. }
  1359. /** @ignore */
  1360. export class ReadFileError extends BaseError {
  1361. file: File;
  1362. /**
  1363. * Creates a new ReadFileError
  1364. * @param message defines the message of the error
  1365. * @param file defines the optional file
  1366. */
  1367. constructor(message: string, file: File);
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export class FileTools {
  1373. /**
  1374. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1375. */
  1376. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1377. /**
  1378. * Gets or sets the base URL to use to load assets
  1379. */
  1380. static BaseUrl: string;
  1381. /**
  1382. * Default behaviour for cors in the application.
  1383. * It can be a string if the expected behavior is identical in the entire app.
  1384. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1385. */
  1386. static CorsBehavior: string | ((url: string | string[]) => string);
  1387. /**
  1388. * Gets or sets a function used to pre-process url before using them to load assets
  1389. */
  1390. static PreprocessUrl: (url: string) => string;
  1391. /**
  1392. * Removes unwanted characters from an url
  1393. * @param url defines the url to clean
  1394. * @returns the cleaned url
  1395. */
  1396. private static _CleanUrl;
  1397. /**
  1398. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1399. * @param url define the url we are trying
  1400. * @param element define the dom element where to configure the cors policy
  1401. */
  1402. static SetCorsBehavior(url: string | string[], element: {
  1403. crossOrigin: string | null;
  1404. }): void;
  1405. /**
  1406. * Loads an image as an HTMLImageElement.
  1407. * @param input url string, ArrayBuffer, or Blob to load
  1408. * @param onLoad callback called when the image successfully loads
  1409. * @param onError callback called when the image fails to load
  1410. * @param offlineProvider offline provider for caching
  1411. * @param mimeType optional mime type
  1412. * @returns the HTMLImageElement of the loaded image
  1413. */
  1414. 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>;
  1415. /**
  1416. * Reads a file from a File object
  1417. * @param file defines the file to load
  1418. * @param onSuccess defines the callback to call when data is loaded
  1419. * @param onProgress defines the callback to call during loading process
  1420. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1421. * @param onError defines the callback to call when an error occurs
  1422. * @returns a file request object
  1423. */
  1424. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1425. /**
  1426. * Loads a file from a url
  1427. * @param url url to load
  1428. * @param onSuccess callback called when the file successfully loads
  1429. * @param onProgress callback called while file is loading (if the server supports this mode)
  1430. * @param offlineProvider defines the offline provider for caching
  1431. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1432. * @param onError callback called when the file fails to load
  1433. * @returns a file request object
  1434. */
  1435. 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;
  1436. /**
  1437. * Loads a file
  1438. * @param url url to load
  1439. * @param onSuccess callback called when the file successfully loads
  1440. * @param onProgress callback called while file is loading (if the server supports this mode)
  1441. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1442. * @param onError callback called when the file fails to load
  1443. * @param onOpened callback called when the web request is opened
  1444. * @returns a file request object
  1445. */
  1446. 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;
  1447. /**
  1448. * Checks if the loaded document was accessed via `file:`-Protocol.
  1449. * @returns boolean
  1450. */
  1451. static IsFileURL(): boolean;
  1452. }
  1453. }
  1454. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1455. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1456. import { WebRequest } from "babylonjs/Misc/webRequest";
  1457. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1458. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1459. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1460. /** @hidden */
  1461. export class ShaderProcessor {
  1462. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1463. private static _ProcessPrecision;
  1464. private static _ExtractOperation;
  1465. private static _BuildSubExpression;
  1466. private static _BuildExpression;
  1467. private static _MoveCursorWithinIf;
  1468. private static _MoveCursor;
  1469. private static _EvaluatePreProcessors;
  1470. private static _PreparePreProcessors;
  1471. private static _ProcessShaderConversion;
  1472. private static _ProcessIncludes;
  1473. /**
  1474. * Loads a file from a url
  1475. * @param url url to load
  1476. * @param onSuccess callback called when the file successfully loads
  1477. * @param onProgress callback called while file is loading (if the server supports this mode)
  1478. * @param offlineProvider defines the offline provider for caching
  1479. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1480. * @param onError callback called when the file fails to load
  1481. * @returns a file request object
  1482. * @hidden
  1483. */
  1484. 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;
  1485. }
  1486. }
  1487. declare module "babylonjs/Maths/math.like" {
  1488. import { float, int, DeepImmutable } from "babylonjs/types";
  1489. /**
  1490. * @hidden
  1491. */
  1492. export interface IColor4Like {
  1493. r: float;
  1494. g: float;
  1495. b: float;
  1496. a: float;
  1497. }
  1498. /**
  1499. * @hidden
  1500. */
  1501. export interface IColor3Like {
  1502. r: float;
  1503. g: float;
  1504. b: float;
  1505. }
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IVector4Like {
  1510. x: float;
  1511. y: float;
  1512. z: float;
  1513. w: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IVector3Like {
  1519. x: float;
  1520. y: float;
  1521. z: float;
  1522. }
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IVector2Like {
  1527. x: float;
  1528. y: float;
  1529. }
  1530. /**
  1531. * @hidden
  1532. */
  1533. export interface IMatrixLike {
  1534. toArray(): DeepImmutable<Float32Array>;
  1535. updateFlag: int;
  1536. }
  1537. /**
  1538. * @hidden
  1539. */
  1540. export interface IViewportLike {
  1541. x: float;
  1542. y: float;
  1543. width: float;
  1544. height: float;
  1545. }
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IPlaneLike {
  1550. normal: IVector3Like;
  1551. d: float;
  1552. normalize(): void;
  1553. }
  1554. }
  1555. declare module "babylonjs/Materials/iEffectFallbacks" {
  1556. import { Effect } from "babylonjs/Materials/effect";
  1557. /**
  1558. * Interface used to define common properties for effect fallbacks
  1559. */
  1560. export interface IEffectFallbacks {
  1561. /**
  1562. * Removes the defines that should be removed when falling back.
  1563. * @param currentDefines defines the current define statements for the shader.
  1564. * @param effect defines the current effect we try to compile
  1565. * @returns The resulting defines with defines of the current rank removed.
  1566. */
  1567. reduce(currentDefines: string, effect: Effect): string;
  1568. /**
  1569. * Removes the fallback from the bound mesh.
  1570. */
  1571. unBindMesh(): void;
  1572. /**
  1573. * Checks to see if more fallbacks are still availible.
  1574. */
  1575. hasMoreFallbacks: boolean;
  1576. }
  1577. }
  1578. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1579. /**
  1580. * Class used to evalaute queries containing `and` and `or` operators
  1581. */
  1582. export class AndOrNotEvaluator {
  1583. /**
  1584. * Evaluate a query
  1585. * @param query defines the query to evaluate
  1586. * @param evaluateCallback defines the callback used to filter result
  1587. * @returns true if the query matches
  1588. */
  1589. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1590. private static _HandleParenthesisContent;
  1591. private static _SimplifyNegation;
  1592. }
  1593. }
  1594. declare module "babylonjs/Misc/tags" {
  1595. /**
  1596. * Class used to store custom tags
  1597. */
  1598. export class Tags {
  1599. /**
  1600. * Adds support for tags on the given object
  1601. * @param obj defines the object to use
  1602. */
  1603. static EnableFor(obj: any): void;
  1604. /**
  1605. * Removes tags support
  1606. * @param obj defines the object to use
  1607. */
  1608. static DisableFor(obj: any): void;
  1609. /**
  1610. * Gets a boolean indicating if the given object has tags
  1611. * @param obj defines the object to use
  1612. * @returns a boolean
  1613. */
  1614. static HasTags(obj: any): boolean;
  1615. /**
  1616. * Gets the tags available on a given object
  1617. * @param obj defines the object to use
  1618. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1619. * @returns the tags
  1620. */
  1621. static GetTags(obj: any, asString?: boolean): any;
  1622. /**
  1623. * Adds tags to an object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1626. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1627. */
  1628. static AddTagsTo(obj: any, tagsString: string): void;
  1629. /**
  1630. * @hidden
  1631. */
  1632. static _AddTagTo(obj: any, tag: string): void;
  1633. /**
  1634. * Removes specific tags from a specific object
  1635. * @param obj defines the object to use
  1636. * @param tagsString defines the tags to remove
  1637. */
  1638. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1639. /**
  1640. * @hidden
  1641. */
  1642. static _RemoveTagFrom(obj: any, tag: string): void;
  1643. /**
  1644. * Defines if tags hosted on an object match a given query
  1645. * @param obj defines the object to use
  1646. * @param tagsQuery defines the tag query
  1647. * @returns a boolean
  1648. */
  1649. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1650. }
  1651. }
  1652. declare module "babylonjs/Maths/math.scalar" {
  1653. /**
  1654. * Scalar computation library
  1655. */
  1656. export class Scalar {
  1657. /**
  1658. * Two pi constants convenient for computation.
  1659. */
  1660. static TwoPi: number;
  1661. /**
  1662. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. * @param a number
  1664. * @param b number
  1665. * @param epsilon (default = 1.401298E-45)
  1666. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1667. */
  1668. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1669. /**
  1670. * Returns a string : the upper case translation of the number i to hexadecimal.
  1671. * @param i number
  1672. * @returns the upper case translation of the number i to hexadecimal.
  1673. */
  1674. static ToHex(i: number): string;
  1675. /**
  1676. * Returns -1 if value is negative and +1 is value is positive.
  1677. * @param value the value
  1678. * @returns the value itself if it's equal to zero.
  1679. */
  1680. static Sign(value: number): number;
  1681. /**
  1682. * Returns the value itself if it's between min and max.
  1683. * Returns min if the value is lower than min.
  1684. * Returns max if the value is greater than max.
  1685. * @param value the value to clmap
  1686. * @param min the min value to clamp to (default: 0)
  1687. * @param max the max value to clamp to (default: 1)
  1688. * @returns the clamped value
  1689. */
  1690. static Clamp(value: number, min?: number, max?: number): number;
  1691. /**
  1692. * the log2 of value.
  1693. * @param value the value to compute log2 of
  1694. * @returns the log2 of value.
  1695. */
  1696. static Log2(value: number): number;
  1697. /**
  1698. * Loops the value, so that it is never larger than length and never smaller than 0.
  1699. *
  1700. * This is similar to the modulo operator but it works with floating point numbers.
  1701. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1702. * With t = 5 and length = 2.5, the result would be 0.0.
  1703. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1704. * @param value the value
  1705. * @param length the length
  1706. * @returns the looped value
  1707. */
  1708. static Repeat(value: number, length: number): number;
  1709. /**
  1710. * Normalize the value between 0.0 and 1.0 using min and max values
  1711. * @param value value to normalize
  1712. * @param min max to normalize between
  1713. * @param max min to normalize between
  1714. * @returns the normalized value
  1715. */
  1716. static Normalize(value: number, min: number, max: number): number;
  1717. /**
  1718. * Denormalize the value from 0.0 and 1.0 using min and max values
  1719. * @param normalized value to denormalize
  1720. * @param min max to denormalize between
  1721. * @param max min to denormalize between
  1722. * @returns the denormalized value
  1723. */
  1724. static Denormalize(normalized: number, min: number, max: number): number;
  1725. /**
  1726. * Calculates the shortest difference between two given angles given in degrees.
  1727. * @param current current angle in degrees
  1728. * @param target target angle in degrees
  1729. * @returns the delta
  1730. */
  1731. static DeltaAngle(current: number, target: number): number;
  1732. /**
  1733. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1734. * @param tx value
  1735. * @param length length
  1736. * @returns The returned value will move back and forth between 0 and length
  1737. */
  1738. static PingPong(tx: number, length: number): number;
  1739. /**
  1740. * Interpolates between min and max with smoothing at the limits.
  1741. *
  1742. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1743. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1744. * @param from from
  1745. * @param to to
  1746. * @param tx value
  1747. * @returns the smooth stepped value
  1748. */
  1749. static SmoothStep(from: number, to: number, tx: number): number;
  1750. /**
  1751. * Moves a value current towards target.
  1752. *
  1753. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1754. * Negative values of maxDelta pushes the value away from target.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting value
  1759. */
  1760. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1763. *
  1764. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1765. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1766. * @param current current value
  1767. * @param target target value
  1768. * @param maxDelta max distance to move
  1769. * @returns resulting angle
  1770. */
  1771. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1772. /**
  1773. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1774. * @param start start value
  1775. * @param end target value
  1776. * @param amount amount to lerp between
  1777. * @returns the lerped value
  1778. */
  1779. static Lerp(start: number, end: number, amount: number): number;
  1780. /**
  1781. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1782. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1783. * @param start start value
  1784. * @param end target value
  1785. * @param amount amount to lerp between
  1786. * @returns the lerped value
  1787. */
  1788. static LerpAngle(start: number, end: number, amount: number): number;
  1789. /**
  1790. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1791. * @param a start value
  1792. * @param b target value
  1793. * @param value value between a and b
  1794. * @returns the inverseLerp value
  1795. */
  1796. static InverseLerp(a: number, b: number, value: number): number;
  1797. /**
  1798. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1799. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1800. * @param value1 spline value
  1801. * @param tangent1 spline value
  1802. * @param value2 spline value
  1803. * @param tangent2 spline value
  1804. * @param amount input value
  1805. * @returns hermite result
  1806. */
  1807. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1808. /**
  1809. * Returns a random float number between and min and max values
  1810. * @param min min value of random
  1811. * @param max max value of random
  1812. * @returns random value
  1813. */
  1814. static RandomRange(min: number, max: number): number;
  1815. /**
  1816. * This function returns percentage of a number in a given range.
  1817. *
  1818. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1819. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1820. * @param number to convert to percentage
  1821. * @param min min range
  1822. * @param max max range
  1823. * @returns the percentage
  1824. */
  1825. static RangeToPercent(number: number, min: number, max: number): number;
  1826. /**
  1827. * This function returns number that corresponds to the percentage in a given range.
  1828. *
  1829. * PercentToRange(0.34,0,100) will return 34.
  1830. * @param percent to convert to number
  1831. * @param min min range
  1832. * @param max max range
  1833. * @returns the number
  1834. */
  1835. static PercentToRange(percent: number, min: number, max: number): number;
  1836. /**
  1837. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1838. * @param angle The angle to normalize in radian.
  1839. * @return The converted angle.
  1840. */
  1841. static NormalizeRadians(angle: number): number;
  1842. }
  1843. }
  1844. declare module "babylonjs/Maths/math.constants" {
  1845. /**
  1846. * Constant used to convert a value to gamma space
  1847. * @ignorenaming
  1848. */
  1849. export const ToGammaSpace: number;
  1850. /**
  1851. * Constant used to convert a value to linear space
  1852. * @ignorenaming
  1853. */
  1854. export const ToLinearSpace = 2.2;
  1855. /**
  1856. * Constant used to define the minimal number value in Babylon.js
  1857. * @ignorenaming
  1858. */
  1859. let Epsilon: number;
  1860. export { Epsilon };
  1861. }
  1862. declare module "babylonjs/Maths/math.viewport" {
  1863. /**
  1864. * Class used to represent a viewport on screen
  1865. */
  1866. export class Viewport {
  1867. /** viewport left coordinate */
  1868. x: number;
  1869. /** viewport top coordinate */
  1870. y: number;
  1871. /**viewport width */
  1872. width: number;
  1873. /** viewport height */
  1874. height: number;
  1875. /**
  1876. * Creates a Viewport object located at (x, y) and sized (width, height)
  1877. * @param x defines viewport left coordinate
  1878. * @param y defines viewport top coordinate
  1879. * @param width defines the viewport width
  1880. * @param height defines the viewport height
  1881. */
  1882. constructor(
  1883. /** viewport left coordinate */
  1884. x: number,
  1885. /** viewport top coordinate */
  1886. y: number,
  1887. /**viewport width */
  1888. width: number,
  1889. /** viewport height */
  1890. height: number);
  1891. /**
  1892. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1893. * @param renderWidth defines the rendering width
  1894. * @param renderHeight defines the rendering height
  1895. * @returns a new Viewport
  1896. */
  1897. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1898. /**
  1899. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1900. * @param renderWidth defines the rendering width
  1901. * @param renderHeight defines the rendering height
  1902. * @param ref defines the target viewport
  1903. * @returns the current viewport
  1904. */
  1905. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1906. /**
  1907. * Returns a new Viewport copied from the current one
  1908. * @returns a new Viewport
  1909. */
  1910. clone(): Viewport;
  1911. }
  1912. }
  1913. declare module "babylonjs/Misc/arrayTools" {
  1914. /**
  1915. * Class containing a set of static utilities functions for arrays.
  1916. */
  1917. export class ArrayTools {
  1918. /**
  1919. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1920. * @param size the number of element to construct and put in the array
  1921. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1922. * @returns a new array filled with new objects
  1923. */
  1924. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1925. }
  1926. }
  1927. declare module "babylonjs/Maths/math.vector" {
  1928. import { Viewport } from "babylonjs/Maths/math.viewport";
  1929. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1930. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1931. /**
  1932. * Class representing a vector containing 2 coordinates
  1933. */
  1934. export class Vector2 {
  1935. /** defines the first coordinate */
  1936. x: number;
  1937. /** defines the second coordinate */
  1938. y: number;
  1939. /**
  1940. * Creates a new Vector2 from the given x and y coordinates
  1941. * @param x defines the first coordinate
  1942. * @param y defines the second coordinate
  1943. */
  1944. constructor(
  1945. /** defines the first coordinate */
  1946. x?: number,
  1947. /** defines the second coordinate */
  1948. y?: number);
  1949. /**
  1950. * Gets a string with the Vector2 coordinates
  1951. * @returns a string with the Vector2 coordinates
  1952. */
  1953. toString(): string;
  1954. /**
  1955. * Gets class name
  1956. * @returns the string "Vector2"
  1957. */
  1958. getClassName(): string;
  1959. /**
  1960. * Gets current vector hash code
  1961. * @returns the Vector2 hash code as a number
  1962. */
  1963. getHashCode(): number;
  1964. /**
  1965. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1966. * @param array defines the source array
  1967. * @param index defines the offset in source array
  1968. * @returns the current Vector2
  1969. */
  1970. toArray(array: FloatArray, index?: number): Vector2;
  1971. /**
  1972. * Copy the current vector to an array
  1973. * @returns a new array with 2 elements: the Vector2 coordinates.
  1974. */
  1975. asArray(): number[];
  1976. /**
  1977. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1978. * @param source defines the source Vector2
  1979. * @returns the current updated Vector2
  1980. */
  1981. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Sets the Vector2 coordinates with the given floats
  1984. * @param x defines the first coordinate
  1985. * @param y defines the second coordinate
  1986. * @returns the current updated Vector2
  1987. */
  1988. copyFromFloats(x: number, y: number): 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. set(x: number, y: number): Vector2;
  1996. /**
  1997. * Add another vector with the current one
  1998. * @param otherVector defines the other vector
  1999. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2000. */
  2001. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2002. /**
  2003. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2004. * @param otherVector defines the other vector
  2005. * @param result defines the target vector
  2006. * @returns the unmodified current Vector2
  2007. */
  2008. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2009. /**
  2010. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2011. * @param otherVector defines the other vector
  2012. * @returns the current updated Vector2
  2013. */
  2014. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2015. /**
  2016. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2017. * @param otherVector defines the other vector
  2018. * @returns a new Vector2
  2019. */
  2020. addVector3(otherVector: Vector3): Vector2;
  2021. /**
  2022. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2023. * @param otherVector defines the other vector
  2024. * @returns a new Vector2
  2025. */
  2026. subtract(otherVector: Vector2): Vector2;
  2027. /**
  2028. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2029. * @param otherVector defines the other vector
  2030. * @param result defines the target vector
  2031. * @returns the unmodified current Vector2
  2032. */
  2033. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2034. /**
  2035. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2036. * @param otherVector defines the other vector
  2037. * @returns the current updated Vector2
  2038. */
  2039. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2040. /**
  2041. * Multiplies in place the current Vector2 coordinates by the given ones
  2042. * @param otherVector defines the other vector
  2043. * @returns the current updated Vector2
  2044. */
  2045. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2046. /**
  2047. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2048. * @param otherVector defines the other vector
  2049. * @returns a new Vector2
  2050. */
  2051. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2052. /**
  2053. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2054. * @param otherVector defines the other vector
  2055. * @param result defines the target vector
  2056. * @returns the unmodified current Vector2
  2057. */
  2058. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2059. /**
  2060. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2061. * @param x defines the first coordinate
  2062. * @param y defines the second coordinate
  2063. * @returns a new Vector2
  2064. */
  2065. multiplyByFloats(x: number, y: number): Vector2;
  2066. /**
  2067. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2068. * @param otherVector defines the other vector
  2069. * @returns a new Vector2
  2070. */
  2071. divide(otherVector: Vector2): Vector2;
  2072. /**
  2073. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2074. * @param otherVector defines the other vector
  2075. * @param result defines the target vector
  2076. * @returns the unmodified current Vector2
  2077. */
  2078. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2079. /**
  2080. * Divides the current Vector2 coordinates by the given ones
  2081. * @param otherVector defines the other vector
  2082. * @returns the current updated Vector2
  2083. */
  2084. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2085. /**
  2086. * Gets a new Vector2 with current Vector2 negated coordinates
  2087. * @returns a new Vector2
  2088. */
  2089. negate(): Vector2;
  2090. /**
  2091. * Negate this vector in place
  2092. * @returns this
  2093. */
  2094. negateInPlace(): Vector2;
  2095. /**
  2096. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2097. * @param result defines the Vector3 object where to store the result
  2098. * @returns the current Vector2
  2099. */
  2100. negateToRef(result: Vector2): Vector2;
  2101. /**
  2102. * Multiply the Vector2 coordinates by scale
  2103. * @param scale defines the scaling factor
  2104. * @returns the current updated Vector2
  2105. */
  2106. scaleInPlace(scale: number): Vector2;
  2107. /**
  2108. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2109. * @param scale defines the scaling factor
  2110. * @returns a new Vector2
  2111. */
  2112. scale(scale: number): Vector2;
  2113. /**
  2114. * Scale the current Vector2 values by a factor to a given Vector2
  2115. * @param scale defines the scale factor
  2116. * @param result defines the Vector2 object where to store the result
  2117. * @returns the unmodified current Vector2
  2118. */
  2119. scaleToRef(scale: number, result: Vector2): Vector2;
  2120. /**
  2121. * Scale the current Vector2 values by a factor and add the result 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. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2127. /**
  2128. * Gets a boolean if two vectors are equals
  2129. * @param otherVector defines the other vector
  2130. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2131. */
  2132. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2133. /**
  2134. * Gets a boolean if two vectors are equals (using an epsilon value)
  2135. * @param otherVector defines the other vector
  2136. * @param epsilon defines the minimal distance to consider equality
  2137. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2138. */
  2139. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2140. /**
  2141. * Gets a new Vector2 from current Vector2 floored values
  2142. * @returns a new Vector2
  2143. */
  2144. floor(): Vector2;
  2145. /**
  2146. * Gets a new Vector2 from current Vector2 floored values
  2147. * @returns a new Vector2
  2148. */
  2149. fract(): Vector2;
  2150. /**
  2151. * Gets the length of the vector
  2152. * @returns the vector length (float)
  2153. */
  2154. length(): number;
  2155. /**
  2156. * Gets the vector squared length
  2157. * @returns the vector squared length (float)
  2158. */
  2159. lengthSquared(): number;
  2160. /**
  2161. * Normalize the vector
  2162. * @returns the current updated Vector2
  2163. */
  2164. normalize(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 copied from the Vector2
  2167. * @returns a new Vector2
  2168. */
  2169. clone(): Vector2;
  2170. /**
  2171. * Gets a new Vector2(0, 0)
  2172. * @returns a new Vector2
  2173. */
  2174. static Zero(): Vector2;
  2175. /**
  2176. * Gets a new Vector2(1, 1)
  2177. * @returns a new Vector2
  2178. */
  2179. static One(): Vector2;
  2180. /**
  2181. * Gets a new Vector2 set from the given index element of the given array
  2182. * @param array defines the data source
  2183. * @param offset defines the offset in the data source
  2184. * @returns a new Vector2
  2185. */
  2186. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2187. /**
  2188. * Sets "result" 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. * @param result defines the target vector
  2192. */
  2193. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2194. /**
  2195. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2196. * @param value1 defines 1st point of control
  2197. * @param value2 defines 2nd point of control
  2198. * @param value3 defines 3rd point of control
  2199. * @param value4 defines 4th point of control
  2200. * @param amount defines the interpolation factor
  2201. * @returns a new Vector2
  2202. */
  2203. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2204. /**
  2205. * 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".
  2206. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2207. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2208. * @param value defines the value to clamp
  2209. * @param min defines the lower limit
  2210. * @param max defines the upper limit
  2211. * @returns a new Vector2
  2212. */
  2213. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2216. * @param value1 defines the 1st control point
  2217. * @param tangent1 defines the outgoing tangent
  2218. * @param value2 defines the 2nd control point
  2219. * @param tangent2 defines the incoming tangent
  2220. * @param amount defines the interpolation factor
  2221. * @returns a new Vector2
  2222. */
  2223. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2224. /**
  2225. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2226. * @param start defines the start vector
  2227. * @param end defines the end vector
  2228. * @param amount defines the interpolation factor
  2229. * @returns a new Vector2
  2230. */
  2231. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2232. /**
  2233. * Gets the dot product of the vector "left" and the vector "right"
  2234. * @param left defines first vector
  2235. * @param right defines second vector
  2236. * @returns the dot product (float)
  2237. */
  2238. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2239. /**
  2240. * Returns a new Vector2 equal to the normalized given vector
  2241. * @param vector defines the vector to normalize
  2242. * @returns a new Vector2
  2243. */
  2244. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2245. /**
  2246. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2247. * @param left defines 1st vector
  2248. * @param right defines 2nd vector
  2249. * @returns a new Vector2
  2250. */
  2251. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vecto2 set with the maximal 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 Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2259. /**
  2260. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2261. * @param vector defines the vector to transform
  2262. * @param transformation defines the matrix to apply
  2263. * @returns a new Vector2
  2264. */
  2265. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2266. /**
  2267. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2268. * @param vector defines the vector to transform
  2269. * @param transformation defines the matrix to apply
  2270. * @param result defines the target vector
  2271. */
  2272. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2273. /**
  2274. * Determines if a given vector is included in a triangle
  2275. * @param p defines the vector to test
  2276. * @param p0 defines 1st triangle point
  2277. * @param p1 defines 2nd triangle point
  2278. * @param p2 defines 3rd triangle point
  2279. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2280. */
  2281. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2282. /**
  2283. * Gets the distance between the vectors "value1" and "value2"
  2284. * @param value1 defines first vector
  2285. * @param value2 defines second vector
  2286. * @returns the distance between vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2289. /**
  2290. * Returns the squared distance between the vectors "value1" and "value2"
  2291. * @param value1 defines first vector
  2292. * @param value2 defines second vector
  2293. * @returns the squared distance between vectors
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2296. /**
  2297. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2298. * @param value1 defines first vector
  2299. * @param value2 defines second vector
  2300. * @returns a new Vector2
  2301. */
  2302. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2303. /**
  2304. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2305. * @param p defines the middle point
  2306. * @param segA defines one point of the segment
  2307. * @param segB defines the other point of the segment
  2308. * @returns the shortest distance
  2309. */
  2310. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2311. }
  2312. /**
  2313. * Class used to store (x,y,z) vector representation
  2314. * A Vector3 is the main object used in 3D geometry
  2315. * It can represent etiher the coordinates of a point the space, either a direction
  2316. * Reminder: js uses a left handed forward facing system
  2317. */
  2318. export class Vector3 {
  2319. /**
  2320. * Defines the first coordinates (on X axis)
  2321. */
  2322. x: number;
  2323. /**
  2324. * Defines the second coordinates (on Y axis)
  2325. */
  2326. y: number;
  2327. /**
  2328. * Defines the third coordinates (on Z axis)
  2329. */
  2330. z: number;
  2331. private static _UpReadOnly;
  2332. private static _ZeroReadOnly;
  2333. /**
  2334. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2335. * @param x defines the first coordinates (on X axis)
  2336. * @param y defines the second coordinates (on Y axis)
  2337. * @param z defines the third coordinates (on Z axis)
  2338. */
  2339. constructor(
  2340. /**
  2341. * Defines the first coordinates (on X axis)
  2342. */
  2343. x?: number,
  2344. /**
  2345. * Defines the second coordinates (on Y axis)
  2346. */
  2347. y?: number,
  2348. /**
  2349. * Defines the third coordinates (on Z axis)
  2350. */
  2351. z?: number);
  2352. /**
  2353. * Creates a string representation of the Vector3
  2354. * @returns a string with the Vector3 coordinates.
  2355. */
  2356. toString(): string;
  2357. /**
  2358. * Gets the class name
  2359. * @returns the string "Vector3"
  2360. */
  2361. getClassName(): string;
  2362. /**
  2363. * Creates the Vector3 hash code
  2364. * @returns a number which tends to be unique between Vector3 instances
  2365. */
  2366. getHashCode(): number;
  2367. /**
  2368. * Creates an array containing three elements : the coordinates of the Vector3
  2369. * @returns a new array of numbers
  2370. */
  2371. asArray(): number[];
  2372. /**
  2373. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2374. * @param array defines the destination array
  2375. * @param index defines the offset in the destination array
  2376. * @returns the current Vector3
  2377. */
  2378. toArray(array: FloatArray, index?: number): Vector3;
  2379. /**
  2380. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2381. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2382. */
  2383. toQuaternion(): Quaternion;
  2384. /**
  2385. * Adds the given vector to the current Vector3
  2386. * @param otherVector defines the second operand
  2387. * @returns the current updated Vector3
  2388. */
  2389. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2390. /**
  2391. * Adds the given coordinates to the current Vector3
  2392. * @param x defines the x coordinate of the operand
  2393. * @param y defines the y coordinate of the operand
  2394. * @param z defines the z coordinate of the operand
  2395. * @returns the current updated Vector3
  2396. */
  2397. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2398. /**
  2399. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2400. * @param otherVector defines the second operand
  2401. * @returns the resulting Vector3
  2402. */
  2403. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2404. /**
  2405. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2406. * @param otherVector defines the second operand
  2407. * @param result defines the Vector3 object where to store the result
  2408. * @returns the current Vector3
  2409. */
  2410. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2411. /**
  2412. * Subtract the given vector from the current Vector3
  2413. * @param otherVector defines the second operand
  2414. * @returns the current updated Vector3
  2415. */
  2416. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2417. /**
  2418. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2419. * @param otherVector defines the second operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2423. /**
  2424. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2425. * @param otherVector defines the second operand
  2426. * @param result defines the Vector3 object where to store the result
  2427. * @returns the current Vector3
  2428. */
  2429. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2430. /**
  2431. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2432. * @param x defines the x coordinate of the operand
  2433. * @param y defines the y coordinate of the operand
  2434. * @param z defines the z coordinate of the operand
  2435. * @returns the resulting Vector3
  2436. */
  2437. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2438. /**
  2439. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2440. * @param x defines the x coordinate of the operand
  2441. * @param y defines the y coordinate of the operand
  2442. * @param z defines the z coordinate of the operand
  2443. * @param result defines the Vector3 object where to store the result
  2444. * @returns the current Vector3
  2445. */
  2446. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2447. /**
  2448. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2449. * @returns a new Vector3
  2450. */
  2451. negate(): Vector3;
  2452. /**
  2453. * Negate this vector in place
  2454. * @returns this
  2455. */
  2456. negateInPlace(): Vector3;
  2457. /**
  2458. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the current Vector3
  2461. */
  2462. negateToRef(result: Vector3): Vector3;
  2463. /**
  2464. * Multiplies the Vector3 coordinates by the float "scale"
  2465. * @param scale defines the multiplier factor
  2466. * @returns the current updated Vector3
  2467. */
  2468. scaleInPlace(scale: number): Vector3;
  2469. /**
  2470. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2471. * @param scale defines the multiplier factor
  2472. * @returns a new Vector3
  2473. */
  2474. scale(scale: number): Vector3;
  2475. /**
  2476. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2477. * @param scale defines the multiplier factor
  2478. * @param result defines the Vector3 object where to store the result
  2479. * @returns the current Vector3
  2480. */
  2481. scaleToRef(scale: number, result: Vector3): Vector3;
  2482. /**
  2483. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2484. * @param scale defines the scale factor
  2485. * @param result defines the Vector3 object where to store the result
  2486. * @returns the unmodified current Vector3
  2487. */
  2488. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2489. /**
  2490. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2491. * @param otherVector defines the second operand
  2492. * @returns true if both vectors are equals
  2493. */
  2494. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2495. /**
  2496. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2497. * @param otherVector defines the second operand
  2498. * @param epsilon defines the minimal distance to define values as equals
  2499. * @returns true if both vectors are distant less than epsilon
  2500. */
  2501. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2502. /**
  2503. * Returns true if the current Vector3 coordinates equals the given floats
  2504. * @param x defines the x coordinate of the operand
  2505. * @param y defines the y coordinate of the operand
  2506. * @param z defines the z coordinate of the operand
  2507. * @returns true if both vectors are equals
  2508. */
  2509. equalsToFloats(x: number, y: number, z: number): boolean;
  2510. /**
  2511. * Multiplies the current Vector3 coordinates by the given ones
  2512. * @param otherVector defines the second operand
  2513. * @returns the current updated Vector3
  2514. */
  2515. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2516. /**
  2517. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2518. * @param otherVector defines the second operand
  2519. * @returns the new Vector3
  2520. */
  2521. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2522. /**
  2523. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2524. * @param otherVector defines the second operand
  2525. * @param result defines the Vector3 object where to store the result
  2526. * @returns the current Vector3
  2527. */
  2528. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2529. /**
  2530. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2531. * @param x defines the x coordinate of the operand
  2532. * @param y defines the y coordinate of the operand
  2533. * @param z defines the z coordinate of the operand
  2534. * @returns the new Vector3
  2535. */
  2536. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2537. /**
  2538. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2539. * @param otherVector defines the second operand
  2540. * @returns the new Vector3
  2541. */
  2542. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2543. /**
  2544. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2545. * @param otherVector defines the second operand
  2546. * @param result defines the Vector3 object where to store the result
  2547. * @returns the current Vector3
  2548. */
  2549. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2550. /**
  2551. * Divides the current Vector3 coordinates by the given ones.
  2552. * @param otherVector defines the second operand
  2553. * @returns the current updated Vector3
  2554. */
  2555. divideInPlace(otherVector: Vector3): Vector3;
  2556. /**
  2557. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2558. * @param other defines the second operand
  2559. * @returns the current updated Vector3
  2560. */
  2561. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2562. /**
  2563. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2564. * @param other defines the second operand
  2565. * @returns the current updated Vector3
  2566. */
  2567. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2568. /**
  2569. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2570. * @param x defines the x coordinate of the operand
  2571. * @param y defines the y coordinate of the operand
  2572. * @param z defines the z coordinate of the operand
  2573. * @returns the current updated Vector3
  2574. */
  2575. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2576. /**
  2577. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2578. * @param x defines the x coordinate of the operand
  2579. * @param y defines the y coordinate of the operand
  2580. * @param z defines the z coordinate of the operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2584. /**
  2585. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2586. * Check if is non uniform within a certain amount of decimal places to account for this
  2587. * @param epsilon the amount the values can differ
  2588. * @returns if the the vector is non uniform to a certain number of decimal places
  2589. */
  2590. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2591. /**
  2592. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2593. */
  2594. get isNonUniform(): boolean;
  2595. /**
  2596. * Gets a new Vector3 from current Vector3 floored values
  2597. * @returns a new Vector3
  2598. */
  2599. floor(): Vector3;
  2600. /**
  2601. * Gets a new Vector3 from current Vector3 floored values
  2602. * @returns a new Vector3
  2603. */
  2604. fract(): Vector3;
  2605. /**
  2606. * Gets the length of the Vector3
  2607. * @returns the length of the Vector3
  2608. */
  2609. length(): number;
  2610. /**
  2611. * Gets the squared length of the Vector3
  2612. * @returns squared length of the Vector3
  2613. */
  2614. lengthSquared(): number;
  2615. /**
  2616. * Normalize the current Vector3.
  2617. * Please note that this is an in place operation.
  2618. * @returns the current updated Vector3
  2619. */
  2620. normalize(): Vector3;
  2621. /**
  2622. * Reorders the x y z properties of the vector in place
  2623. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2624. * @returns the current updated vector
  2625. */
  2626. reorderInPlace(order: string): this;
  2627. /**
  2628. * Rotates the vector around 0,0,0 by a quaternion
  2629. * @param quaternion the rotation quaternion
  2630. * @param result vector to store the result
  2631. * @returns the resulting vector
  2632. */
  2633. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2634. /**
  2635. * Rotates a vector around a given point
  2636. * @param quaternion the rotation quaternion
  2637. * @param point the point to rotate around
  2638. * @param result vector to store the result
  2639. * @returns the resulting vector
  2640. */
  2641. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2642. /**
  2643. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2644. * The cross product is then orthogonal to both current and "other"
  2645. * @param other defines the right operand
  2646. * @returns the cross product
  2647. */
  2648. cross(other: Vector3): Vector3;
  2649. /**
  2650. * Normalize the current Vector3 with the given input length.
  2651. * Please note that this is an in place operation.
  2652. * @param len the length of the vector
  2653. * @returns the current updated Vector3
  2654. */
  2655. normalizeFromLength(len: number): Vector3;
  2656. /**
  2657. * Normalize the current Vector3 to a new vector
  2658. * @returns the new Vector3
  2659. */
  2660. normalizeToNew(): Vector3;
  2661. /**
  2662. * Normalize the current Vector3 to the reference
  2663. * @param reference define the Vector3 to update
  2664. * @returns the updated Vector3
  2665. */
  2666. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Creates a new Vector3 copied from the current Vector3
  2669. * @returns the new Vector3
  2670. */
  2671. clone(): Vector3;
  2672. /**
  2673. * Copies the given vector coordinates to the current Vector3 ones
  2674. * @param source defines the source Vector3
  2675. * @returns the current updated Vector3
  2676. */
  2677. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2678. /**
  2679. * Copies the given floats to the current Vector3 coordinates
  2680. * @param x defines the x coordinate of the operand
  2681. * @param y defines the y coordinate of the operand
  2682. * @param z defines the z coordinate of the operand
  2683. * @returns the current updated Vector3
  2684. */
  2685. copyFromFloats(x: number, y: number, z: number): Vector3;
  2686. /**
  2687. * Copies the given floats to the current Vector3 coordinates
  2688. * @param x defines the x coordinate of the operand
  2689. * @param y defines the y coordinate of the operand
  2690. * @param z defines the z coordinate of the operand
  2691. * @returns the current updated Vector3
  2692. */
  2693. set(x: number, y: number, z: number): Vector3;
  2694. /**
  2695. * Copies the given float to the current Vector3 coordinates
  2696. * @param v defines the x, y and z coordinates of the operand
  2697. * @returns the current updated Vector3
  2698. */
  2699. setAll(v: number): Vector3;
  2700. /**
  2701. * Get the clip factor between two vectors
  2702. * @param vector0 defines the first operand
  2703. * @param vector1 defines the second operand
  2704. * @param axis defines the axis to use
  2705. * @param size defines the size along the axis
  2706. * @returns the clip factor
  2707. */
  2708. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2709. /**
  2710. * Get angle between two vectors
  2711. * @param vector0 angle between vector0 and vector1
  2712. * @param vector1 angle between vector0 and vector1
  2713. * @param normal direction of the normal
  2714. * @return the angle between vector0 and vector1
  2715. */
  2716. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2717. /**
  2718. * Returns a new Vector3 set from the index "offset" of the given array
  2719. * @param array defines the source array
  2720. * @param offset defines the offset in the source array
  2721. * @returns the new Vector3
  2722. */
  2723. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2724. /**
  2725. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2726. * @param array defines the source array
  2727. * @param offset defines the offset in the source array
  2728. * @returns the new Vector3
  2729. * @deprecated Please use FromArray instead.
  2730. */
  2731. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2732. /**
  2733. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2734. * @param array defines the source array
  2735. * @param offset defines the offset in the source array
  2736. * @param result defines the Vector3 where to store the result
  2737. */
  2738. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2739. /**
  2740. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  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. * @deprecated Please use FromArrayToRef instead.
  2745. */
  2746. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2747. /**
  2748. * Sets the given vector "result" with the given floats.
  2749. * @param x defines the x coordinate of the source
  2750. * @param y defines the y coordinate of the source
  2751. * @param z defines the z coordinate of the source
  2752. * @param result defines the Vector3 where to store the result
  2753. */
  2754. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2755. /**
  2756. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2757. * @returns a new empty Vector3
  2758. */
  2759. static Zero(): Vector3;
  2760. /**
  2761. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2762. * @returns a new unit Vector3
  2763. */
  2764. static One(): Vector3;
  2765. /**
  2766. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2767. * @returns a new up Vector3
  2768. */
  2769. static Up(): Vector3;
  2770. /**
  2771. * Gets a up Vector3 that must not be updated
  2772. */
  2773. static get UpReadOnly(): DeepImmutable<Vector3>;
  2774. /**
  2775. * Gets a zero Vector3 that must not be updated
  2776. */
  2777. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2778. /**
  2779. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2780. * @returns a new down Vector3
  2781. */
  2782. static Down(): Vector3;
  2783. /**
  2784. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2785. * @returns a new forward Vector3
  2786. */
  2787. static Forward(): Vector3;
  2788. /**
  2789. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2790. * @returns a new forward Vector3
  2791. */
  2792. static Backward(): Vector3;
  2793. /**
  2794. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2795. * @returns a new right Vector3
  2796. */
  2797. static Right(): Vector3;
  2798. /**
  2799. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2800. * @returns a new left Vector3
  2801. */
  2802. static Left(): Vector3;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2805. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the transformed Vector3
  2809. */
  2810. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2813. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2821. * This method computes tranformed coordinates only, not transformed direction vectors
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2831. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2832. * @param vector defines the Vector3 to transform
  2833. * @param transformation defines the transformation matrix
  2834. * @returns the new Vector3
  2835. */
  2836. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2837. /**
  2838. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2839. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2840. * @param vector defines the Vector3 to transform
  2841. * @param transformation defines the transformation matrix
  2842. * @param result defines the Vector3 where to store the result
  2843. */
  2844. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2847. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2848. * @param x define the x coordinate of the source vector
  2849. * @param y define the y coordinate of the source vector
  2850. * @param z define the z coordinate of the source vector
  2851. * @param transformation defines the transformation matrix
  2852. * @param result defines the Vector3 where to store the result
  2853. */
  2854. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2855. /**
  2856. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2857. * @param value1 defines the first control point
  2858. * @param value2 defines the second control point
  2859. * @param value3 defines the third control point
  2860. * @param value4 defines the fourth control point
  2861. * @param amount defines the amount on the spline to use
  2862. * @returns the new Vector3
  2863. */
  2864. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2865. /**
  2866. * 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"
  2867. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2868. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2869. * @param value defines the current value
  2870. * @param min defines the lower range value
  2871. * @param max defines the upper range value
  2872. * @returns the new Vector3
  2873. */
  2874. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2875. /**
  2876. * 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"
  2877. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2878. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2879. * @param value defines the current value
  2880. * @param min defines the lower range value
  2881. * @param max defines the upper range value
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2885. /**
  2886. * Checks if a given vector is inside a specific range
  2887. * @param v defines the vector to test
  2888. * @param min defines the minimum range
  2889. * @param max defines the maximum range
  2890. */
  2891. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2892. /**
  2893. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2894. * @param value1 defines the first control point
  2895. * @param tangent1 defines the first tangent vector
  2896. * @param value2 defines the second control point
  2897. * @param tangent2 defines the second tangent vector
  2898. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2899. * @returns the new Vector3
  2900. */
  2901. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2902. /**
  2903. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2904. * @param start defines the start value
  2905. * @param end defines the end value
  2906. * @param amount max defines amount between both (between 0 and 1)
  2907. * @returns the new Vector3
  2908. */
  2909. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2910. /**
  2911. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2912. * @param start defines the start value
  2913. * @param end defines the end value
  2914. * @param amount max defines amount between both (between 0 and 1)
  2915. * @param result defines the Vector3 where to store the result
  2916. */
  2917. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2918. /**
  2919. * Returns the dot product (float) between the vectors "left" and "right"
  2920. * @param left defines the left operand
  2921. * @param right defines the right operand
  2922. * @returns the dot product
  2923. */
  2924. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2925. /**
  2926. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2927. * The cross product is then orthogonal to both "left" and "right"
  2928. * @param left defines the left operand
  2929. * @param right defines the right operand
  2930. * @returns the cross product
  2931. */
  2932. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2933. /**
  2934. * Sets the given vector "result" with the cross product of "left" and "right"
  2935. * The cross product is then orthogonal to both "left" and "right"
  2936. * @param left defines the left operand
  2937. * @param right defines the right operand
  2938. * @param result defines the Vector3 where to store the result
  2939. */
  2940. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2941. /**
  2942. * Returns a new Vector3 as the normalization of the given vector
  2943. * @param vector defines the Vector3 to normalize
  2944. * @returns the new Vector3
  2945. */
  2946. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2947. /**
  2948. * Sets the given vector "result" with the normalization of the given first vector
  2949. * @param vector defines the Vector3 to normalize
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2953. /**
  2954. * Project a Vector3 onto screen space
  2955. * @param vector defines the Vector3 to project
  2956. * @param world defines the world matrix to use
  2957. * @param transform defines the transform (view x projection) matrix to use
  2958. * @param viewport defines the screen viewport to use
  2959. * @returns the new Vector3
  2960. */
  2961. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2962. /** @hidden */
  2963. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2964. /**
  2965. * Unproject from screen space to object space
  2966. * @param source defines the screen space Vector3 to use
  2967. * @param viewportWidth defines the current width of the viewport
  2968. * @param viewportHeight defines the current height of the viewport
  2969. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2970. * @param transform defines the transform (view x projection) matrix to use
  2971. * @returns the new Vector3
  2972. */
  2973. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2974. /**
  2975. * Unproject from screen space to object space
  2976. * @param source defines the screen space Vector3 to use
  2977. * @param viewportWidth defines the current width of the viewport
  2978. * @param viewportHeight defines the current height of the viewport
  2979. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2980. * @param view defines the view matrix to use
  2981. * @param projection defines the projection matrix to use
  2982. * @returns the new Vector3
  2983. */
  2984. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2985. /**
  2986. * Unproject from screen space to object space
  2987. * @param source defines the screen space Vector3 to use
  2988. * @param viewportWidth defines the current width of the viewport
  2989. * @param viewportHeight defines the current height of the viewport
  2990. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2991. * @param view defines the view matrix to use
  2992. * @param projection defines the projection matrix to use
  2993. * @param result defines the Vector3 where to store the result
  2994. */
  2995. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2996. /**
  2997. * Unproject from screen space to object space
  2998. * @param sourceX defines the screen space x coordinate to use
  2999. * @param sourceY defines the screen space y coordinate to use
  3000. * @param sourceZ defines the screen space z coordinate to use
  3001. * @param viewportWidth defines the current width of the viewport
  3002. * @param viewportHeight defines the current height of the viewport
  3003. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3004. * @param view defines the view matrix to use
  3005. * @param projection defines the projection matrix to use
  3006. * @param result defines the Vector3 where to store the result
  3007. */
  3008. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3009. /**
  3010. * Gets the minimal coordinate values between two Vector3
  3011. * @param left defines the first operand
  3012. * @param right defines the second operand
  3013. * @returns the new Vector3
  3014. */
  3015. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3016. /**
  3017. * Gets the maximal 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 Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * Returns the distance between the vectors "value1" and "value2"
  3025. * @param value1 defines the first operand
  3026. * @param value2 defines the second operand
  3027. * @returns the distance
  3028. */
  3029. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3030. /**
  3031. * Returns the squared distance between the vectors "value1" and "value2"
  3032. * @param value1 defines the first operand
  3033. * @param value2 defines the second operand
  3034. * @returns the squared distance
  3035. */
  3036. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3037. /**
  3038. * Returns a new Vector3 located at the center between "value1" and "value2"
  3039. * @param value1 defines the first operand
  3040. * @param value2 defines the second operand
  3041. * @returns the new Vector3
  3042. */
  3043. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3044. /**
  3045. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3046. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3047. * to something in order to rotate it from its local system to the given target system
  3048. * Note: axis1, axis2 and axis3 are normalized during this operation
  3049. * @param axis1 defines the first axis
  3050. * @param axis2 defines the second axis
  3051. * @param axis3 defines the third axis
  3052. * @returns a new Vector3
  3053. */
  3054. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3055. /**
  3056. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3057. * @param axis1 defines the first axis
  3058. * @param axis2 defines the second axis
  3059. * @param axis3 defines the third axis
  3060. * @param ref defines the Vector3 where to store the result
  3061. */
  3062. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3063. }
  3064. /**
  3065. * Vector4 class created for EulerAngle class conversion to Quaternion
  3066. */
  3067. export class Vector4 {
  3068. /** x value of the vector */
  3069. x: number;
  3070. /** y value of the vector */
  3071. y: number;
  3072. /** z value of the vector */
  3073. z: number;
  3074. /** w value of the vector */
  3075. w: number;
  3076. /**
  3077. * Creates a Vector4 object from the given floats.
  3078. * @param x x value of the vector
  3079. * @param y y value of the vector
  3080. * @param z z value of the vector
  3081. * @param w w value of the vector
  3082. */
  3083. constructor(
  3084. /** x value of the vector */
  3085. x: number,
  3086. /** y value of the vector */
  3087. y: number,
  3088. /** z value of the vector */
  3089. z: number,
  3090. /** w value of the vector */
  3091. w: number);
  3092. /**
  3093. * Returns the string with the Vector4 coordinates.
  3094. * @returns a string containing all the vector values
  3095. */
  3096. toString(): string;
  3097. /**
  3098. * Returns the string "Vector4".
  3099. * @returns "Vector4"
  3100. */
  3101. getClassName(): string;
  3102. /**
  3103. * Returns the Vector4 hash code.
  3104. * @returns a unique hash code
  3105. */
  3106. getHashCode(): number;
  3107. /**
  3108. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3109. * @returns the resulting array
  3110. */
  3111. asArray(): number[];
  3112. /**
  3113. * Populates the given array from the given index with the Vector4 coordinates.
  3114. * @param array array to populate
  3115. * @param index index of the array to start at (default: 0)
  3116. * @returns the Vector4.
  3117. */
  3118. toArray(array: FloatArray, index?: number): Vector4;
  3119. /**
  3120. * Adds the given vector to the current Vector4.
  3121. * @param otherVector the vector to add
  3122. * @returns the updated Vector4.
  3123. */
  3124. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3125. /**
  3126. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3127. * @param otherVector the vector to add
  3128. * @returns the resulting vector
  3129. */
  3130. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3131. /**
  3132. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3133. * @param otherVector the vector to add
  3134. * @param result the vector to store the result
  3135. * @returns the current Vector4.
  3136. */
  3137. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3138. /**
  3139. * Subtract in place the given vector from the current Vector4.
  3140. * @param otherVector the vector to subtract
  3141. * @returns the updated Vector4.
  3142. */
  3143. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3144. /**
  3145. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3146. * @param otherVector the vector to add
  3147. * @returns the new vector with the result
  3148. */
  3149. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3150. /**
  3151. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3152. * @param otherVector the vector to subtract
  3153. * @param result the vector to store the result
  3154. * @returns the current Vector4.
  3155. */
  3156. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3157. /**
  3158. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3159. */
  3160. /**
  3161. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3162. * @param x value to subtract
  3163. * @param y value to subtract
  3164. * @param z value to subtract
  3165. * @param w value to subtract
  3166. * @returns new vector containing the result
  3167. */
  3168. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3169. /**
  3170. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3171. * @param x value to subtract
  3172. * @param y value to subtract
  3173. * @param z value to subtract
  3174. * @param w value to subtract
  3175. * @param result the vector to store the result in
  3176. * @returns the current Vector4.
  3177. */
  3178. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3179. /**
  3180. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3181. * @returns a new vector with the negated values
  3182. */
  3183. negate(): Vector4;
  3184. /**
  3185. * Negate this vector in place
  3186. * @returns this
  3187. */
  3188. negateInPlace(): Vector4;
  3189. /**
  3190. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3191. * @param result defines the Vector3 object where to store the result
  3192. * @returns the current Vector4
  3193. */
  3194. negateToRef(result: Vector4): Vector4;
  3195. /**
  3196. * Multiplies the current Vector4 coordinates by scale (float).
  3197. * @param scale the number to scale with
  3198. * @returns the updated Vector4.
  3199. */
  3200. scaleInPlace(scale: number): Vector4;
  3201. /**
  3202. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3203. * @param scale the number to scale with
  3204. * @returns a new vector with the result
  3205. */
  3206. scale(scale: number): Vector4;
  3207. /**
  3208. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3209. * @param scale the number to scale with
  3210. * @param result a vector to store the result in
  3211. * @returns the current Vector4.
  3212. */
  3213. scaleToRef(scale: number, result: Vector4): Vector4;
  3214. /**
  3215. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3216. * @param scale defines the scale factor
  3217. * @param result defines the Vector4 object where to store the result
  3218. * @returns the unmodified current Vector4
  3219. */
  3220. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3221. /**
  3222. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3223. * @param otherVector the vector to compare against
  3224. * @returns true if they are equal
  3225. */
  3226. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3227. /**
  3228. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3229. * @param otherVector vector to compare against
  3230. * @param epsilon (Default: very small number)
  3231. * @returns true if they are equal
  3232. */
  3233. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3234. /**
  3235. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3236. * @param x x value to compare against
  3237. * @param y y value to compare against
  3238. * @param z z value to compare against
  3239. * @param w w value to compare against
  3240. * @returns true if equal
  3241. */
  3242. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3243. /**
  3244. * Multiplies in place the current Vector4 by the given one.
  3245. * @param otherVector vector to multiple with
  3246. * @returns the updated Vector4.
  3247. */
  3248. multiplyInPlace(otherVector: Vector4): Vector4;
  3249. /**
  3250. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3251. * @param otherVector vector to multiple with
  3252. * @returns resulting new vector
  3253. */
  3254. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3255. /**
  3256. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3257. * @param otherVector vector to multiple with
  3258. * @param result vector to store the result
  3259. * @returns the current Vector4.
  3260. */
  3261. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3262. /**
  3263. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3264. * @param x x value multiply with
  3265. * @param y y value multiply with
  3266. * @param z z value multiply with
  3267. * @param w w value multiply with
  3268. * @returns resulting new vector
  3269. */
  3270. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3271. /**
  3272. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3273. * @param otherVector vector to devide with
  3274. * @returns resulting new vector
  3275. */
  3276. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3277. /**
  3278. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3279. * @param otherVector vector to devide with
  3280. * @param result vector to store the result
  3281. * @returns the current Vector4.
  3282. */
  3283. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3284. /**
  3285. * Divides the current Vector3 coordinates by the given ones.
  3286. * @param otherVector vector to devide with
  3287. * @returns the updated Vector3.
  3288. */
  3289. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3290. /**
  3291. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3292. * @param other defines the second operand
  3293. * @returns the current updated Vector4
  3294. */
  3295. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3296. /**
  3297. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3298. * @param other defines the second operand
  3299. * @returns the current updated Vector4
  3300. */
  3301. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3302. /**
  3303. * Gets a new Vector4 from current Vector4 floored values
  3304. * @returns a new Vector4
  3305. */
  3306. floor(): Vector4;
  3307. /**
  3308. * Gets a new Vector4 from current Vector3 floored values
  3309. * @returns a new Vector4
  3310. */
  3311. fract(): Vector4;
  3312. /**
  3313. * Returns the Vector4 length (float).
  3314. * @returns the length
  3315. */
  3316. length(): number;
  3317. /**
  3318. * Returns the Vector4 squared length (float).
  3319. * @returns the length squared
  3320. */
  3321. lengthSquared(): number;
  3322. /**
  3323. * Normalizes in place the Vector4.
  3324. * @returns the updated Vector4.
  3325. */
  3326. normalize(): Vector4;
  3327. /**
  3328. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3329. * @returns this converted to a new vector3
  3330. */
  3331. toVector3(): Vector3;
  3332. /**
  3333. * Returns a new Vector4 copied from the current one.
  3334. * @returns the new cloned vector
  3335. */
  3336. clone(): Vector4;
  3337. /**
  3338. * Updates the current Vector4 with the given one coordinates.
  3339. * @param source the source vector to copy from
  3340. * @returns the updated Vector4.
  3341. */
  3342. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3343. /**
  3344. * Updates the current Vector4 coordinates with the given floats.
  3345. * @param x float to copy from
  3346. * @param y float to copy from
  3347. * @param z float to copy from
  3348. * @param w float to copy from
  3349. * @returns the updated Vector4.
  3350. */
  3351. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3352. /**
  3353. * Updates the current Vector4 coordinates with the given floats.
  3354. * @param x float to set from
  3355. * @param y float to set from
  3356. * @param z float to set from
  3357. * @param w float to set from
  3358. * @returns the updated Vector4.
  3359. */
  3360. set(x: number, y: number, z: number, w: number): Vector4;
  3361. /**
  3362. * Copies the given float to the current Vector3 coordinates
  3363. * @param v defines the x, y, z and w coordinates of the operand
  3364. * @returns the current updated Vector3
  3365. */
  3366. setAll(v: number): Vector4;
  3367. /**
  3368. * Returns a new Vector4 set from the starting index of the given array.
  3369. * @param array the array to pull values from
  3370. * @param offset the offset into the array to start at
  3371. * @returns the new vector
  3372. */
  3373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3374. /**
  3375. * Updates the given vector "result" 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. * @param result the vector to store the result in
  3379. */
  3380. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3381. /**
  3382. * Updates the given vector "result" from the starting index of the given Float32Array.
  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 FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3388. /**
  3389. * Updates the given vector "result" coordinates from the given floats.
  3390. * @param x float to set from
  3391. * @param y float to set from
  3392. * @param z float to set from
  3393. * @param w float to set from
  3394. * @param result the vector to the floats in
  3395. */
  3396. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3397. /**
  3398. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3399. * @returns the new vector
  3400. */
  3401. static Zero(): Vector4;
  3402. /**
  3403. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3404. * @returns the new vector
  3405. */
  3406. static One(): Vector4;
  3407. /**
  3408. * Returns a new normalized Vector4 from the given one.
  3409. * @param vector the vector to normalize
  3410. * @returns the vector
  3411. */
  3412. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3413. /**
  3414. * Updates the given vector "result" from the normalization of the given one.
  3415. * @param vector the vector to normalize
  3416. * @param result the vector to store the result in
  3417. */
  3418. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3419. /**
  3420. * Returns a vector with the minimum values from the left and right vectors
  3421. * @param left left vector to minimize
  3422. * @param right right vector to minimize
  3423. * @returns a new vector with the minimum of the left and right vector values
  3424. */
  3425. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3426. /**
  3427. * Returns a vector with the maximum values from the left and right vectors
  3428. * @param left left vector to maximize
  3429. * @param right right vector to maximize
  3430. * @returns a new vector with the maximum of the left and right vector values
  3431. */
  3432. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3433. /**
  3434. * Returns the distance (float) between the vectors "value1" and "value2".
  3435. * @param value1 value to calulate the distance between
  3436. * @param value2 value to calulate the distance between
  3437. * @return the distance between the two vectors
  3438. */
  3439. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3440. /**
  3441. * Returns the squared 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 squared
  3445. */
  3446. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3447. /**
  3448. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3449. * @param value1 value to calulate the center between
  3450. * @param value2 value to calulate the center between
  3451. * @return the center between the two vectors
  3452. */
  3453. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3454. /**
  3455. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3456. * This methods computes transformed normalized direction vectors only.
  3457. * @param vector the vector to transform
  3458. * @param transformation the transformation matrix to apply
  3459. * @returns the new vector
  3460. */
  3461. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3462. /**
  3463. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3464. * This methods computes transformed normalized direction vectors only.
  3465. * @param vector the vector to transform
  3466. * @param transformation the transformation matrix to apply
  3467. * @param result the vector to store the result in
  3468. */
  3469. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3470. /**
  3471. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3472. * This methods computes transformed normalized direction vectors only.
  3473. * @param x value to transform
  3474. * @param y value to transform
  3475. * @param z value to transform
  3476. * @param w value to transform
  3477. * @param transformation the transformation matrix to apply
  3478. * @param result the vector to store the results in
  3479. */
  3480. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3481. /**
  3482. * Creates a new Vector4 from a Vector3
  3483. * @param source defines the source data
  3484. * @param w defines the 4th component (default is 0)
  3485. * @returns a new Vector4
  3486. */
  3487. static FromVector3(source: Vector3, w?: number): Vector4;
  3488. }
  3489. /**
  3490. * Class used to store quaternion data
  3491. * @see https://en.wikipedia.org/wiki/Quaternion
  3492. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3493. */
  3494. export class Quaternion {
  3495. /** defines the first component (0 by default) */
  3496. x: number;
  3497. /** defines the second component (0 by default) */
  3498. y: number;
  3499. /** defines the third component (0 by default) */
  3500. z: number;
  3501. /** defines the fourth component (1.0 by default) */
  3502. w: number;
  3503. /**
  3504. * Creates a new Quaternion from the given floats
  3505. * @param x defines the first component (0 by default)
  3506. * @param y defines the second component (0 by default)
  3507. * @param z defines the third component (0 by default)
  3508. * @param w defines the fourth component (1.0 by default)
  3509. */
  3510. constructor(
  3511. /** defines the first component (0 by default) */
  3512. x?: number,
  3513. /** defines the second component (0 by default) */
  3514. y?: number,
  3515. /** defines the third component (0 by default) */
  3516. z?: number,
  3517. /** defines the fourth component (1.0 by default) */
  3518. w?: number);
  3519. /**
  3520. * Gets a string representation for the current quaternion
  3521. * @returns a string with the Quaternion coordinates
  3522. */
  3523. toString(): string;
  3524. /**
  3525. * Gets the class name of the quaternion
  3526. * @returns the string "Quaternion"
  3527. */
  3528. getClassName(): string;
  3529. /**
  3530. * Gets a hash code for this quaternion
  3531. * @returns the quaternion hash code
  3532. */
  3533. getHashCode(): number;
  3534. /**
  3535. * Copy the quaternion to an array
  3536. * @returns a new array populated with 4 elements from the quaternion coordinates
  3537. */
  3538. asArray(): number[];
  3539. /**
  3540. * Check if two quaternions are equals
  3541. * @param otherQuaternion defines the second operand
  3542. * @return true if the current quaternion and the given one coordinates are strictly equals
  3543. */
  3544. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3545. /**
  3546. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3547. * @param otherQuaternion defines the other quaternion
  3548. * @param epsilon defines the minimal distance to consider equality
  3549. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3550. */
  3551. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3552. /**
  3553. * Clone the current quaternion
  3554. * @returns a new quaternion copied from the current one
  3555. */
  3556. clone(): Quaternion;
  3557. /**
  3558. * Copy a quaternion to the current one
  3559. * @param other defines the other quaternion
  3560. * @returns the updated current quaternion
  3561. */
  3562. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3563. /**
  3564. * Updates the current quaternion with the given float coordinates
  3565. * @param x defines the x coordinate
  3566. * @param y defines the y coordinate
  3567. * @param z defines the z coordinate
  3568. * @param w defines the w coordinate
  3569. * @returns the updated current quaternion
  3570. */
  3571. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3572. /**
  3573. * Updates the current quaternion from the given float coordinates
  3574. * @param x defines the x coordinate
  3575. * @param y defines the y coordinate
  3576. * @param z defines the z coordinate
  3577. * @param w defines the w coordinate
  3578. * @returns the updated current quaternion
  3579. */
  3580. set(x: number, y: number, z: number, w: number): Quaternion;
  3581. /**
  3582. * Adds two quaternions
  3583. * @param other defines the second operand
  3584. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3585. */
  3586. add(other: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Add a quaternion to the current one
  3589. * @param other defines the quaternion to add
  3590. * @returns the current quaternion
  3591. */
  3592. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3593. /**
  3594. * Subtract two quaternions
  3595. * @param other defines the second operand
  3596. * @returns a new quaternion as the subtraction result of the given one from the current one
  3597. */
  3598. subtract(other: Quaternion): Quaternion;
  3599. /**
  3600. * Multiplies the current quaternion by a scale factor
  3601. * @param value defines the scale factor
  3602. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3603. */
  3604. scale(value: number): Quaternion;
  3605. /**
  3606. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3607. * @param scale defines the scale factor
  3608. * @param result defines the Quaternion object where to store the result
  3609. * @returns the unmodified current quaternion
  3610. */
  3611. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3612. /**
  3613. * Multiplies in place the current quaternion by a scale factor
  3614. * @param value defines the scale factor
  3615. * @returns the current modified quaternion
  3616. */
  3617. scaleInPlace(value: number): Quaternion;
  3618. /**
  3619. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3620. * @param scale defines the scale factor
  3621. * @param result defines the Quaternion object where to store the result
  3622. * @returns the unmodified current quaternion
  3623. */
  3624. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3625. /**
  3626. * Multiplies two quaternions
  3627. * @param q1 defines the second operand
  3628. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3629. */
  3630. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3631. /**
  3632. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3633. * @param q1 defines the second operand
  3634. * @param result defines the target quaternion
  3635. * @returns the current quaternion
  3636. */
  3637. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3638. /**
  3639. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3640. * @param q1 defines the second operand
  3641. * @returns the currentupdated quaternion
  3642. */
  3643. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3644. /**
  3645. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3646. * @param ref defines the target quaternion
  3647. * @returns the current quaternion
  3648. */
  3649. conjugateToRef(ref: Quaternion): Quaternion;
  3650. /**
  3651. * Conjugates in place (1-q) the current quaternion
  3652. * @returns the current updated quaternion
  3653. */
  3654. conjugateInPlace(): Quaternion;
  3655. /**
  3656. * Conjugates in place (1-q) the current quaternion
  3657. * @returns a new quaternion
  3658. */
  3659. conjugate(): Quaternion;
  3660. /**
  3661. * Gets length of current quaternion
  3662. * @returns the quaternion length (float)
  3663. */
  3664. length(): number;
  3665. /**
  3666. * Normalize in place the current quaternion
  3667. * @returns the current updated quaternion
  3668. */
  3669. normalize(): Quaternion;
  3670. /**
  3671. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3672. * @param order is a reserved parameter and is ignore for now
  3673. * @returns a new Vector3 containing the Euler angles
  3674. */
  3675. toEulerAngles(order?: string): Vector3;
  3676. /**
  3677. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3678. * @param result defines the vector which will be filled with the Euler angles
  3679. * @param order is a reserved parameter and is ignore for now
  3680. * @returns the current unchanged quaternion
  3681. */
  3682. toEulerAnglesToRef(result: Vector3): Quaternion;
  3683. /**
  3684. * Updates the given rotation matrix with the current quaternion values
  3685. * @param result defines the target matrix
  3686. * @returns the current unchanged quaternion
  3687. */
  3688. toRotationMatrix(result: Matrix): Quaternion;
  3689. /**
  3690. * Updates the current quaternion from the given rotation matrix values
  3691. * @param matrix defines the source matrix
  3692. * @returns the current updated quaternion
  3693. */
  3694. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3695. /**
  3696. * Creates a new quaternion from a rotation matrix
  3697. * @param matrix defines the source matrix
  3698. * @returns a new quaternion created from the given rotation matrix values
  3699. */
  3700. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3701. /**
  3702. * Updates the given quaternion with the given rotation matrix values
  3703. * @param matrix defines the source matrix
  3704. * @param result defines the target quaternion
  3705. */
  3706. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3707. /**
  3708. * Returns the dot product (float) between the quaternions "left" and "right"
  3709. * @param left defines the left operand
  3710. * @param right defines the right operand
  3711. * @returns the dot product
  3712. */
  3713. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3714. /**
  3715. * Checks if the two quaternions are close to each other
  3716. * @param quat0 defines the first quaternion to check
  3717. * @param quat1 defines the second quaternion to check
  3718. * @returns true if the two quaternions are close to each other
  3719. */
  3720. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3721. /**
  3722. * Creates an empty quaternion
  3723. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3724. */
  3725. static Zero(): Quaternion;
  3726. /**
  3727. * Inverse a given quaternion
  3728. * @param q defines the source quaternion
  3729. * @returns a new quaternion as the inverted current quaternion
  3730. */
  3731. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3732. /**
  3733. * Inverse a given quaternion
  3734. * @param q defines the source quaternion
  3735. * @param result the quaternion the result will be stored in
  3736. * @returns the result quaternion
  3737. */
  3738. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3739. /**
  3740. * Creates an identity quaternion
  3741. * @returns the identity quaternion
  3742. */
  3743. static Identity(): Quaternion;
  3744. /**
  3745. * Gets a boolean indicating if the given quaternion is identity
  3746. * @param quaternion defines the quaternion to check
  3747. * @returns true if the quaternion is identity
  3748. */
  3749. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3750. /**
  3751. * Creates a quaternion from a rotation around an axis
  3752. * @param axis defines the axis to use
  3753. * @param angle defines the angle to use
  3754. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3755. */
  3756. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3757. /**
  3758. * Creates a rotation around an axis and stores it into the given quaternion
  3759. * @param axis defines the axis to use
  3760. * @param angle defines the angle to use
  3761. * @param result defines the target quaternion
  3762. * @returns the target quaternion
  3763. */
  3764. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3765. /**
  3766. * Creates a new quaternion from data stored into an array
  3767. * @param array defines the data source
  3768. * @param offset defines the offset in the source array where the data starts
  3769. * @returns a new quaternion
  3770. */
  3771. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3772. /**
  3773. * Updates the given quaternion "result" from the starting index of the given array.
  3774. * @param array the array to pull values from
  3775. * @param offset the offset into the array to start at
  3776. * @param result the quaternion to store the result in
  3777. */
  3778. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  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. _getVertexShaderCode(): string | null;
  7245. _getFragmentShaderCode(): string | null;
  7246. }
  7247. }
  7248. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7249. import { FloatArray, Nullable } from "babylonjs/types";
  7250. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7251. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7252. module "babylonjs/Engines/thinEngine" {
  7253. interface ThinEngine {
  7254. /**
  7255. * Create an uniform buffer
  7256. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7257. * @param elements defines the content of the uniform buffer
  7258. * @returns the webGL uniform buffer
  7259. */
  7260. createUniformBuffer(elements: FloatArray): DataBuffer;
  7261. /**
  7262. * Create a dynamic uniform buffer
  7263. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7264. * @param elements defines the content of the uniform buffer
  7265. * @returns the webGL uniform buffer
  7266. */
  7267. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7268. /**
  7269. * Update an existing uniform buffer
  7270. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7271. * @param uniformBuffer defines the target uniform buffer
  7272. * @param elements defines the content to update
  7273. * @param offset defines the offset in the uniform buffer where update should start
  7274. * @param count defines the size of the data to update
  7275. */
  7276. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7277. /**
  7278. * Bind an uniform buffer to the current webGL context
  7279. * @param buffer defines the buffer to bind
  7280. */
  7281. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7282. /**
  7283. * Bind a buffer to the current webGL context at a given location
  7284. * @param buffer defines the buffer to bind
  7285. * @param location defines the index where to bind the buffer
  7286. */
  7287. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7288. /**
  7289. * Bind a specific block at a given index in a specific shader program
  7290. * @param pipelineContext defines the pipeline context to use
  7291. * @param blockName defines the block name
  7292. * @param index defines the index where to bind the block
  7293. */
  7294. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7295. }
  7296. }
  7297. }
  7298. declare module "babylonjs/Materials/uniformBuffer" {
  7299. import { Nullable, FloatArray } from "babylonjs/types";
  7300. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7301. import { Engine } from "babylonjs/Engines/engine";
  7302. import { Effect } from "babylonjs/Materials/effect";
  7303. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7304. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7305. import { Color3 } from "babylonjs/Maths/math.color";
  7306. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7307. /**
  7308. * Uniform buffer objects.
  7309. *
  7310. * Handles blocks of uniform on the GPU.
  7311. *
  7312. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7313. *
  7314. * For more information, please refer to :
  7315. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7316. */
  7317. export class UniformBuffer {
  7318. private _engine;
  7319. private _buffer;
  7320. private _data;
  7321. private _bufferData;
  7322. private _dynamic?;
  7323. private _uniformLocations;
  7324. private _uniformSizes;
  7325. private _uniformLocationPointer;
  7326. private _needSync;
  7327. private _noUBO;
  7328. private _currentEffect;
  7329. /** @hidden */
  7330. _alreadyBound: boolean;
  7331. private static _MAX_UNIFORM_SIZE;
  7332. private static _tempBuffer;
  7333. /**
  7334. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7339. /**
  7340. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7341. * This is dynamic to allow compat with webgl 1 and 2.
  7342. * You will need to pass the name of the uniform as well as the value.
  7343. */
  7344. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7345. /**
  7346. * Lambda to Update a single float in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateFloat: (name: string, x: number) => void;
  7351. /**
  7352. * Lambda to Update a vec2 of float in a uniform buffer.
  7353. * This is dynamic to allow compat with webgl 1 and 2.
  7354. * You will need to pass the name of the uniform as well as the value.
  7355. */
  7356. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7357. /**
  7358. * Lambda to Update a vec3 of float in a uniform buffer.
  7359. * This is dynamic to allow compat with webgl 1 and 2.
  7360. * You will need to pass the name of the uniform as well as the value.
  7361. */
  7362. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7363. /**
  7364. * Lambda to Update a vec4 of float in a uniform buffer.
  7365. * This is dynamic to allow compat with webgl 1 and 2.
  7366. * You will need to pass the name of the uniform as well as the value.
  7367. */
  7368. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7369. /**
  7370. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7371. * This is dynamic to allow compat with webgl 1 and 2.
  7372. * You will need to pass the name of the uniform as well as the value.
  7373. */
  7374. updateMatrix: (name: string, mat: Matrix) => void;
  7375. /**
  7376. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7377. * This is dynamic to allow compat with webgl 1 and 2.
  7378. * You will need to pass the name of the uniform as well as the value.
  7379. */
  7380. updateVector3: (name: string, vector: Vector3) => void;
  7381. /**
  7382. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7383. * This is dynamic to allow compat with webgl 1 and 2.
  7384. * You will need to pass the name of the uniform as well as the value.
  7385. */
  7386. updateVector4: (name: string, vector: Vector4) => void;
  7387. /**
  7388. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7389. * This is dynamic to allow compat with webgl 1 and 2.
  7390. * You will need to pass the name of the uniform as well as the value.
  7391. */
  7392. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7393. /**
  7394. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7395. * This is dynamic to allow compat with webgl 1 and 2.
  7396. * You will need to pass the name of the uniform as well as the value.
  7397. */
  7398. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7399. /**
  7400. * Instantiates a new Uniform buffer objects.
  7401. *
  7402. * Handles blocks of uniform on the GPU.
  7403. *
  7404. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7405. *
  7406. * For more information, please refer to :
  7407. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7408. * @param engine Define the engine the buffer is associated with
  7409. * @param data Define the data contained in the buffer
  7410. * @param dynamic Define if the buffer is updatable
  7411. */
  7412. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7413. /**
  7414. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7415. * or just falling back on setUniformXXX calls.
  7416. */
  7417. get useUbo(): boolean;
  7418. /**
  7419. * Indicates if the WebGL underlying uniform buffer is in sync
  7420. * with the javascript cache data.
  7421. */
  7422. get isSync(): boolean;
  7423. /**
  7424. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7425. * Also, a dynamic UniformBuffer will disable cache verification and always
  7426. * update the underlying WebGL uniform buffer to the GPU.
  7427. * @returns if Dynamic, otherwise false
  7428. */
  7429. isDynamic(): boolean;
  7430. /**
  7431. * The data cache on JS side.
  7432. * @returns the underlying data as a float array
  7433. */
  7434. getData(): Float32Array;
  7435. /**
  7436. * The underlying WebGL Uniform buffer.
  7437. * @returns the webgl buffer
  7438. */
  7439. getBuffer(): Nullable<DataBuffer>;
  7440. /**
  7441. * std140 layout specifies how to align data within an UBO structure.
  7442. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7443. * for specs.
  7444. */
  7445. private _fillAlignment;
  7446. /**
  7447. * Adds an uniform in the buffer.
  7448. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7449. * for the layout to be correct !
  7450. * @param name Name of the uniform, as used in the uniform block in the shader.
  7451. * @param size Data size, or data directly.
  7452. */
  7453. addUniform(name: string, size: number | number[]): void;
  7454. /**
  7455. * Adds a Matrix 4x4 to the uniform buffer.
  7456. * @param name Name of the uniform, as used in the uniform block in the shader.
  7457. * @param mat A 4x4 matrix.
  7458. */
  7459. addMatrix(name: string, mat: Matrix): void;
  7460. /**
  7461. * Adds a vec2 to the uniform buffer.
  7462. * @param name Name of the uniform, as used in the uniform block in the shader.
  7463. * @param x Define the x component value of the vec2
  7464. * @param y Define the y component value of the vec2
  7465. */
  7466. addFloat2(name: string, x: number, y: number): void;
  7467. /**
  7468. * Adds a vec3 to the uniform buffer.
  7469. * @param name Name of the uniform, as used in the uniform block in the shader.
  7470. * @param x Define the x component value of the vec3
  7471. * @param y Define the y component value of the vec3
  7472. * @param z Define the z component value of the vec3
  7473. */
  7474. addFloat3(name: string, x: number, y: number, z: number): void;
  7475. /**
  7476. * Adds a vec3 to the uniform buffer.
  7477. * @param name Name of the uniform, as used in the uniform block in the shader.
  7478. * @param color Define the vec3 from a Color
  7479. */
  7480. addColor3(name: string, color: Color3): void;
  7481. /**
  7482. * Adds a vec4 to the uniform buffer.
  7483. * @param name Name of the uniform, as used in the uniform block in the shader.
  7484. * @param color Define the rgb components from a Color
  7485. * @param alpha Define the a component of the vec4
  7486. */
  7487. addColor4(name: string, color: Color3, alpha: number): void;
  7488. /**
  7489. * Adds a vec3 to the uniform buffer.
  7490. * @param name Name of the uniform, as used in the uniform block in the shader.
  7491. * @param vector Define the vec3 components from a Vector
  7492. */
  7493. addVector3(name: string, vector: Vector3): void;
  7494. /**
  7495. * Adds a Matrix 3x3 to the uniform buffer.
  7496. * @param name Name of the uniform, as used in the uniform block in the shader.
  7497. */
  7498. addMatrix3x3(name: string): void;
  7499. /**
  7500. * Adds a Matrix 2x2 to the uniform buffer.
  7501. * @param name Name of the uniform, as used in the uniform block in the shader.
  7502. */
  7503. addMatrix2x2(name: string): void;
  7504. /**
  7505. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7506. */
  7507. create(): void;
  7508. /** @hidden */
  7509. _rebuild(): void;
  7510. /**
  7511. * Updates the WebGL Uniform Buffer on the GPU.
  7512. * If the `dynamic` flag is set to true, no cache comparison is done.
  7513. * Otherwise, the buffer will be updated only if the cache differs.
  7514. */
  7515. update(): void;
  7516. /**
  7517. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7518. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7519. * @param data Define the flattened data
  7520. * @param size Define the size of the data.
  7521. */
  7522. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7523. private _valueCache;
  7524. private _cacheMatrix;
  7525. private _updateMatrix3x3ForUniform;
  7526. private _updateMatrix3x3ForEffect;
  7527. private _updateMatrix2x2ForEffect;
  7528. private _updateMatrix2x2ForUniform;
  7529. private _updateFloatForEffect;
  7530. private _updateFloatForUniform;
  7531. private _updateFloat2ForEffect;
  7532. private _updateFloat2ForUniform;
  7533. private _updateFloat3ForEffect;
  7534. private _updateFloat3ForUniform;
  7535. private _updateFloat4ForEffect;
  7536. private _updateFloat4ForUniform;
  7537. private _updateMatrixForEffect;
  7538. private _updateMatrixForUniform;
  7539. private _updateVector3ForEffect;
  7540. private _updateVector3ForUniform;
  7541. private _updateVector4ForEffect;
  7542. private _updateVector4ForUniform;
  7543. private _updateColor3ForEffect;
  7544. private _updateColor3ForUniform;
  7545. private _updateColor4ForEffect;
  7546. private _updateColor4ForUniform;
  7547. /**
  7548. * Sets a sampler uniform on the effect.
  7549. * @param name Define the name of the sampler.
  7550. * @param texture Define the texture to set in the sampler
  7551. */
  7552. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7553. /**
  7554. * Directly updates the value of the uniform in the cache AND on the GPU.
  7555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7556. * @param data Define the flattened data
  7557. */
  7558. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7559. /**
  7560. * Binds this uniform buffer to an effect.
  7561. * @param effect Define the effect to bind the buffer to
  7562. * @param name Name of the uniform block in the shader.
  7563. */
  7564. bindToEffect(effect: Effect, name: string): void;
  7565. /**
  7566. * Disposes the uniform buffer.
  7567. */
  7568. dispose(): void;
  7569. }
  7570. }
  7571. declare module "babylonjs/Misc/iInspectable" {
  7572. /**
  7573. * Enum that determines the text-wrapping mode to use.
  7574. */
  7575. export enum InspectableType {
  7576. /**
  7577. * Checkbox for booleans
  7578. */
  7579. Checkbox = 0,
  7580. /**
  7581. * Sliders for numbers
  7582. */
  7583. Slider = 1,
  7584. /**
  7585. * Vector3
  7586. */
  7587. Vector3 = 2,
  7588. /**
  7589. * Quaternions
  7590. */
  7591. Quaternion = 3,
  7592. /**
  7593. * Color3
  7594. */
  7595. Color3 = 4,
  7596. /**
  7597. * String
  7598. */
  7599. String = 5
  7600. }
  7601. /**
  7602. * Interface used to define custom inspectable properties.
  7603. * This interface is used by the inspector to display custom property grids
  7604. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7605. */
  7606. export interface IInspectable {
  7607. /**
  7608. * Gets the label to display
  7609. */
  7610. label: string;
  7611. /**
  7612. * Gets the name of the property to edit
  7613. */
  7614. propertyName: string;
  7615. /**
  7616. * Gets the type of the editor to use
  7617. */
  7618. type: InspectableType;
  7619. /**
  7620. * Gets the minimum value of the property when using in "slider" mode
  7621. */
  7622. min?: number;
  7623. /**
  7624. * Gets the maximum value of the property when using in "slider" mode
  7625. */
  7626. max?: number;
  7627. /**
  7628. * Gets the setp to use when using in "slider" mode
  7629. */
  7630. step?: number;
  7631. }
  7632. }
  7633. declare module "babylonjs/Misc/timingTools" {
  7634. /**
  7635. * Class used to provide helper for timing
  7636. */
  7637. export class TimingTools {
  7638. /**
  7639. * Polyfill for setImmediate
  7640. * @param action defines the action to execute after the current execution block
  7641. */
  7642. static SetImmediate(action: () => void): void;
  7643. }
  7644. }
  7645. declare module "babylonjs/Misc/instantiationTools" {
  7646. /**
  7647. * Class used to enable instatition of objects by class name
  7648. */
  7649. export class InstantiationTools {
  7650. /**
  7651. * Use this object to register external classes like custom textures or material
  7652. * to allow the laoders to instantiate them
  7653. */
  7654. static RegisteredExternalClasses: {
  7655. [key: string]: Object;
  7656. };
  7657. /**
  7658. * Tries to instantiate a new object from a given class name
  7659. * @param className defines the class name to instantiate
  7660. * @returns the new object or null if the system was not able to do the instantiation
  7661. */
  7662. static Instantiate(className: string): any;
  7663. }
  7664. }
  7665. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7666. /**
  7667. * Define options used to create a depth texture
  7668. */
  7669. export class DepthTextureCreationOptions {
  7670. /** Specifies whether or not a stencil should be allocated in the texture */
  7671. generateStencil?: boolean;
  7672. /** Specifies whether or not bilinear filtering is enable on the texture */
  7673. bilinearFiltering?: boolean;
  7674. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7675. comparisonFunction?: number;
  7676. /** Specifies if the created texture is a cube texture */
  7677. isCube?: boolean;
  7678. }
  7679. }
  7680. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7681. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7682. import { Nullable } from "babylonjs/types";
  7683. import { Scene } from "babylonjs/scene";
  7684. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7685. module "babylonjs/Engines/thinEngine" {
  7686. interface ThinEngine {
  7687. /**
  7688. * Creates a depth stencil cube texture.
  7689. * This is only available in WebGL 2.
  7690. * @param size The size of face edge in the cube texture.
  7691. * @param options The options defining the cube texture.
  7692. * @returns The cube texture
  7693. */
  7694. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7695. /**
  7696. * Creates a cube texture
  7697. * @param rootUrl defines the url where the files to load is located
  7698. * @param scene defines the current scene
  7699. * @param files defines the list of files to load (1 per face)
  7700. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7701. * @param onLoad defines an optional callback raised when the texture is loaded
  7702. * @param onError defines an optional callback raised if there is an issue to load the texture
  7703. * @param format defines the format of the data
  7704. * @param forcedExtension defines the extension to use to pick the right loader
  7705. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7706. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7707. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7708. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  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>): 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. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8662. * panning
  8663. */
  8664. invertRotation: boolean;
  8665. /**
  8666. * Speed multiplier for inverse camera panning
  8667. */
  8668. inverseRotationSpeed: number;
  8669. /**
  8670. * Define the current target of the camera as an object or a position.
  8671. */
  8672. lockedTarget: any;
  8673. /** @hidden */
  8674. _currentTarget: Vector3;
  8675. /** @hidden */
  8676. _initialFocalDistance: number;
  8677. /** @hidden */
  8678. _viewMatrix: Matrix;
  8679. /** @hidden */
  8680. _camMatrix: Matrix;
  8681. /** @hidden */
  8682. _cameraTransformMatrix: Matrix;
  8683. /** @hidden */
  8684. _cameraRotationMatrix: Matrix;
  8685. /** @hidden */
  8686. _referencePoint: Vector3;
  8687. /** @hidden */
  8688. _transformedReferencePoint: Vector3;
  8689. protected _globalCurrentTarget: Vector3;
  8690. protected _globalCurrentUpVector: Vector3;
  8691. /** @hidden */
  8692. _reset: () => void;
  8693. private _defaultUp;
  8694. /**
  8695. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8696. * This is the base of the follow, arc rotate cameras and Free camera
  8697. * @see http://doc.babylonjs.com/features/cameras
  8698. * @param name Defines the name of the camera in the scene
  8699. * @param position Defines the start position of the camera in the scene
  8700. * @param scene Defines the scene the camera belongs to
  8701. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8702. */
  8703. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8704. /**
  8705. * Gets the position in front of the camera at a given distance.
  8706. * @param distance The distance from the camera we want the position to be
  8707. * @returns the position
  8708. */
  8709. getFrontPosition(distance: number): Vector3;
  8710. /** @hidden */
  8711. _getLockedTargetPosition(): Nullable<Vector3>;
  8712. private _storedPosition;
  8713. private _storedRotation;
  8714. private _storedRotationQuaternion;
  8715. /**
  8716. * Store current camera state of the camera (fov, position, rotation, etc..)
  8717. * @returns the camera
  8718. */
  8719. storeState(): Camera;
  8720. /**
  8721. * Restored camera state. You must call storeState() first
  8722. * @returns whether it was successful or not
  8723. * @hidden
  8724. */
  8725. _restoreStateValues(): boolean;
  8726. /** @hidden */
  8727. _initCache(): void;
  8728. /** @hidden */
  8729. _updateCache(ignoreParentClass?: boolean): void;
  8730. /** @hidden */
  8731. _isSynchronizedViewMatrix(): boolean;
  8732. /** @hidden */
  8733. _computeLocalCameraSpeed(): number;
  8734. /**
  8735. * Defines the target the camera should look at.
  8736. * @param target Defines the new target as a Vector or a mesh
  8737. */
  8738. setTarget(target: Vector3): void;
  8739. /**
  8740. * Return the current target position of the camera. This value is expressed in local space.
  8741. * @returns the target position
  8742. */
  8743. getTarget(): Vector3;
  8744. /** @hidden */
  8745. _decideIfNeedsToMove(): boolean;
  8746. /** @hidden */
  8747. _updatePosition(): void;
  8748. /** @hidden */
  8749. _checkInputs(): void;
  8750. protected _updateCameraRotationMatrix(): void;
  8751. /**
  8752. * 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)
  8753. * @returns the current camera
  8754. */
  8755. private _rotateUpVectorWithCameraRotationMatrix;
  8756. private _cachedRotationZ;
  8757. private _cachedQuaternionRotationZ;
  8758. /** @hidden */
  8759. _getViewMatrix(): Matrix;
  8760. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8761. /**
  8762. * @hidden
  8763. */
  8764. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8765. /**
  8766. * @hidden
  8767. */
  8768. _updateRigCameras(): void;
  8769. private _getRigCamPositionAndTarget;
  8770. /**
  8771. * Gets the current object class name.
  8772. * @return the class name
  8773. */
  8774. getClassName(): string;
  8775. }
  8776. }
  8777. declare module "babylonjs/Events/keyboardEvents" {
  8778. /**
  8779. * Gather the list of keyboard event types as constants.
  8780. */
  8781. export class KeyboardEventTypes {
  8782. /**
  8783. * The keydown event is fired when a key becomes active (pressed).
  8784. */
  8785. static readonly KEYDOWN: number;
  8786. /**
  8787. * The keyup event is fired when a key has been released.
  8788. */
  8789. static readonly KEYUP: number;
  8790. }
  8791. /**
  8792. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8793. */
  8794. export class KeyboardInfo {
  8795. /**
  8796. * Defines the type of event (KeyboardEventTypes)
  8797. */
  8798. type: number;
  8799. /**
  8800. * Defines the related dom event
  8801. */
  8802. event: KeyboardEvent;
  8803. /**
  8804. * Instantiates a new keyboard info.
  8805. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8806. * @param type Defines the type of event (KeyboardEventTypes)
  8807. * @param event Defines the related dom event
  8808. */
  8809. constructor(
  8810. /**
  8811. * Defines the type of event (KeyboardEventTypes)
  8812. */
  8813. type: number,
  8814. /**
  8815. * Defines the related dom event
  8816. */
  8817. event: KeyboardEvent);
  8818. }
  8819. /**
  8820. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8821. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8822. */
  8823. export class KeyboardInfoPre extends KeyboardInfo {
  8824. /**
  8825. * Defines the type of event (KeyboardEventTypes)
  8826. */
  8827. type: number;
  8828. /**
  8829. * Defines the related dom event
  8830. */
  8831. event: KeyboardEvent;
  8832. /**
  8833. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8834. */
  8835. skipOnPointerObservable: boolean;
  8836. /**
  8837. * Instantiates a new keyboard pre info.
  8838. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8839. * @param type Defines the type of event (KeyboardEventTypes)
  8840. * @param event Defines the related dom event
  8841. */
  8842. constructor(
  8843. /**
  8844. * Defines the type of event (KeyboardEventTypes)
  8845. */
  8846. type: number,
  8847. /**
  8848. * Defines the related dom event
  8849. */
  8850. event: KeyboardEvent);
  8851. }
  8852. }
  8853. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8854. import { Nullable } from "babylonjs/types";
  8855. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8856. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8857. /**
  8858. * Manage the keyboard inputs to control the movement of a free camera.
  8859. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8860. */
  8861. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8862. /**
  8863. * Defines the camera the input is attached to.
  8864. */
  8865. camera: FreeCamera;
  8866. /**
  8867. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8868. */
  8869. keysUp: number[];
  8870. /**
  8871. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8872. */
  8873. keysDown: number[];
  8874. /**
  8875. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8876. */
  8877. keysLeft: number[];
  8878. /**
  8879. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8880. */
  8881. keysRight: number[];
  8882. private _keys;
  8883. private _onCanvasBlurObserver;
  8884. private _onKeyboardObserver;
  8885. private _engine;
  8886. private _scene;
  8887. /**
  8888. * Attach the input controls to a specific dom element to get the input from.
  8889. * @param element Defines the element the controls should be listened from
  8890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8891. */
  8892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8893. /**
  8894. * Detach the current controls from the specified dom element.
  8895. * @param element Defines the element to stop listening the inputs from
  8896. */
  8897. detachControl(element: Nullable<HTMLElement>): void;
  8898. /**
  8899. * Update the current camera state depending on the inputs that have been used this frame.
  8900. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8901. */
  8902. checkInputs(): void;
  8903. /**
  8904. * Gets the class name of the current intput.
  8905. * @returns the class name
  8906. */
  8907. getClassName(): string;
  8908. /** @hidden */
  8909. _onLostFocus(): void;
  8910. /**
  8911. * Get the friendly name associated with the input class.
  8912. * @returns the input friendly name
  8913. */
  8914. getSimpleName(): string;
  8915. }
  8916. }
  8917. declare module "babylonjs/Lights/shadowLight" {
  8918. import { Camera } from "babylonjs/Cameras/camera";
  8919. import { Scene } from "babylonjs/scene";
  8920. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8922. import { Light } from "babylonjs/Lights/light";
  8923. /**
  8924. * Interface describing all the common properties and methods a shadow light needs to implement.
  8925. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8926. * as well as binding the different shadow properties to the effects.
  8927. */
  8928. export interface IShadowLight extends Light {
  8929. /**
  8930. * The light id in the scene (used in scene.findLighById for instance)
  8931. */
  8932. id: string;
  8933. /**
  8934. * The position the shdow will be casted from.
  8935. */
  8936. position: Vector3;
  8937. /**
  8938. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8939. */
  8940. direction: Vector3;
  8941. /**
  8942. * The transformed position. Position of the light in world space taking parenting in account.
  8943. */
  8944. transformedPosition: Vector3;
  8945. /**
  8946. * The transformed direction. Direction of the light in world space taking parenting in account.
  8947. */
  8948. transformedDirection: Vector3;
  8949. /**
  8950. * The friendly name of the light in the scene.
  8951. */
  8952. name: string;
  8953. /**
  8954. * Defines the shadow projection clipping minimum z value.
  8955. */
  8956. shadowMinZ: number;
  8957. /**
  8958. * Defines the shadow projection clipping maximum z value.
  8959. */
  8960. shadowMaxZ: number;
  8961. /**
  8962. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8963. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8964. */
  8965. computeTransformedInformation(): boolean;
  8966. /**
  8967. * Gets the scene the light belongs to.
  8968. * @returns The scene
  8969. */
  8970. getScene(): Scene;
  8971. /**
  8972. * Callback defining a custom Projection Matrix Builder.
  8973. * This can be used to override the default projection matrix computation.
  8974. */
  8975. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8976. /**
  8977. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8978. * @param matrix The materix to updated with the projection information
  8979. * @param viewMatrix The transform matrix of the light
  8980. * @param renderList The list of mesh to render in the map
  8981. * @returns The current light
  8982. */
  8983. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8984. /**
  8985. * Gets the current depth scale used in ESM.
  8986. * @returns The scale
  8987. */
  8988. getDepthScale(): number;
  8989. /**
  8990. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8991. * @returns true if a cube texture needs to be use
  8992. */
  8993. needCube(): boolean;
  8994. /**
  8995. * Detects if the projection matrix requires to be recomputed this frame.
  8996. * @returns true if it requires to be recomputed otherwise, false.
  8997. */
  8998. needProjectionMatrixCompute(): boolean;
  8999. /**
  9000. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9001. */
  9002. forceProjectionMatrixCompute(): void;
  9003. /**
  9004. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9005. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9006. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9007. */
  9008. getShadowDirection(faceIndex?: number): Vector3;
  9009. /**
  9010. * Gets the minZ used for shadow according to both the scene and the light.
  9011. * @param activeCamera The camera we are returning the min for
  9012. * @returns the depth min z
  9013. */
  9014. getDepthMinZ(activeCamera: Camera): number;
  9015. /**
  9016. * Gets the maxZ used for shadow according to both the scene and the light.
  9017. * @param activeCamera The camera we are returning the max for
  9018. * @returns the depth max z
  9019. */
  9020. getDepthMaxZ(activeCamera: Camera): number;
  9021. }
  9022. /**
  9023. * Base implementation IShadowLight
  9024. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9025. */
  9026. export abstract class ShadowLight extends Light implements IShadowLight {
  9027. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9028. protected _position: Vector3;
  9029. protected _setPosition(value: Vector3): void;
  9030. /**
  9031. * Sets the position the shadow will be casted from. Also use as the light position for both
  9032. * point and spot lights.
  9033. */
  9034. get position(): Vector3;
  9035. /**
  9036. * Sets the position the shadow will be casted from. Also use as the light position for both
  9037. * point and spot lights.
  9038. */
  9039. set position(value: Vector3);
  9040. protected _direction: Vector3;
  9041. protected _setDirection(value: Vector3): void;
  9042. /**
  9043. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9044. * Also use as the light direction on spot and directional lights.
  9045. */
  9046. get direction(): Vector3;
  9047. /**
  9048. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9049. * Also use as the light direction on spot and directional lights.
  9050. */
  9051. set direction(value: Vector3);
  9052. protected _shadowMinZ: number;
  9053. /**
  9054. * Gets the shadow projection clipping minimum z value.
  9055. */
  9056. get shadowMinZ(): number;
  9057. /**
  9058. * Sets the shadow projection clipping minimum z value.
  9059. */
  9060. set shadowMinZ(value: number);
  9061. protected _shadowMaxZ: number;
  9062. /**
  9063. * Sets the shadow projection clipping maximum z value.
  9064. */
  9065. get shadowMaxZ(): number;
  9066. /**
  9067. * Gets the shadow projection clipping maximum z value.
  9068. */
  9069. set shadowMaxZ(value: number);
  9070. /**
  9071. * Callback defining a custom Projection Matrix Builder.
  9072. * This can be used to override the default projection matrix computation.
  9073. */
  9074. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9075. /**
  9076. * The transformed position. Position of the light in world space taking parenting in account.
  9077. */
  9078. transformedPosition: Vector3;
  9079. /**
  9080. * The transformed direction. Direction of the light in world space taking parenting in account.
  9081. */
  9082. transformedDirection: Vector3;
  9083. private _needProjectionMatrixCompute;
  9084. /**
  9085. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9086. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9087. */
  9088. computeTransformedInformation(): boolean;
  9089. /**
  9090. * Return the depth scale used for the shadow map.
  9091. * @returns the depth scale.
  9092. */
  9093. getDepthScale(): number;
  9094. /**
  9095. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9096. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9097. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9098. */
  9099. getShadowDirection(faceIndex?: number): Vector3;
  9100. /**
  9101. * Returns the ShadowLight absolute position in the World.
  9102. * @returns the position vector in world space
  9103. */
  9104. getAbsolutePosition(): Vector3;
  9105. /**
  9106. * Sets the ShadowLight direction toward the passed target.
  9107. * @param target The point to target in local space
  9108. * @returns the updated ShadowLight direction
  9109. */
  9110. setDirectionToTarget(target: Vector3): Vector3;
  9111. /**
  9112. * Returns the light rotation in euler definition.
  9113. * @returns the x y z rotation in local space.
  9114. */
  9115. getRotation(): Vector3;
  9116. /**
  9117. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9118. * @returns true if a cube texture needs to be use
  9119. */
  9120. needCube(): boolean;
  9121. /**
  9122. * Detects if the projection matrix requires to be recomputed this frame.
  9123. * @returns true if it requires to be recomputed otherwise, false.
  9124. */
  9125. needProjectionMatrixCompute(): boolean;
  9126. /**
  9127. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9128. */
  9129. forceProjectionMatrixCompute(): void;
  9130. /** @hidden */
  9131. _initCache(): void;
  9132. /** @hidden */
  9133. _isSynchronized(): boolean;
  9134. /**
  9135. * Computes the world matrix of the node
  9136. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9137. * @returns the world matrix
  9138. */
  9139. computeWorldMatrix(force?: boolean): Matrix;
  9140. /**
  9141. * Gets the minZ used for shadow according to both the scene and the light.
  9142. * @param activeCamera The camera we are returning the min for
  9143. * @returns the depth min z
  9144. */
  9145. getDepthMinZ(activeCamera: Camera): number;
  9146. /**
  9147. * Gets the maxZ used for shadow according to both the scene and the light.
  9148. * @param activeCamera The camera we are returning the max for
  9149. * @returns the depth max z
  9150. */
  9151. getDepthMaxZ(activeCamera: Camera): number;
  9152. /**
  9153. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9154. * @param matrix The materix to updated with the projection information
  9155. * @param viewMatrix The transform matrix of the light
  9156. * @param renderList The list of mesh to render in the map
  9157. * @returns The current light
  9158. */
  9159. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9160. }
  9161. }
  9162. declare module "babylonjs/Materials/effectFallbacks" {
  9163. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9164. import { Effect } from "babylonjs/Materials/effect";
  9165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9166. /**
  9167. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9168. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9169. */
  9170. export class EffectFallbacks implements IEffectFallbacks {
  9171. private _defines;
  9172. private _currentRank;
  9173. private _maxRank;
  9174. private _mesh;
  9175. /**
  9176. * Removes the fallback from the bound mesh.
  9177. */
  9178. unBindMesh(): void;
  9179. /**
  9180. * Adds a fallback on the specified property.
  9181. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9182. * @param define The name of the define in the shader
  9183. */
  9184. addFallback(rank: number, define: string): void;
  9185. /**
  9186. * Sets the mesh to use CPU skinning when needing to fallback.
  9187. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9188. * @param mesh The mesh to use the fallbacks.
  9189. */
  9190. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9191. /**
  9192. * Checks to see if more fallbacks are still availible.
  9193. */
  9194. get hasMoreFallbacks(): boolean;
  9195. /**
  9196. * Removes the defines that should be removed when falling back.
  9197. * @param currentDefines defines the current define statements for the shader.
  9198. * @param effect defines the current effect we try to compile
  9199. * @returns The resulting defines with defines of the current rank removed.
  9200. */
  9201. reduce(currentDefines: string, effect: Effect): string;
  9202. }
  9203. }
  9204. declare module "babylonjs/Materials/materialHelper" {
  9205. import { Nullable } from "babylonjs/types";
  9206. import { Scene } from "babylonjs/scene";
  9207. import { Engine } from "babylonjs/Engines/engine";
  9208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9209. import { Light } from "babylonjs/Lights/light";
  9210. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9211. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9212. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9213. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9214. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9215. /**
  9216. * "Static Class" containing the most commonly used helper while dealing with material for
  9217. * rendering purpose.
  9218. *
  9219. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9220. *
  9221. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9222. */
  9223. export class MaterialHelper {
  9224. /**
  9225. * Bind the current view position to an effect.
  9226. * @param effect The effect to be bound
  9227. * @param scene The scene the eyes position is used from
  9228. */
  9229. static BindEyePosition(effect: Effect, scene: Scene): void;
  9230. /**
  9231. * Helps preparing the defines values about the UVs in used in the effect.
  9232. * UVs are shared as much as we can accross channels in the shaders.
  9233. * @param texture The texture we are preparing the UVs for
  9234. * @param defines The defines to update
  9235. * @param key The channel key "diffuse", "specular"... used in the shader
  9236. */
  9237. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9238. /**
  9239. * Binds a texture matrix value to its corrsponding uniform
  9240. * @param texture The texture to bind the matrix for
  9241. * @param uniformBuffer The uniform buffer receivin the data
  9242. * @param key The channel key "diffuse", "specular"... used in the shader
  9243. */
  9244. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9245. /**
  9246. * Gets the current status of the fog (should it be enabled?)
  9247. * @param mesh defines the mesh to evaluate for fog support
  9248. * @param scene defines the hosting scene
  9249. * @returns true if fog must be enabled
  9250. */
  9251. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9252. /**
  9253. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9254. * @param mesh defines the current mesh
  9255. * @param scene defines the current scene
  9256. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9257. * @param pointsCloud defines if point cloud rendering has to be turned on
  9258. * @param fogEnabled defines if fog has to be turned on
  9259. * @param alphaTest defines if alpha testing has to be turned on
  9260. * @param defines defines the current list of defines
  9261. */
  9262. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9263. /**
  9264. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9265. * @param scene defines the current scene
  9266. * @param engine defines the current engine
  9267. * @param defines specifies the list of active defines
  9268. * @param useInstances defines if instances have to be turned on
  9269. * @param useClipPlane defines if clip plane have to be turned on
  9270. */
  9271. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9272. /**
  9273. * Prepares the defines for bones
  9274. * @param mesh The mesh containing the geometry data we will draw
  9275. * @param defines The defines to update
  9276. */
  9277. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9278. /**
  9279. * Prepares the defines for morph targets
  9280. * @param mesh The mesh containing the geometry data we will draw
  9281. * @param defines The defines to update
  9282. */
  9283. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9284. /**
  9285. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9286. * @param mesh The mesh containing the geometry data we will draw
  9287. * @param defines The defines to update
  9288. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9289. * @param useBones Precise whether bones should be used or not (override mesh info)
  9290. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9291. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9292. * @returns false if defines are considered not dirty and have not been checked
  9293. */
  9294. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9295. /**
  9296. * Prepares the defines related to multiview
  9297. * @param scene The scene we are intending to draw
  9298. * @param defines The defines to update
  9299. */
  9300. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9301. /**
  9302. * Prepares the defines related to the light information passed in parameter
  9303. * @param scene The scene we are intending to draw
  9304. * @param mesh The mesh the effect is compiling for
  9305. * @param light The light the effect is compiling for
  9306. * @param lightIndex The index of the light
  9307. * @param defines The defines to update
  9308. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9309. * @param state Defines the current state regarding what is needed (normals, etc...)
  9310. */
  9311. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9312. needNormals: boolean;
  9313. needRebuild: boolean;
  9314. shadowEnabled: boolean;
  9315. specularEnabled: boolean;
  9316. lightmapMode: boolean;
  9317. }): void;
  9318. /**
  9319. * Prepares the defines related to the light information passed in parameter
  9320. * @param scene The scene we are intending to draw
  9321. * @param mesh The mesh the effect is compiling for
  9322. * @param defines The defines to update
  9323. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9324. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9325. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9326. * @returns true if normals will be required for the rest of the effect
  9327. */
  9328. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9329. /**
  9330. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9331. * @param lightIndex defines the light index
  9332. * @param uniformsList The uniform list
  9333. * @param samplersList The sampler list
  9334. * @param projectedLightTexture defines if projected texture must be used
  9335. * @param uniformBuffersList defines an optional list of uniform buffers
  9336. */
  9337. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9338. /**
  9339. * Prepares the uniforms and samplers list to be used in the effect
  9340. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9341. * @param samplersList The sampler list
  9342. * @param defines The defines helping in the list generation
  9343. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9344. */
  9345. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9346. /**
  9347. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9348. * @param defines The defines to update while falling back
  9349. * @param fallbacks The authorized effect fallbacks
  9350. * @param maxSimultaneousLights The maximum number of lights allowed
  9351. * @param rank the current rank of the Effect
  9352. * @returns The newly affected rank
  9353. */
  9354. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9355. private static _TmpMorphInfluencers;
  9356. /**
  9357. * Prepares the list of attributes required for morph targets according to the effect defines.
  9358. * @param attribs The current list of supported attribs
  9359. * @param mesh The mesh to prepare the morph targets attributes for
  9360. * @param influencers The number of influencers
  9361. */
  9362. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9363. /**
  9364. * Prepares the list of attributes required for morph targets according to the effect defines.
  9365. * @param attribs The current list of supported attribs
  9366. * @param mesh The mesh to prepare the morph targets attributes for
  9367. * @param defines The current Defines of the effect
  9368. */
  9369. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9370. /**
  9371. * Prepares the list of attributes required for bones according to the effect defines.
  9372. * @param attribs The current list of supported attribs
  9373. * @param mesh The mesh to prepare the bones attributes for
  9374. * @param defines The current Defines of the effect
  9375. * @param fallbacks The current efffect fallback strategy
  9376. */
  9377. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9378. /**
  9379. * Check and prepare the list of attributes required for instances according to the effect defines.
  9380. * @param attribs The current list of supported attribs
  9381. * @param defines The current MaterialDefines of the effect
  9382. */
  9383. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9384. /**
  9385. * Add the list of attributes required for instances to the attribs array.
  9386. * @param attribs The current list of supported attribs
  9387. */
  9388. static PushAttributesForInstances(attribs: string[]): void;
  9389. /**
  9390. * Binds the light information to the effect.
  9391. * @param light The light containing the generator
  9392. * @param effect The effect we are binding the data to
  9393. * @param lightIndex The light index in the effect used to render
  9394. */
  9395. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9396. /**
  9397. * Binds the lights information from the scene to the effect for the given mesh.
  9398. * @param light Light to bind
  9399. * @param lightIndex Light index
  9400. * @param scene The scene where the light belongs to
  9401. * @param effect The effect we are binding the data to
  9402. * @param useSpecular Defines if specular is supported
  9403. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9404. */
  9405. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9406. /**
  9407. * Binds the lights information from the scene to the effect for the given mesh.
  9408. * @param scene The scene the lights belongs to
  9409. * @param mesh The mesh we are binding the information to render
  9410. * @param effect The effect we are binding the data to
  9411. * @param defines The generated defines for the effect
  9412. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9413. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9414. */
  9415. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9416. private static _tempFogColor;
  9417. /**
  9418. * Binds the fog information from the scene to the effect for the given mesh.
  9419. * @param scene The scene the lights belongs to
  9420. * @param mesh The mesh we are binding the information to render
  9421. * @param effect The effect we are binding the data to
  9422. * @param linearSpace Defines if the fog effect is applied in linear space
  9423. */
  9424. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9425. /**
  9426. * Binds the bones information from the mesh to the effect.
  9427. * @param mesh The mesh we are binding the information to render
  9428. * @param effect The effect we are binding the data to
  9429. */
  9430. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9431. /**
  9432. * Binds the morph targets information from the mesh to the effect.
  9433. * @param abstractMesh The mesh we are binding the information to render
  9434. * @param effect The effect we are binding the data to
  9435. */
  9436. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9437. /**
  9438. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9439. * @param defines The generated defines used in the effect
  9440. * @param effect The effect we are binding the data to
  9441. * @param scene The scene we are willing to render with logarithmic scale for
  9442. */
  9443. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9444. /**
  9445. * Binds the clip plane information from the scene to the effect.
  9446. * @param scene The scene the clip plane information are extracted from
  9447. * @param effect The effect we are binding the data to
  9448. */
  9449. static BindClipPlane(effect: Effect, scene: Scene): void;
  9450. }
  9451. }
  9452. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9453. /** @hidden */
  9454. export var packingFunctions: {
  9455. name: string;
  9456. shader: string;
  9457. };
  9458. }
  9459. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9460. /** @hidden */
  9461. export var clipPlaneFragmentDeclaration: {
  9462. name: string;
  9463. shader: string;
  9464. };
  9465. }
  9466. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9467. /** @hidden */
  9468. export var clipPlaneFragment: {
  9469. name: string;
  9470. shader: string;
  9471. };
  9472. }
  9473. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9474. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9475. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9476. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9477. /** @hidden */
  9478. export var shadowMapPixelShader: {
  9479. name: string;
  9480. shader: string;
  9481. };
  9482. }
  9483. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9484. /** @hidden */
  9485. export var bonesDeclaration: {
  9486. name: string;
  9487. shader: string;
  9488. };
  9489. }
  9490. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9491. /** @hidden */
  9492. export var morphTargetsVertexGlobalDeclaration: {
  9493. name: string;
  9494. shader: string;
  9495. };
  9496. }
  9497. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9498. /** @hidden */
  9499. export var morphTargetsVertexDeclaration: {
  9500. name: string;
  9501. shader: string;
  9502. };
  9503. }
  9504. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9505. /** @hidden */
  9506. export var instancesDeclaration: {
  9507. name: string;
  9508. shader: string;
  9509. };
  9510. }
  9511. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9512. /** @hidden */
  9513. export var helperFunctions: {
  9514. name: string;
  9515. shader: string;
  9516. };
  9517. }
  9518. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9519. /** @hidden */
  9520. export var clipPlaneVertexDeclaration: {
  9521. name: string;
  9522. shader: string;
  9523. };
  9524. }
  9525. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9526. /** @hidden */
  9527. export var morphTargetsVertex: {
  9528. name: string;
  9529. shader: string;
  9530. };
  9531. }
  9532. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9533. /** @hidden */
  9534. export var instancesVertex: {
  9535. name: string;
  9536. shader: string;
  9537. };
  9538. }
  9539. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9540. /** @hidden */
  9541. export var bonesVertex: {
  9542. name: string;
  9543. shader: string;
  9544. };
  9545. }
  9546. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9547. /** @hidden */
  9548. export var clipPlaneVertex: {
  9549. name: string;
  9550. shader: string;
  9551. };
  9552. }
  9553. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9554. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9555. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9556. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9557. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9558. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9559. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9560. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9561. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9562. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9563. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9564. /** @hidden */
  9565. export var shadowMapVertexShader: {
  9566. name: string;
  9567. shader: string;
  9568. };
  9569. }
  9570. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9571. /** @hidden */
  9572. export var depthBoxBlurPixelShader: {
  9573. name: string;
  9574. shader: string;
  9575. };
  9576. }
  9577. declare module "babylonjs/Culling/ray" {
  9578. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9579. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9581. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9582. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9583. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9584. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9585. import { Plane } from "babylonjs/Maths/math.plane";
  9586. /**
  9587. * Class representing a ray with position and direction
  9588. */
  9589. export class Ray {
  9590. /** origin point */
  9591. origin: Vector3;
  9592. /** direction */
  9593. direction: Vector3;
  9594. /** length of the ray */
  9595. length: number;
  9596. private static readonly TmpVector3;
  9597. private _tmpRay;
  9598. /**
  9599. * Creates a new ray
  9600. * @param origin origin point
  9601. * @param direction direction
  9602. * @param length length of the ray
  9603. */
  9604. constructor(
  9605. /** origin point */
  9606. origin: Vector3,
  9607. /** direction */
  9608. direction: Vector3,
  9609. /** length of the ray */
  9610. length?: number);
  9611. /**
  9612. * Checks if the ray intersects a box
  9613. * @param minimum bound of the box
  9614. * @param maximum bound of the box
  9615. * @param intersectionTreshold extra extend to be added to the box in all direction
  9616. * @returns if the box was hit
  9617. */
  9618. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9619. /**
  9620. * Checks if the ray intersects a box
  9621. * @param box the bounding box to check
  9622. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9623. * @returns if the box was hit
  9624. */
  9625. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9626. /**
  9627. * If the ray hits a sphere
  9628. * @param sphere the bounding sphere to check
  9629. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9630. * @returns true if it hits the sphere
  9631. */
  9632. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9633. /**
  9634. * If the ray hits a triange
  9635. * @param vertex0 triangle vertex
  9636. * @param vertex1 triangle vertex
  9637. * @param vertex2 triangle vertex
  9638. * @returns intersection information if hit
  9639. */
  9640. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9641. /**
  9642. * Checks if ray intersects a plane
  9643. * @param plane the plane to check
  9644. * @returns the distance away it was hit
  9645. */
  9646. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9647. /**
  9648. * Calculate the intercept of a ray on a given axis
  9649. * @param axis to check 'x' | 'y' | 'z'
  9650. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9651. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9652. */
  9653. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9654. /**
  9655. * Checks if ray intersects a mesh
  9656. * @param mesh the mesh to check
  9657. * @param fastCheck if only the bounding box should checked
  9658. * @returns picking info of the intersecton
  9659. */
  9660. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9661. /**
  9662. * Checks if ray intersects a mesh
  9663. * @param meshes the meshes to check
  9664. * @param fastCheck if only the bounding box should checked
  9665. * @param results array to store result in
  9666. * @returns Array of picking infos
  9667. */
  9668. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9669. private _comparePickingInfo;
  9670. private static smallnum;
  9671. private static rayl;
  9672. /**
  9673. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9674. * @param sega the first point of the segment to test the intersection against
  9675. * @param segb the second point of the segment to test the intersection against
  9676. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9677. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9678. */
  9679. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9680. /**
  9681. * Update the ray from viewport position
  9682. * @param x position
  9683. * @param y y position
  9684. * @param viewportWidth viewport width
  9685. * @param viewportHeight viewport height
  9686. * @param world world matrix
  9687. * @param view view matrix
  9688. * @param projection projection matrix
  9689. * @returns this ray updated
  9690. */
  9691. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9692. /**
  9693. * Creates a ray with origin and direction of 0,0,0
  9694. * @returns the new ray
  9695. */
  9696. static Zero(): Ray;
  9697. /**
  9698. * Creates a new ray from screen space and viewport
  9699. * @param x position
  9700. * @param y y position
  9701. * @param viewportWidth viewport width
  9702. * @param viewportHeight viewport height
  9703. * @param world world matrix
  9704. * @param view view matrix
  9705. * @param projection projection matrix
  9706. * @returns new ray
  9707. */
  9708. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9709. /**
  9710. * 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
  9711. * transformed to the given world matrix.
  9712. * @param origin The origin point
  9713. * @param end The end point
  9714. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9715. * @returns the new ray
  9716. */
  9717. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9718. /**
  9719. * Transforms a ray by a matrix
  9720. * @param ray ray to transform
  9721. * @param matrix matrix to apply
  9722. * @returns the resulting new ray
  9723. */
  9724. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9725. /**
  9726. * Transforms a ray by a matrix
  9727. * @param ray ray to transform
  9728. * @param matrix matrix to apply
  9729. * @param result ray to store result in
  9730. */
  9731. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9732. /**
  9733. * Unproject a ray from screen space to object space
  9734. * @param sourceX defines the screen space x coordinate to use
  9735. * @param sourceY defines the screen space y coordinate to use
  9736. * @param viewportWidth defines the current width of the viewport
  9737. * @param viewportHeight defines the current height of the viewport
  9738. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9739. * @param view defines the view matrix to use
  9740. * @param projection defines the projection matrix to use
  9741. */
  9742. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9743. }
  9744. /**
  9745. * Type used to define predicate used to select faces when a mesh intersection is detected
  9746. */
  9747. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9748. module "babylonjs/scene" {
  9749. interface Scene {
  9750. /** @hidden */
  9751. _tempPickingRay: Nullable<Ray>;
  9752. /** @hidden */
  9753. _cachedRayForTransform: Ray;
  9754. /** @hidden */
  9755. _pickWithRayInverseMatrix: Matrix;
  9756. /** @hidden */
  9757. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9758. /** @hidden */
  9759. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9760. }
  9761. }
  9762. }
  9763. declare module "babylonjs/sceneComponent" {
  9764. import { Scene } from "babylonjs/scene";
  9765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9766. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9767. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9768. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9769. import { Nullable } from "babylonjs/types";
  9770. import { Camera } from "babylonjs/Cameras/camera";
  9771. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9772. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9773. import { AbstractScene } from "babylonjs/abstractScene";
  9774. import { Mesh } from "babylonjs/Meshes/mesh";
  9775. /**
  9776. * Groups all the scene component constants in one place to ease maintenance.
  9777. * @hidden
  9778. */
  9779. export class SceneComponentConstants {
  9780. static readonly NAME_EFFECTLAYER: string;
  9781. static readonly NAME_LAYER: string;
  9782. static readonly NAME_LENSFLARESYSTEM: string;
  9783. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9784. static readonly NAME_PARTICLESYSTEM: string;
  9785. static readonly NAME_GAMEPAD: string;
  9786. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9787. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9788. static readonly NAME_DEPTHRENDERER: string;
  9789. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9790. static readonly NAME_SPRITE: string;
  9791. static readonly NAME_OUTLINERENDERER: string;
  9792. static readonly NAME_PROCEDURALTEXTURE: string;
  9793. static readonly NAME_SHADOWGENERATOR: string;
  9794. static readonly NAME_OCTREE: string;
  9795. static readonly NAME_PHYSICSENGINE: string;
  9796. static readonly NAME_AUDIO: string;
  9797. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9798. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9799. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9800. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9801. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9802. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9803. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9804. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9805. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9806. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9807. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9808. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9809. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9810. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9811. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9812. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9813. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9814. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9815. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9816. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9817. static readonly STEP_AFTERRENDER_AUDIO: number;
  9818. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9819. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9820. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9821. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9822. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9823. static readonly STEP_POINTERMOVE_SPRITE: number;
  9824. static readonly STEP_POINTERDOWN_SPRITE: number;
  9825. static readonly STEP_POINTERUP_SPRITE: number;
  9826. }
  9827. /**
  9828. * This represents a scene component.
  9829. *
  9830. * This is used to decouple the dependency the scene is having on the different workloads like
  9831. * layers, post processes...
  9832. */
  9833. export interface ISceneComponent {
  9834. /**
  9835. * The name of the component. Each component must have a unique name.
  9836. */
  9837. name: string;
  9838. /**
  9839. * The scene the component belongs to.
  9840. */
  9841. scene: Scene;
  9842. /**
  9843. * Register the component to one instance of a scene.
  9844. */
  9845. register(): void;
  9846. /**
  9847. * Rebuilds the elements related to this component in case of
  9848. * context lost for instance.
  9849. */
  9850. rebuild(): void;
  9851. /**
  9852. * Disposes the component and the associated ressources.
  9853. */
  9854. dispose(): void;
  9855. }
  9856. /**
  9857. * This represents a SERIALIZABLE scene component.
  9858. *
  9859. * This extends Scene Component to add Serialization methods on top.
  9860. */
  9861. export interface ISceneSerializableComponent extends ISceneComponent {
  9862. /**
  9863. * Adds all the elements from the container to the scene
  9864. * @param container the container holding the elements
  9865. */
  9866. addFromContainer(container: AbstractScene): void;
  9867. /**
  9868. * Removes all the elements in the container from the scene
  9869. * @param container contains the elements to remove
  9870. * @param dispose if the removed element should be disposed (default: false)
  9871. */
  9872. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9873. /**
  9874. * Serializes the component data to the specified json object
  9875. * @param serializationObject The object to serialize to
  9876. */
  9877. serialize(serializationObject: any): void;
  9878. }
  9879. /**
  9880. * Strong typing of a Mesh related stage step action
  9881. */
  9882. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9883. /**
  9884. * Strong typing of a Evaluate Sub Mesh related stage step action
  9885. */
  9886. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9887. /**
  9888. * Strong typing of a Active Mesh related stage step action
  9889. */
  9890. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9891. /**
  9892. * Strong typing of a Camera related stage step action
  9893. */
  9894. export type CameraStageAction = (camera: Camera) => void;
  9895. /**
  9896. * Strong typing of a Camera Frame buffer related stage step action
  9897. */
  9898. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9899. /**
  9900. * Strong typing of a Render Target related stage step action
  9901. */
  9902. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9903. /**
  9904. * Strong typing of a RenderingGroup related stage step action
  9905. */
  9906. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9907. /**
  9908. * Strong typing of a Mesh Render related stage step action
  9909. */
  9910. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9911. /**
  9912. * Strong typing of a simple stage step action
  9913. */
  9914. export type SimpleStageAction = () => void;
  9915. /**
  9916. * Strong typing of a render target action.
  9917. */
  9918. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9919. /**
  9920. * Strong typing of a pointer move action.
  9921. */
  9922. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9923. /**
  9924. * Strong typing of a pointer up/down action.
  9925. */
  9926. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9927. /**
  9928. * Representation of a stage in the scene (Basically a list of ordered steps)
  9929. * @hidden
  9930. */
  9931. export class Stage<T extends Function> extends Array<{
  9932. index: number;
  9933. component: ISceneComponent;
  9934. action: T;
  9935. }> {
  9936. /**
  9937. * Hide ctor from the rest of the world.
  9938. * @param items The items to add.
  9939. */
  9940. private constructor();
  9941. /**
  9942. * Creates a new Stage.
  9943. * @returns A new instance of a Stage
  9944. */
  9945. static Create<T extends Function>(): Stage<T>;
  9946. /**
  9947. * Registers a step in an ordered way in the targeted stage.
  9948. * @param index Defines the position to register the step in
  9949. * @param component Defines the component attached to the step
  9950. * @param action Defines the action to launch during the step
  9951. */
  9952. registerStep(index: number, component: ISceneComponent, action: T): void;
  9953. /**
  9954. * Clears all the steps from the stage.
  9955. */
  9956. clear(): void;
  9957. }
  9958. }
  9959. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9960. import { Nullable } from "babylonjs/types";
  9961. import { Observable } from "babylonjs/Misc/observable";
  9962. import { Scene } from "babylonjs/scene";
  9963. import { Sprite } from "babylonjs/Sprites/sprite";
  9964. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9965. import { Ray } from "babylonjs/Culling/ray";
  9966. import { Camera } from "babylonjs/Cameras/camera";
  9967. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9968. import { ISceneComponent } from "babylonjs/sceneComponent";
  9969. module "babylonjs/scene" {
  9970. interface Scene {
  9971. /** @hidden */
  9972. _pointerOverSprite: Nullable<Sprite>;
  9973. /** @hidden */
  9974. _pickedDownSprite: Nullable<Sprite>;
  9975. /** @hidden */
  9976. _tempSpritePickingRay: Nullable<Ray>;
  9977. /**
  9978. * All of the sprite managers added to this scene
  9979. * @see http://doc.babylonjs.com/babylon101/sprites
  9980. */
  9981. spriteManagers: Array<ISpriteManager>;
  9982. /**
  9983. * An event triggered when sprites rendering is about to start
  9984. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9985. */
  9986. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9987. /**
  9988. * An event triggered when sprites rendering is done
  9989. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9990. */
  9991. onAfterSpritesRenderingObservable: Observable<Scene>;
  9992. /** @hidden */
  9993. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9994. /** Launch a ray to try to pick a sprite in the scene
  9995. * @param x position on screen
  9996. * @param y position on screen
  9997. * @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
  9998. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9999. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10000. * @returns a PickingInfo
  10001. */
  10002. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10003. /** Use the given ray to pick a sprite in the scene
  10004. * @param ray The ray (in world space) to use to pick meshes
  10005. * @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
  10006. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10007. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10008. * @returns a PickingInfo
  10009. */
  10010. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10011. /** @hidden */
  10012. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10013. /** Launch a ray to try to pick sprites in the scene
  10014. * @param x position on screen
  10015. * @param y position on screen
  10016. * @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
  10017. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10018. * @returns a PickingInfo array
  10019. */
  10020. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10021. /** Use the given ray to pick sprites in the scene
  10022. * @param ray The ray (in world space) to use to pick meshes
  10023. * @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
  10024. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10025. * @returns a PickingInfo array
  10026. */
  10027. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10028. /**
  10029. * Force the sprite under the pointer
  10030. * @param sprite defines the sprite to use
  10031. */
  10032. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10033. /**
  10034. * Gets the sprite under the pointer
  10035. * @returns a Sprite or null if no sprite is under the pointer
  10036. */
  10037. getPointerOverSprite(): Nullable<Sprite>;
  10038. }
  10039. }
  10040. /**
  10041. * Defines the sprite scene component responsible to manage sprites
  10042. * in a given scene.
  10043. */
  10044. export class SpriteSceneComponent implements ISceneComponent {
  10045. /**
  10046. * The component name helpfull to identify the component in the list of scene components.
  10047. */
  10048. readonly name: string;
  10049. /**
  10050. * The scene the component belongs to.
  10051. */
  10052. scene: Scene;
  10053. /** @hidden */
  10054. private _spritePredicate;
  10055. /**
  10056. * Creates a new instance of the component for the given scene
  10057. * @param scene Defines the scene to register the component in
  10058. */
  10059. constructor(scene: Scene);
  10060. /**
  10061. * Registers the component in a given scene
  10062. */
  10063. register(): void;
  10064. /**
  10065. * Rebuilds the elements related to this component in case of
  10066. * context lost for instance.
  10067. */
  10068. rebuild(): void;
  10069. /**
  10070. * Disposes the component and the associated ressources.
  10071. */
  10072. dispose(): void;
  10073. private _pickSpriteButKeepRay;
  10074. private _pointerMove;
  10075. private _pointerDown;
  10076. private _pointerUp;
  10077. }
  10078. }
  10079. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10080. /** @hidden */
  10081. export var fogFragmentDeclaration: {
  10082. name: string;
  10083. shader: string;
  10084. };
  10085. }
  10086. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10087. /** @hidden */
  10088. export var fogFragment: {
  10089. name: string;
  10090. shader: string;
  10091. };
  10092. }
  10093. declare module "babylonjs/Shaders/sprites.fragment" {
  10094. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10095. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10096. /** @hidden */
  10097. export var spritesPixelShader: {
  10098. name: string;
  10099. shader: string;
  10100. };
  10101. }
  10102. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10103. /** @hidden */
  10104. export var fogVertexDeclaration: {
  10105. name: string;
  10106. shader: string;
  10107. };
  10108. }
  10109. declare module "babylonjs/Shaders/sprites.vertex" {
  10110. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10111. /** @hidden */
  10112. export var spritesVertexShader: {
  10113. name: string;
  10114. shader: string;
  10115. };
  10116. }
  10117. declare module "babylonjs/Sprites/spriteManager" {
  10118. import { IDisposable, Scene } from "babylonjs/scene";
  10119. import { Nullable } from "babylonjs/types";
  10120. import { Observable } from "babylonjs/Misc/observable";
  10121. import { Sprite } from "babylonjs/Sprites/sprite";
  10122. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10123. import { Camera } from "babylonjs/Cameras/camera";
  10124. import { Texture } from "babylonjs/Materials/Textures/texture";
  10125. import "babylonjs/Shaders/sprites.fragment";
  10126. import "babylonjs/Shaders/sprites.vertex";
  10127. import { Ray } from "babylonjs/Culling/ray";
  10128. /**
  10129. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10130. */
  10131. export interface ISpriteManager extends IDisposable {
  10132. /**
  10133. * Restricts the camera to viewing objects with the same layerMask.
  10134. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10135. */
  10136. layerMask: number;
  10137. /**
  10138. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10139. */
  10140. isPickable: boolean;
  10141. /**
  10142. * Specifies the rendering group id for this mesh (0 by default)
  10143. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10144. */
  10145. renderingGroupId: number;
  10146. /**
  10147. * Defines the list of sprites managed by the manager.
  10148. */
  10149. sprites: Array<Sprite>;
  10150. /**
  10151. * Tests the intersection of a sprite with a specific ray.
  10152. * @param ray The ray we are sending to test the collision
  10153. * @param camera The camera space we are sending rays in
  10154. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10155. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10156. * @returns picking info or null.
  10157. */
  10158. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10159. /**
  10160. * Intersects the sprites with a ray
  10161. * @param ray defines the ray to intersect with
  10162. * @param camera defines the current active camera
  10163. * @param predicate defines a predicate used to select candidate sprites
  10164. * @returns null if no hit or a PickingInfo array
  10165. */
  10166. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10167. /**
  10168. * Renders the list of sprites on screen.
  10169. */
  10170. render(): void;
  10171. }
  10172. /**
  10173. * Class used to manage multiple sprites on the same spritesheet
  10174. * @see http://doc.babylonjs.com/babylon101/sprites
  10175. */
  10176. export class SpriteManager implements ISpriteManager {
  10177. /** defines the manager's name */
  10178. name: string;
  10179. /** Gets the list of sprites */
  10180. sprites: Sprite[];
  10181. /** Gets or sets the rendering group id (0 by default) */
  10182. renderingGroupId: number;
  10183. /** Gets or sets camera layer mask */
  10184. layerMask: number;
  10185. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10186. fogEnabled: boolean;
  10187. /** Gets or sets a boolean indicating if the sprites are pickable */
  10188. isPickable: boolean;
  10189. /** Defines the default width of a cell in the spritesheet */
  10190. cellWidth: number;
  10191. /** Defines the default height of a cell in the spritesheet */
  10192. cellHeight: number;
  10193. /** Associative array from JSON sprite data file */
  10194. private _cellData;
  10195. /** Array of sprite names from JSON sprite data file */
  10196. private _spriteMap;
  10197. /** True when packed cell data from JSON file is ready*/
  10198. private _packedAndReady;
  10199. /**
  10200. * An event triggered when the manager is disposed.
  10201. */
  10202. onDisposeObservable: Observable<SpriteManager>;
  10203. private _onDisposeObserver;
  10204. /**
  10205. * Callback called when the manager is disposed
  10206. */
  10207. set onDispose(callback: () => void);
  10208. private _capacity;
  10209. private _fromPacked;
  10210. private _spriteTexture;
  10211. private _epsilon;
  10212. private _scene;
  10213. private _vertexData;
  10214. private _buffer;
  10215. private _vertexBuffers;
  10216. private _indexBuffer;
  10217. private _effectBase;
  10218. private _effectFog;
  10219. /**
  10220. * Gets or sets the spritesheet texture
  10221. */
  10222. get texture(): Texture;
  10223. set texture(value: Texture);
  10224. private _blendMode;
  10225. /**
  10226. * Blend mode use to render the particle, it can be any of
  10227. * the static Constants.ALPHA_x properties provided in this class.
  10228. * Default value is Constants.ALPHA_COMBINE
  10229. */
  10230. get blendMode(): number;
  10231. set blendMode(blendMode: number);
  10232. /** Disables writing to the depth buffer when rendering the sprites.
  10233. * It can be handy to disable depth writing when using textures without alpha channel
  10234. * and setting some specific blend modes.
  10235. */
  10236. disableDepthWrite: boolean;
  10237. /**
  10238. * Creates a new sprite manager
  10239. * @param name defines the manager's name
  10240. * @param imgUrl defines the sprite sheet url
  10241. * @param capacity defines the maximum allowed number of sprites
  10242. * @param cellSize defines the size of a sprite cell
  10243. * @param scene defines the hosting scene
  10244. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10245. * @param samplingMode defines the smapling mode to use with spritesheet
  10246. * @param fromPacked set to false; do not alter
  10247. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10248. */
  10249. constructor(
  10250. /** defines the manager's name */
  10251. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10252. private _makePacked;
  10253. private _appendSpriteVertex;
  10254. /**
  10255. * Intersects the sprites with a ray
  10256. * @param ray defines the ray to intersect with
  10257. * @param camera defines the current active camera
  10258. * @param predicate defines a predicate used to select candidate sprites
  10259. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10260. * @returns null if no hit or a PickingInfo
  10261. */
  10262. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10263. /**
  10264. * Intersects the sprites with a ray
  10265. * @param ray defines the ray to intersect with
  10266. * @param camera defines the current active camera
  10267. * @param predicate defines a predicate used to select candidate sprites
  10268. * @returns null if no hit or a PickingInfo array
  10269. */
  10270. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10271. /**
  10272. * Render all child sprites
  10273. */
  10274. render(): void;
  10275. /**
  10276. * Release associated resources
  10277. */
  10278. dispose(): void;
  10279. }
  10280. }
  10281. declare module "babylonjs/Misc/gradients" {
  10282. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10283. /** Interface used by value gradients (color, factor, ...) */
  10284. export interface IValueGradient {
  10285. /**
  10286. * Gets or sets the gradient value (between 0 and 1)
  10287. */
  10288. gradient: number;
  10289. }
  10290. /** Class used to store color4 gradient */
  10291. export class ColorGradient implements IValueGradient {
  10292. /**
  10293. * Gets or sets the gradient value (between 0 and 1)
  10294. */
  10295. gradient: number;
  10296. /**
  10297. * Gets or sets first associated color
  10298. */
  10299. color1: Color4;
  10300. /**
  10301. * Gets or sets second associated color
  10302. */
  10303. color2?: Color4;
  10304. /**
  10305. * Will get a color picked randomly between color1 and color2.
  10306. * If color2 is undefined then color1 will be used
  10307. * @param result defines the target Color4 to store the result in
  10308. */
  10309. getColorToRef(result: Color4): void;
  10310. }
  10311. /** Class used to store color 3 gradient */
  10312. export class Color3Gradient implements IValueGradient {
  10313. /**
  10314. * Gets or sets the gradient value (between 0 and 1)
  10315. */
  10316. gradient: number;
  10317. /**
  10318. * Gets or sets the associated color
  10319. */
  10320. color: Color3;
  10321. }
  10322. /** Class used to store factor gradient */
  10323. export class FactorGradient implements IValueGradient {
  10324. /**
  10325. * Gets or sets the gradient value (between 0 and 1)
  10326. */
  10327. gradient: number;
  10328. /**
  10329. * Gets or sets first associated factor
  10330. */
  10331. factor1: number;
  10332. /**
  10333. * Gets or sets second associated factor
  10334. */
  10335. factor2?: number;
  10336. /**
  10337. * Will get a number picked randomly between factor1 and factor2.
  10338. * If factor2 is undefined then factor1 will be used
  10339. * @returns the picked number
  10340. */
  10341. getFactor(): number;
  10342. }
  10343. /**
  10344. * Helper used to simplify some generic gradient tasks
  10345. */
  10346. export class GradientHelper {
  10347. /**
  10348. * Gets the current gradient from an array of IValueGradient
  10349. * @param ratio defines the current ratio to get
  10350. * @param gradients defines the array of IValueGradient
  10351. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10352. */
  10353. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10354. }
  10355. }
  10356. declare module "babylonjs/Maths/math.size" {
  10357. /**
  10358. * Interface for the size containing width and height
  10359. */
  10360. export interface ISize {
  10361. /**
  10362. * Width
  10363. */
  10364. width: number;
  10365. /**
  10366. * Heighht
  10367. */
  10368. height: number;
  10369. }
  10370. /**
  10371. * Size containing widht and height
  10372. */
  10373. export class Size implements ISize {
  10374. /**
  10375. * Width
  10376. */
  10377. width: number;
  10378. /**
  10379. * Height
  10380. */
  10381. height: number;
  10382. /**
  10383. * Creates a Size object from the given width and height (floats).
  10384. * @param width width of the new size
  10385. * @param height height of the new size
  10386. */
  10387. constructor(width: number, height: number);
  10388. /**
  10389. * Returns a string with the Size width and height
  10390. * @returns a string with the Size width and height
  10391. */
  10392. toString(): string;
  10393. /**
  10394. * "Size"
  10395. * @returns the string "Size"
  10396. */
  10397. getClassName(): string;
  10398. /**
  10399. * Returns the Size hash code.
  10400. * @returns a hash code for a unique width and height
  10401. */
  10402. getHashCode(): number;
  10403. /**
  10404. * Updates the current size from the given one.
  10405. * @param src the given size
  10406. */
  10407. copyFrom(src: Size): void;
  10408. /**
  10409. * Updates in place the current Size from the given floats.
  10410. * @param width width of the new size
  10411. * @param height height of the new size
  10412. * @returns the updated Size.
  10413. */
  10414. copyFromFloats(width: number, height: number): Size;
  10415. /**
  10416. * Updates in place the current Size from the given floats.
  10417. * @param width width to set
  10418. * @param height height to set
  10419. * @returns the updated Size.
  10420. */
  10421. set(width: number, height: number): Size;
  10422. /**
  10423. * Multiplies the width and height by numbers
  10424. * @param w factor to multiple the width by
  10425. * @param h factor to multiple the height by
  10426. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10427. */
  10428. multiplyByFloats(w: number, h: number): Size;
  10429. /**
  10430. * Clones the size
  10431. * @returns a new Size copied from the given one.
  10432. */
  10433. clone(): Size;
  10434. /**
  10435. * True if the current Size and the given one width and height are strictly equal.
  10436. * @param other the other size to compare against
  10437. * @returns True if the current Size and the given one width and height are strictly equal.
  10438. */
  10439. equals(other: Size): boolean;
  10440. /**
  10441. * The surface of the Size : width * height (float).
  10442. */
  10443. get surface(): number;
  10444. /**
  10445. * Create a new size of zero
  10446. * @returns a new Size set to (0.0, 0.0)
  10447. */
  10448. static Zero(): Size;
  10449. /**
  10450. * Sums the width and height of two sizes
  10451. * @param otherSize size to add to this size
  10452. * @returns a new Size set as the addition result of the current Size and the given one.
  10453. */
  10454. add(otherSize: Size): Size;
  10455. /**
  10456. * Subtracts the width and height of two
  10457. * @param otherSize size to subtract to this size
  10458. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10459. */
  10460. subtract(otherSize: Size): Size;
  10461. /**
  10462. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10463. * @param start starting size to lerp between
  10464. * @param end end size to lerp between
  10465. * @param amount amount to lerp between the start and end values
  10466. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10467. */
  10468. static Lerp(start: Size, end: Size, amount: number): Size;
  10469. }
  10470. }
  10471. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10472. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10473. import { Nullable } from "babylonjs/types";
  10474. module "babylonjs/Engines/thinEngine" {
  10475. interface ThinEngine {
  10476. /**
  10477. * Creates a dynamic texture
  10478. * @param width defines the width of the texture
  10479. * @param height defines the height of the texture
  10480. * @param generateMipMaps defines if the engine should generate the mip levels
  10481. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10482. * @returns the dynamic texture inside an InternalTexture
  10483. */
  10484. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10485. /**
  10486. * Update the content of a dynamic texture
  10487. * @param texture defines the texture to update
  10488. * @param canvas defines the canvas containing the source
  10489. * @param invertY defines if data must be stored with Y axis inverted
  10490. * @param premulAlpha defines if alpha is stored as premultiplied
  10491. * @param format defines the format of the data
  10492. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10493. */
  10494. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10495. }
  10496. }
  10497. }
  10498. declare module "babylonjs/Misc/canvasGenerator" {
  10499. /**
  10500. * Helper class used to generate a canvas to manipulate images
  10501. */
  10502. export class CanvasGenerator {
  10503. /**
  10504. * Create a new canvas (or offscreen canvas depending on the context)
  10505. * @param width defines the expected width
  10506. * @param height defines the expected height
  10507. * @return a new canvas or offscreen canvas
  10508. */
  10509. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10510. }
  10511. }
  10512. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10513. import { Scene } from "babylonjs/scene";
  10514. import { Texture } from "babylonjs/Materials/Textures/texture";
  10515. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10516. /**
  10517. * A class extending Texture allowing drawing on a texture
  10518. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10519. */
  10520. export class DynamicTexture extends Texture {
  10521. private _generateMipMaps;
  10522. private _canvas;
  10523. private _context;
  10524. private _engine;
  10525. /**
  10526. * Creates a DynamicTexture
  10527. * @param name defines the name of the texture
  10528. * @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
  10529. * @param scene defines the scene where you want the texture
  10530. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10531. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10532. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10533. */
  10534. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10535. /**
  10536. * Get the current class name of the texture useful for serialization or dynamic coding.
  10537. * @returns "DynamicTexture"
  10538. */
  10539. getClassName(): string;
  10540. /**
  10541. * Gets the current state of canRescale
  10542. */
  10543. get canRescale(): boolean;
  10544. private _recreate;
  10545. /**
  10546. * Scales the texture
  10547. * @param ratio the scale factor to apply to both width and height
  10548. */
  10549. scale(ratio: number): void;
  10550. /**
  10551. * Resizes the texture
  10552. * @param width the new width
  10553. * @param height the new height
  10554. */
  10555. scaleTo(width: number, height: number): void;
  10556. /**
  10557. * Gets the context of the canvas used by the texture
  10558. * @returns the canvas context of the dynamic texture
  10559. */
  10560. getContext(): CanvasRenderingContext2D;
  10561. /**
  10562. * Clears the texture
  10563. */
  10564. clear(): void;
  10565. /**
  10566. * Updates the texture
  10567. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10568. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10569. */
  10570. update(invertY?: boolean, premulAlpha?: boolean): void;
  10571. /**
  10572. * Draws text onto the texture
  10573. * @param text defines the text to be drawn
  10574. * @param x defines the placement of the text from the left
  10575. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10576. * @param font defines the font to be used with font-style, font-size, font-name
  10577. * @param color defines the color used for the text
  10578. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10579. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10580. * @param update defines whether texture is immediately update (default is true)
  10581. */
  10582. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10583. /**
  10584. * Clones the texture
  10585. * @returns the clone of the texture.
  10586. */
  10587. clone(): DynamicTexture;
  10588. /**
  10589. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10590. * @returns a serialized dynamic texture object
  10591. */
  10592. serialize(): any;
  10593. /** @hidden */
  10594. _rebuild(): void;
  10595. }
  10596. }
  10597. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10598. import { Nullable } from "babylonjs/types";
  10599. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10600. import { Scene } from "babylonjs/scene";
  10601. module "babylonjs/Engines/engine" {
  10602. interface Engine {
  10603. /**
  10604. * Creates a raw texture
  10605. * @param data defines the data to store in the texture
  10606. * @param width defines the width of the texture
  10607. * @param height defines the height of the texture
  10608. * @param format defines the format of the data
  10609. * @param generateMipMaps defines if the engine should generate the mip levels
  10610. * @param invertY defines if data must be stored with Y axis inverted
  10611. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10612. * @param compression defines the compression used (null by default)
  10613. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10614. * @returns the raw texture inside an InternalTexture
  10615. */
  10616. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10617. /**
  10618. * Update a raw texture
  10619. * @param texture defines the texture to update
  10620. * @param data defines the data to store in the texture
  10621. * @param format defines the format of the data
  10622. * @param invertY defines if data must be stored with Y axis inverted
  10623. */
  10624. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10625. /**
  10626. * Update a raw texture
  10627. * @param texture defines the texture to update
  10628. * @param data defines the data to store in the texture
  10629. * @param format defines the format of the data
  10630. * @param invertY defines if data must be stored with Y axis inverted
  10631. * @param compression defines the compression used (null by default)
  10632. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10633. */
  10634. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10635. /**
  10636. * Creates a new raw cube texture
  10637. * @param data defines the array of data to use to create each face
  10638. * @param size defines the size of the textures
  10639. * @param format defines the format of the data
  10640. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10641. * @param generateMipMaps defines if the engine should generate the mip levels
  10642. * @param invertY defines if data must be stored with Y axis inverted
  10643. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10644. * @param compression defines the compression used (null by default)
  10645. * @returns the cube texture as an InternalTexture
  10646. */
  10647. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10648. /**
  10649. * Update a raw cube texture
  10650. * @param texture defines the texture to udpdate
  10651. * @param data defines the data to store
  10652. * @param format defines the data format
  10653. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10654. * @param invertY defines if data must be stored with Y axis inverted
  10655. */
  10656. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10657. /**
  10658. * Update a raw cube texture
  10659. * @param texture defines the texture to udpdate
  10660. * @param data defines the data to store
  10661. * @param format defines the data format
  10662. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10663. * @param invertY defines if data must be stored with Y axis inverted
  10664. * @param compression defines the compression used (null by default)
  10665. */
  10666. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10667. /**
  10668. * Update a raw cube texture
  10669. * @param texture defines the texture to udpdate
  10670. * @param data defines the data to store
  10671. * @param format defines the data format
  10672. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10673. * @param invertY defines if data must be stored with Y axis inverted
  10674. * @param compression defines the compression used (null by default)
  10675. * @param level defines which level of the texture to update
  10676. */
  10677. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10678. /**
  10679. * Creates a new raw cube texture from a specified url
  10680. * @param url defines the url where the data is located
  10681. * @param scene defines the current scene
  10682. * @param size defines the size of the textures
  10683. * @param format defines the format of the data
  10684. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10685. * @param noMipmap defines if the engine should avoid generating the mip levels
  10686. * @param callback defines a callback used to extract texture data from loaded data
  10687. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10688. * @param onLoad defines a callback called when texture is loaded
  10689. * @param onError defines a callback called if there is an error
  10690. * @returns the cube texture as an InternalTexture
  10691. */
  10692. 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;
  10693. /**
  10694. * Creates a new raw cube texture from a specified url
  10695. * @param url defines the url where the data is located
  10696. * @param scene defines the current scene
  10697. * @param size defines the size of the textures
  10698. * @param format defines the format of the data
  10699. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10700. * @param noMipmap defines if the engine should avoid generating the mip levels
  10701. * @param callback defines a callback used to extract texture data from loaded data
  10702. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10703. * @param onLoad defines a callback called when texture is loaded
  10704. * @param onError defines a callback called if there is an error
  10705. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10706. * @param invertY defines if data must be stored with Y axis inverted
  10707. * @returns the cube texture as an InternalTexture
  10708. */
  10709. 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;
  10710. /**
  10711. * Creates a new raw 3D texture
  10712. * @param data defines the data used to create the texture
  10713. * @param width defines the width of the texture
  10714. * @param height defines the height of the texture
  10715. * @param depth defines the depth of the texture
  10716. * @param format defines the format of the texture
  10717. * @param generateMipMaps defines if the engine must generate mip levels
  10718. * @param invertY defines if data must be stored with Y axis inverted
  10719. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10720. * @param compression defines the compressed used (can be null)
  10721. * @param textureType defines the compressed used (can be null)
  10722. * @returns a new raw 3D texture (stored in an InternalTexture)
  10723. */
  10724. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10725. /**
  10726. * Update a raw 3D texture
  10727. * @param texture defines the texture to update
  10728. * @param data defines the data to store
  10729. * @param format defines the data format
  10730. * @param invertY defines if data must be stored with Y axis inverted
  10731. */
  10732. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10733. /**
  10734. * Update a raw 3D texture
  10735. * @param texture defines the texture to update
  10736. * @param data defines the data to store
  10737. * @param format defines the data format
  10738. * @param invertY defines if data must be stored with Y axis inverted
  10739. * @param compression defines the used compression (can be null)
  10740. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10741. */
  10742. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10743. /**
  10744. * Creates a new raw 2D array texture
  10745. * @param data defines the data used to create the texture
  10746. * @param width defines the width of the texture
  10747. * @param height defines the height of the texture
  10748. * @param depth defines the number of layers of the texture
  10749. * @param format defines the format of the texture
  10750. * @param generateMipMaps defines if the engine must generate mip levels
  10751. * @param invertY defines if data must be stored with Y axis inverted
  10752. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10753. * @param compression defines the compressed used (can be null)
  10754. * @param textureType defines the compressed used (can be null)
  10755. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10756. */
  10757. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10758. /**
  10759. * Update a raw 2D array texture
  10760. * @param texture defines the texture to update
  10761. * @param data defines the data to store
  10762. * @param format defines the data format
  10763. * @param invertY defines if data must be stored with Y axis inverted
  10764. */
  10765. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10766. /**
  10767. * Update a raw 2D array texture
  10768. * @param texture defines the texture to update
  10769. * @param data defines the data to store
  10770. * @param format defines the data format
  10771. * @param invertY defines if data must be stored with Y axis inverted
  10772. * @param compression defines the used compression (can be null)
  10773. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10774. */
  10775. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10776. }
  10777. }
  10778. }
  10779. declare module "babylonjs/Materials/Textures/rawTexture" {
  10780. import { Scene } from "babylonjs/scene";
  10781. import { Texture } from "babylonjs/Materials/Textures/texture";
  10782. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10783. /**
  10784. * Raw texture can help creating a texture directly from an array of data.
  10785. * This can be super useful if you either get the data from an uncompressed source or
  10786. * if you wish to create your texture pixel by pixel.
  10787. */
  10788. export class RawTexture extends Texture {
  10789. /**
  10790. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10791. */
  10792. format: number;
  10793. private _engine;
  10794. /**
  10795. * Instantiates a new RawTexture.
  10796. * Raw texture can help creating a texture directly from an array of data.
  10797. * This can be super useful if you either get the data from an uncompressed source or
  10798. * if you wish to create your texture pixel by pixel.
  10799. * @param data define the array of data to use to create the texture
  10800. * @param width define the width of the texture
  10801. * @param height define the height of the texture
  10802. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10803. * @param scene define the scene the texture belongs to
  10804. * @param generateMipMaps define whether mip maps should be generated or not
  10805. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10806. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10807. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10808. */
  10809. constructor(data: ArrayBufferView, width: number, height: number,
  10810. /**
  10811. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10812. */
  10813. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10814. /**
  10815. * Updates the texture underlying data.
  10816. * @param data Define the new data of the texture
  10817. */
  10818. update(data: ArrayBufferView): void;
  10819. /**
  10820. * Creates a luminance texture from some data.
  10821. * @param data Define the texture data
  10822. * @param width Define the width of the texture
  10823. * @param height Define the height of the texture
  10824. * @param scene Define the scene the texture belongs to
  10825. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10826. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10827. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10828. * @returns the luminance texture
  10829. */
  10830. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10831. /**
  10832. * Creates a luminance alpha texture from some data.
  10833. * @param data Define the texture data
  10834. * @param width Define the width of the texture
  10835. * @param height Define the height of the texture
  10836. * @param scene Define the scene the texture belongs to
  10837. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10838. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10839. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10840. * @returns the luminance alpha texture
  10841. */
  10842. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10843. /**
  10844. * Creates an alpha texture from some data.
  10845. * @param data Define the texture data
  10846. * @param width Define the width of the texture
  10847. * @param height Define the height of the texture
  10848. * @param scene Define the scene the texture belongs to
  10849. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10850. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10851. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10852. * @returns the alpha texture
  10853. */
  10854. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10855. /**
  10856. * Creates a RGB texture from some data.
  10857. * @param data Define the texture data
  10858. * @param width Define the width of the texture
  10859. * @param height Define the height of the texture
  10860. * @param scene Define the scene the texture belongs to
  10861. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10862. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10863. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10864. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10865. * @returns the RGB alpha texture
  10866. */
  10867. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10868. /**
  10869. * Creates a RGBA texture from some data.
  10870. * @param data Define the texture data
  10871. * @param width Define the width of the texture
  10872. * @param height Define the height of the texture
  10873. * @param scene Define the scene the texture belongs to
  10874. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10875. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10876. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10877. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10878. * @returns the RGBA texture
  10879. */
  10880. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10881. /**
  10882. * Creates a R texture from some data.
  10883. * @param data Define the texture data
  10884. * @param width Define the width of the texture
  10885. * @param height Define the height of the texture
  10886. * @param scene Define the scene the texture belongs to
  10887. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10888. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10889. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10890. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10891. * @returns the R texture
  10892. */
  10893. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10894. }
  10895. }
  10896. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10897. import { Scene } from "babylonjs/scene";
  10898. import { ISceneComponent } from "babylonjs/sceneComponent";
  10899. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10900. module "babylonjs/abstractScene" {
  10901. interface AbstractScene {
  10902. /**
  10903. * The list of procedural textures added to the scene
  10904. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10905. */
  10906. proceduralTextures: Array<ProceduralTexture>;
  10907. }
  10908. }
  10909. /**
  10910. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10911. * in a given scene.
  10912. */
  10913. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10914. /**
  10915. * The component name helpfull to identify the component in the list of scene components.
  10916. */
  10917. readonly name: string;
  10918. /**
  10919. * The scene the component belongs to.
  10920. */
  10921. scene: Scene;
  10922. /**
  10923. * Creates a new instance of the component for the given scene
  10924. * @param scene Defines the scene to register the component in
  10925. */
  10926. constructor(scene: Scene);
  10927. /**
  10928. * Registers the component in a given scene
  10929. */
  10930. register(): void;
  10931. /**
  10932. * Rebuilds the elements related to this component in case of
  10933. * context lost for instance.
  10934. */
  10935. rebuild(): void;
  10936. /**
  10937. * Disposes the component and the associated ressources.
  10938. */
  10939. dispose(): void;
  10940. private _beforeClear;
  10941. }
  10942. }
  10943. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10944. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10945. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10946. module "babylonjs/Engines/thinEngine" {
  10947. interface ThinEngine {
  10948. /**
  10949. * Creates a new render target cube texture
  10950. * @param size defines the size of the texture
  10951. * @param options defines the options used to create the texture
  10952. * @returns a new render target cube texture stored in an InternalTexture
  10953. */
  10954. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10955. }
  10956. }
  10957. }
  10958. declare module "babylonjs/Shaders/procedural.vertex" {
  10959. /** @hidden */
  10960. export var proceduralVertexShader: {
  10961. name: string;
  10962. shader: string;
  10963. };
  10964. }
  10965. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10966. import { Observable } from "babylonjs/Misc/observable";
  10967. import { Nullable } from "babylonjs/types";
  10968. import { Scene } from "babylonjs/scene";
  10969. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10970. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10971. import { Effect } from "babylonjs/Materials/effect";
  10972. import { Texture } from "babylonjs/Materials/Textures/texture";
  10973. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10974. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10975. import "babylonjs/Shaders/procedural.vertex";
  10976. /**
  10977. * 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.
  10978. * This is the base class of any Procedural texture and contains most of the shareable code.
  10979. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10980. */
  10981. export class ProceduralTexture extends Texture {
  10982. isCube: boolean;
  10983. /**
  10984. * Define if the texture is enabled or not (disabled texture will not render)
  10985. */
  10986. isEnabled: boolean;
  10987. /**
  10988. * Define if the texture must be cleared before rendering (default is true)
  10989. */
  10990. autoClear: boolean;
  10991. /**
  10992. * Callback called when the texture is generated
  10993. */
  10994. onGenerated: () => void;
  10995. /**
  10996. * Event raised when the texture is generated
  10997. */
  10998. onGeneratedObservable: Observable<ProceduralTexture>;
  10999. /** @hidden */
  11000. _generateMipMaps: boolean;
  11001. /** @hidden **/
  11002. _effect: Effect;
  11003. /** @hidden */
  11004. _textures: {
  11005. [key: string]: Texture;
  11006. };
  11007. private _size;
  11008. private _currentRefreshId;
  11009. private _frameId;
  11010. private _refreshRate;
  11011. private _vertexBuffers;
  11012. private _indexBuffer;
  11013. private _uniforms;
  11014. private _samplers;
  11015. private _fragment;
  11016. private _floats;
  11017. private _ints;
  11018. private _floatsArrays;
  11019. private _colors3;
  11020. private _colors4;
  11021. private _vectors2;
  11022. private _vectors3;
  11023. private _matrices;
  11024. private _fallbackTexture;
  11025. private _fallbackTextureUsed;
  11026. private _engine;
  11027. private _cachedDefines;
  11028. private _contentUpdateId;
  11029. private _contentData;
  11030. /**
  11031. * Instantiates a new procedural texture.
  11032. * 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.
  11033. * This is the base class of any Procedural texture and contains most of the shareable code.
  11034. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11035. * @param name Define the name of the texture
  11036. * @param size Define the size of the texture to create
  11037. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11038. * @param scene Define the scene the texture belongs to
  11039. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11040. * @param generateMipMaps Define if the texture should creates mip maps or not
  11041. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11042. */
  11043. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11044. /**
  11045. * The effect that is created when initializing the post process.
  11046. * @returns The created effect corresponding the the postprocess.
  11047. */
  11048. getEffect(): Effect;
  11049. /**
  11050. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11051. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11052. */
  11053. getContent(): Nullable<ArrayBufferView>;
  11054. private _createIndexBuffer;
  11055. /** @hidden */
  11056. _rebuild(): void;
  11057. /**
  11058. * Resets the texture in order to recreate its associated resources.
  11059. * This can be called in case of context loss
  11060. */
  11061. reset(): void;
  11062. protected _getDefines(): string;
  11063. /**
  11064. * Is the texture ready to be used ? (rendered at least once)
  11065. * @returns true if ready, otherwise, false.
  11066. */
  11067. isReady(): boolean;
  11068. /**
  11069. * Resets the refresh counter of the texture and start bak from scratch.
  11070. * Could be useful to regenerate the texture if it is setup to render only once.
  11071. */
  11072. resetRefreshCounter(): void;
  11073. /**
  11074. * Set the fragment shader to use in order to render the texture.
  11075. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11076. */
  11077. setFragment(fragment: any): void;
  11078. /**
  11079. * Define the refresh rate of the texture or the rendering frequency.
  11080. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11081. */
  11082. get refreshRate(): number;
  11083. set refreshRate(value: number);
  11084. /** @hidden */
  11085. _shouldRender(): boolean;
  11086. /**
  11087. * Get the size the texture is rendering at.
  11088. * @returns the size (texture is always squared)
  11089. */
  11090. getRenderSize(): number;
  11091. /**
  11092. * Resize the texture to new value.
  11093. * @param size Define the new size the texture should have
  11094. * @param generateMipMaps Define whether the new texture should create mip maps
  11095. */
  11096. resize(size: number, generateMipMaps: boolean): void;
  11097. private _checkUniform;
  11098. /**
  11099. * Set a texture in the shader program used to render.
  11100. * @param name Define the name of the uniform samplers as defined in the shader
  11101. * @param texture Define the texture to bind to this sampler
  11102. * @return the texture itself allowing "fluent" like uniform updates
  11103. */
  11104. setTexture(name: string, texture: Texture): ProceduralTexture;
  11105. /**
  11106. * Set a float in the shader.
  11107. * @param name Define the name of the uniform as defined in the shader
  11108. * @param value Define the value to give to the uniform
  11109. * @return the texture itself allowing "fluent" like uniform updates
  11110. */
  11111. setFloat(name: string, value: number): ProceduralTexture;
  11112. /**
  11113. * Set a int in the shader.
  11114. * @param name Define the name of the uniform as defined in the shader
  11115. * @param value Define the value to give to the uniform
  11116. * @return the texture itself allowing "fluent" like uniform updates
  11117. */
  11118. setInt(name: string, value: number): ProceduralTexture;
  11119. /**
  11120. * Set an array of floats in the shader.
  11121. * @param name Define the name of the uniform as defined in the shader
  11122. * @param value Define the value to give to the uniform
  11123. * @return the texture itself allowing "fluent" like uniform updates
  11124. */
  11125. setFloats(name: string, value: number[]): ProceduralTexture;
  11126. /**
  11127. * Set a vec3 in the shader from a Color3.
  11128. * @param name Define the name of the uniform as defined in the shader
  11129. * @param value Define the value to give to the uniform
  11130. * @return the texture itself allowing "fluent" like uniform updates
  11131. */
  11132. setColor3(name: string, value: Color3): ProceduralTexture;
  11133. /**
  11134. * Set a vec4 in the shader from a Color4.
  11135. * @param name Define the name of the uniform as defined in the shader
  11136. * @param value Define the value to give to the uniform
  11137. * @return the texture itself allowing "fluent" like uniform updates
  11138. */
  11139. setColor4(name: string, value: Color4): ProceduralTexture;
  11140. /**
  11141. * Set a vec2 in the shader from a Vector2.
  11142. * @param name Define the name of the uniform as defined in the shader
  11143. * @param value Define the value to give to the uniform
  11144. * @return the texture itself allowing "fluent" like uniform updates
  11145. */
  11146. setVector2(name: string, value: Vector2): ProceduralTexture;
  11147. /**
  11148. * Set a vec3 in the shader from a Vector3.
  11149. * @param name Define the name of the uniform as defined in the shader
  11150. * @param value Define the value to give to the uniform
  11151. * @return the texture itself allowing "fluent" like uniform updates
  11152. */
  11153. setVector3(name: string, value: Vector3): ProceduralTexture;
  11154. /**
  11155. * Set a mat4 in the shader from a MAtrix.
  11156. * @param name Define the name of the uniform as defined in the shader
  11157. * @param value Define the value to give to the uniform
  11158. * @return the texture itself allowing "fluent" like uniform updates
  11159. */
  11160. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11161. /**
  11162. * Render the texture to its associated render target.
  11163. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11164. */
  11165. render(useCameraPostProcess?: boolean): void;
  11166. /**
  11167. * Clone the texture.
  11168. * @returns the cloned texture
  11169. */
  11170. clone(): ProceduralTexture;
  11171. /**
  11172. * Dispose the texture and release its asoociated resources.
  11173. */
  11174. dispose(): void;
  11175. }
  11176. }
  11177. declare module "babylonjs/Particles/baseParticleSystem" {
  11178. import { Nullable } from "babylonjs/types";
  11179. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11181. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11182. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11183. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11184. import { Scene } from "babylonjs/scene";
  11185. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11186. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11187. import { Texture } from "babylonjs/Materials/Textures/texture";
  11188. import { Color4 } from "babylonjs/Maths/math.color";
  11189. import { Animation } from "babylonjs/Animations/animation";
  11190. /**
  11191. * This represents the base class for particle system in Babylon.
  11192. * 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.
  11193. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11194. * @example https://doc.babylonjs.com/babylon101/particles
  11195. */
  11196. export class BaseParticleSystem {
  11197. /**
  11198. * Source color is added to the destination color without alpha affecting the result
  11199. */
  11200. static BLENDMODE_ONEONE: number;
  11201. /**
  11202. * Blend current color and particle color using particle’s alpha
  11203. */
  11204. static BLENDMODE_STANDARD: number;
  11205. /**
  11206. * Add current color and particle color multiplied by particle’s alpha
  11207. */
  11208. static BLENDMODE_ADD: number;
  11209. /**
  11210. * Multiply current color with particle color
  11211. */
  11212. static BLENDMODE_MULTIPLY: number;
  11213. /**
  11214. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11215. */
  11216. static BLENDMODE_MULTIPLYADD: number;
  11217. /**
  11218. * List of animations used by the particle system.
  11219. */
  11220. animations: Animation[];
  11221. /**
  11222. * The id of the Particle system.
  11223. */
  11224. id: string;
  11225. /**
  11226. * The friendly name of the Particle system.
  11227. */
  11228. name: string;
  11229. /**
  11230. * The rendering group used by the Particle system to chose when to render.
  11231. */
  11232. renderingGroupId: number;
  11233. /**
  11234. * The emitter represents the Mesh or position we are attaching the particle system to.
  11235. */
  11236. emitter: Nullable<AbstractMesh | Vector3>;
  11237. /**
  11238. * The maximum number of particles to emit per frame
  11239. */
  11240. emitRate: number;
  11241. /**
  11242. * If you want to launch only a few particles at once, that can be done, as well.
  11243. */
  11244. manualEmitCount: number;
  11245. /**
  11246. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11247. */
  11248. updateSpeed: number;
  11249. /**
  11250. * The amount of time the particle system is running (depends of the overall update speed).
  11251. */
  11252. targetStopDuration: number;
  11253. /**
  11254. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11255. */
  11256. disposeOnStop: boolean;
  11257. /**
  11258. * Minimum power of emitting particles.
  11259. */
  11260. minEmitPower: number;
  11261. /**
  11262. * Maximum power of emitting particles.
  11263. */
  11264. maxEmitPower: number;
  11265. /**
  11266. * Minimum life time of emitting particles.
  11267. */
  11268. minLifeTime: number;
  11269. /**
  11270. * Maximum life time of emitting particles.
  11271. */
  11272. maxLifeTime: number;
  11273. /**
  11274. * Minimum Size of emitting particles.
  11275. */
  11276. minSize: number;
  11277. /**
  11278. * Maximum Size of emitting particles.
  11279. */
  11280. maxSize: number;
  11281. /**
  11282. * Minimum scale of emitting particles on X axis.
  11283. */
  11284. minScaleX: number;
  11285. /**
  11286. * Maximum scale of emitting particles on X axis.
  11287. */
  11288. maxScaleX: number;
  11289. /**
  11290. * Minimum scale of emitting particles on Y axis.
  11291. */
  11292. minScaleY: number;
  11293. /**
  11294. * Maximum scale of emitting particles on Y axis.
  11295. */
  11296. maxScaleY: number;
  11297. /**
  11298. * Gets or sets the minimal initial rotation in radians.
  11299. */
  11300. minInitialRotation: number;
  11301. /**
  11302. * Gets or sets the maximal initial rotation in radians.
  11303. */
  11304. maxInitialRotation: number;
  11305. /**
  11306. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11307. */
  11308. minAngularSpeed: number;
  11309. /**
  11310. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11311. */
  11312. maxAngularSpeed: number;
  11313. /**
  11314. * The texture used to render each particle. (this can be a spritesheet)
  11315. */
  11316. particleTexture: Nullable<Texture>;
  11317. /**
  11318. * The layer mask we are rendering the particles through.
  11319. */
  11320. layerMask: number;
  11321. /**
  11322. * This can help using your own shader to render the particle system.
  11323. * The according effect will be created
  11324. */
  11325. customShader: any;
  11326. /**
  11327. * By default particle system starts as soon as they are created. This prevents the
  11328. * automatic start to happen and let you decide when to start emitting particles.
  11329. */
  11330. preventAutoStart: boolean;
  11331. private _noiseTexture;
  11332. /**
  11333. * Gets or sets a texture used to add random noise to particle positions
  11334. */
  11335. get noiseTexture(): Nullable<ProceduralTexture>;
  11336. set noiseTexture(value: Nullable<ProceduralTexture>);
  11337. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11338. noiseStrength: Vector3;
  11339. /**
  11340. * Callback triggered when the particle animation is ending.
  11341. */
  11342. onAnimationEnd: Nullable<() => void>;
  11343. /**
  11344. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11345. */
  11346. blendMode: number;
  11347. /**
  11348. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11349. * to override the particles.
  11350. */
  11351. forceDepthWrite: boolean;
  11352. /** 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 */
  11353. preWarmCycles: number;
  11354. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11355. preWarmStepOffset: number;
  11356. /**
  11357. * 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)
  11358. */
  11359. spriteCellChangeSpeed: number;
  11360. /**
  11361. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11362. */
  11363. startSpriteCellID: number;
  11364. /**
  11365. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11366. */
  11367. endSpriteCellID: number;
  11368. /**
  11369. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11370. */
  11371. spriteCellWidth: number;
  11372. /**
  11373. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11374. */
  11375. spriteCellHeight: number;
  11376. /**
  11377. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11378. */
  11379. spriteRandomStartCell: boolean;
  11380. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11381. translationPivot: Vector2;
  11382. /** @hidden */
  11383. protected _isAnimationSheetEnabled: boolean;
  11384. /**
  11385. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11386. */
  11387. beginAnimationOnStart: boolean;
  11388. /**
  11389. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11390. */
  11391. beginAnimationFrom: number;
  11392. /**
  11393. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11394. */
  11395. beginAnimationTo: number;
  11396. /**
  11397. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11398. */
  11399. beginAnimationLoop: boolean;
  11400. /**
  11401. * Gets or sets a world offset applied to all particles
  11402. */
  11403. worldOffset: Vector3;
  11404. /**
  11405. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11406. */
  11407. get isAnimationSheetEnabled(): boolean;
  11408. set isAnimationSheetEnabled(value: boolean);
  11409. /**
  11410. * Get hosting scene
  11411. * @returns the scene
  11412. */
  11413. getScene(): Scene;
  11414. /**
  11415. * You can use gravity if you want to give an orientation to your particles.
  11416. */
  11417. gravity: Vector3;
  11418. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11419. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11420. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11421. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11422. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11423. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11424. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11425. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11426. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11427. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11428. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11429. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11430. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11431. /**
  11432. * Defines the delay in milliseconds before starting the system (0 by default)
  11433. */
  11434. startDelay: number;
  11435. /**
  11436. * Gets the current list of drag gradients.
  11437. * You must use addDragGradient and removeDragGradient to udpate this list
  11438. * @returns the list of drag gradients
  11439. */
  11440. getDragGradients(): Nullable<Array<FactorGradient>>;
  11441. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11442. limitVelocityDamping: number;
  11443. /**
  11444. * Gets the current list of limit velocity gradients.
  11445. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11446. * @returns the list of limit velocity gradients
  11447. */
  11448. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11449. /**
  11450. * Gets the current list of color gradients.
  11451. * You must use addColorGradient and removeColorGradient to udpate this list
  11452. * @returns the list of color gradients
  11453. */
  11454. getColorGradients(): Nullable<Array<ColorGradient>>;
  11455. /**
  11456. * Gets the current list of size gradients.
  11457. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11458. * @returns the list of size gradients
  11459. */
  11460. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11461. /**
  11462. * Gets the current list of color remap gradients.
  11463. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11464. * @returns the list of color remap gradients
  11465. */
  11466. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11467. /**
  11468. * Gets the current list of alpha remap gradients.
  11469. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11470. * @returns the list of alpha remap gradients
  11471. */
  11472. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11473. /**
  11474. * Gets the current list of life time gradients.
  11475. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11476. * @returns the list of life time gradients
  11477. */
  11478. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11479. /**
  11480. * Gets the current list of angular speed gradients.
  11481. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11482. * @returns the list of angular speed gradients
  11483. */
  11484. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11485. /**
  11486. * Gets the current list of velocity gradients.
  11487. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11488. * @returns the list of velocity gradients
  11489. */
  11490. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11491. /**
  11492. * Gets the current list of start size gradients.
  11493. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11494. * @returns the list of start size gradients
  11495. */
  11496. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11497. /**
  11498. * Gets the current list of emit rate gradients.
  11499. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11500. * @returns the list of emit rate gradients
  11501. */
  11502. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11503. /**
  11504. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11505. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11506. */
  11507. get direction1(): Vector3;
  11508. set direction1(value: Vector3);
  11509. /**
  11510. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11511. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11512. */
  11513. get direction2(): Vector3;
  11514. set direction2(value: Vector3);
  11515. /**
  11516. * 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.
  11517. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11518. */
  11519. get minEmitBox(): Vector3;
  11520. set minEmitBox(value: Vector3);
  11521. /**
  11522. * 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.
  11523. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11524. */
  11525. get maxEmitBox(): Vector3;
  11526. set maxEmitBox(value: Vector3);
  11527. /**
  11528. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11529. */
  11530. color1: Color4;
  11531. /**
  11532. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11533. */
  11534. color2: Color4;
  11535. /**
  11536. * Color the particle will have at the end of its lifetime
  11537. */
  11538. colorDead: Color4;
  11539. /**
  11540. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11541. */
  11542. textureMask: Color4;
  11543. /**
  11544. * The particle emitter type defines the emitter used by the particle system.
  11545. * It can be for example box, sphere, or cone...
  11546. */
  11547. particleEmitterType: IParticleEmitterType;
  11548. /** @hidden */
  11549. _isSubEmitter: boolean;
  11550. /**
  11551. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11552. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11553. */
  11554. billboardMode: number;
  11555. protected _isBillboardBased: boolean;
  11556. /**
  11557. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11558. */
  11559. get isBillboardBased(): boolean;
  11560. set isBillboardBased(value: boolean);
  11561. /**
  11562. * The scene the particle system belongs to.
  11563. */
  11564. protected _scene: Scene;
  11565. /**
  11566. * Local cache of defines for image processing.
  11567. */
  11568. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11569. /**
  11570. * Default configuration related to image processing available in the standard Material.
  11571. */
  11572. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11573. /**
  11574. * Gets the image processing configuration used either in this material.
  11575. */
  11576. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11577. /**
  11578. * Sets the Default image processing configuration used either in the this material.
  11579. *
  11580. * If sets to null, the scene one is in use.
  11581. */
  11582. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11583. /**
  11584. * Attaches a new image processing configuration to the Standard Material.
  11585. * @param configuration
  11586. */
  11587. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11588. /** @hidden */
  11589. protected _reset(): void;
  11590. /** @hidden */
  11591. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11592. /**
  11593. * Instantiates a particle system.
  11594. * 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.
  11595. * @param name The name of the particle system
  11596. */
  11597. constructor(name: string);
  11598. /**
  11599. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11602. * @returns the emitter
  11603. */
  11604. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11605. /**
  11606. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11607. * @param radius The radius of the hemisphere to emit from
  11608. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11609. * @returns the emitter
  11610. */
  11611. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11612. /**
  11613. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11614. * @param radius The radius of the sphere to emit from
  11615. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11616. * @returns the emitter
  11617. */
  11618. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11619. /**
  11620. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11621. * @param radius The radius of the sphere to emit from
  11622. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11623. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11624. * @returns the emitter
  11625. */
  11626. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11627. /**
  11628. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11629. * @param radius The radius of the emission cylinder
  11630. * @param height The height of the emission cylinder
  11631. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11632. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11633. * @returns the emitter
  11634. */
  11635. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11636. /**
  11637. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11638. * @param radius The radius of the cylinder to emit from
  11639. * @param height The height of the emission cylinder
  11640. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11641. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11642. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11643. * @returns the emitter
  11644. */
  11645. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11646. /**
  11647. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11648. * @param radius The radius of the cone to emit from
  11649. * @param angle The base angle of the cone
  11650. * @returns the emitter
  11651. */
  11652. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11653. /**
  11654. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11655. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11656. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11657. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11658. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11659. * @returns the emitter
  11660. */
  11661. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11662. }
  11663. }
  11664. declare module "babylonjs/Particles/subEmitter" {
  11665. import { Scene } from "babylonjs/scene";
  11666. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11667. /**
  11668. * Type of sub emitter
  11669. */
  11670. export enum SubEmitterType {
  11671. /**
  11672. * Attached to the particle over it's lifetime
  11673. */
  11674. ATTACHED = 0,
  11675. /**
  11676. * Created when the particle dies
  11677. */
  11678. END = 1
  11679. }
  11680. /**
  11681. * Sub emitter class used to emit particles from an existing particle
  11682. */
  11683. export class SubEmitter {
  11684. /**
  11685. * the particle system to be used by the sub emitter
  11686. */
  11687. particleSystem: ParticleSystem;
  11688. /**
  11689. * Type of the submitter (Default: END)
  11690. */
  11691. type: SubEmitterType;
  11692. /**
  11693. * 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)
  11694. * Note: This only is supported when using an emitter of type Mesh
  11695. */
  11696. inheritDirection: boolean;
  11697. /**
  11698. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11699. */
  11700. inheritedVelocityAmount: number;
  11701. /**
  11702. * Creates a sub emitter
  11703. * @param particleSystem the particle system to be used by the sub emitter
  11704. */
  11705. constructor(
  11706. /**
  11707. * the particle system to be used by the sub emitter
  11708. */
  11709. particleSystem: ParticleSystem);
  11710. /**
  11711. * Clones the sub emitter
  11712. * @returns the cloned sub emitter
  11713. */
  11714. clone(): SubEmitter;
  11715. /**
  11716. * Serialize current object to a JSON object
  11717. * @returns the serialized object
  11718. */
  11719. serialize(): any;
  11720. /** @hidden */
  11721. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11722. /**
  11723. * Creates a new SubEmitter from a serialized JSON version
  11724. * @param serializationObject defines the JSON object to read from
  11725. * @param scene defines the hosting scene
  11726. * @param rootUrl defines the rootUrl for data loading
  11727. * @returns a new SubEmitter
  11728. */
  11729. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11730. /** Release associated resources */
  11731. dispose(): void;
  11732. }
  11733. }
  11734. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11735. /** @hidden */
  11736. export var imageProcessingDeclaration: {
  11737. name: string;
  11738. shader: string;
  11739. };
  11740. }
  11741. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11742. /** @hidden */
  11743. export var imageProcessingFunctions: {
  11744. name: string;
  11745. shader: string;
  11746. };
  11747. }
  11748. declare module "babylonjs/Shaders/particles.fragment" {
  11749. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11750. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11751. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11752. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11753. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11754. /** @hidden */
  11755. export var particlesPixelShader: {
  11756. name: string;
  11757. shader: string;
  11758. };
  11759. }
  11760. declare module "babylonjs/Shaders/particles.vertex" {
  11761. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11762. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11763. /** @hidden */
  11764. export var particlesVertexShader: {
  11765. name: string;
  11766. shader: string;
  11767. };
  11768. }
  11769. declare module "babylonjs/Particles/particleSystem" {
  11770. import { Nullable } from "babylonjs/types";
  11771. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11772. import { Observable } from "babylonjs/Misc/observable";
  11773. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11774. import { Effect } from "babylonjs/Materials/effect";
  11775. import { Scene, IDisposable } from "babylonjs/scene";
  11776. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11777. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11778. import { Particle } from "babylonjs/Particles/particle";
  11779. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11780. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11781. import "babylonjs/Shaders/particles.fragment";
  11782. import "babylonjs/Shaders/particles.vertex";
  11783. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11784. /**
  11785. * This represents a particle system in Babylon.
  11786. * 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.
  11787. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11788. * @example https://doc.babylonjs.com/babylon101/particles
  11789. */
  11790. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11791. /**
  11792. * Billboard mode will only apply to Y axis
  11793. */
  11794. static readonly BILLBOARDMODE_Y: number;
  11795. /**
  11796. * Billboard mode will apply to all axes
  11797. */
  11798. static readonly BILLBOARDMODE_ALL: number;
  11799. /**
  11800. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11801. */
  11802. static readonly BILLBOARDMODE_STRETCHED: number;
  11803. /**
  11804. * This function can be defined to provide custom update for active particles.
  11805. * This function will be called instead of regular update (age, position, color, etc.).
  11806. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11807. */
  11808. updateFunction: (particles: Particle[]) => void;
  11809. private _emitterWorldMatrix;
  11810. /**
  11811. * This function can be defined to specify initial direction for every new particle.
  11812. * It by default use the emitterType defined function
  11813. */
  11814. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11815. /**
  11816. * This function can be defined to specify initial position for every new particle.
  11817. * It by default use the emitterType defined function
  11818. */
  11819. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11820. /**
  11821. * @hidden
  11822. */
  11823. _inheritedVelocityOffset: Vector3;
  11824. /**
  11825. * An event triggered when the system is disposed
  11826. */
  11827. onDisposeObservable: Observable<ParticleSystem>;
  11828. private _onDisposeObserver;
  11829. /**
  11830. * Sets a callback that will be triggered when the system is disposed
  11831. */
  11832. set onDispose(callback: () => void);
  11833. private _particles;
  11834. private _epsilon;
  11835. private _capacity;
  11836. private _stockParticles;
  11837. private _newPartsExcess;
  11838. private _vertexData;
  11839. private _vertexBuffer;
  11840. private _vertexBuffers;
  11841. private _spriteBuffer;
  11842. private _indexBuffer;
  11843. private _effect;
  11844. private _customEffect;
  11845. private _cachedDefines;
  11846. private _scaledColorStep;
  11847. private _colorDiff;
  11848. private _scaledDirection;
  11849. private _scaledGravity;
  11850. private _currentRenderId;
  11851. private _alive;
  11852. private _useInstancing;
  11853. private _started;
  11854. private _stopped;
  11855. private _actualFrame;
  11856. private _scaledUpdateSpeed;
  11857. private _vertexBufferSize;
  11858. /** @hidden */
  11859. _currentEmitRateGradient: Nullable<FactorGradient>;
  11860. /** @hidden */
  11861. _currentEmitRate1: number;
  11862. /** @hidden */
  11863. _currentEmitRate2: number;
  11864. /** @hidden */
  11865. _currentStartSizeGradient: Nullable<FactorGradient>;
  11866. /** @hidden */
  11867. _currentStartSize1: number;
  11868. /** @hidden */
  11869. _currentStartSize2: number;
  11870. private readonly _rawTextureWidth;
  11871. private _rampGradientsTexture;
  11872. private _useRampGradients;
  11873. /** Gets or sets a boolean indicating that ramp gradients must be used
  11874. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11875. */
  11876. get useRampGradients(): boolean;
  11877. set useRampGradients(value: boolean);
  11878. /**
  11879. * 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.
  11880. * 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: [])
  11881. */
  11882. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11883. private _subEmitters;
  11884. /**
  11885. * @hidden
  11886. * If the particle systems emitter should be disposed when the particle system is disposed
  11887. */
  11888. _disposeEmitterOnDispose: boolean;
  11889. /**
  11890. * The current active Sub-systems, this property is used by the root particle system only.
  11891. */
  11892. activeSubSystems: Array<ParticleSystem>;
  11893. /**
  11894. * Specifies if the particles are updated in emitter local space or world space
  11895. */
  11896. isLocal: boolean;
  11897. private _rootParticleSystem;
  11898. /**
  11899. * Gets the current list of active particles
  11900. */
  11901. get particles(): Particle[];
  11902. /**
  11903. * Returns the string "ParticleSystem"
  11904. * @returns a string containing the class name
  11905. */
  11906. getClassName(): string;
  11907. /**
  11908. * Instantiates a particle system.
  11909. * 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.
  11910. * @param name The name of the particle system
  11911. * @param capacity The max number of particles alive at the same time
  11912. * @param scene The scene the particle system belongs to
  11913. * @param customEffect a custom effect used to change the way particles are rendered by default
  11914. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11915. * @param epsilon Offset used to render the particles
  11916. */
  11917. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11918. private _addFactorGradient;
  11919. private _removeFactorGradient;
  11920. /**
  11921. * Adds a new life time gradient
  11922. * @param gradient defines the gradient to use (between 0 and 1)
  11923. * @param factor defines the life time factor to affect to the specified gradient
  11924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11925. * @returns the current particle system
  11926. */
  11927. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11928. /**
  11929. * Remove a specific life time gradient
  11930. * @param gradient defines the gradient to remove
  11931. * @returns the current particle system
  11932. */
  11933. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11934. /**
  11935. * Adds a new size gradient
  11936. * @param gradient defines the gradient to use (between 0 and 1)
  11937. * @param factor defines the size factor to affect to the specified gradient
  11938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11939. * @returns the current particle system
  11940. */
  11941. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11942. /**
  11943. * Remove a specific size gradient
  11944. * @param gradient defines the gradient to remove
  11945. * @returns the current particle system
  11946. */
  11947. removeSizeGradient(gradient: number): IParticleSystem;
  11948. /**
  11949. * Adds a new color remap gradient
  11950. * @param gradient defines the gradient to use (between 0 and 1)
  11951. * @param min defines the color remap minimal range
  11952. * @param max defines the color remap maximal range
  11953. * @returns the current particle system
  11954. */
  11955. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11956. /**
  11957. * Remove a specific color remap gradient
  11958. * @param gradient defines the gradient to remove
  11959. * @returns the current particle system
  11960. */
  11961. removeColorRemapGradient(gradient: number): IParticleSystem;
  11962. /**
  11963. * Adds a new alpha remap gradient
  11964. * @param gradient defines the gradient to use (between 0 and 1)
  11965. * @param min defines the alpha remap minimal range
  11966. * @param max defines the alpha remap maximal range
  11967. * @returns the current particle system
  11968. */
  11969. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11970. /**
  11971. * Remove a specific alpha remap gradient
  11972. * @param gradient defines the gradient to remove
  11973. * @returns the current particle system
  11974. */
  11975. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11976. /**
  11977. * Adds a new angular speed gradient
  11978. * @param gradient defines the gradient to use (between 0 and 1)
  11979. * @param factor defines the angular speed to affect to the specified gradient
  11980. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11981. * @returns the current particle system
  11982. */
  11983. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11984. /**
  11985. * Remove a specific angular speed gradient
  11986. * @param gradient defines the gradient to remove
  11987. * @returns the current particle system
  11988. */
  11989. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11990. /**
  11991. * Adds a new velocity gradient
  11992. * @param gradient defines the gradient to use (between 0 and 1)
  11993. * @param factor defines the velocity to affect to the specified gradient
  11994. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11995. * @returns the current particle system
  11996. */
  11997. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11998. /**
  11999. * Remove a specific velocity gradient
  12000. * @param gradient defines the gradient to remove
  12001. * @returns the current particle system
  12002. */
  12003. removeVelocityGradient(gradient: number): IParticleSystem;
  12004. /**
  12005. * Adds a new limit velocity gradient
  12006. * @param gradient defines the gradient to use (between 0 and 1)
  12007. * @param factor defines the limit velocity value to affect to the specified gradient
  12008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12009. * @returns the current particle system
  12010. */
  12011. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12012. /**
  12013. * Remove a specific limit velocity gradient
  12014. * @param gradient defines the gradient to remove
  12015. * @returns the current particle system
  12016. */
  12017. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12018. /**
  12019. * Adds a new drag gradient
  12020. * @param gradient defines the gradient to use (between 0 and 1)
  12021. * @param factor defines the drag value to affect to the specified gradient
  12022. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12023. * @returns the current particle system
  12024. */
  12025. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12026. /**
  12027. * Remove a specific drag gradient
  12028. * @param gradient defines the gradient to remove
  12029. * @returns the current particle system
  12030. */
  12031. removeDragGradient(gradient: number): IParticleSystem;
  12032. /**
  12033. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12034. * @param gradient defines the gradient to use (between 0 and 1)
  12035. * @param factor defines the emit rate value to affect to the specified gradient
  12036. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12037. * @returns the current particle system
  12038. */
  12039. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12040. /**
  12041. * Remove a specific emit rate gradient
  12042. * @param gradient defines the gradient to remove
  12043. * @returns the current particle system
  12044. */
  12045. removeEmitRateGradient(gradient: number): IParticleSystem;
  12046. /**
  12047. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12048. * @param gradient defines the gradient to use (between 0 and 1)
  12049. * @param factor defines the start size value to affect to the specified gradient
  12050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12051. * @returns the current particle system
  12052. */
  12053. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12054. /**
  12055. * Remove a specific start size gradient
  12056. * @param gradient defines the gradient to remove
  12057. * @returns the current particle system
  12058. */
  12059. removeStartSizeGradient(gradient: number): IParticleSystem;
  12060. private _createRampGradientTexture;
  12061. /**
  12062. * Gets the current list of ramp gradients.
  12063. * You must use addRampGradient and removeRampGradient to udpate this list
  12064. * @returns the list of ramp gradients
  12065. */
  12066. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12067. /**
  12068. * Adds a new ramp gradient used to remap particle colors
  12069. * @param gradient defines the gradient to use (between 0 and 1)
  12070. * @param color defines the color to affect to the specified gradient
  12071. * @returns the current particle system
  12072. */
  12073. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12074. /**
  12075. * Remove a specific ramp gradient
  12076. * @param gradient defines the gradient to remove
  12077. * @returns the current particle system
  12078. */
  12079. removeRampGradient(gradient: number): ParticleSystem;
  12080. /**
  12081. * Adds a new color gradient
  12082. * @param gradient defines the gradient to use (between 0 and 1)
  12083. * @param color1 defines the color to affect to the specified gradient
  12084. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12085. * @returns this particle system
  12086. */
  12087. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12088. /**
  12089. * Remove a specific color gradient
  12090. * @param gradient defines the gradient to remove
  12091. * @returns this particle system
  12092. */
  12093. removeColorGradient(gradient: number): IParticleSystem;
  12094. private _fetchR;
  12095. protected _reset(): void;
  12096. private _resetEffect;
  12097. private _createVertexBuffers;
  12098. private _createIndexBuffer;
  12099. /**
  12100. * Gets the maximum number of particles active at the same time.
  12101. * @returns The max number of active particles.
  12102. */
  12103. getCapacity(): number;
  12104. /**
  12105. * Gets whether there are still active particles in the system.
  12106. * @returns True if it is alive, otherwise false.
  12107. */
  12108. isAlive(): boolean;
  12109. /**
  12110. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12111. * @returns True if it has been started, otherwise false.
  12112. */
  12113. isStarted(): boolean;
  12114. private _prepareSubEmitterInternalArray;
  12115. /**
  12116. * Starts the particle system and begins to emit
  12117. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12118. */
  12119. start(delay?: number): void;
  12120. /**
  12121. * Stops the particle system.
  12122. * @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.
  12123. */
  12124. stop(stopSubEmitters?: boolean): void;
  12125. /**
  12126. * Remove all active particles
  12127. */
  12128. reset(): void;
  12129. /**
  12130. * @hidden (for internal use only)
  12131. */
  12132. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12133. /**
  12134. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12135. * Its lifetime will start back at 0.
  12136. */
  12137. recycleParticle: (particle: Particle) => void;
  12138. private _stopSubEmitters;
  12139. private _createParticle;
  12140. private _removeFromRoot;
  12141. private _emitFromParticle;
  12142. private _update;
  12143. /** @hidden */
  12144. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12145. /** @hidden */
  12146. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12147. /** @hidden */
  12148. private _getEffect;
  12149. /**
  12150. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12151. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12152. */
  12153. animate(preWarmOnly?: boolean): void;
  12154. private _appendParticleVertices;
  12155. /**
  12156. * Rebuilds the particle system.
  12157. */
  12158. rebuild(): void;
  12159. /**
  12160. * Is this system ready to be used/rendered
  12161. * @return true if the system is ready
  12162. */
  12163. isReady(): boolean;
  12164. private _render;
  12165. /**
  12166. * Renders the particle system in its current state.
  12167. * @returns the current number of particles
  12168. */
  12169. render(): number;
  12170. /**
  12171. * Disposes the particle system and free the associated resources
  12172. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12173. */
  12174. dispose(disposeTexture?: boolean): void;
  12175. /**
  12176. * Clones the particle system.
  12177. * @param name The name of the cloned object
  12178. * @param newEmitter The new emitter to use
  12179. * @returns the cloned particle system
  12180. */
  12181. clone(name: string, newEmitter: any): ParticleSystem;
  12182. /**
  12183. * Serializes the particle system to a JSON object.
  12184. * @returns the JSON object
  12185. */
  12186. serialize(): any;
  12187. /** @hidden */
  12188. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12189. /** @hidden */
  12190. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12191. /**
  12192. * Parses a JSON object to create a particle system.
  12193. * @param parsedParticleSystem The JSON object to parse
  12194. * @param scene The scene to create the particle system in
  12195. * @param rootUrl The root url to use to load external dependencies like texture
  12196. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12197. * @returns the Parsed particle system
  12198. */
  12199. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12200. }
  12201. }
  12202. declare module "babylonjs/Particles/particle" {
  12203. import { Nullable } from "babylonjs/types";
  12204. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12205. import { Color4 } from "babylonjs/Maths/math.color";
  12206. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12207. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12208. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12209. /**
  12210. * A particle represents one of the element emitted by a particle system.
  12211. * This is mainly define by its coordinates, direction, velocity and age.
  12212. */
  12213. export class Particle {
  12214. /**
  12215. * The particle system the particle belongs to.
  12216. */
  12217. particleSystem: ParticleSystem;
  12218. private static _Count;
  12219. /**
  12220. * Unique ID of the particle
  12221. */
  12222. id: number;
  12223. /**
  12224. * The world position of the particle in the scene.
  12225. */
  12226. position: Vector3;
  12227. /**
  12228. * The world direction of the particle in the scene.
  12229. */
  12230. direction: Vector3;
  12231. /**
  12232. * The color of the particle.
  12233. */
  12234. color: Color4;
  12235. /**
  12236. * The color change of the particle per step.
  12237. */
  12238. colorStep: Color4;
  12239. /**
  12240. * Defines how long will the life of the particle be.
  12241. */
  12242. lifeTime: number;
  12243. /**
  12244. * The current age of the particle.
  12245. */
  12246. age: number;
  12247. /**
  12248. * The current size of the particle.
  12249. */
  12250. size: number;
  12251. /**
  12252. * The current scale of the particle.
  12253. */
  12254. scale: Vector2;
  12255. /**
  12256. * The current angle of the particle.
  12257. */
  12258. angle: number;
  12259. /**
  12260. * Defines how fast is the angle changing.
  12261. */
  12262. angularSpeed: number;
  12263. /**
  12264. * Defines the cell index used by the particle to be rendered from a sprite.
  12265. */
  12266. cellIndex: number;
  12267. /**
  12268. * The information required to support color remapping
  12269. */
  12270. remapData: Vector4;
  12271. /** @hidden */
  12272. _randomCellOffset?: number;
  12273. /** @hidden */
  12274. _initialDirection: Nullable<Vector3>;
  12275. /** @hidden */
  12276. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12277. /** @hidden */
  12278. _initialStartSpriteCellID: number;
  12279. /** @hidden */
  12280. _initialEndSpriteCellID: number;
  12281. /** @hidden */
  12282. _currentColorGradient: Nullable<ColorGradient>;
  12283. /** @hidden */
  12284. _currentColor1: Color4;
  12285. /** @hidden */
  12286. _currentColor2: Color4;
  12287. /** @hidden */
  12288. _currentSizeGradient: Nullable<FactorGradient>;
  12289. /** @hidden */
  12290. _currentSize1: number;
  12291. /** @hidden */
  12292. _currentSize2: number;
  12293. /** @hidden */
  12294. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12295. /** @hidden */
  12296. _currentAngularSpeed1: number;
  12297. /** @hidden */
  12298. _currentAngularSpeed2: number;
  12299. /** @hidden */
  12300. _currentVelocityGradient: Nullable<FactorGradient>;
  12301. /** @hidden */
  12302. _currentVelocity1: number;
  12303. /** @hidden */
  12304. _currentVelocity2: number;
  12305. /** @hidden */
  12306. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12307. /** @hidden */
  12308. _currentLimitVelocity1: number;
  12309. /** @hidden */
  12310. _currentLimitVelocity2: number;
  12311. /** @hidden */
  12312. _currentDragGradient: Nullable<FactorGradient>;
  12313. /** @hidden */
  12314. _currentDrag1: number;
  12315. /** @hidden */
  12316. _currentDrag2: number;
  12317. /** @hidden */
  12318. _randomNoiseCoordinates1: Vector3;
  12319. /** @hidden */
  12320. _randomNoiseCoordinates2: Vector3;
  12321. /** @hidden */
  12322. _localPosition?: Vector3;
  12323. /**
  12324. * Creates a new instance Particle
  12325. * @param particleSystem the particle system the particle belongs to
  12326. */
  12327. constructor(
  12328. /**
  12329. * The particle system the particle belongs to.
  12330. */
  12331. particleSystem: ParticleSystem);
  12332. private updateCellInfoFromSystem;
  12333. /**
  12334. * Defines how the sprite cell index is updated for the particle
  12335. */
  12336. updateCellIndex(): void;
  12337. /** @hidden */
  12338. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12339. /** @hidden */
  12340. _inheritParticleInfoToSubEmitters(): void;
  12341. /** @hidden */
  12342. _reset(): void;
  12343. /**
  12344. * Copy the properties of particle to another one.
  12345. * @param other the particle to copy the information to.
  12346. */
  12347. copyTo(other: Particle): void;
  12348. }
  12349. }
  12350. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12351. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12352. import { Effect } from "babylonjs/Materials/effect";
  12353. import { Particle } from "babylonjs/Particles/particle";
  12354. import { Scene } from "babylonjs/scene";
  12355. /**
  12356. * Particle emitter represents a volume emitting particles.
  12357. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12358. */
  12359. export interface IParticleEmitterType {
  12360. /**
  12361. * Called by the particle System when the direction is computed for the created particle.
  12362. * @param worldMatrix is the world matrix of the particle system
  12363. * @param directionToUpdate is the direction vector to update with the result
  12364. * @param particle is the particle we are computed the direction for
  12365. * @param isLocal defines if the direction should be set in local space
  12366. */
  12367. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12368. /**
  12369. * Called by the particle System when the position is computed for the created particle.
  12370. * @param worldMatrix is the world matrix of the particle system
  12371. * @param positionToUpdate is the position vector to update with the result
  12372. * @param particle is the particle we are computed the position for
  12373. * @param isLocal defines if the position should be set in local space
  12374. */
  12375. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12376. /**
  12377. * Clones the current emitter and returns a copy of it
  12378. * @returns the new emitter
  12379. */
  12380. clone(): IParticleEmitterType;
  12381. /**
  12382. * Called by the GPUParticleSystem to setup the update shader
  12383. * @param effect defines the update shader
  12384. */
  12385. applyToShader(effect: Effect): void;
  12386. /**
  12387. * Returns a string to use to update the GPU particles update shader
  12388. * @returns the effect defines string
  12389. */
  12390. getEffectDefines(): string;
  12391. /**
  12392. * Returns a string representing the class name
  12393. * @returns a string containing the class name
  12394. */
  12395. getClassName(): string;
  12396. /**
  12397. * Serializes the particle system to a JSON object.
  12398. * @returns the JSON object
  12399. */
  12400. serialize(): any;
  12401. /**
  12402. * Parse properties from a JSON object
  12403. * @param serializationObject defines the JSON object
  12404. * @param scene defines the hosting scene
  12405. */
  12406. parse(serializationObject: any, scene: Scene): void;
  12407. }
  12408. }
  12409. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12410. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12411. import { Effect } from "babylonjs/Materials/effect";
  12412. import { Particle } from "babylonjs/Particles/particle";
  12413. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12414. /**
  12415. * Particle emitter emitting particles from the inside of a box.
  12416. * It emits the particles randomly between 2 given directions.
  12417. */
  12418. export class BoxParticleEmitter implements IParticleEmitterType {
  12419. /**
  12420. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12421. */
  12422. direction1: Vector3;
  12423. /**
  12424. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12425. */
  12426. direction2: Vector3;
  12427. /**
  12428. * 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.
  12429. */
  12430. minEmitBox: Vector3;
  12431. /**
  12432. * 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.
  12433. */
  12434. maxEmitBox: Vector3;
  12435. /**
  12436. * Creates a new instance BoxParticleEmitter
  12437. */
  12438. constructor();
  12439. /**
  12440. * Called by the particle System when the direction is computed for the created particle.
  12441. * @param worldMatrix is the world matrix of the particle system
  12442. * @param directionToUpdate is the direction vector to update with the result
  12443. * @param particle is the particle we are computed the direction for
  12444. * @param isLocal defines if the direction should be set in local space
  12445. */
  12446. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12447. /**
  12448. * Called by the particle System when the position is computed for the created particle.
  12449. * @param worldMatrix is the world matrix of the particle system
  12450. * @param positionToUpdate is the position vector to update with the result
  12451. * @param particle is the particle we are computed the position for
  12452. * @param isLocal defines if the position should be set in local space
  12453. */
  12454. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12455. /**
  12456. * Clones the current emitter and returns a copy of it
  12457. * @returns the new emitter
  12458. */
  12459. clone(): BoxParticleEmitter;
  12460. /**
  12461. * Called by the GPUParticleSystem to setup the update shader
  12462. * @param effect defines the update shader
  12463. */
  12464. applyToShader(effect: Effect): void;
  12465. /**
  12466. * Returns a string to use to update the GPU particles update shader
  12467. * @returns a string containng the defines string
  12468. */
  12469. getEffectDefines(): string;
  12470. /**
  12471. * Returns the string "BoxParticleEmitter"
  12472. * @returns a string containing the class name
  12473. */
  12474. getClassName(): string;
  12475. /**
  12476. * Serializes the particle system to a JSON object.
  12477. * @returns the JSON object
  12478. */
  12479. serialize(): any;
  12480. /**
  12481. * Parse properties from a JSON object
  12482. * @param serializationObject defines the JSON object
  12483. */
  12484. parse(serializationObject: any): void;
  12485. }
  12486. }
  12487. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12488. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12489. import { Effect } from "babylonjs/Materials/effect";
  12490. import { Particle } from "babylonjs/Particles/particle";
  12491. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12492. /**
  12493. * Particle emitter emitting particles from the inside of a cone.
  12494. * It emits the particles alongside the cone volume from the base to the particle.
  12495. * The emission direction might be randomized.
  12496. */
  12497. export class ConeParticleEmitter implements IParticleEmitterType {
  12498. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12499. directionRandomizer: number;
  12500. private _radius;
  12501. private _angle;
  12502. private _height;
  12503. /**
  12504. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12505. */
  12506. radiusRange: number;
  12507. /**
  12508. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12509. */
  12510. heightRange: number;
  12511. /**
  12512. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12513. */
  12514. emitFromSpawnPointOnly: boolean;
  12515. /**
  12516. * Gets or sets the radius of the emission cone
  12517. */
  12518. get radius(): number;
  12519. set radius(value: number);
  12520. /**
  12521. * Gets or sets the angle of the emission cone
  12522. */
  12523. get angle(): number;
  12524. set angle(value: number);
  12525. private _buildHeight;
  12526. /**
  12527. * Creates a new instance ConeParticleEmitter
  12528. * @param radius the radius of the emission cone (1 by default)
  12529. * @param angle the cone base angle (PI by default)
  12530. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12531. */
  12532. constructor(radius?: number, angle?: number,
  12533. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12534. directionRandomizer?: number);
  12535. /**
  12536. * Called by the particle System when the direction is computed for the created particle.
  12537. * @param worldMatrix is the world matrix of the particle system
  12538. * @param directionToUpdate is the direction vector to update with the result
  12539. * @param particle is the particle we are computed the direction for
  12540. * @param isLocal defines if the direction should be set in local space
  12541. */
  12542. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12543. /**
  12544. * Called by the particle System when the position is computed for the created particle.
  12545. * @param worldMatrix is the world matrix of the particle system
  12546. * @param positionToUpdate is the position vector to update with the result
  12547. * @param particle is the particle we are computed the position for
  12548. * @param isLocal defines if the position should be set in local space
  12549. */
  12550. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12551. /**
  12552. * Clones the current emitter and returns a copy of it
  12553. * @returns the new emitter
  12554. */
  12555. clone(): ConeParticleEmitter;
  12556. /**
  12557. * Called by the GPUParticleSystem to setup the update shader
  12558. * @param effect defines the update shader
  12559. */
  12560. applyToShader(effect: Effect): void;
  12561. /**
  12562. * Returns a string to use to update the GPU particles update shader
  12563. * @returns a string containng the defines string
  12564. */
  12565. getEffectDefines(): string;
  12566. /**
  12567. * Returns the string "ConeParticleEmitter"
  12568. * @returns a string containing the class name
  12569. */
  12570. getClassName(): string;
  12571. /**
  12572. * Serializes the particle system to a JSON object.
  12573. * @returns the JSON object
  12574. */
  12575. serialize(): any;
  12576. /**
  12577. * Parse properties from a JSON object
  12578. * @param serializationObject defines the JSON object
  12579. */
  12580. parse(serializationObject: any): void;
  12581. }
  12582. }
  12583. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12584. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12585. import { Effect } from "babylonjs/Materials/effect";
  12586. import { Particle } from "babylonjs/Particles/particle";
  12587. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12588. /**
  12589. * Particle emitter emitting particles from the inside of a cylinder.
  12590. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12591. */
  12592. export class CylinderParticleEmitter implements IParticleEmitterType {
  12593. /**
  12594. * The radius of the emission cylinder.
  12595. */
  12596. radius: number;
  12597. /**
  12598. * The height of the emission cylinder.
  12599. */
  12600. height: number;
  12601. /**
  12602. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12603. */
  12604. radiusRange: number;
  12605. /**
  12606. * How much to randomize the particle direction [0-1].
  12607. */
  12608. directionRandomizer: number;
  12609. /**
  12610. * Creates a new instance CylinderParticleEmitter
  12611. * @param radius the radius of the emission cylinder (1 by default)
  12612. * @param height the height of the emission cylinder (1 by default)
  12613. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12614. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12615. */
  12616. constructor(
  12617. /**
  12618. * The radius of the emission cylinder.
  12619. */
  12620. radius?: number,
  12621. /**
  12622. * The height of the emission cylinder.
  12623. */
  12624. height?: number,
  12625. /**
  12626. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12627. */
  12628. radiusRange?: number,
  12629. /**
  12630. * How much to randomize the particle direction [0-1].
  12631. */
  12632. directionRandomizer?: number);
  12633. /**
  12634. * Called by the particle System when the direction is computed for the created particle.
  12635. * @param worldMatrix is the world matrix of the particle system
  12636. * @param directionToUpdate is the direction vector to update with the result
  12637. * @param particle is the particle we are computed the direction for
  12638. * @param isLocal defines if the direction should be set in local space
  12639. */
  12640. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12641. /**
  12642. * Called by the particle System when the position is computed for the created particle.
  12643. * @param worldMatrix is the world matrix of the particle system
  12644. * @param positionToUpdate is the position vector to update with the result
  12645. * @param particle is the particle we are computed the position for
  12646. * @param isLocal defines if the position should be set in local space
  12647. */
  12648. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12649. /**
  12650. * Clones the current emitter and returns a copy of it
  12651. * @returns the new emitter
  12652. */
  12653. clone(): CylinderParticleEmitter;
  12654. /**
  12655. * Called by the GPUParticleSystem to setup the update shader
  12656. * @param effect defines the update shader
  12657. */
  12658. applyToShader(effect: Effect): void;
  12659. /**
  12660. * Returns a string to use to update the GPU particles update shader
  12661. * @returns a string containng the defines string
  12662. */
  12663. getEffectDefines(): string;
  12664. /**
  12665. * Returns the string "CylinderParticleEmitter"
  12666. * @returns a string containing the class name
  12667. */
  12668. getClassName(): string;
  12669. /**
  12670. * Serializes the particle system to a JSON object.
  12671. * @returns the JSON object
  12672. */
  12673. serialize(): any;
  12674. /**
  12675. * Parse properties from a JSON object
  12676. * @param serializationObject defines the JSON object
  12677. */
  12678. parse(serializationObject: any): void;
  12679. }
  12680. /**
  12681. * Particle emitter emitting particles from the inside of a cylinder.
  12682. * It emits the particles randomly between two vectors.
  12683. */
  12684. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12685. /**
  12686. * The min limit of the emission direction.
  12687. */
  12688. direction1: Vector3;
  12689. /**
  12690. * The max limit of the emission direction.
  12691. */
  12692. direction2: Vector3;
  12693. /**
  12694. * Creates a new instance CylinderDirectedParticleEmitter
  12695. * @param radius the radius of the emission cylinder (1 by default)
  12696. * @param height the height of the emission cylinder (1 by default)
  12697. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12698. * @param direction1 the min limit of the emission direction (up vector by default)
  12699. * @param direction2 the max limit of the emission direction (up vector by default)
  12700. */
  12701. constructor(radius?: number, height?: number, radiusRange?: number,
  12702. /**
  12703. * The min limit of the emission direction.
  12704. */
  12705. direction1?: Vector3,
  12706. /**
  12707. * The max limit of the emission direction.
  12708. */
  12709. direction2?: Vector3);
  12710. /**
  12711. * Called by the particle System when the direction is computed for the created particle.
  12712. * @param worldMatrix is the world matrix of the particle system
  12713. * @param directionToUpdate is the direction vector to update with the result
  12714. * @param particle is the particle we are computed the direction for
  12715. */
  12716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12717. /**
  12718. * Clones the current emitter and returns a copy of it
  12719. * @returns the new emitter
  12720. */
  12721. clone(): CylinderDirectedParticleEmitter;
  12722. /**
  12723. * Called by the GPUParticleSystem to setup the update shader
  12724. * @param effect defines the update shader
  12725. */
  12726. applyToShader(effect: Effect): void;
  12727. /**
  12728. * Returns a string to use to update the GPU particles update shader
  12729. * @returns a string containng the defines string
  12730. */
  12731. getEffectDefines(): string;
  12732. /**
  12733. * Returns the string "CylinderDirectedParticleEmitter"
  12734. * @returns a string containing the class name
  12735. */
  12736. getClassName(): string;
  12737. /**
  12738. * Serializes the particle system to a JSON object.
  12739. * @returns the JSON object
  12740. */
  12741. serialize(): any;
  12742. /**
  12743. * Parse properties from a JSON object
  12744. * @param serializationObject defines the JSON object
  12745. */
  12746. parse(serializationObject: any): void;
  12747. }
  12748. }
  12749. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12750. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12751. import { Effect } from "babylonjs/Materials/effect";
  12752. import { Particle } from "babylonjs/Particles/particle";
  12753. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12754. /**
  12755. * Particle emitter emitting particles from the inside of a hemisphere.
  12756. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12757. */
  12758. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12759. /**
  12760. * The radius of the emission hemisphere.
  12761. */
  12762. radius: number;
  12763. /**
  12764. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12765. */
  12766. radiusRange: number;
  12767. /**
  12768. * How much to randomize the particle direction [0-1].
  12769. */
  12770. directionRandomizer: number;
  12771. /**
  12772. * Creates a new instance HemisphericParticleEmitter
  12773. * @param radius the radius of the emission hemisphere (1 by default)
  12774. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12775. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12776. */
  12777. constructor(
  12778. /**
  12779. * The radius of the emission hemisphere.
  12780. */
  12781. radius?: number,
  12782. /**
  12783. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12784. */
  12785. radiusRange?: number,
  12786. /**
  12787. * How much to randomize the particle direction [0-1].
  12788. */
  12789. directionRandomizer?: number);
  12790. /**
  12791. * Called by the particle System when the direction is computed for the created particle.
  12792. * @param worldMatrix is the world matrix of the particle system
  12793. * @param directionToUpdate is the direction vector to update with the result
  12794. * @param particle is the particle we are computed the direction for
  12795. * @param isLocal defines if the direction should be set in local space
  12796. */
  12797. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12798. /**
  12799. * Called by the particle System when the position is computed for the created particle.
  12800. * @param worldMatrix is the world matrix of the particle system
  12801. * @param positionToUpdate is the position vector to update with the result
  12802. * @param particle is the particle we are computed the position for
  12803. * @param isLocal defines if the position should be set in local space
  12804. */
  12805. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12806. /**
  12807. * Clones the current emitter and returns a copy of it
  12808. * @returns the new emitter
  12809. */
  12810. clone(): HemisphericParticleEmitter;
  12811. /**
  12812. * Called by the GPUParticleSystem to setup the update shader
  12813. * @param effect defines the update shader
  12814. */
  12815. applyToShader(effect: Effect): void;
  12816. /**
  12817. * Returns a string to use to update the GPU particles update shader
  12818. * @returns a string containng the defines string
  12819. */
  12820. getEffectDefines(): string;
  12821. /**
  12822. * Returns the string "HemisphericParticleEmitter"
  12823. * @returns a string containing the class name
  12824. */
  12825. getClassName(): string;
  12826. /**
  12827. * Serializes the particle system to a JSON object.
  12828. * @returns the JSON object
  12829. */
  12830. serialize(): any;
  12831. /**
  12832. * Parse properties from a JSON object
  12833. * @param serializationObject defines the JSON object
  12834. */
  12835. parse(serializationObject: any): void;
  12836. }
  12837. }
  12838. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12839. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12840. import { Effect } from "babylonjs/Materials/effect";
  12841. import { Particle } from "babylonjs/Particles/particle";
  12842. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12843. /**
  12844. * Particle emitter emitting particles from a point.
  12845. * It emits the particles randomly between 2 given directions.
  12846. */
  12847. export class PointParticleEmitter implements IParticleEmitterType {
  12848. /**
  12849. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12850. */
  12851. direction1: Vector3;
  12852. /**
  12853. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12854. */
  12855. direction2: Vector3;
  12856. /**
  12857. * Creates a new instance PointParticleEmitter
  12858. */
  12859. constructor();
  12860. /**
  12861. * Called by the particle System when the direction is computed for the created particle.
  12862. * @param worldMatrix is the world matrix of the particle system
  12863. * @param directionToUpdate is the direction vector to update with the result
  12864. * @param particle is the particle we are computed the direction for
  12865. * @param isLocal defines if the direction should be set in local space
  12866. */
  12867. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12868. /**
  12869. * Called by the particle System when the position is computed for the created particle.
  12870. * @param worldMatrix is the world matrix of the particle system
  12871. * @param positionToUpdate is the position vector to update with the result
  12872. * @param particle is the particle we are computed the position for
  12873. * @param isLocal defines if the position should be set in local space
  12874. */
  12875. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12876. /**
  12877. * Clones the current emitter and returns a copy of it
  12878. * @returns the new emitter
  12879. */
  12880. clone(): PointParticleEmitter;
  12881. /**
  12882. * Called by the GPUParticleSystem to setup the update shader
  12883. * @param effect defines the update shader
  12884. */
  12885. applyToShader(effect: Effect): void;
  12886. /**
  12887. * Returns a string to use to update the GPU particles update shader
  12888. * @returns a string containng the defines string
  12889. */
  12890. getEffectDefines(): string;
  12891. /**
  12892. * Returns the string "PointParticleEmitter"
  12893. * @returns a string containing the class name
  12894. */
  12895. getClassName(): string;
  12896. /**
  12897. * Serializes the particle system to a JSON object.
  12898. * @returns the JSON object
  12899. */
  12900. serialize(): any;
  12901. /**
  12902. * Parse properties from a JSON object
  12903. * @param serializationObject defines the JSON object
  12904. */
  12905. parse(serializationObject: any): void;
  12906. }
  12907. }
  12908. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12909. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12910. import { Effect } from "babylonjs/Materials/effect";
  12911. import { Particle } from "babylonjs/Particles/particle";
  12912. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12913. /**
  12914. * Particle emitter emitting particles from the inside of a sphere.
  12915. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12916. */
  12917. export class SphereParticleEmitter implements IParticleEmitterType {
  12918. /**
  12919. * The radius of the emission sphere.
  12920. */
  12921. radius: number;
  12922. /**
  12923. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12924. */
  12925. radiusRange: number;
  12926. /**
  12927. * How much to randomize the particle direction [0-1].
  12928. */
  12929. directionRandomizer: number;
  12930. /**
  12931. * Creates a new instance SphereParticleEmitter
  12932. * @param radius the radius of the emission sphere (1 by default)
  12933. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12934. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12935. */
  12936. constructor(
  12937. /**
  12938. * The radius of the emission sphere.
  12939. */
  12940. radius?: number,
  12941. /**
  12942. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12943. */
  12944. radiusRange?: number,
  12945. /**
  12946. * How much to randomize the particle direction [0-1].
  12947. */
  12948. directionRandomizer?: number);
  12949. /**
  12950. * Called by the particle System when the direction is computed for the created particle.
  12951. * @param worldMatrix is the world matrix of the particle system
  12952. * @param directionToUpdate is the direction vector to update with the result
  12953. * @param particle is the particle we are computed the direction for
  12954. * @param isLocal defines if the direction should be set in local space
  12955. */
  12956. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12957. /**
  12958. * Called by the particle System when the position is computed for the created particle.
  12959. * @param worldMatrix is the world matrix of the particle system
  12960. * @param positionToUpdate is the position vector to update with the result
  12961. * @param particle is the particle we are computed the position for
  12962. * @param isLocal defines if the position should be set in local space
  12963. */
  12964. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12965. /**
  12966. * Clones the current emitter and returns a copy of it
  12967. * @returns the new emitter
  12968. */
  12969. clone(): SphereParticleEmitter;
  12970. /**
  12971. * Called by the GPUParticleSystem to setup the update shader
  12972. * @param effect defines the update shader
  12973. */
  12974. applyToShader(effect: Effect): void;
  12975. /**
  12976. * Returns a string to use to update the GPU particles update shader
  12977. * @returns a string containng the defines string
  12978. */
  12979. getEffectDefines(): string;
  12980. /**
  12981. * Returns the string "SphereParticleEmitter"
  12982. * @returns a string containing the class name
  12983. */
  12984. getClassName(): string;
  12985. /**
  12986. * Serializes the particle system to a JSON object.
  12987. * @returns the JSON object
  12988. */
  12989. serialize(): any;
  12990. /**
  12991. * Parse properties from a JSON object
  12992. * @param serializationObject defines the JSON object
  12993. */
  12994. parse(serializationObject: any): void;
  12995. }
  12996. /**
  12997. * Particle emitter emitting particles from the inside of a sphere.
  12998. * It emits the particles randomly between two vectors.
  12999. */
  13000. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13001. /**
  13002. * The min limit of the emission direction.
  13003. */
  13004. direction1: Vector3;
  13005. /**
  13006. * The max limit of the emission direction.
  13007. */
  13008. direction2: Vector3;
  13009. /**
  13010. * Creates a new instance SphereDirectedParticleEmitter
  13011. * @param radius the radius of the emission sphere (1 by default)
  13012. * @param direction1 the min limit of the emission direction (up vector by default)
  13013. * @param direction2 the max limit of the emission direction (up vector by default)
  13014. */
  13015. constructor(radius?: number,
  13016. /**
  13017. * The min limit of the emission direction.
  13018. */
  13019. direction1?: Vector3,
  13020. /**
  13021. * The max limit of the emission direction.
  13022. */
  13023. direction2?: Vector3);
  13024. /**
  13025. * Called by the particle System when the direction is computed for the created particle.
  13026. * @param worldMatrix is the world matrix of the particle system
  13027. * @param directionToUpdate is the direction vector to update with the result
  13028. * @param particle is the particle we are computed the direction for
  13029. */
  13030. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13031. /**
  13032. * Clones the current emitter and returns a copy of it
  13033. * @returns the new emitter
  13034. */
  13035. clone(): SphereDirectedParticleEmitter;
  13036. /**
  13037. * Called by the GPUParticleSystem to setup the update shader
  13038. * @param effect defines the update shader
  13039. */
  13040. applyToShader(effect: Effect): void;
  13041. /**
  13042. * Returns a string to use to update the GPU particles update shader
  13043. * @returns a string containng the defines string
  13044. */
  13045. getEffectDefines(): string;
  13046. /**
  13047. * Returns the string "SphereDirectedParticleEmitter"
  13048. * @returns a string containing the class name
  13049. */
  13050. getClassName(): string;
  13051. /**
  13052. * Serializes the particle system to a JSON object.
  13053. * @returns the JSON object
  13054. */
  13055. serialize(): any;
  13056. /**
  13057. * Parse properties from a JSON object
  13058. * @param serializationObject defines the JSON object
  13059. */
  13060. parse(serializationObject: any): void;
  13061. }
  13062. }
  13063. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13064. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13065. import { Effect } from "babylonjs/Materials/effect";
  13066. import { Particle } from "babylonjs/Particles/particle";
  13067. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13068. import { Nullable } from "babylonjs/types";
  13069. /**
  13070. * Particle emitter emitting particles from a custom list of positions.
  13071. */
  13072. export class CustomParticleEmitter implements IParticleEmitterType {
  13073. /**
  13074. * Gets or sets the position generator that will create the inital position of each particle.
  13075. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13076. */
  13077. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13078. /**
  13079. * Gets or sets the destination generator that will create the final destination of each particle.
  13080. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13081. */
  13082. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13083. /**
  13084. * Creates a new instance CustomParticleEmitter
  13085. */
  13086. constructor();
  13087. /**
  13088. * Called by the particle System when the direction is computed for the created particle.
  13089. * @param worldMatrix is the world matrix of the particle system
  13090. * @param directionToUpdate is the direction vector to update with the result
  13091. * @param particle is the particle we are computed the direction for
  13092. * @param isLocal defines if the direction should be set in local space
  13093. */
  13094. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13095. /**
  13096. * Called by the particle System when the position is computed for the created particle.
  13097. * @param worldMatrix is the world matrix of the particle system
  13098. * @param positionToUpdate is the position vector to update with the result
  13099. * @param particle is the particle we are computed the position for
  13100. * @param isLocal defines if the position should be set in local space
  13101. */
  13102. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13103. /**
  13104. * Clones the current emitter and returns a copy of it
  13105. * @returns the new emitter
  13106. */
  13107. clone(): CustomParticleEmitter;
  13108. /**
  13109. * Called by the GPUParticleSystem to setup the update shader
  13110. * @param effect defines the update shader
  13111. */
  13112. applyToShader(effect: Effect): void;
  13113. /**
  13114. * Returns a string to use to update the GPU particles update shader
  13115. * @returns a string containng the defines string
  13116. */
  13117. getEffectDefines(): string;
  13118. /**
  13119. * Returns the string "PointParticleEmitter"
  13120. * @returns a string containing the class name
  13121. */
  13122. getClassName(): string;
  13123. /**
  13124. * Serializes the particle system to a JSON object.
  13125. * @returns the JSON object
  13126. */
  13127. serialize(): any;
  13128. /**
  13129. * Parse properties from a JSON object
  13130. * @param serializationObject defines the JSON object
  13131. */
  13132. parse(serializationObject: any): void;
  13133. }
  13134. }
  13135. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13136. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13137. import { Effect } from "babylonjs/Materials/effect";
  13138. import { Particle } from "babylonjs/Particles/particle";
  13139. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13140. import { Scene } from "babylonjs/scene";
  13141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13142. /**
  13143. * Particle emitter emitting particles from the inside of a box.
  13144. * It emits the particles randomly between 2 given directions.
  13145. */
  13146. export class MeshParticleEmitter implements IParticleEmitterType {
  13147. /** Defines the mesh to use as source */
  13148. mesh?: AbstractMesh | undefined;
  13149. private _indices;
  13150. private _positions;
  13151. private _normals;
  13152. private _storedNormal;
  13153. /**
  13154. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13155. */
  13156. direction1: Vector3;
  13157. /**
  13158. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13159. */
  13160. direction2: Vector3;
  13161. /**
  13162. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13163. */
  13164. useMeshNormalsForDirection: boolean;
  13165. /**
  13166. * Creates a new instance MeshParticleEmitter
  13167. * @param mesh defines the mesh to use as source
  13168. */
  13169. constructor(
  13170. /** Defines the mesh to use as source */
  13171. mesh?: AbstractMesh | undefined);
  13172. /**
  13173. * Called by the particle System when the direction is computed for the created particle.
  13174. * @param worldMatrix is the world matrix of the particle system
  13175. * @param directionToUpdate is the direction vector to update with the result
  13176. * @param particle is the particle we are computed the direction for
  13177. * @param isLocal defines if the direction should be set in local space
  13178. */
  13179. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13180. /**
  13181. * Called by the particle System when the position is computed for the created particle.
  13182. * @param worldMatrix is the world matrix of the particle system
  13183. * @param positionToUpdate is the position vector to update with the result
  13184. * @param particle is the particle we are computed the position for
  13185. * @param isLocal defines if the position should be set in local space
  13186. */
  13187. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13188. /**
  13189. * Clones the current emitter and returns a copy of it
  13190. * @returns the new emitter
  13191. */
  13192. clone(): MeshParticleEmitter;
  13193. /**
  13194. * Called by the GPUParticleSystem to setup the update shader
  13195. * @param effect defines the update shader
  13196. */
  13197. applyToShader(effect: Effect): void;
  13198. /**
  13199. * Returns a string to use to update the GPU particles update shader
  13200. * @returns a string containng the defines string
  13201. */
  13202. getEffectDefines(): string;
  13203. /**
  13204. * Returns the string "BoxParticleEmitter"
  13205. * @returns a string containing the class name
  13206. */
  13207. getClassName(): string;
  13208. /**
  13209. * Serializes the particle system to a JSON object.
  13210. * @returns the JSON object
  13211. */
  13212. serialize(): any;
  13213. /**
  13214. * Parse properties from a JSON object
  13215. * @param serializationObject defines the JSON object
  13216. * @param scene defines the hosting scene
  13217. */
  13218. parse(serializationObject: any, scene: Scene): void;
  13219. }
  13220. }
  13221. declare module "babylonjs/Particles/EmitterTypes/index" {
  13222. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13223. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13224. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13225. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13226. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13227. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13228. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13229. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13230. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13231. }
  13232. declare module "babylonjs/Particles/IParticleSystem" {
  13233. import { Nullable } from "babylonjs/types";
  13234. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13235. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13238. import { Texture } from "babylonjs/Materials/Textures/texture";
  13239. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13240. import { Scene } from "babylonjs/scene";
  13241. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13242. import { Animation } from "babylonjs/Animations/animation";
  13243. /**
  13244. * Interface representing a particle system in Babylon.js.
  13245. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13246. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13247. */
  13248. export interface IParticleSystem {
  13249. /**
  13250. * List of animations used by the particle system.
  13251. */
  13252. animations: Animation[];
  13253. /**
  13254. * The id of the Particle system.
  13255. */
  13256. id: string;
  13257. /**
  13258. * The name of the Particle system.
  13259. */
  13260. name: string;
  13261. /**
  13262. * The emitter represents the Mesh or position we are attaching the particle system to.
  13263. */
  13264. emitter: Nullable<AbstractMesh | Vector3>;
  13265. /**
  13266. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13267. */
  13268. isBillboardBased: boolean;
  13269. /**
  13270. * The rendering group used by the Particle system to chose when to render.
  13271. */
  13272. renderingGroupId: number;
  13273. /**
  13274. * The layer mask we are rendering the particles through.
  13275. */
  13276. layerMask: number;
  13277. /**
  13278. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13279. */
  13280. updateSpeed: number;
  13281. /**
  13282. * The amount of time the particle system is running (depends of the overall update speed).
  13283. */
  13284. targetStopDuration: number;
  13285. /**
  13286. * The texture used to render each particle. (this can be a spritesheet)
  13287. */
  13288. particleTexture: Nullable<Texture>;
  13289. /**
  13290. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13291. */
  13292. blendMode: number;
  13293. /**
  13294. * Minimum life time of emitting particles.
  13295. */
  13296. minLifeTime: number;
  13297. /**
  13298. * Maximum life time of emitting particles.
  13299. */
  13300. maxLifeTime: number;
  13301. /**
  13302. * Minimum Size of emitting particles.
  13303. */
  13304. minSize: number;
  13305. /**
  13306. * Maximum Size of emitting particles.
  13307. */
  13308. maxSize: number;
  13309. /**
  13310. * Minimum scale of emitting particles on X axis.
  13311. */
  13312. minScaleX: number;
  13313. /**
  13314. * Maximum scale of emitting particles on X axis.
  13315. */
  13316. maxScaleX: number;
  13317. /**
  13318. * Minimum scale of emitting particles on Y axis.
  13319. */
  13320. minScaleY: number;
  13321. /**
  13322. * Maximum scale of emitting particles on Y axis.
  13323. */
  13324. maxScaleY: number;
  13325. /**
  13326. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13327. */
  13328. color1: Color4;
  13329. /**
  13330. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13331. */
  13332. color2: Color4;
  13333. /**
  13334. * Color the particle will have at the end of its lifetime.
  13335. */
  13336. colorDead: Color4;
  13337. /**
  13338. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13339. */
  13340. emitRate: number;
  13341. /**
  13342. * You can use gravity if you want to give an orientation to your particles.
  13343. */
  13344. gravity: Vector3;
  13345. /**
  13346. * Minimum power of emitting particles.
  13347. */
  13348. minEmitPower: number;
  13349. /**
  13350. * Maximum power of emitting particles.
  13351. */
  13352. maxEmitPower: number;
  13353. /**
  13354. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13355. */
  13356. minAngularSpeed: number;
  13357. /**
  13358. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13359. */
  13360. maxAngularSpeed: number;
  13361. /**
  13362. * Gets or sets the minimal initial rotation in radians.
  13363. */
  13364. minInitialRotation: number;
  13365. /**
  13366. * Gets or sets the maximal initial rotation in radians.
  13367. */
  13368. maxInitialRotation: number;
  13369. /**
  13370. * The particle emitter type defines the emitter used by the particle system.
  13371. * It can be for example box, sphere, or cone...
  13372. */
  13373. particleEmitterType: Nullable<IParticleEmitterType>;
  13374. /**
  13375. * Defines the delay in milliseconds before starting the system (0 by default)
  13376. */
  13377. startDelay: number;
  13378. /**
  13379. * 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
  13380. */
  13381. preWarmCycles: number;
  13382. /**
  13383. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13384. */
  13385. preWarmStepOffset: number;
  13386. /**
  13387. * 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)
  13388. */
  13389. spriteCellChangeSpeed: number;
  13390. /**
  13391. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13392. */
  13393. startSpriteCellID: number;
  13394. /**
  13395. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13396. */
  13397. endSpriteCellID: number;
  13398. /**
  13399. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13400. */
  13401. spriteCellWidth: number;
  13402. /**
  13403. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13404. */
  13405. spriteCellHeight: number;
  13406. /**
  13407. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13408. */
  13409. spriteRandomStartCell: boolean;
  13410. /**
  13411. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13412. */
  13413. isAnimationSheetEnabled: boolean;
  13414. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13415. translationPivot: Vector2;
  13416. /**
  13417. * Gets or sets a texture used to add random noise to particle positions
  13418. */
  13419. noiseTexture: Nullable<BaseTexture>;
  13420. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13421. noiseStrength: Vector3;
  13422. /**
  13423. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13424. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13425. */
  13426. billboardMode: number;
  13427. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13428. limitVelocityDamping: number;
  13429. /**
  13430. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13431. */
  13432. beginAnimationOnStart: boolean;
  13433. /**
  13434. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13435. */
  13436. beginAnimationFrom: number;
  13437. /**
  13438. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13439. */
  13440. beginAnimationTo: number;
  13441. /**
  13442. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13443. */
  13444. beginAnimationLoop: boolean;
  13445. /**
  13446. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13447. */
  13448. disposeOnStop: boolean;
  13449. /**
  13450. * Specifies if the particles are updated in emitter local space or world space
  13451. */
  13452. isLocal: boolean;
  13453. /**
  13454. * Gets the maximum number of particles active at the same time.
  13455. * @returns The max number of active particles.
  13456. */
  13457. getCapacity(): number;
  13458. /**
  13459. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13460. * @returns True if it has been started, otherwise false.
  13461. */
  13462. isStarted(): boolean;
  13463. /**
  13464. * Animates the particle system for this frame.
  13465. */
  13466. animate(): void;
  13467. /**
  13468. * Renders the particle system in its current state.
  13469. * @returns the current number of particles
  13470. */
  13471. render(): number;
  13472. /**
  13473. * Dispose the particle system and frees its associated resources.
  13474. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13475. */
  13476. dispose(disposeTexture?: boolean): void;
  13477. /**
  13478. * Clones the particle system.
  13479. * @param name The name of the cloned object
  13480. * @param newEmitter The new emitter to use
  13481. * @returns the cloned particle system
  13482. */
  13483. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13484. /**
  13485. * Serializes the particle system to a JSON object.
  13486. * @returns the JSON object
  13487. */
  13488. serialize(): any;
  13489. /**
  13490. * Rebuild the particle system
  13491. */
  13492. rebuild(): void;
  13493. /**
  13494. * Starts the particle system and begins to emit
  13495. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13496. */
  13497. start(delay?: number): void;
  13498. /**
  13499. * Stops the particle system.
  13500. */
  13501. stop(): void;
  13502. /**
  13503. * Remove all active particles
  13504. */
  13505. reset(): void;
  13506. /**
  13507. * Is this system ready to be used/rendered
  13508. * @return true if the system is ready
  13509. */
  13510. isReady(): boolean;
  13511. /**
  13512. * Returns the string "ParticleSystem"
  13513. * @returns a string containing the class name
  13514. */
  13515. getClassName(): string;
  13516. /**
  13517. * Adds a new color gradient
  13518. * @param gradient defines the gradient to use (between 0 and 1)
  13519. * @param color1 defines the color to affect to the specified gradient
  13520. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13521. * @returns the current particle system
  13522. */
  13523. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13524. /**
  13525. * Remove a specific color gradient
  13526. * @param gradient defines the gradient to remove
  13527. * @returns the current particle system
  13528. */
  13529. removeColorGradient(gradient: number): IParticleSystem;
  13530. /**
  13531. * Adds a new size gradient
  13532. * @param gradient defines the gradient to use (between 0 and 1)
  13533. * @param factor defines the size factor to affect to the specified gradient
  13534. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13535. * @returns the current particle system
  13536. */
  13537. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13538. /**
  13539. * Remove a specific size gradient
  13540. * @param gradient defines the gradient to remove
  13541. * @returns the current particle system
  13542. */
  13543. removeSizeGradient(gradient: number): IParticleSystem;
  13544. /**
  13545. * Gets the current list of color gradients.
  13546. * You must use addColorGradient and removeColorGradient to udpate this list
  13547. * @returns the list of color gradients
  13548. */
  13549. getColorGradients(): Nullable<Array<ColorGradient>>;
  13550. /**
  13551. * Gets the current list of size gradients.
  13552. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13553. * @returns the list of size gradients
  13554. */
  13555. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13556. /**
  13557. * Gets the current list of angular speed gradients.
  13558. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13559. * @returns the list of angular speed gradients
  13560. */
  13561. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13562. /**
  13563. * Adds a new angular speed gradient
  13564. * @param gradient defines the gradient to use (between 0 and 1)
  13565. * @param factor defines the angular speed to affect to the specified gradient
  13566. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13567. * @returns the current particle system
  13568. */
  13569. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13570. /**
  13571. * Remove a specific angular speed gradient
  13572. * @param gradient defines the gradient to remove
  13573. * @returns the current particle system
  13574. */
  13575. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13576. /**
  13577. * Gets the current list of velocity gradients.
  13578. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13579. * @returns the list of velocity gradients
  13580. */
  13581. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13582. /**
  13583. * Adds a new velocity gradient
  13584. * @param gradient defines the gradient to use (between 0 and 1)
  13585. * @param factor defines the velocity to affect to the specified gradient
  13586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13587. * @returns the current particle system
  13588. */
  13589. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13590. /**
  13591. * Remove a specific velocity gradient
  13592. * @param gradient defines the gradient to remove
  13593. * @returns the current particle system
  13594. */
  13595. removeVelocityGradient(gradient: number): IParticleSystem;
  13596. /**
  13597. * Gets the current list of limit velocity gradients.
  13598. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13599. * @returns the list of limit velocity gradients
  13600. */
  13601. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13602. /**
  13603. * Adds a new limit velocity gradient
  13604. * @param gradient defines the gradient to use (between 0 and 1)
  13605. * @param factor defines the limit velocity to affect to the specified gradient
  13606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13607. * @returns the current particle system
  13608. */
  13609. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13610. /**
  13611. * Remove a specific limit velocity gradient
  13612. * @param gradient defines the gradient to remove
  13613. * @returns the current particle system
  13614. */
  13615. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13616. /**
  13617. * Adds a new drag gradient
  13618. * @param gradient defines the gradient to use (between 0 and 1)
  13619. * @param factor defines the drag to affect to the specified gradient
  13620. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13621. * @returns the current particle system
  13622. */
  13623. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13624. /**
  13625. * Remove a specific drag gradient
  13626. * @param gradient defines the gradient to remove
  13627. * @returns the current particle system
  13628. */
  13629. removeDragGradient(gradient: number): IParticleSystem;
  13630. /**
  13631. * Gets the current list of drag gradients.
  13632. * You must use addDragGradient and removeDragGradient to udpate this list
  13633. * @returns the list of drag gradients
  13634. */
  13635. getDragGradients(): Nullable<Array<FactorGradient>>;
  13636. /**
  13637. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13638. * @param gradient defines the gradient to use (between 0 and 1)
  13639. * @param factor defines the emit rate to affect to the specified gradient
  13640. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13641. * @returns the current particle system
  13642. */
  13643. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13644. /**
  13645. * Remove a specific emit rate gradient
  13646. * @param gradient defines the gradient to remove
  13647. * @returns the current particle system
  13648. */
  13649. removeEmitRateGradient(gradient: number): IParticleSystem;
  13650. /**
  13651. * Gets the current list of emit rate gradients.
  13652. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13653. * @returns the list of emit rate gradients
  13654. */
  13655. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13656. /**
  13657. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13658. * @param gradient defines the gradient to use (between 0 and 1)
  13659. * @param factor defines the start size to affect to the specified gradient
  13660. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13661. * @returns the current particle system
  13662. */
  13663. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13664. /**
  13665. * Remove a specific start size gradient
  13666. * @param gradient defines the gradient to remove
  13667. * @returns the current particle system
  13668. */
  13669. removeStartSizeGradient(gradient: number): IParticleSystem;
  13670. /**
  13671. * Gets the current list of start size gradients.
  13672. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13673. * @returns the list of start size gradients
  13674. */
  13675. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13676. /**
  13677. * Adds a new life time gradient
  13678. * @param gradient defines the gradient to use (between 0 and 1)
  13679. * @param factor defines the life time factor to affect to the specified gradient
  13680. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13681. * @returns the current particle system
  13682. */
  13683. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13684. /**
  13685. * Remove a specific life time gradient
  13686. * @param gradient defines the gradient to remove
  13687. * @returns the current particle system
  13688. */
  13689. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13690. /**
  13691. * Gets the current list of life time gradients.
  13692. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13693. * @returns the list of life time gradients
  13694. */
  13695. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13696. /**
  13697. * Gets the current list of color gradients.
  13698. * You must use addColorGradient and removeColorGradient to udpate this list
  13699. * @returns the list of color gradients
  13700. */
  13701. getColorGradients(): Nullable<Array<ColorGradient>>;
  13702. /**
  13703. * Adds a new ramp gradient used to remap particle colors
  13704. * @param gradient defines the gradient to use (between 0 and 1)
  13705. * @param color defines the color to affect to the specified gradient
  13706. * @returns the current particle system
  13707. */
  13708. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13709. /**
  13710. * Gets the current list of ramp gradients.
  13711. * You must use addRampGradient and removeRampGradient to udpate this list
  13712. * @returns the list of ramp gradients
  13713. */
  13714. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13715. /** Gets or sets a boolean indicating that ramp gradients must be used
  13716. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13717. */
  13718. useRampGradients: boolean;
  13719. /**
  13720. * Adds a new color remap gradient
  13721. * @param gradient defines the gradient to use (between 0 and 1)
  13722. * @param min defines the color remap minimal range
  13723. * @param max defines the color remap maximal range
  13724. * @returns the current particle system
  13725. */
  13726. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13727. /**
  13728. * Gets the current list of color remap gradients.
  13729. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13730. * @returns the list of color remap gradients
  13731. */
  13732. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13733. /**
  13734. * Adds a new alpha remap gradient
  13735. * @param gradient defines the gradient to use (between 0 and 1)
  13736. * @param min defines the alpha remap minimal range
  13737. * @param max defines the alpha remap maximal range
  13738. * @returns the current particle system
  13739. */
  13740. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13741. /**
  13742. * Gets the current list of alpha remap gradients.
  13743. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13744. * @returns the list of alpha remap gradients
  13745. */
  13746. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13747. /**
  13748. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  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. * @returns the emitter
  13752. */
  13753. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13754. /**
  13755. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13756. * @param radius The radius of the hemisphere to emit from
  13757. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13758. * @returns the emitter
  13759. */
  13760. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13761. /**
  13762. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13763. * @param radius The radius of the sphere to emit from
  13764. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13765. * @returns the emitter
  13766. */
  13767. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13768. /**
  13769. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13770. * @param radius The radius of the sphere to emit from
  13771. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13772. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13773. * @returns the emitter
  13774. */
  13775. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13776. /**
  13777. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13778. * @param radius The radius of the emission cylinder
  13779. * @param height The height of the emission cylinder
  13780. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13781. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13782. * @returns the emitter
  13783. */
  13784. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13785. /**
  13786. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13787. * @param radius The radius of the cylinder to emit from
  13788. * @param height The height of the emission cylinder
  13789. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13790. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13791. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13792. * @returns the emitter
  13793. */
  13794. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13795. /**
  13796. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13797. * @param radius The radius of the cone to emit from
  13798. * @param angle The base angle of the cone
  13799. * @returns the emitter
  13800. */
  13801. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13802. /**
  13803. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13804. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13805. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13806. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13807. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13808. * @returns the emitter
  13809. */
  13810. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13811. /**
  13812. * Get hosting scene
  13813. * @returns the scene
  13814. */
  13815. getScene(): Scene;
  13816. }
  13817. }
  13818. declare module "babylonjs/Meshes/transformNode" {
  13819. import { DeepImmutable } from "babylonjs/types";
  13820. import { Observable } from "babylonjs/Misc/observable";
  13821. import { Nullable } from "babylonjs/types";
  13822. import { Camera } from "babylonjs/Cameras/camera";
  13823. import { Scene } from "babylonjs/scene";
  13824. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13825. import { Node } from "babylonjs/node";
  13826. import { Bone } from "babylonjs/Bones/bone";
  13827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13828. import { Space } from "babylonjs/Maths/math.axis";
  13829. /**
  13830. * 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.
  13831. * @see https://doc.babylonjs.com/how_to/transformnode
  13832. */
  13833. export class TransformNode extends Node {
  13834. /**
  13835. * Object will not rotate to face the camera
  13836. */
  13837. static BILLBOARDMODE_NONE: number;
  13838. /**
  13839. * Object will rotate to face the camera but only on the x axis
  13840. */
  13841. static BILLBOARDMODE_X: number;
  13842. /**
  13843. * Object will rotate to face the camera but only on the y axis
  13844. */
  13845. static BILLBOARDMODE_Y: number;
  13846. /**
  13847. * Object will rotate to face the camera but only on the z axis
  13848. */
  13849. static BILLBOARDMODE_Z: number;
  13850. /**
  13851. * Object will rotate to face the camera
  13852. */
  13853. static BILLBOARDMODE_ALL: number;
  13854. /**
  13855. * Object will rotate to face the camera's position instead of orientation
  13856. */
  13857. static BILLBOARDMODE_USE_POSITION: number;
  13858. private _forward;
  13859. private _forwardInverted;
  13860. private _up;
  13861. private _right;
  13862. private _rightInverted;
  13863. private _position;
  13864. private _rotation;
  13865. private _rotationQuaternion;
  13866. protected _scaling: Vector3;
  13867. protected _isDirty: boolean;
  13868. private _transformToBoneReferal;
  13869. private _isAbsoluteSynced;
  13870. private _billboardMode;
  13871. /**
  13872. * Gets or sets the billboard mode. Default is 0.
  13873. *
  13874. * | Value | Type | Description |
  13875. * | --- | --- | --- |
  13876. * | 0 | BILLBOARDMODE_NONE | |
  13877. * | 1 | BILLBOARDMODE_X | |
  13878. * | 2 | BILLBOARDMODE_Y | |
  13879. * | 4 | BILLBOARDMODE_Z | |
  13880. * | 7 | BILLBOARDMODE_ALL | |
  13881. *
  13882. */
  13883. get billboardMode(): number;
  13884. set billboardMode(value: number);
  13885. private _preserveParentRotationForBillboard;
  13886. /**
  13887. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13888. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13889. */
  13890. get preserveParentRotationForBillboard(): boolean;
  13891. set preserveParentRotationForBillboard(value: boolean);
  13892. /**
  13893. * 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
  13894. */
  13895. scalingDeterminant: number;
  13896. private _infiniteDistance;
  13897. /**
  13898. * Gets or sets the distance of the object to max, often used by skybox
  13899. */
  13900. get infiniteDistance(): boolean;
  13901. set infiniteDistance(value: boolean);
  13902. /**
  13903. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13904. * By default the system will update normals to compensate
  13905. */
  13906. ignoreNonUniformScaling: boolean;
  13907. /**
  13908. * 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
  13909. */
  13910. reIntegrateRotationIntoRotationQuaternion: boolean;
  13911. /** @hidden */
  13912. _poseMatrix: Nullable<Matrix>;
  13913. /** @hidden */
  13914. _localMatrix: Matrix;
  13915. private _usePivotMatrix;
  13916. private _absolutePosition;
  13917. private _absoluteScaling;
  13918. private _absoluteRotationQuaternion;
  13919. private _pivotMatrix;
  13920. private _pivotMatrixInverse;
  13921. protected _postMultiplyPivotMatrix: boolean;
  13922. protected _isWorldMatrixFrozen: boolean;
  13923. /** @hidden */
  13924. _indexInSceneTransformNodesArray: number;
  13925. /**
  13926. * An event triggered after the world matrix is updated
  13927. */
  13928. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13929. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13930. /**
  13931. * Gets a string identifying the name of the class
  13932. * @returns "TransformNode" string
  13933. */
  13934. getClassName(): string;
  13935. /**
  13936. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13937. */
  13938. get position(): Vector3;
  13939. set position(newPosition: Vector3);
  13940. /**
  13941. * 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)).
  13942. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13943. */
  13944. get rotation(): Vector3;
  13945. set rotation(newRotation: Vector3);
  13946. /**
  13947. * 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)).
  13948. */
  13949. get scaling(): Vector3;
  13950. set scaling(newScaling: Vector3);
  13951. /**
  13952. * 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).
  13953. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13954. */
  13955. get rotationQuaternion(): Nullable<Quaternion>;
  13956. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13957. /**
  13958. * The forward direction of that transform in world space.
  13959. */
  13960. get forward(): Vector3;
  13961. /**
  13962. * The up direction of that transform in world space.
  13963. */
  13964. get up(): Vector3;
  13965. /**
  13966. * The right direction of that transform in world space.
  13967. */
  13968. get right(): Vector3;
  13969. /**
  13970. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13971. * @param matrix the matrix to copy the pose from
  13972. * @returns this TransformNode.
  13973. */
  13974. updatePoseMatrix(matrix: Matrix): TransformNode;
  13975. /**
  13976. * Returns the mesh Pose matrix.
  13977. * @returns the pose matrix
  13978. */
  13979. getPoseMatrix(): Matrix;
  13980. /** @hidden */
  13981. _isSynchronized(): boolean;
  13982. /** @hidden */
  13983. _initCache(): void;
  13984. /**
  13985. * Flag the transform node as dirty (Forcing it to update everything)
  13986. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13987. * @returns this transform node
  13988. */
  13989. markAsDirty(property: string): TransformNode;
  13990. /**
  13991. * Returns the current mesh absolute position.
  13992. * Returns a Vector3.
  13993. */
  13994. get absolutePosition(): Vector3;
  13995. /**
  13996. * Returns the current mesh absolute scaling.
  13997. * Returns a Vector3.
  13998. */
  13999. get absoluteScaling(): Vector3;
  14000. /**
  14001. * Returns the current mesh absolute rotation.
  14002. * Returns a Quaternion.
  14003. */
  14004. get absoluteRotationQuaternion(): Quaternion;
  14005. /**
  14006. * Sets a new matrix to apply before all other transformation
  14007. * @param matrix defines the transform matrix
  14008. * @returns the current TransformNode
  14009. */
  14010. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14011. /**
  14012. * Sets a new pivot matrix to the current node
  14013. * @param matrix defines the new pivot matrix to use
  14014. * @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
  14015. * @returns the current TransformNode
  14016. */
  14017. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14018. /**
  14019. * Returns the mesh pivot matrix.
  14020. * Default : Identity.
  14021. * @returns the matrix
  14022. */
  14023. getPivotMatrix(): Matrix;
  14024. /**
  14025. * Instantiate (when possible) or clone that node with its hierarchy
  14026. * @param newParent defines the new parent to use for the instance (or clone)
  14027. * @param options defines options to configure how copy is done
  14028. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14029. * @returns an instance (or a clone) of the current node with its hiearchy
  14030. */
  14031. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14032. doNotInstantiate: boolean;
  14033. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14034. /**
  14035. * Prevents the World matrix to be computed any longer
  14036. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14037. * @returns the TransformNode.
  14038. */
  14039. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14040. /**
  14041. * Allows back the World matrix computation.
  14042. * @returns the TransformNode.
  14043. */
  14044. unfreezeWorldMatrix(): this;
  14045. /**
  14046. * True if the World matrix has been frozen.
  14047. */
  14048. get isWorldMatrixFrozen(): boolean;
  14049. /**
  14050. * Retuns the mesh absolute position in the World.
  14051. * @returns a Vector3.
  14052. */
  14053. getAbsolutePosition(): Vector3;
  14054. /**
  14055. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14056. * @param absolutePosition the absolute position to set
  14057. * @returns the TransformNode.
  14058. */
  14059. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14060. /**
  14061. * Sets the mesh position in its local space.
  14062. * @param vector3 the position to set in localspace
  14063. * @returns the TransformNode.
  14064. */
  14065. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14066. /**
  14067. * Returns the mesh position in the local space from the current World matrix values.
  14068. * @returns a new Vector3.
  14069. */
  14070. getPositionExpressedInLocalSpace(): Vector3;
  14071. /**
  14072. * Translates the mesh along the passed Vector3 in its local space.
  14073. * @param vector3 the distance to translate in localspace
  14074. * @returns the TransformNode.
  14075. */
  14076. locallyTranslate(vector3: Vector3): TransformNode;
  14077. private static _lookAtVectorCache;
  14078. /**
  14079. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14080. * @param targetPoint the position (must be in same space as current mesh) to look at
  14081. * @param yawCor optional yaw (y-axis) correction in radians
  14082. * @param pitchCor optional pitch (x-axis) correction in radians
  14083. * @param rollCor optional roll (z-axis) correction in radians
  14084. * @param space the choosen space of the target
  14085. * @returns the TransformNode.
  14086. */
  14087. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14088. /**
  14089. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14090. * This Vector3 is expressed in the World space.
  14091. * @param localAxis axis to rotate
  14092. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14093. */
  14094. getDirection(localAxis: Vector3): Vector3;
  14095. /**
  14096. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14097. * localAxis is expressed in the mesh local space.
  14098. * result is computed in the Wordl space from the mesh World matrix.
  14099. * @param localAxis axis to rotate
  14100. * @param result the resulting transformnode
  14101. * @returns this TransformNode.
  14102. */
  14103. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14104. /**
  14105. * Sets this transform node rotation to the given local axis.
  14106. * @param localAxis the axis in local space
  14107. * @param yawCor optional yaw (y-axis) correction in radians
  14108. * @param pitchCor optional pitch (x-axis) correction in radians
  14109. * @param rollCor optional roll (z-axis) correction in radians
  14110. * @returns this TransformNode
  14111. */
  14112. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14113. /**
  14114. * Sets a new pivot point to the current node
  14115. * @param point defines the new pivot point to use
  14116. * @param space defines if the point is in world or local space (local by default)
  14117. * @returns the current TransformNode
  14118. */
  14119. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14120. /**
  14121. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14122. * @returns the pivot point
  14123. */
  14124. getPivotPoint(): Vector3;
  14125. /**
  14126. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14127. * @param result the vector3 to store the result
  14128. * @returns this TransformNode.
  14129. */
  14130. getPivotPointToRef(result: Vector3): TransformNode;
  14131. /**
  14132. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14133. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14134. */
  14135. getAbsolutePivotPoint(): Vector3;
  14136. /**
  14137. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14138. * @param result vector3 to store the result
  14139. * @returns this TransformNode.
  14140. */
  14141. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14142. /**
  14143. * Defines the passed node as the parent of the current node.
  14144. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14145. * @see https://doc.babylonjs.com/how_to/parenting
  14146. * @param node the node ot set as the parent
  14147. * @returns this TransformNode.
  14148. */
  14149. setParent(node: Nullable<Node>): TransformNode;
  14150. private _nonUniformScaling;
  14151. /**
  14152. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14153. */
  14154. get nonUniformScaling(): boolean;
  14155. /** @hidden */
  14156. _updateNonUniformScalingState(value: boolean): boolean;
  14157. /**
  14158. * Attach the current TransformNode to another TransformNode associated with a bone
  14159. * @param bone Bone affecting the TransformNode
  14160. * @param affectedTransformNode TransformNode associated with the bone
  14161. * @returns this object
  14162. */
  14163. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14164. /**
  14165. * Detach the transform node if its associated with a bone
  14166. * @returns this object
  14167. */
  14168. detachFromBone(): TransformNode;
  14169. private static _rotationAxisCache;
  14170. /**
  14171. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14172. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14173. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14174. * The passed axis is also normalized.
  14175. * @param axis the axis to rotate around
  14176. * @param amount the amount to rotate in radians
  14177. * @param space Space to rotate in (Default: local)
  14178. * @returns the TransformNode.
  14179. */
  14180. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14181. /**
  14182. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14183. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14184. * The passed axis is also normalized. .
  14185. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14186. * @param point the point to rotate around
  14187. * @param axis the axis to rotate around
  14188. * @param amount the amount to rotate in radians
  14189. * @returns the TransformNode
  14190. */
  14191. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14192. /**
  14193. * Translates the mesh along the axis vector for the passed distance in the given space.
  14194. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14195. * @param axis the axis to translate in
  14196. * @param distance the distance to translate
  14197. * @param space Space to rotate in (Default: local)
  14198. * @returns the TransformNode.
  14199. */
  14200. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14201. /**
  14202. * Adds a rotation step to the mesh current rotation.
  14203. * x, y, z are Euler angles expressed in radians.
  14204. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14205. * This means this rotation is made in the mesh local space only.
  14206. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14207. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14208. * ```javascript
  14209. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14210. * ```
  14211. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14212. * 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.
  14213. * @param x Rotation to add
  14214. * @param y Rotation to add
  14215. * @param z Rotation to add
  14216. * @returns the TransformNode.
  14217. */
  14218. addRotation(x: number, y: number, z: number): TransformNode;
  14219. /**
  14220. * @hidden
  14221. */
  14222. protected _getEffectiveParent(): Nullable<Node>;
  14223. /**
  14224. * Computes the world matrix of the node
  14225. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14226. * @returns the world matrix
  14227. */
  14228. computeWorldMatrix(force?: boolean): Matrix;
  14229. /**
  14230. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14231. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14232. */
  14233. resetLocalMatrix(independentOfChildren?: boolean): void;
  14234. protected _afterComputeWorldMatrix(): void;
  14235. /**
  14236. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14237. * @param func callback function to add
  14238. *
  14239. * @returns the TransformNode.
  14240. */
  14241. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14242. /**
  14243. * Removes a registered callback function.
  14244. * @param func callback function to remove
  14245. * @returns the TransformNode.
  14246. */
  14247. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14248. /**
  14249. * Gets the position of the current mesh in camera space
  14250. * @param camera defines the camera to use
  14251. * @returns a position
  14252. */
  14253. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14254. /**
  14255. * Returns the distance from the mesh to the active camera
  14256. * @param camera defines the camera to use
  14257. * @returns the distance
  14258. */
  14259. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14260. /**
  14261. * Clone the current transform node
  14262. * @param name Name of the new clone
  14263. * @param newParent New parent for the clone
  14264. * @param doNotCloneChildren Do not clone children hierarchy
  14265. * @returns the new transform node
  14266. */
  14267. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14268. /**
  14269. * Serializes the objects information.
  14270. * @param currentSerializationObject defines the object to serialize in
  14271. * @returns the serialized object
  14272. */
  14273. serialize(currentSerializationObject?: any): any;
  14274. /**
  14275. * Returns a new TransformNode object parsed from the source provided.
  14276. * @param parsedTransformNode is the source.
  14277. * @param scene the scne the object belongs to
  14278. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14279. * @returns a new TransformNode object parsed from the source provided.
  14280. */
  14281. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14282. /**
  14283. * Get all child-transformNodes of this node
  14284. * @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
  14285. * @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
  14286. * @returns an array of TransformNode
  14287. */
  14288. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14289. /**
  14290. * Releases resources associated with this transform node.
  14291. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14292. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14293. */
  14294. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14295. /**
  14296. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14297. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14298. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14299. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14300. * @returns the current mesh
  14301. */
  14302. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14303. private _syncAbsoluteScalingAndRotation;
  14304. }
  14305. }
  14306. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14307. /**
  14308. * Class used to override all child animations of a given target
  14309. */
  14310. export class AnimationPropertiesOverride {
  14311. /**
  14312. * Gets or sets a value indicating if animation blending must be used
  14313. */
  14314. enableBlending: boolean;
  14315. /**
  14316. * Gets or sets the blending speed to use when enableBlending is true
  14317. */
  14318. blendingSpeed: number;
  14319. /**
  14320. * Gets or sets the default loop mode to use
  14321. */
  14322. loopMode: number;
  14323. }
  14324. }
  14325. declare module "babylonjs/Bones/bone" {
  14326. import { Skeleton } from "babylonjs/Bones/skeleton";
  14327. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14328. import { Nullable } from "babylonjs/types";
  14329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14330. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14331. import { Node } from "babylonjs/node";
  14332. import { Space } from "babylonjs/Maths/math.axis";
  14333. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14334. /**
  14335. * Class used to store bone information
  14336. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14337. */
  14338. export class Bone extends Node {
  14339. /**
  14340. * defines the bone name
  14341. */
  14342. name: string;
  14343. private static _tmpVecs;
  14344. private static _tmpQuat;
  14345. private static _tmpMats;
  14346. /**
  14347. * Gets the list of child bones
  14348. */
  14349. children: Bone[];
  14350. /** Gets the animations associated with this bone */
  14351. animations: import("babylonjs/Animations/animation").Animation[];
  14352. /**
  14353. * Gets or sets bone length
  14354. */
  14355. length: number;
  14356. /**
  14357. * @hidden Internal only
  14358. * Set this value to map this bone to a different index in the transform matrices
  14359. * Set this value to -1 to exclude the bone from the transform matrices
  14360. */
  14361. _index: Nullable<number>;
  14362. private _skeleton;
  14363. private _localMatrix;
  14364. private _restPose;
  14365. private _baseMatrix;
  14366. private _absoluteTransform;
  14367. private _invertedAbsoluteTransform;
  14368. private _parent;
  14369. private _scalingDeterminant;
  14370. private _worldTransform;
  14371. private _localScaling;
  14372. private _localRotation;
  14373. private _localPosition;
  14374. private _needToDecompose;
  14375. private _needToCompose;
  14376. /** @hidden */
  14377. _linkedTransformNode: Nullable<TransformNode>;
  14378. /** @hidden */
  14379. _waitingTransformNodeId: Nullable<string>;
  14380. /** @hidden */
  14381. get _matrix(): Matrix;
  14382. /** @hidden */
  14383. set _matrix(value: Matrix);
  14384. /**
  14385. * Create a new bone
  14386. * @param name defines the bone name
  14387. * @param skeleton defines the parent skeleton
  14388. * @param parentBone defines the parent (can be null if the bone is the root)
  14389. * @param localMatrix defines the local matrix
  14390. * @param restPose defines the rest pose matrix
  14391. * @param baseMatrix defines the base matrix
  14392. * @param index defines index of the bone in the hiearchy
  14393. */
  14394. constructor(
  14395. /**
  14396. * defines the bone name
  14397. */
  14398. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14399. /**
  14400. * Gets the current object class name.
  14401. * @return the class name
  14402. */
  14403. getClassName(): string;
  14404. /**
  14405. * Gets the parent skeleton
  14406. * @returns a skeleton
  14407. */
  14408. getSkeleton(): Skeleton;
  14409. /**
  14410. * Gets parent bone
  14411. * @returns a bone or null if the bone is the root of the bone hierarchy
  14412. */
  14413. getParent(): Nullable<Bone>;
  14414. /**
  14415. * Returns an array containing the root bones
  14416. * @returns an array containing the root bones
  14417. */
  14418. getChildren(): Array<Bone>;
  14419. /**
  14420. * Gets the node index in matrix array generated for rendering
  14421. * @returns the node index
  14422. */
  14423. getIndex(): number;
  14424. /**
  14425. * Sets the parent bone
  14426. * @param parent defines the parent (can be null if the bone is the root)
  14427. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14428. */
  14429. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14430. /**
  14431. * Gets the local matrix
  14432. * @returns a matrix
  14433. */
  14434. getLocalMatrix(): Matrix;
  14435. /**
  14436. * Gets the base matrix (initial matrix which remains unchanged)
  14437. * @returns a matrix
  14438. */
  14439. getBaseMatrix(): Matrix;
  14440. /**
  14441. * Gets the rest pose matrix
  14442. * @returns a matrix
  14443. */
  14444. getRestPose(): Matrix;
  14445. /**
  14446. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14447. */
  14448. getWorldMatrix(): Matrix;
  14449. /**
  14450. * Sets the local matrix to rest pose matrix
  14451. */
  14452. returnToRest(): void;
  14453. /**
  14454. * Gets the inverse of the absolute transform matrix.
  14455. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14456. * @returns a matrix
  14457. */
  14458. getInvertedAbsoluteTransform(): Matrix;
  14459. /**
  14460. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14461. * @returns a matrix
  14462. */
  14463. getAbsoluteTransform(): Matrix;
  14464. /**
  14465. * Links with the given transform node.
  14466. * The local matrix of this bone is copied from the transform node every frame.
  14467. * @param transformNode defines the transform node to link to
  14468. */
  14469. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14470. /**
  14471. * Gets the node used to drive the bone's transformation
  14472. * @returns a transform node or null
  14473. */
  14474. getTransformNode(): Nullable<TransformNode>;
  14475. /** Gets or sets current position (in local space) */
  14476. get position(): Vector3;
  14477. set position(newPosition: Vector3);
  14478. /** Gets or sets current rotation (in local space) */
  14479. get rotation(): Vector3;
  14480. set rotation(newRotation: Vector3);
  14481. /** Gets or sets current rotation quaternion (in local space) */
  14482. get rotationQuaternion(): Quaternion;
  14483. set rotationQuaternion(newRotation: Quaternion);
  14484. /** Gets or sets current scaling (in local space) */
  14485. get scaling(): Vector3;
  14486. set scaling(newScaling: Vector3);
  14487. /**
  14488. * Gets the animation properties override
  14489. */
  14490. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14491. private _decompose;
  14492. private _compose;
  14493. /**
  14494. * Update the base and local matrices
  14495. * @param matrix defines the new base or local matrix
  14496. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14497. * @param updateLocalMatrix defines if the local matrix should be updated
  14498. */
  14499. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14500. /** @hidden */
  14501. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14502. /**
  14503. * Flag the bone as dirty (Forcing it to update everything)
  14504. */
  14505. markAsDirty(): void;
  14506. /** @hidden */
  14507. _markAsDirtyAndCompose(): void;
  14508. private _markAsDirtyAndDecompose;
  14509. /**
  14510. * Translate the bone in local or world space
  14511. * @param vec The amount to translate the bone
  14512. * @param space The space that the translation is in
  14513. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14514. */
  14515. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14516. /**
  14517. * Set the postion of the bone in local or world space
  14518. * @param position The position to set the bone
  14519. * @param space The space that the position is in
  14520. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14521. */
  14522. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14523. /**
  14524. * Set the absolute position of the bone (world space)
  14525. * @param position The position to set the bone
  14526. * @param mesh The mesh that this bone is attached to
  14527. */
  14528. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14529. /**
  14530. * Scale the bone on the x, y and z axes (in local space)
  14531. * @param x The amount to scale the bone on the x axis
  14532. * @param y The amount to scale the bone on the y axis
  14533. * @param z The amount to scale the bone on the z axis
  14534. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14535. */
  14536. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14537. /**
  14538. * Set the bone scaling in local space
  14539. * @param scale defines the scaling vector
  14540. */
  14541. setScale(scale: Vector3): void;
  14542. /**
  14543. * Gets the current scaling in local space
  14544. * @returns the current scaling vector
  14545. */
  14546. getScale(): Vector3;
  14547. /**
  14548. * Gets the current scaling in local space and stores it in a target vector
  14549. * @param result defines the target vector
  14550. */
  14551. getScaleToRef(result: Vector3): void;
  14552. /**
  14553. * Set the yaw, pitch, and roll of the bone in local or world space
  14554. * @param yaw The rotation of the bone on the y axis
  14555. * @param pitch The rotation of the bone on the x axis
  14556. * @param roll The rotation of the bone on the z axis
  14557. * @param space The space that the axes of rotation are in
  14558. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14559. */
  14560. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14561. /**
  14562. * Add a rotation to the bone on an axis in local or world space
  14563. * @param axis The axis to rotate the bone on
  14564. * @param amount The amount to rotate the bone
  14565. * @param space The space that the axis is in
  14566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14567. */
  14568. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14569. /**
  14570. * Set the rotation of the bone to a particular axis angle in local or world space
  14571. * @param axis The axis to rotate the bone on
  14572. * @param angle The angle that the bone should be rotated to
  14573. * @param space The space that the axis is in
  14574. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14575. */
  14576. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14577. /**
  14578. * Set the euler rotation of the bone in local of world space
  14579. * @param rotation The euler rotation that the bone should be set to
  14580. * @param space The space that the rotation is in
  14581. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14582. */
  14583. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14584. /**
  14585. * Set the quaternion rotation of the bone in local of world space
  14586. * @param quat The quaternion rotation that the bone should be set to
  14587. * @param space The space that the rotation is in
  14588. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14589. */
  14590. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14591. /**
  14592. * Set the rotation matrix of the bone in local of world space
  14593. * @param rotMat The rotation matrix that the bone should be set to
  14594. * @param space The space that the rotation is in
  14595. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14596. */
  14597. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14598. private _rotateWithMatrix;
  14599. private _getNegativeRotationToRef;
  14600. /**
  14601. * Get the position of the bone in local or world space
  14602. * @param space The space that the returned position is in
  14603. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14604. * @returns The position of the bone
  14605. */
  14606. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14607. /**
  14608. * Copy the position of the bone to a vector3 in local or world space
  14609. * @param space The space that the returned position is in
  14610. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14611. * @param result The vector3 to copy the position to
  14612. */
  14613. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14614. /**
  14615. * Get the absolute position of the bone (world space)
  14616. * @param mesh The mesh that this bone is attached to
  14617. * @returns The absolute position of the bone
  14618. */
  14619. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14620. /**
  14621. * Copy the absolute position of the bone (world space) to the result param
  14622. * @param mesh The mesh that this bone is attached to
  14623. * @param result The vector3 to copy the absolute position to
  14624. */
  14625. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14626. /**
  14627. * Compute the absolute transforms of this bone and its children
  14628. */
  14629. computeAbsoluteTransforms(): void;
  14630. /**
  14631. * Get the world direction from an axis that is in the local space of the bone
  14632. * @param localAxis The local direction that is used to compute the world direction
  14633. * @param mesh The mesh that this bone is attached to
  14634. * @returns The world direction
  14635. */
  14636. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14637. /**
  14638. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14639. * @param localAxis The local direction that is used to compute the world direction
  14640. * @param mesh The mesh that this bone is attached to
  14641. * @param result The vector3 that the world direction will be copied to
  14642. */
  14643. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14644. /**
  14645. * Get the euler rotation of the bone in local or world space
  14646. * @param space The space that the rotation should be in
  14647. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14648. * @returns The euler rotation
  14649. */
  14650. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14651. /**
  14652. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14653. * @param space The space that the rotation should be in
  14654. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14655. * @param result The vector3 that the rotation should be copied to
  14656. */
  14657. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14658. /**
  14659. * Get the quaternion rotation of the bone in either local or world space
  14660. * @param space The space that the rotation should be in
  14661. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14662. * @returns The quaternion rotation
  14663. */
  14664. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14665. /**
  14666. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14667. * @param space The space that the rotation should be in
  14668. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14669. * @param result The quaternion that the rotation should be copied to
  14670. */
  14671. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14672. /**
  14673. * Get the rotation matrix of the bone in local or world space
  14674. * @param space The space that the rotation should be in
  14675. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14676. * @returns The rotation matrix
  14677. */
  14678. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14679. /**
  14680. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14681. * @param space The space that the rotation should be in
  14682. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14683. * @param result The quaternion that the rotation should be copied to
  14684. */
  14685. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14686. /**
  14687. * Get the world position of a point that is in the local space of the bone
  14688. * @param position The local position
  14689. * @param mesh The mesh that this bone is attached to
  14690. * @returns The world position
  14691. */
  14692. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14693. /**
  14694. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14695. * @param position The local position
  14696. * @param mesh The mesh that this bone is attached to
  14697. * @param result The vector3 that the world position should be copied to
  14698. */
  14699. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14700. /**
  14701. * Get the local position of a point that is in world space
  14702. * @param position The world position
  14703. * @param mesh The mesh that this bone is attached to
  14704. * @returns The local position
  14705. */
  14706. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14707. /**
  14708. * Get the local position of a point that is in world space and copy it to the result param
  14709. * @param position The world position
  14710. * @param mesh The mesh that this bone is attached to
  14711. * @param result The vector3 that the local position should be copied to
  14712. */
  14713. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14714. }
  14715. }
  14716. declare module "babylonjs/Animations/runtimeAnimation" {
  14717. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14718. import { Animatable } from "babylonjs/Animations/animatable";
  14719. import { Scene } from "babylonjs/scene";
  14720. /**
  14721. * Defines a runtime animation
  14722. */
  14723. export class RuntimeAnimation {
  14724. private _events;
  14725. /**
  14726. * The current frame of the runtime animation
  14727. */
  14728. private _currentFrame;
  14729. /**
  14730. * The animation used by the runtime animation
  14731. */
  14732. private _animation;
  14733. /**
  14734. * The target of the runtime animation
  14735. */
  14736. private _target;
  14737. /**
  14738. * The initiating animatable
  14739. */
  14740. private _host;
  14741. /**
  14742. * The original value of the runtime animation
  14743. */
  14744. private _originalValue;
  14745. /**
  14746. * The original blend value of the runtime animation
  14747. */
  14748. private _originalBlendValue;
  14749. /**
  14750. * The offsets cache of the runtime animation
  14751. */
  14752. private _offsetsCache;
  14753. /**
  14754. * The high limits cache of the runtime animation
  14755. */
  14756. private _highLimitsCache;
  14757. /**
  14758. * Specifies if the runtime animation has been stopped
  14759. */
  14760. private _stopped;
  14761. /**
  14762. * The blending factor of the runtime animation
  14763. */
  14764. private _blendingFactor;
  14765. /**
  14766. * The BabylonJS scene
  14767. */
  14768. private _scene;
  14769. /**
  14770. * The current value of the runtime animation
  14771. */
  14772. private _currentValue;
  14773. /** @hidden */
  14774. _animationState: _IAnimationState;
  14775. /**
  14776. * The active target of the runtime animation
  14777. */
  14778. private _activeTargets;
  14779. private _currentActiveTarget;
  14780. private _directTarget;
  14781. /**
  14782. * The target path of the runtime animation
  14783. */
  14784. private _targetPath;
  14785. /**
  14786. * The weight of the runtime animation
  14787. */
  14788. private _weight;
  14789. /**
  14790. * The ratio offset of the runtime animation
  14791. */
  14792. private _ratioOffset;
  14793. /**
  14794. * The previous delay of the runtime animation
  14795. */
  14796. private _previousDelay;
  14797. /**
  14798. * The previous ratio of the runtime animation
  14799. */
  14800. private _previousRatio;
  14801. private _enableBlending;
  14802. private _keys;
  14803. private _minFrame;
  14804. private _maxFrame;
  14805. private _minValue;
  14806. private _maxValue;
  14807. private _targetIsArray;
  14808. /**
  14809. * Gets the current frame of the runtime animation
  14810. */
  14811. get currentFrame(): number;
  14812. /**
  14813. * Gets the weight of the runtime animation
  14814. */
  14815. get weight(): number;
  14816. /**
  14817. * Gets the current value of the runtime animation
  14818. */
  14819. get currentValue(): any;
  14820. /**
  14821. * Gets the target path of the runtime animation
  14822. */
  14823. get targetPath(): string;
  14824. /**
  14825. * Gets the actual target of the runtime animation
  14826. */
  14827. get target(): any;
  14828. /** @hidden */
  14829. _onLoop: () => void;
  14830. /**
  14831. * Create a new RuntimeAnimation object
  14832. * @param target defines the target of the animation
  14833. * @param animation defines the source animation object
  14834. * @param scene defines the hosting scene
  14835. * @param host defines the initiating Animatable
  14836. */
  14837. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14838. private _preparePath;
  14839. /**
  14840. * Gets the animation from the runtime animation
  14841. */
  14842. get animation(): Animation;
  14843. /**
  14844. * Resets the runtime animation to the beginning
  14845. * @param restoreOriginal defines whether to restore the target property to the original value
  14846. */
  14847. reset(restoreOriginal?: boolean): void;
  14848. /**
  14849. * Specifies if the runtime animation is stopped
  14850. * @returns Boolean specifying if the runtime animation is stopped
  14851. */
  14852. isStopped(): boolean;
  14853. /**
  14854. * Disposes of the runtime animation
  14855. */
  14856. dispose(): void;
  14857. /**
  14858. * Apply the interpolated value to the target
  14859. * @param currentValue defines the value computed by the animation
  14860. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14861. */
  14862. setValue(currentValue: any, weight: number): void;
  14863. private _getOriginalValues;
  14864. private _setValue;
  14865. /**
  14866. * Gets the loop pmode of the runtime animation
  14867. * @returns Loop Mode
  14868. */
  14869. private _getCorrectLoopMode;
  14870. /**
  14871. * Move the current animation to a given frame
  14872. * @param frame defines the frame to move to
  14873. */
  14874. goToFrame(frame: number): void;
  14875. /**
  14876. * @hidden Internal use only
  14877. */
  14878. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14879. /**
  14880. * Execute the current animation
  14881. * @param delay defines the delay to add to the current frame
  14882. * @param from defines the lower bound of the animation range
  14883. * @param to defines the upper bound of the animation range
  14884. * @param loop defines if the current animation must loop
  14885. * @param speedRatio defines the current speed ratio
  14886. * @param weight defines the weight of the animation (default is -1 so no weight)
  14887. * @param onLoop optional callback called when animation loops
  14888. * @returns a boolean indicating if the animation is running
  14889. */
  14890. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14891. }
  14892. }
  14893. declare module "babylonjs/Animations/animatable" {
  14894. import { Animation } from "babylonjs/Animations/animation";
  14895. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14896. import { Nullable } from "babylonjs/types";
  14897. import { Observable } from "babylonjs/Misc/observable";
  14898. import { Scene } from "babylonjs/scene";
  14899. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14900. import { Node } from "babylonjs/node";
  14901. /**
  14902. * Class used to store an actual running animation
  14903. */
  14904. export class Animatable {
  14905. /** defines the target object */
  14906. target: any;
  14907. /** defines the starting frame number (default is 0) */
  14908. fromFrame: number;
  14909. /** defines the ending frame number (default is 100) */
  14910. toFrame: number;
  14911. /** defines if the animation must loop (default is false) */
  14912. loopAnimation: boolean;
  14913. /** defines a callback to call when animation ends if it is not looping */
  14914. onAnimationEnd?: (() => void) | null | undefined;
  14915. /** defines a callback to call when animation loops */
  14916. onAnimationLoop?: (() => void) | null | undefined;
  14917. private _localDelayOffset;
  14918. private _pausedDelay;
  14919. private _runtimeAnimations;
  14920. private _paused;
  14921. private _scene;
  14922. private _speedRatio;
  14923. private _weight;
  14924. private _syncRoot;
  14925. /**
  14926. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14927. * This will only apply for non looping animation (default is true)
  14928. */
  14929. disposeOnEnd: boolean;
  14930. /**
  14931. * Gets a boolean indicating if the animation has started
  14932. */
  14933. animationStarted: boolean;
  14934. /**
  14935. * Observer raised when the animation ends
  14936. */
  14937. onAnimationEndObservable: Observable<Animatable>;
  14938. /**
  14939. * Observer raised when the animation loops
  14940. */
  14941. onAnimationLoopObservable: Observable<Animatable>;
  14942. /**
  14943. * Gets the root Animatable used to synchronize and normalize animations
  14944. */
  14945. get syncRoot(): Nullable<Animatable>;
  14946. /**
  14947. * Gets the current frame of the first RuntimeAnimation
  14948. * Used to synchronize Animatables
  14949. */
  14950. get masterFrame(): number;
  14951. /**
  14952. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14953. */
  14954. get weight(): number;
  14955. set weight(value: number);
  14956. /**
  14957. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14958. */
  14959. get speedRatio(): number;
  14960. set speedRatio(value: number);
  14961. /**
  14962. * Creates a new Animatable
  14963. * @param scene defines the hosting scene
  14964. * @param target defines the target object
  14965. * @param fromFrame defines the starting frame number (default is 0)
  14966. * @param toFrame defines the ending frame number (default is 100)
  14967. * @param loopAnimation defines if the animation must loop (default is false)
  14968. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14969. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14970. * @param animations defines a group of animation to add to the new Animatable
  14971. * @param onAnimationLoop defines a callback to call when animation loops
  14972. */
  14973. constructor(scene: Scene,
  14974. /** defines the target object */
  14975. target: any,
  14976. /** defines the starting frame number (default is 0) */
  14977. fromFrame?: number,
  14978. /** defines the ending frame number (default is 100) */
  14979. toFrame?: number,
  14980. /** defines if the animation must loop (default is false) */
  14981. loopAnimation?: boolean, speedRatio?: number,
  14982. /** defines a callback to call when animation ends if it is not looping */
  14983. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14984. /** defines a callback to call when animation loops */
  14985. onAnimationLoop?: (() => void) | null | undefined);
  14986. /**
  14987. * Synchronize and normalize current Animatable with a source Animatable
  14988. * This is useful when using animation weights and when animations are not of the same length
  14989. * @param root defines the root Animatable to synchronize with
  14990. * @returns the current Animatable
  14991. */
  14992. syncWith(root: Animatable): Animatable;
  14993. /**
  14994. * Gets the list of runtime animations
  14995. * @returns an array of RuntimeAnimation
  14996. */
  14997. getAnimations(): RuntimeAnimation[];
  14998. /**
  14999. * Adds more animations to the current animatable
  15000. * @param target defines the target of the animations
  15001. * @param animations defines the new animations to add
  15002. */
  15003. appendAnimations(target: any, animations: Animation[]): void;
  15004. /**
  15005. * Gets the source animation for a specific property
  15006. * @param property defines the propertyu to look for
  15007. * @returns null or the source animation for the given property
  15008. */
  15009. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15010. /**
  15011. * Gets the runtime animation for a specific property
  15012. * @param property defines the propertyu to look for
  15013. * @returns null or the runtime animation for the given property
  15014. */
  15015. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15016. /**
  15017. * Resets the animatable to its original state
  15018. */
  15019. reset(): void;
  15020. /**
  15021. * Allows the animatable to blend with current running animations
  15022. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15023. * @param blendingSpeed defines the blending speed to use
  15024. */
  15025. enableBlending(blendingSpeed: number): void;
  15026. /**
  15027. * Disable animation blending
  15028. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15029. */
  15030. disableBlending(): void;
  15031. /**
  15032. * Jump directly to a given frame
  15033. * @param frame defines the frame to jump to
  15034. */
  15035. goToFrame(frame: number): void;
  15036. /**
  15037. * Pause the animation
  15038. */
  15039. pause(): void;
  15040. /**
  15041. * Restart the animation
  15042. */
  15043. restart(): void;
  15044. private _raiseOnAnimationEnd;
  15045. /**
  15046. * Stop and delete the current animation
  15047. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15048. * @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)
  15049. */
  15050. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15051. /**
  15052. * Wait asynchronously for the animation to end
  15053. * @returns a promise which will be fullfilled when the animation ends
  15054. */
  15055. waitAsync(): Promise<Animatable>;
  15056. /** @hidden */
  15057. _animate(delay: number): boolean;
  15058. }
  15059. module "babylonjs/scene" {
  15060. interface Scene {
  15061. /** @hidden */
  15062. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15063. /** @hidden */
  15064. _processLateAnimationBindingsForMatrices(holder: {
  15065. totalWeight: number;
  15066. animations: RuntimeAnimation[];
  15067. originalValue: Matrix;
  15068. }): any;
  15069. /** @hidden */
  15070. _processLateAnimationBindingsForQuaternions(holder: {
  15071. totalWeight: number;
  15072. animations: RuntimeAnimation[];
  15073. originalValue: Quaternion;
  15074. }, refQuaternion: Quaternion): Quaternion;
  15075. /** @hidden */
  15076. _processLateAnimationBindings(): void;
  15077. /**
  15078. * Will start the animation sequence of a given target
  15079. * @param target defines the target
  15080. * @param from defines from which frame should animation start
  15081. * @param to defines until which frame should animation run.
  15082. * @param weight defines the weight to apply to the animation (1.0 by default)
  15083. * @param loop defines if the animation loops
  15084. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15085. * @param onAnimationEnd defines the function to be executed when the animation ends
  15086. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15087. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15088. * @param onAnimationLoop defines the callback to call when an animation loops
  15089. * @returns the animatable object created for this animation
  15090. */
  15091. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15092. /**
  15093. * Will start the animation sequence of a given target
  15094. * @param target defines the target
  15095. * @param from defines from which frame should animation start
  15096. * @param to defines until which frame should animation run.
  15097. * @param loop defines if the animation loops
  15098. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15099. * @param onAnimationEnd defines the function to be executed when the animation ends
  15100. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15101. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15102. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15103. * @param onAnimationLoop defines the callback to call when an animation loops
  15104. * @returns the animatable object created for this animation
  15105. */
  15106. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15107. /**
  15108. * Will start the animation sequence of a given target and its hierarchy
  15109. * @param target defines the target
  15110. * @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.
  15111. * @param from defines from which frame should animation start
  15112. * @param to defines until which frame should animation run.
  15113. * @param loop defines if the animation loops
  15114. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15115. * @param onAnimationEnd defines the function to be executed when the animation ends
  15116. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15117. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15118. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15119. * @param onAnimationLoop defines the callback to call when an animation loops
  15120. * @returns the list of created animatables
  15121. */
  15122. 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[];
  15123. /**
  15124. * Begin a new animation on a given node
  15125. * @param target defines the target where the animation will take place
  15126. * @param animations defines the list of animations to start
  15127. * @param from defines the initial value
  15128. * @param to defines the final value
  15129. * @param loop defines if you want animation to loop (off by default)
  15130. * @param speedRatio defines the speed ratio to apply to all animations
  15131. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15132. * @param onAnimationLoop defines the callback to call when an animation loops
  15133. * @returns the list of created animatables
  15134. */
  15135. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15136. /**
  15137. * Begin a new animation on a given node and its hierarchy
  15138. * @param target defines the root node where the animation will take place
  15139. * @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.
  15140. * @param animations defines the list of animations to start
  15141. * @param from defines the initial value
  15142. * @param to defines the final value
  15143. * @param loop defines if you want animation to loop (off by default)
  15144. * @param speedRatio defines the speed ratio to apply to all animations
  15145. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15146. * @param onAnimationLoop defines the callback to call when an animation loops
  15147. * @returns the list of animatables created for all nodes
  15148. */
  15149. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15150. /**
  15151. * Gets the animatable associated with a specific target
  15152. * @param target defines the target of the animatable
  15153. * @returns the required animatable if found
  15154. */
  15155. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15156. /**
  15157. * Gets all animatables associated with a given target
  15158. * @param target defines the target to look animatables for
  15159. * @returns an array of Animatables
  15160. */
  15161. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15162. /**
  15163. * Stops and removes all animations that have been applied to the scene
  15164. */
  15165. stopAllAnimations(): void;
  15166. /**
  15167. * Gets the current delta time used by animation engine
  15168. */
  15169. deltaTime: number;
  15170. }
  15171. }
  15172. module "babylonjs/Bones/bone" {
  15173. interface Bone {
  15174. /**
  15175. * Copy an animation range from another bone
  15176. * @param source defines the source bone
  15177. * @param rangeName defines the range name to copy
  15178. * @param frameOffset defines the frame offset
  15179. * @param rescaleAsRequired defines if rescaling must be applied if required
  15180. * @param skelDimensionsRatio defines the scaling ratio
  15181. * @returns true if operation was successful
  15182. */
  15183. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15184. }
  15185. }
  15186. }
  15187. declare module "babylonjs/Bones/skeleton" {
  15188. import { Bone } from "babylonjs/Bones/bone";
  15189. import { Observable } from "babylonjs/Misc/observable";
  15190. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15191. import { Scene } from "babylonjs/scene";
  15192. import { Nullable } from "babylonjs/types";
  15193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15194. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15195. import { Animatable } from "babylonjs/Animations/animatable";
  15196. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15197. import { Animation } from "babylonjs/Animations/animation";
  15198. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15199. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15200. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15201. /**
  15202. * Class used to handle skinning animations
  15203. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15204. */
  15205. export class Skeleton implements IAnimatable {
  15206. /** defines the skeleton name */
  15207. name: string;
  15208. /** defines the skeleton Id */
  15209. id: string;
  15210. /**
  15211. * Defines the list of child bones
  15212. */
  15213. bones: Bone[];
  15214. /**
  15215. * Defines an estimate of the dimension of the skeleton at rest
  15216. */
  15217. dimensionsAtRest: Vector3;
  15218. /**
  15219. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15220. */
  15221. needInitialSkinMatrix: boolean;
  15222. /**
  15223. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15224. */
  15225. overrideMesh: Nullable<AbstractMesh>;
  15226. /**
  15227. * Gets the list of animations attached to this skeleton
  15228. */
  15229. animations: Array<Animation>;
  15230. private _scene;
  15231. private _isDirty;
  15232. private _transformMatrices;
  15233. private _transformMatrixTexture;
  15234. private _meshesWithPoseMatrix;
  15235. private _animatables;
  15236. private _identity;
  15237. private _synchronizedWithMesh;
  15238. private _ranges;
  15239. private _lastAbsoluteTransformsUpdateId;
  15240. private _canUseTextureForBones;
  15241. private _uniqueId;
  15242. /** @hidden */
  15243. _numBonesWithLinkedTransformNode: number;
  15244. /** @hidden */
  15245. _hasWaitingData: Nullable<boolean>;
  15246. /**
  15247. * Specifies if the skeleton should be serialized
  15248. */
  15249. doNotSerialize: boolean;
  15250. private _useTextureToStoreBoneMatrices;
  15251. /**
  15252. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15253. * Please note that this option is not available if the hardware does not support it
  15254. */
  15255. get useTextureToStoreBoneMatrices(): boolean;
  15256. set useTextureToStoreBoneMatrices(value: boolean);
  15257. private _animationPropertiesOverride;
  15258. /**
  15259. * Gets or sets the animation properties override
  15260. */
  15261. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15262. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15263. /**
  15264. * List of inspectable custom properties (used by the Inspector)
  15265. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15266. */
  15267. inspectableCustomProperties: IInspectable[];
  15268. /**
  15269. * An observable triggered before computing the skeleton's matrices
  15270. */
  15271. onBeforeComputeObservable: Observable<Skeleton>;
  15272. /**
  15273. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15274. */
  15275. get isUsingTextureForMatrices(): boolean;
  15276. /**
  15277. * Gets the unique ID of this skeleton
  15278. */
  15279. get uniqueId(): number;
  15280. /**
  15281. * Creates a new skeleton
  15282. * @param name defines the skeleton name
  15283. * @param id defines the skeleton Id
  15284. * @param scene defines the hosting scene
  15285. */
  15286. constructor(
  15287. /** defines the skeleton name */
  15288. name: string,
  15289. /** defines the skeleton Id */
  15290. id: string, scene: Scene);
  15291. /**
  15292. * Gets the current object class name.
  15293. * @return the class name
  15294. */
  15295. getClassName(): string;
  15296. /**
  15297. * Returns an array containing the root bones
  15298. * @returns an array containing the root bones
  15299. */
  15300. getChildren(): Array<Bone>;
  15301. /**
  15302. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15303. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15304. * @returns a Float32Array containing matrices data
  15305. */
  15306. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15307. /**
  15308. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15309. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15310. * @returns a raw texture containing the data
  15311. */
  15312. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15313. /**
  15314. * Gets the current hosting scene
  15315. * @returns a scene object
  15316. */
  15317. getScene(): Scene;
  15318. /**
  15319. * Gets a string representing the current skeleton data
  15320. * @param fullDetails defines a boolean indicating if we want a verbose version
  15321. * @returns a string representing the current skeleton data
  15322. */
  15323. toString(fullDetails?: boolean): string;
  15324. /**
  15325. * Get bone's index searching by name
  15326. * @param name defines bone's name to search for
  15327. * @return the indice of the bone. Returns -1 if not found
  15328. */
  15329. getBoneIndexByName(name: string): number;
  15330. /**
  15331. * Creater a new animation range
  15332. * @param name defines the name of the range
  15333. * @param from defines the start key
  15334. * @param to defines the end key
  15335. */
  15336. createAnimationRange(name: string, from: number, to: number): void;
  15337. /**
  15338. * Delete a specific animation range
  15339. * @param name defines the name of the range
  15340. * @param deleteFrames defines if frames must be removed as well
  15341. */
  15342. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15343. /**
  15344. * Gets a specific animation range
  15345. * @param name defines the name of the range to look for
  15346. * @returns the requested animation range or null if not found
  15347. */
  15348. getAnimationRange(name: string): Nullable<AnimationRange>;
  15349. /**
  15350. * Gets the list of all animation ranges defined on this skeleton
  15351. * @returns an array
  15352. */
  15353. getAnimationRanges(): Nullable<AnimationRange>[];
  15354. /**
  15355. * Copy animation range from a source skeleton.
  15356. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15357. * @param source defines the source skeleton
  15358. * @param name defines the name of the range to copy
  15359. * @param rescaleAsRequired defines if rescaling must be applied if required
  15360. * @returns true if operation was successful
  15361. */
  15362. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15363. /**
  15364. * Forces the skeleton to go to rest pose
  15365. */
  15366. returnToRest(): void;
  15367. private _getHighestAnimationFrame;
  15368. /**
  15369. * Begin a specific animation range
  15370. * @param name defines the name of the range to start
  15371. * @param loop defines if looping must be turned on (false by default)
  15372. * @param speedRatio defines the speed ratio to apply (1 by default)
  15373. * @param onAnimationEnd defines a callback which will be called when animation will end
  15374. * @returns a new animatable
  15375. */
  15376. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15377. /** @hidden */
  15378. _markAsDirty(): void;
  15379. /** @hidden */
  15380. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15381. /** @hidden */
  15382. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15383. private _computeTransformMatrices;
  15384. /**
  15385. * Build all resources required to render a skeleton
  15386. */
  15387. prepare(): void;
  15388. /**
  15389. * Gets the list of animatables currently running for this skeleton
  15390. * @returns an array of animatables
  15391. */
  15392. getAnimatables(): IAnimatable[];
  15393. /**
  15394. * Clone the current skeleton
  15395. * @param name defines the name of the new skeleton
  15396. * @param id defines the id of the new skeleton
  15397. * @returns the new skeleton
  15398. */
  15399. clone(name: string, id?: string): Skeleton;
  15400. /**
  15401. * Enable animation blending for this skeleton
  15402. * @param blendingSpeed defines the blending speed to apply
  15403. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15404. */
  15405. enableBlending(blendingSpeed?: number): void;
  15406. /**
  15407. * Releases all resources associated with the current skeleton
  15408. */
  15409. dispose(): void;
  15410. /**
  15411. * Serialize the skeleton in a JSON object
  15412. * @returns a JSON object
  15413. */
  15414. serialize(): any;
  15415. /**
  15416. * Creates a new skeleton from serialized data
  15417. * @param parsedSkeleton defines the serialized data
  15418. * @param scene defines the hosting scene
  15419. * @returns a new skeleton
  15420. */
  15421. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15422. /**
  15423. * Compute all node absolute transforms
  15424. * @param forceUpdate defines if computation must be done even if cache is up to date
  15425. */
  15426. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15427. /**
  15428. * Gets the root pose matrix
  15429. * @returns a matrix
  15430. */
  15431. getPoseMatrix(): Nullable<Matrix>;
  15432. /**
  15433. * Sorts bones per internal index
  15434. */
  15435. sortBones(): void;
  15436. private _sortBones;
  15437. }
  15438. }
  15439. declare module "babylonjs/Meshes/instancedMesh" {
  15440. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15441. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15442. import { Camera } from "babylonjs/Cameras/camera";
  15443. import { Node } from "babylonjs/node";
  15444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15445. import { Mesh } from "babylonjs/Meshes/mesh";
  15446. import { Material } from "babylonjs/Materials/material";
  15447. import { Skeleton } from "babylonjs/Bones/skeleton";
  15448. import { Light } from "babylonjs/Lights/light";
  15449. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15450. /**
  15451. * Creates an instance based on a source mesh.
  15452. */
  15453. export class InstancedMesh extends AbstractMesh {
  15454. private _sourceMesh;
  15455. private _currentLOD;
  15456. /** @hidden */
  15457. _indexInSourceMeshInstanceArray: number;
  15458. constructor(name: string, source: Mesh);
  15459. /**
  15460. * Returns the string "InstancedMesh".
  15461. */
  15462. getClassName(): string;
  15463. /** Gets the list of lights affecting that mesh */
  15464. get lightSources(): Light[];
  15465. _resyncLightSources(): void;
  15466. _resyncLightSource(light: Light): void;
  15467. _removeLightSource(light: Light, dispose: boolean): void;
  15468. /**
  15469. * If the source mesh receives shadows
  15470. */
  15471. get receiveShadows(): boolean;
  15472. /**
  15473. * The material of the source mesh
  15474. */
  15475. get material(): Nullable<Material>;
  15476. /**
  15477. * Visibility of the source mesh
  15478. */
  15479. get visibility(): number;
  15480. /**
  15481. * Skeleton of the source mesh
  15482. */
  15483. get skeleton(): Nullable<Skeleton>;
  15484. /**
  15485. * Rendering ground id of the source mesh
  15486. */
  15487. get renderingGroupId(): number;
  15488. set renderingGroupId(value: number);
  15489. /**
  15490. * Returns the total number of vertices (integer).
  15491. */
  15492. getTotalVertices(): number;
  15493. /**
  15494. * Returns a positive integer : the total number of indices in this mesh geometry.
  15495. * @returns the numner of indices or zero if the mesh has no geometry.
  15496. */
  15497. getTotalIndices(): number;
  15498. /**
  15499. * The source mesh of the instance
  15500. */
  15501. get sourceMesh(): Mesh;
  15502. /**
  15503. * Is this node ready to be used/rendered
  15504. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15505. * @return {boolean} is it ready
  15506. */
  15507. isReady(completeCheck?: boolean): boolean;
  15508. /**
  15509. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15510. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15511. * @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.
  15512. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15513. */
  15514. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15515. /**
  15516. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15517. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15518. * The `data` are either a numeric array either a Float32Array.
  15519. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15520. * 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).
  15521. * Note that a new underlying VertexBuffer object is created each call.
  15522. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15523. *
  15524. * Possible `kind` values :
  15525. * - VertexBuffer.PositionKind
  15526. * - VertexBuffer.UVKind
  15527. * - VertexBuffer.UV2Kind
  15528. * - VertexBuffer.UV3Kind
  15529. * - VertexBuffer.UV4Kind
  15530. * - VertexBuffer.UV5Kind
  15531. * - VertexBuffer.UV6Kind
  15532. * - VertexBuffer.ColorKind
  15533. * - VertexBuffer.MatricesIndicesKind
  15534. * - VertexBuffer.MatricesIndicesExtraKind
  15535. * - VertexBuffer.MatricesWeightsKind
  15536. * - VertexBuffer.MatricesWeightsExtraKind
  15537. *
  15538. * Returns the Mesh.
  15539. */
  15540. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15541. /**
  15542. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15543. * If the mesh has no geometry, it is simply returned as it is.
  15544. * The `data` are either a numeric array either a Float32Array.
  15545. * No new underlying VertexBuffer object is created.
  15546. * 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.
  15547. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15548. *
  15549. * Possible `kind` values :
  15550. * - VertexBuffer.PositionKind
  15551. * - VertexBuffer.UVKind
  15552. * - VertexBuffer.UV2Kind
  15553. * - VertexBuffer.UV3Kind
  15554. * - VertexBuffer.UV4Kind
  15555. * - VertexBuffer.UV5Kind
  15556. * - VertexBuffer.UV6Kind
  15557. * - VertexBuffer.ColorKind
  15558. * - VertexBuffer.MatricesIndicesKind
  15559. * - VertexBuffer.MatricesIndicesExtraKind
  15560. * - VertexBuffer.MatricesWeightsKind
  15561. * - VertexBuffer.MatricesWeightsExtraKind
  15562. *
  15563. * Returns the Mesh.
  15564. */
  15565. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15566. /**
  15567. * Sets the mesh indices.
  15568. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15569. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15570. * This method creates a new index buffer each call.
  15571. * Returns the Mesh.
  15572. */
  15573. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15574. /**
  15575. * Boolean : True if the mesh owns the requested kind of data.
  15576. */
  15577. isVerticesDataPresent(kind: string): boolean;
  15578. /**
  15579. * Returns an array of indices (IndicesArray).
  15580. */
  15581. getIndices(): Nullable<IndicesArray>;
  15582. get _positions(): Nullable<Vector3[]>;
  15583. /**
  15584. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15585. * This means the mesh underlying bounding box and sphere are recomputed.
  15586. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15587. * @returns the current mesh
  15588. */
  15589. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15590. /** @hidden */
  15591. _preActivate(): InstancedMesh;
  15592. /** @hidden */
  15593. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15594. /** @hidden */
  15595. _postActivate(): void;
  15596. getWorldMatrix(): Matrix;
  15597. get isAnInstance(): boolean;
  15598. /**
  15599. * Returns the current associated LOD AbstractMesh.
  15600. */
  15601. getLOD(camera: Camera): AbstractMesh;
  15602. /** @hidden */
  15603. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15604. /** @hidden */
  15605. _syncSubMeshes(): InstancedMesh;
  15606. /** @hidden */
  15607. _generatePointsArray(): boolean;
  15608. /**
  15609. * Creates a new InstancedMesh from the current mesh.
  15610. * - name (string) : the cloned mesh name
  15611. * - newParent (optional Node) : the optional Node to parent the clone to.
  15612. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15613. *
  15614. * Returns the clone.
  15615. */
  15616. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15617. /**
  15618. * Disposes the InstancedMesh.
  15619. * Returns nothing.
  15620. */
  15621. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15622. }
  15623. module "babylonjs/Meshes/mesh" {
  15624. interface Mesh {
  15625. /**
  15626. * Register a custom buffer that will be instanced
  15627. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15628. * @param kind defines the buffer kind
  15629. * @param stride defines the stride in floats
  15630. */
  15631. registerInstancedBuffer(kind: string, stride: number): void;
  15632. /** @hidden */
  15633. _userInstancedBuffersStorage: {
  15634. data: {
  15635. [key: string]: Float32Array;
  15636. };
  15637. sizes: {
  15638. [key: string]: number;
  15639. };
  15640. vertexBuffers: {
  15641. [key: string]: Nullable<VertexBuffer>;
  15642. };
  15643. strides: {
  15644. [key: string]: number;
  15645. };
  15646. };
  15647. }
  15648. }
  15649. module "babylonjs/Meshes/abstractMesh" {
  15650. interface AbstractMesh {
  15651. /**
  15652. * Object used to store instanced buffers defined by user
  15653. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15654. */
  15655. instancedBuffers: {
  15656. [key: string]: any;
  15657. };
  15658. }
  15659. }
  15660. }
  15661. declare module "babylonjs/Materials/shaderMaterial" {
  15662. import { Scene } from "babylonjs/scene";
  15663. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15665. import { Mesh } from "babylonjs/Meshes/mesh";
  15666. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15667. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15668. import { Texture } from "babylonjs/Materials/Textures/texture";
  15669. import { Material } from "babylonjs/Materials/material";
  15670. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15671. /**
  15672. * Defines the options associated with the creation of a shader material.
  15673. */
  15674. export interface IShaderMaterialOptions {
  15675. /**
  15676. * Does the material work in alpha blend mode
  15677. */
  15678. needAlphaBlending: boolean;
  15679. /**
  15680. * Does the material work in alpha test mode
  15681. */
  15682. needAlphaTesting: boolean;
  15683. /**
  15684. * The list of attribute names used in the shader
  15685. */
  15686. attributes: string[];
  15687. /**
  15688. * The list of unifrom names used in the shader
  15689. */
  15690. uniforms: string[];
  15691. /**
  15692. * The list of UBO names used in the shader
  15693. */
  15694. uniformBuffers: string[];
  15695. /**
  15696. * The list of sampler names used in the shader
  15697. */
  15698. samplers: string[];
  15699. /**
  15700. * The list of defines used in the shader
  15701. */
  15702. defines: string[];
  15703. }
  15704. /**
  15705. * 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.
  15706. *
  15707. * This returned material effects how the mesh will look based on the code in the shaders.
  15708. *
  15709. * @see http://doc.babylonjs.com/how_to/shader_material
  15710. */
  15711. export class ShaderMaterial extends Material {
  15712. private _shaderPath;
  15713. private _options;
  15714. private _textures;
  15715. private _textureArrays;
  15716. private _floats;
  15717. private _ints;
  15718. private _floatsArrays;
  15719. private _colors3;
  15720. private _colors3Arrays;
  15721. private _colors4;
  15722. private _colors4Arrays;
  15723. private _vectors2;
  15724. private _vectors3;
  15725. private _vectors4;
  15726. private _matrices;
  15727. private _matrixArrays;
  15728. private _matrices3x3;
  15729. private _matrices2x2;
  15730. private _vectors2Arrays;
  15731. private _vectors3Arrays;
  15732. private _vectors4Arrays;
  15733. private _cachedWorldViewMatrix;
  15734. private _cachedWorldViewProjectionMatrix;
  15735. private _renderId;
  15736. private _multiview;
  15737. /**
  15738. * Instantiate a new shader material.
  15739. * 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.
  15740. * This returned material effects how the mesh will look based on the code in the shaders.
  15741. * @see http://doc.babylonjs.com/how_to/shader_material
  15742. * @param name Define the name of the material in the scene
  15743. * @param scene Define the scene the material belongs to
  15744. * @param shaderPath Defines the route to the shader code in one of three ways:
  15745. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15746. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15747. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15748. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15749. * @param options Define the options used to create the shader
  15750. */
  15751. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15752. /**
  15753. * Gets the shader path used to define the shader code
  15754. * It can be modified to trigger a new compilation
  15755. */
  15756. get shaderPath(): any;
  15757. /**
  15758. * Sets the shader path used to define the shader code
  15759. * It can be modified to trigger a new compilation
  15760. */
  15761. set shaderPath(shaderPath: any);
  15762. /**
  15763. * Gets the options used to compile the shader.
  15764. * They can be modified to trigger a new compilation
  15765. */
  15766. get options(): IShaderMaterialOptions;
  15767. /**
  15768. * Gets the current class name of the material e.g. "ShaderMaterial"
  15769. * Mainly use in serialization.
  15770. * @returns the class name
  15771. */
  15772. getClassName(): string;
  15773. /**
  15774. * Specifies if the material will require alpha blending
  15775. * @returns a boolean specifying if alpha blending is needed
  15776. */
  15777. needAlphaBlending(): boolean;
  15778. /**
  15779. * Specifies if this material should be rendered in alpha test mode
  15780. * @returns a boolean specifying if an alpha test is needed.
  15781. */
  15782. needAlphaTesting(): boolean;
  15783. private _checkUniform;
  15784. /**
  15785. * Set a texture in the shader.
  15786. * @param name Define the name of the uniform samplers as defined in the shader
  15787. * @param texture Define the texture to bind to this sampler
  15788. * @return the material itself allowing "fluent" like uniform updates
  15789. */
  15790. setTexture(name: string, texture: Texture): ShaderMaterial;
  15791. /**
  15792. * Set a texture array in the shader.
  15793. * @param name Define the name of the uniform sampler array as defined in the shader
  15794. * @param textures Define the list of textures to bind to this sampler
  15795. * @return the material itself allowing "fluent" like uniform updates
  15796. */
  15797. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15798. /**
  15799. * Set a float in the shader.
  15800. * @param name Define the name of the uniform as defined in the shader
  15801. * @param value Define the value to give to the uniform
  15802. * @return the material itself allowing "fluent" like uniform updates
  15803. */
  15804. setFloat(name: string, value: number): ShaderMaterial;
  15805. /**
  15806. * Set a int in the shader.
  15807. * @param name Define the name of the uniform as defined in the shader
  15808. * @param value Define the value to give to the uniform
  15809. * @return the material itself allowing "fluent" like uniform updates
  15810. */
  15811. setInt(name: string, value: number): ShaderMaterial;
  15812. /**
  15813. * Set an array of floats in the shader.
  15814. * @param name Define the name of the uniform as defined in the shader
  15815. * @param value Define the value to give to the uniform
  15816. * @return the material itself allowing "fluent" like uniform updates
  15817. */
  15818. setFloats(name: string, value: number[]): ShaderMaterial;
  15819. /**
  15820. * Set a vec3 in the shader from a Color3.
  15821. * @param name Define the name of the uniform as defined in the shader
  15822. * @param value Define the value to give to the uniform
  15823. * @return the material itself allowing "fluent" like uniform updates
  15824. */
  15825. setColor3(name: string, value: Color3): ShaderMaterial;
  15826. /**
  15827. * Set a vec3 array in the shader from a Color3 array.
  15828. * @param name Define the name of the uniform as defined in the shader
  15829. * @param value Define the value to give to the uniform
  15830. * @return the material itself allowing "fluent" like uniform updates
  15831. */
  15832. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15833. /**
  15834. * Set a vec4 in the shader from a Color4.
  15835. * @param name Define the name of the uniform as defined in the shader
  15836. * @param value Define the value to give to the uniform
  15837. * @return the material itself allowing "fluent" like uniform updates
  15838. */
  15839. setColor4(name: string, value: Color4): ShaderMaterial;
  15840. /**
  15841. * Set a vec4 array in the shader from a Color4 array.
  15842. * @param name Define the name of the uniform as defined in the shader
  15843. * @param value Define the value to give to the uniform
  15844. * @return the material itself allowing "fluent" like uniform updates
  15845. */
  15846. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15847. /**
  15848. * Set a vec2 in the shader from a Vector2.
  15849. * @param name Define the name of the uniform as defined in the shader
  15850. * @param value Define the value to give to the uniform
  15851. * @return the material itself allowing "fluent" like uniform updates
  15852. */
  15853. setVector2(name: string, value: Vector2): ShaderMaterial;
  15854. /**
  15855. * Set a vec3 in the shader from a Vector3.
  15856. * @param name Define the name of the uniform as defined in the shader
  15857. * @param value Define the value to give to the uniform
  15858. * @return the material itself allowing "fluent" like uniform updates
  15859. */
  15860. setVector3(name: string, value: Vector3): ShaderMaterial;
  15861. /**
  15862. * Set a vec4 in the shader from a Vector4.
  15863. * @param name Define the name of the uniform as defined in the shader
  15864. * @param value Define the value to give to the uniform
  15865. * @return the material itself allowing "fluent" like uniform updates
  15866. */
  15867. setVector4(name: string, value: Vector4): ShaderMaterial;
  15868. /**
  15869. * Set a mat4 in the shader from a Matrix.
  15870. * @param name Define the name of the uniform as defined in the shader
  15871. * @param value Define the value to give to the uniform
  15872. * @return the material itself allowing "fluent" like uniform updates
  15873. */
  15874. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15875. /**
  15876. * Set a float32Array in the shader from a matrix array.
  15877. * @param name Define the name of the uniform as defined in the shader
  15878. * @param value Define the value to give to the uniform
  15879. * @return the material itself allowing "fluent" like uniform updates
  15880. */
  15881. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15882. /**
  15883. * Set a mat3 in the shader from a Float32Array.
  15884. * @param name Define the name of the uniform as defined in the shader
  15885. * @param value Define the value to give to the uniform
  15886. * @return the material itself allowing "fluent" like uniform updates
  15887. */
  15888. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15889. /**
  15890. * Set a mat2 in the shader from a Float32Array.
  15891. * @param name Define the name of the uniform as defined in the shader
  15892. * @param value Define the value to give to the uniform
  15893. * @return the material itself allowing "fluent" like uniform updates
  15894. */
  15895. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15896. /**
  15897. * Set a vec2 array in the shader from a number array.
  15898. * @param name Define the name of the uniform as defined in the shader
  15899. * @param value Define the value to give to the uniform
  15900. * @return the material itself allowing "fluent" like uniform updates
  15901. */
  15902. setArray2(name: string, value: number[]): ShaderMaterial;
  15903. /**
  15904. * Set a vec3 array in the shader from a number array.
  15905. * @param name Define the name of the uniform as defined in the shader
  15906. * @param value Define the value to give to the uniform
  15907. * @return the material itself allowing "fluent" like uniform updates
  15908. */
  15909. setArray3(name: string, value: number[]): ShaderMaterial;
  15910. /**
  15911. * Set a vec4 array in the shader from a number array.
  15912. * @param name Define the name of the uniform as defined in the shader
  15913. * @param value Define the value to give to the uniform
  15914. * @return the material itself allowing "fluent" like uniform updates
  15915. */
  15916. setArray4(name: string, value: number[]): ShaderMaterial;
  15917. private _checkCache;
  15918. /**
  15919. * Specifies that the submesh is ready to be used
  15920. * @param mesh defines the mesh to check
  15921. * @param subMesh defines which submesh to check
  15922. * @param useInstances specifies that instances should be used
  15923. * @returns a boolean indicating that the submesh is ready or not
  15924. */
  15925. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15926. /**
  15927. * Checks if the material is ready to render the requested mesh
  15928. * @param mesh Define the mesh to render
  15929. * @param useInstances Define whether or not the material is used with instances
  15930. * @returns true if ready, otherwise false
  15931. */
  15932. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15933. /**
  15934. * Binds the world matrix to the material
  15935. * @param world defines the world transformation matrix
  15936. */
  15937. bindOnlyWorldMatrix(world: Matrix): void;
  15938. /**
  15939. * Binds the material to the mesh
  15940. * @param world defines the world transformation matrix
  15941. * @param mesh defines the mesh to bind the material to
  15942. */
  15943. bind(world: Matrix, mesh?: Mesh): void;
  15944. /**
  15945. * Gets the active textures from the material
  15946. * @returns an array of textures
  15947. */
  15948. getActiveTextures(): BaseTexture[];
  15949. /**
  15950. * Specifies if the material uses a texture
  15951. * @param texture defines the texture to check against the material
  15952. * @returns a boolean specifying if the material uses the texture
  15953. */
  15954. hasTexture(texture: BaseTexture): boolean;
  15955. /**
  15956. * Makes a duplicate of the material, and gives it a new name
  15957. * @param name defines the new name for the duplicated material
  15958. * @returns the cloned material
  15959. */
  15960. clone(name: string): ShaderMaterial;
  15961. /**
  15962. * Disposes the material
  15963. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15964. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15965. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15966. */
  15967. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15968. /**
  15969. * Serializes this material in a JSON representation
  15970. * @returns the serialized material object
  15971. */
  15972. serialize(): any;
  15973. /**
  15974. * Creates a shader material from parsed shader material data
  15975. * @param source defines the JSON represnetation of the material
  15976. * @param scene defines the hosting scene
  15977. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15978. * @returns a new material
  15979. */
  15980. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15981. }
  15982. }
  15983. declare module "babylonjs/Shaders/color.fragment" {
  15984. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15985. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15986. /** @hidden */
  15987. export var colorPixelShader: {
  15988. name: string;
  15989. shader: string;
  15990. };
  15991. }
  15992. declare module "babylonjs/Shaders/color.vertex" {
  15993. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  15994. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15995. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  15996. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  15997. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  15998. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15999. /** @hidden */
  16000. export var colorVertexShader: {
  16001. name: string;
  16002. shader: string;
  16003. };
  16004. }
  16005. declare module "babylonjs/Meshes/linesMesh" {
  16006. import { Nullable } from "babylonjs/types";
  16007. import { Scene } from "babylonjs/scene";
  16008. import { Color3 } from "babylonjs/Maths/math.color";
  16009. import { Node } from "babylonjs/node";
  16010. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16011. import { Mesh } from "babylonjs/Meshes/mesh";
  16012. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16013. import { Effect } from "babylonjs/Materials/effect";
  16014. import { Material } from "babylonjs/Materials/material";
  16015. import "babylonjs/Shaders/color.fragment";
  16016. import "babylonjs/Shaders/color.vertex";
  16017. /**
  16018. * Line mesh
  16019. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16020. */
  16021. export class LinesMesh extends Mesh {
  16022. /**
  16023. * If vertex color should be applied to the mesh
  16024. */
  16025. readonly useVertexColor?: boolean | undefined;
  16026. /**
  16027. * If vertex alpha should be applied to the mesh
  16028. */
  16029. readonly useVertexAlpha?: boolean | undefined;
  16030. /**
  16031. * Color of the line (Default: White)
  16032. */
  16033. color: Color3;
  16034. /**
  16035. * Alpha of the line (Default: 1)
  16036. */
  16037. alpha: number;
  16038. /**
  16039. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16040. * This margin is expressed in world space coordinates, so its value may vary.
  16041. * Default value is 0.1
  16042. */
  16043. intersectionThreshold: number;
  16044. private _colorShader;
  16045. private color4;
  16046. /**
  16047. * Creates a new LinesMesh
  16048. * @param name defines the name
  16049. * @param scene defines the hosting scene
  16050. * @param parent defines the parent mesh if any
  16051. * @param source defines the optional source LinesMesh used to clone data from
  16052. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16053. * When false, achieved by calling a clone(), also passing False.
  16054. * This will make creation of children, recursive.
  16055. * @param useVertexColor defines if this LinesMesh supports vertex color
  16056. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16057. */
  16058. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16059. /**
  16060. * If vertex color should be applied to the mesh
  16061. */
  16062. useVertexColor?: boolean | undefined,
  16063. /**
  16064. * If vertex alpha should be applied to the mesh
  16065. */
  16066. useVertexAlpha?: boolean | undefined);
  16067. private _addClipPlaneDefine;
  16068. private _removeClipPlaneDefine;
  16069. isReady(): boolean;
  16070. /**
  16071. * Returns the string "LineMesh"
  16072. */
  16073. getClassName(): string;
  16074. /**
  16075. * @hidden
  16076. */
  16077. get material(): Material;
  16078. /**
  16079. * @hidden
  16080. */
  16081. set material(value: Material);
  16082. /**
  16083. * @hidden
  16084. */
  16085. get checkCollisions(): boolean;
  16086. /** @hidden */
  16087. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16088. /** @hidden */
  16089. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16090. /**
  16091. * Disposes of the line mesh
  16092. * @param doNotRecurse If children should be disposed
  16093. */
  16094. dispose(doNotRecurse?: boolean): void;
  16095. /**
  16096. * Returns a new LineMesh object cloned from the current one.
  16097. */
  16098. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16099. /**
  16100. * Creates a new InstancedLinesMesh object from the mesh model.
  16101. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16102. * @param name defines the name of the new instance
  16103. * @returns a new InstancedLinesMesh
  16104. */
  16105. createInstance(name: string): InstancedLinesMesh;
  16106. }
  16107. /**
  16108. * Creates an instance based on a source LinesMesh
  16109. */
  16110. export class InstancedLinesMesh extends InstancedMesh {
  16111. /**
  16112. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16113. * This margin is expressed in world space coordinates, so its value may vary.
  16114. * Initilized with the intersectionThreshold value of the source LinesMesh
  16115. */
  16116. intersectionThreshold: number;
  16117. constructor(name: string, source: LinesMesh);
  16118. /**
  16119. * Returns the string "InstancedLinesMesh".
  16120. */
  16121. getClassName(): string;
  16122. }
  16123. }
  16124. declare module "babylonjs/Shaders/line.fragment" {
  16125. /** @hidden */
  16126. export var linePixelShader: {
  16127. name: string;
  16128. shader: string;
  16129. };
  16130. }
  16131. declare module "babylonjs/Shaders/line.vertex" {
  16132. /** @hidden */
  16133. export var lineVertexShader: {
  16134. name: string;
  16135. shader: string;
  16136. };
  16137. }
  16138. declare module "babylonjs/Rendering/edgesRenderer" {
  16139. import { Nullable } from "babylonjs/types";
  16140. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16142. import { Vector3 } from "babylonjs/Maths/math.vector";
  16143. import { IDisposable } from "babylonjs/scene";
  16144. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16145. import "babylonjs/Shaders/line.fragment";
  16146. import "babylonjs/Shaders/line.vertex";
  16147. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16148. module "babylonjs/Meshes/abstractMesh" {
  16149. interface AbstractMesh {
  16150. /**
  16151. * Gets the edgesRenderer associated with the mesh
  16152. */
  16153. edgesRenderer: Nullable<EdgesRenderer>;
  16154. }
  16155. }
  16156. module "babylonjs/Meshes/linesMesh" {
  16157. interface LinesMesh {
  16158. /**
  16159. * Enables the edge rendering mode on the mesh.
  16160. * This mode makes the mesh edges visible
  16161. * @param epsilon defines the maximal distance between two angles to detect a face
  16162. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16163. * @returns the currentAbstractMesh
  16164. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16165. */
  16166. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16167. }
  16168. }
  16169. module "babylonjs/Meshes/linesMesh" {
  16170. interface InstancedLinesMesh {
  16171. /**
  16172. * Enables the edge rendering mode on the mesh.
  16173. * This mode makes the mesh edges visible
  16174. * @param epsilon defines the maximal distance between two angles to detect a face
  16175. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16176. * @returns the current InstancedLinesMesh
  16177. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16178. */
  16179. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16180. }
  16181. }
  16182. /**
  16183. * Defines the minimum contract an Edges renderer should follow.
  16184. */
  16185. export interface IEdgesRenderer extends IDisposable {
  16186. /**
  16187. * Gets or sets a boolean indicating if the edgesRenderer is active
  16188. */
  16189. isEnabled: boolean;
  16190. /**
  16191. * Renders the edges of the attached mesh,
  16192. */
  16193. render(): void;
  16194. /**
  16195. * Checks wether or not the edges renderer is ready to render.
  16196. * @return true if ready, otherwise false.
  16197. */
  16198. isReady(): boolean;
  16199. }
  16200. /**
  16201. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16202. */
  16203. export class EdgesRenderer implements IEdgesRenderer {
  16204. /**
  16205. * Define the size of the edges with an orthographic camera
  16206. */
  16207. edgesWidthScalerForOrthographic: number;
  16208. /**
  16209. * Define the size of the edges with a perspective camera
  16210. */
  16211. edgesWidthScalerForPerspective: number;
  16212. protected _source: AbstractMesh;
  16213. protected _linesPositions: number[];
  16214. protected _linesNormals: number[];
  16215. protected _linesIndices: number[];
  16216. protected _epsilon: number;
  16217. protected _indicesCount: number;
  16218. protected _lineShader: ShaderMaterial;
  16219. protected _ib: DataBuffer;
  16220. protected _buffers: {
  16221. [key: string]: Nullable<VertexBuffer>;
  16222. };
  16223. protected _checkVerticesInsteadOfIndices: boolean;
  16224. private _meshRebuildObserver;
  16225. private _meshDisposeObserver;
  16226. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16227. isEnabled: boolean;
  16228. /**
  16229. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16230. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16231. * @param source Mesh used to create edges
  16232. * @param epsilon sum of angles in adjacency to check for edge
  16233. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16234. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16235. */
  16236. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16237. protected _prepareRessources(): void;
  16238. /** @hidden */
  16239. _rebuild(): void;
  16240. /**
  16241. * Releases the required resources for the edges renderer
  16242. */
  16243. dispose(): void;
  16244. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16245. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16246. /**
  16247. * Checks if the pair of p0 and p1 is en edge
  16248. * @param faceIndex
  16249. * @param edge
  16250. * @param faceNormals
  16251. * @param p0
  16252. * @param p1
  16253. * @private
  16254. */
  16255. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16256. /**
  16257. * push line into the position, normal and index buffer
  16258. * @protected
  16259. */
  16260. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16261. /**
  16262. * Generates lines edges from adjacencjes
  16263. * @private
  16264. */
  16265. _generateEdgesLines(): void;
  16266. /**
  16267. * Checks wether or not the edges renderer is ready to render.
  16268. * @return true if ready, otherwise false.
  16269. */
  16270. isReady(): boolean;
  16271. /**
  16272. * Renders the edges of the attached mesh,
  16273. */
  16274. render(): void;
  16275. }
  16276. /**
  16277. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16278. */
  16279. export class LineEdgesRenderer extends EdgesRenderer {
  16280. /**
  16281. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16282. * @param source LineMesh used to generate edges
  16283. * @param epsilon not important (specified angle for edge detection)
  16284. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16285. */
  16286. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16287. /**
  16288. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16289. */
  16290. _generateEdgesLines(): void;
  16291. }
  16292. }
  16293. declare module "babylonjs/Rendering/renderingGroup" {
  16294. import { SmartArray } from "babylonjs/Misc/smartArray";
  16295. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16297. import { Nullable } from "babylonjs/types";
  16298. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16299. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16300. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16301. import { Material } from "babylonjs/Materials/material";
  16302. import { Scene } from "babylonjs/scene";
  16303. /**
  16304. * This represents the object necessary to create a rendering group.
  16305. * This is exclusively used and created by the rendering manager.
  16306. * To modify the behavior, you use the available helpers in your scene or meshes.
  16307. * @hidden
  16308. */
  16309. export class RenderingGroup {
  16310. index: number;
  16311. private static _zeroVector;
  16312. private _scene;
  16313. private _opaqueSubMeshes;
  16314. private _transparentSubMeshes;
  16315. private _alphaTestSubMeshes;
  16316. private _depthOnlySubMeshes;
  16317. private _particleSystems;
  16318. private _spriteManagers;
  16319. private _opaqueSortCompareFn;
  16320. private _alphaTestSortCompareFn;
  16321. private _transparentSortCompareFn;
  16322. private _renderOpaque;
  16323. private _renderAlphaTest;
  16324. private _renderTransparent;
  16325. /** @hidden */
  16326. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16327. onBeforeTransparentRendering: () => void;
  16328. /**
  16329. * Set the opaque sort comparison function.
  16330. * If null the sub meshes will be render in the order they were created
  16331. */
  16332. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16333. /**
  16334. * Set the alpha test sort comparison function.
  16335. * If null the sub meshes will be render in the order they were created
  16336. */
  16337. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16338. /**
  16339. * Set the transparent sort comparison function.
  16340. * If null the sub meshes will be render in the order they were created
  16341. */
  16342. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16343. /**
  16344. * Creates a new rendering group.
  16345. * @param index The rendering group index
  16346. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16347. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16348. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16349. */
  16350. 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>);
  16351. /**
  16352. * Render all the sub meshes contained in the group.
  16353. * @param customRenderFunction Used to override the default render behaviour of the group.
  16354. * @returns true if rendered some submeshes.
  16355. */
  16356. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16357. /**
  16358. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16359. * @param subMeshes The submeshes to render
  16360. */
  16361. private renderOpaqueSorted;
  16362. /**
  16363. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16364. * @param subMeshes The submeshes to render
  16365. */
  16366. private renderAlphaTestSorted;
  16367. /**
  16368. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16369. * @param subMeshes The submeshes to render
  16370. */
  16371. private renderTransparentSorted;
  16372. /**
  16373. * Renders the submeshes in a specified order.
  16374. * @param subMeshes The submeshes to sort before render
  16375. * @param sortCompareFn The comparison function use to sort
  16376. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16377. * @param transparent Specifies to activate blending if true
  16378. */
  16379. private static renderSorted;
  16380. /**
  16381. * Renders the submeshes in the order they were dispatched (no sort applied).
  16382. * @param subMeshes The submeshes to render
  16383. */
  16384. private static renderUnsorted;
  16385. /**
  16386. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16387. * are rendered back to front if in the same alpha index.
  16388. *
  16389. * @param a The first submesh
  16390. * @param b The second submesh
  16391. * @returns The result of the comparison
  16392. */
  16393. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16394. /**
  16395. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16396. * are rendered back to front.
  16397. *
  16398. * @param a The first submesh
  16399. * @param b The second submesh
  16400. * @returns The result of the comparison
  16401. */
  16402. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16403. /**
  16404. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16405. * are rendered front to back (prevent overdraw).
  16406. *
  16407. * @param a The first submesh
  16408. * @param b The second submesh
  16409. * @returns The result of the comparison
  16410. */
  16411. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16412. /**
  16413. * Resets the different lists of submeshes to prepare a new frame.
  16414. */
  16415. prepare(): void;
  16416. dispose(): void;
  16417. /**
  16418. * Inserts the submesh in its correct queue depending on its material.
  16419. * @param subMesh The submesh to dispatch
  16420. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16421. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16422. */
  16423. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16424. dispatchSprites(spriteManager: ISpriteManager): void;
  16425. dispatchParticles(particleSystem: IParticleSystem): void;
  16426. private _renderParticles;
  16427. private _renderSprites;
  16428. }
  16429. }
  16430. declare module "babylonjs/Rendering/renderingManager" {
  16431. import { Nullable } from "babylonjs/types";
  16432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16433. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16434. import { SmartArray } from "babylonjs/Misc/smartArray";
  16435. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16436. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16437. import { Material } from "babylonjs/Materials/material";
  16438. import { Scene } from "babylonjs/scene";
  16439. import { Camera } from "babylonjs/Cameras/camera";
  16440. /**
  16441. * Interface describing the different options available in the rendering manager
  16442. * regarding Auto Clear between groups.
  16443. */
  16444. export interface IRenderingManagerAutoClearSetup {
  16445. /**
  16446. * Defines whether or not autoclear is enable.
  16447. */
  16448. autoClear: boolean;
  16449. /**
  16450. * Defines whether or not to autoclear the depth buffer.
  16451. */
  16452. depth: boolean;
  16453. /**
  16454. * Defines whether or not to autoclear the stencil buffer.
  16455. */
  16456. stencil: boolean;
  16457. }
  16458. /**
  16459. * This class is used by the onRenderingGroupObservable
  16460. */
  16461. export class RenderingGroupInfo {
  16462. /**
  16463. * The Scene that being rendered
  16464. */
  16465. scene: Scene;
  16466. /**
  16467. * The camera currently used for the rendering pass
  16468. */
  16469. camera: Nullable<Camera>;
  16470. /**
  16471. * The ID of the renderingGroup being processed
  16472. */
  16473. renderingGroupId: number;
  16474. }
  16475. /**
  16476. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16477. * It is enable to manage the different groups as well as the different necessary sort functions.
  16478. * This should not be used directly aside of the few static configurations
  16479. */
  16480. export class RenderingManager {
  16481. /**
  16482. * The max id used for rendering groups (not included)
  16483. */
  16484. static MAX_RENDERINGGROUPS: number;
  16485. /**
  16486. * The min id used for rendering groups (included)
  16487. */
  16488. static MIN_RENDERINGGROUPS: number;
  16489. /**
  16490. * Used to globally prevent autoclearing scenes.
  16491. */
  16492. static AUTOCLEAR: boolean;
  16493. /**
  16494. * @hidden
  16495. */
  16496. _useSceneAutoClearSetup: boolean;
  16497. private _scene;
  16498. private _renderingGroups;
  16499. private _depthStencilBufferAlreadyCleaned;
  16500. private _autoClearDepthStencil;
  16501. private _customOpaqueSortCompareFn;
  16502. private _customAlphaTestSortCompareFn;
  16503. private _customTransparentSortCompareFn;
  16504. private _renderingGroupInfo;
  16505. /**
  16506. * Instantiates a new rendering group for a particular scene
  16507. * @param scene Defines the scene the groups belongs to
  16508. */
  16509. constructor(scene: Scene);
  16510. private _clearDepthStencilBuffer;
  16511. /**
  16512. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16513. * @hidden
  16514. */
  16515. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16516. /**
  16517. * Resets the different information of the group to prepare a new frame
  16518. * @hidden
  16519. */
  16520. reset(): void;
  16521. /**
  16522. * Dispose and release the group and its associated resources.
  16523. * @hidden
  16524. */
  16525. dispose(): void;
  16526. /**
  16527. * Clear the info related to rendering groups preventing retention points during dispose.
  16528. */
  16529. freeRenderingGroups(): void;
  16530. private _prepareRenderingGroup;
  16531. /**
  16532. * Add a sprite manager to the rendering manager in order to render it this frame.
  16533. * @param spriteManager Define the sprite manager to render
  16534. */
  16535. dispatchSprites(spriteManager: ISpriteManager): void;
  16536. /**
  16537. * Add a particle system to the rendering manager in order to render it this frame.
  16538. * @param particleSystem Define the particle system to render
  16539. */
  16540. dispatchParticles(particleSystem: IParticleSystem): void;
  16541. /**
  16542. * Add a submesh to the manager in order to render it this frame
  16543. * @param subMesh The submesh to dispatch
  16544. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16545. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16546. */
  16547. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16548. /**
  16549. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16550. * This allowed control for front to back rendering or reversly depending of the special needs.
  16551. *
  16552. * @param renderingGroupId The rendering group id corresponding to its index
  16553. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16554. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16555. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16556. */
  16557. 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;
  16558. /**
  16559. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16560. *
  16561. * @param renderingGroupId The rendering group id corresponding to its index
  16562. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16563. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16564. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16565. */
  16566. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16567. /**
  16568. * Gets the current auto clear configuration for one rendering group of the rendering
  16569. * manager.
  16570. * @param index the rendering group index to get the information for
  16571. * @returns The auto clear setup for the requested rendering group
  16572. */
  16573. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16574. }
  16575. }
  16576. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16577. import { SmartArray } from "babylonjs/Misc/smartArray";
  16578. import { Nullable } from "babylonjs/types";
  16579. import { Scene } from "babylonjs/scene";
  16580. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16581. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16583. import { Mesh } from "babylonjs/Meshes/mesh";
  16584. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16585. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16586. import { Effect } from "babylonjs/Materials/effect";
  16587. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16588. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16589. import "babylonjs/Shaders/shadowMap.fragment";
  16590. import "babylonjs/Shaders/shadowMap.vertex";
  16591. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16592. import { Observable } from "babylonjs/Misc/observable";
  16593. /**
  16594. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16595. */
  16596. export interface ICustomShaderOptions {
  16597. /**
  16598. * Gets or sets the custom shader name to use
  16599. */
  16600. shaderName: string;
  16601. /**
  16602. * The list of attribute names used in the shader
  16603. */
  16604. attributes?: string[];
  16605. /**
  16606. * The list of unifrom names used in the shader
  16607. */
  16608. uniforms?: string[];
  16609. /**
  16610. * The list of sampler names used in the shader
  16611. */
  16612. samplers?: string[];
  16613. /**
  16614. * The list of defines used in the shader
  16615. */
  16616. defines?: string[];
  16617. }
  16618. /**
  16619. * Interface to implement to create a shadow generator compatible with BJS.
  16620. */
  16621. export interface IShadowGenerator {
  16622. /**
  16623. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16624. * @returns The render target texture if present otherwise, null
  16625. */
  16626. getShadowMap(): Nullable<RenderTargetTexture>;
  16627. /**
  16628. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16629. * @param subMesh The submesh we want to render in the shadow map
  16630. * @param useInstances Defines wether will draw in the map using instances
  16631. * @returns true if ready otherwise, false
  16632. */
  16633. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16634. /**
  16635. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16636. * @param defines Defines of the material we want to update
  16637. * @param lightIndex Index of the light in the enabled light list of the material
  16638. */
  16639. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16640. /**
  16641. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16642. * defined in the generator but impacting the effect).
  16643. * It implies the unifroms available on the materials are the standard BJS ones.
  16644. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16645. * @param effect The effect we are binfing the information for
  16646. */
  16647. bindShadowLight(lightIndex: string, effect: Effect): void;
  16648. /**
  16649. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16650. * (eq to shadow prjection matrix * light transform matrix)
  16651. * @returns The transform matrix used to create the shadow map
  16652. */
  16653. getTransformMatrix(): Matrix;
  16654. /**
  16655. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16656. * Cube and 2D textures for instance.
  16657. */
  16658. recreateShadowMap(): void;
  16659. /**
  16660. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16661. * @param onCompiled Callback triggered at the and of the effects compilation
  16662. * @param options Sets of optional options forcing the compilation with different modes
  16663. */
  16664. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16665. useInstances: boolean;
  16666. }>): void;
  16667. /**
  16668. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16669. * @param options Sets of optional options forcing the compilation with different modes
  16670. * @returns A promise that resolves when the compilation completes
  16671. */
  16672. forceCompilationAsync(options?: Partial<{
  16673. useInstances: boolean;
  16674. }>): Promise<void>;
  16675. /**
  16676. * Serializes the shadow generator setup to a json object.
  16677. * @returns The serialized JSON object
  16678. */
  16679. serialize(): any;
  16680. /**
  16681. * Disposes the Shadow map and related Textures and effects.
  16682. */
  16683. dispose(): void;
  16684. }
  16685. /**
  16686. * Default implementation IShadowGenerator.
  16687. * This is the main object responsible of generating shadows in the framework.
  16688. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16689. */
  16690. export class ShadowGenerator implements IShadowGenerator {
  16691. /**
  16692. * Name of the shadow generator class
  16693. */
  16694. static CLASSNAME: string;
  16695. /**
  16696. * Shadow generator mode None: no filtering applied.
  16697. */
  16698. static readonly FILTER_NONE: number;
  16699. /**
  16700. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16701. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16702. */
  16703. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16704. /**
  16705. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16706. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16707. */
  16708. static readonly FILTER_POISSONSAMPLING: number;
  16709. /**
  16710. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16711. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16712. */
  16713. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16714. /**
  16715. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16716. * edge artifacts on steep falloff.
  16717. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16718. */
  16719. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16720. /**
  16721. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16722. * edge artifacts on steep falloff.
  16723. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16724. */
  16725. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16726. /**
  16727. * Shadow generator mode PCF: Percentage Closer Filtering
  16728. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16729. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16730. */
  16731. static readonly FILTER_PCF: number;
  16732. /**
  16733. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16734. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16735. * Contact Hardening
  16736. */
  16737. static readonly FILTER_PCSS: number;
  16738. /**
  16739. * Reserved for PCF and PCSS
  16740. * Highest Quality.
  16741. *
  16742. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16743. *
  16744. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16745. */
  16746. static readonly QUALITY_HIGH: number;
  16747. /**
  16748. * Reserved for PCF and PCSS
  16749. * Good tradeoff for quality/perf cross devices
  16750. *
  16751. * Execute PCF on a 3*3 kernel.
  16752. *
  16753. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16754. */
  16755. static readonly QUALITY_MEDIUM: number;
  16756. /**
  16757. * Reserved for PCF and PCSS
  16758. * The lowest quality but the fastest.
  16759. *
  16760. * Execute PCF on a 1*1 kernel.
  16761. *
  16762. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16763. */
  16764. static readonly QUALITY_LOW: number;
  16765. /** Gets or sets the custom shader name to use */
  16766. customShaderOptions: ICustomShaderOptions;
  16767. /**
  16768. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16769. */
  16770. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16771. /**
  16772. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16773. */
  16774. onAfterShadowMapRenderObservable: Observable<Effect>;
  16775. /**
  16776. * Observable triggered before a mesh is rendered in the shadow map.
  16777. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16778. */
  16779. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16780. /**
  16781. * Observable triggered after a mesh is rendered in the shadow map.
  16782. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16783. */
  16784. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16785. protected _bias: number;
  16786. /**
  16787. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16788. */
  16789. get bias(): number;
  16790. /**
  16791. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16792. */
  16793. set bias(bias: number);
  16794. protected _normalBias: number;
  16795. /**
  16796. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16797. */
  16798. get normalBias(): number;
  16799. /**
  16800. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16801. */
  16802. set normalBias(normalBias: number);
  16803. protected _blurBoxOffset: number;
  16804. /**
  16805. * Gets the blur box offset: offset applied during the blur pass.
  16806. * Only useful if useKernelBlur = false
  16807. */
  16808. get blurBoxOffset(): number;
  16809. /**
  16810. * Sets the blur box offset: offset applied during the blur pass.
  16811. * Only useful if useKernelBlur = false
  16812. */
  16813. set blurBoxOffset(value: number);
  16814. protected _blurScale: number;
  16815. /**
  16816. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16817. * 2 means half of the size.
  16818. */
  16819. get blurScale(): number;
  16820. /**
  16821. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16822. * 2 means half of the size.
  16823. */
  16824. set blurScale(value: number);
  16825. protected _blurKernel: number;
  16826. /**
  16827. * Gets the blur kernel: kernel size of the blur pass.
  16828. * Only useful if useKernelBlur = true
  16829. */
  16830. get blurKernel(): number;
  16831. /**
  16832. * Sets the blur kernel: kernel size of the blur pass.
  16833. * Only useful if useKernelBlur = true
  16834. */
  16835. set blurKernel(value: number);
  16836. protected _useKernelBlur: boolean;
  16837. /**
  16838. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16839. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16840. */
  16841. get useKernelBlur(): boolean;
  16842. /**
  16843. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16844. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16845. */
  16846. set useKernelBlur(value: boolean);
  16847. protected _depthScale: number;
  16848. /**
  16849. * Gets the depth scale used in ESM mode.
  16850. */
  16851. get depthScale(): number;
  16852. /**
  16853. * Sets the depth scale used in ESM mode.
  16854. * This can override the scale stored on the light.
  16855. */
  16856. set depthScale(value: number);
  16857. protected _validateFilter(filter: number): number;
  16858. protected _filter: number;
  16859. /**
  16860. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16861. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16862. */
  16863. get filter(): number;
  16864. /**
  16865. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16866. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16867. */
  16868. set filter(value: number);
  16869. /**
  16870. * Gets if the current filter is set to Poisson Sampling.
  16871. */
  16872. get usePoissonSampling(): boolean;
  16873. /**
  16874. * Sets the current filter to Poisson Sampling.
  16875. */
  16876. set usePoissonSampling(value: boolean);
  16877. /**
  16878. * Gets if the current filter is set to ESM.
  16879. */
  16880. get useExponentialShadowMap(): boolean;
  16881. /**
  16882. * Sets the current filter is to ESM.
  16883. */
  16884. set useExponentialShadowMap(value: boolean);
  16885. /**
  16886. * Gets if the current filter is set to filtered ESM.
  16887. */
  16888. get useBlurExponentialShadowMap(): boolean;
  16889. /**
  16890. * Gets if the current filter is set to filtered ESM.
  16891. */
  16892. set useBlurExponentialShadowMap(value: boolean);
  16893. /**
  16894. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16895. * exponential to prevent steep falloff artifacts).
  16896. */
  16897. get useCloseExponentialShadowMap(): boolean;
  16898. /**
  16899. * Sets the current filter to "close ESM" (using the inverse of the
  16900. * exponential to prevent steep falloff artifacts).
  16901. */
  16902. set useCloseExponentialShadowMap(value: boolean);
  16903. /**
  16904. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16905. * exponential to prevent steep falloff artifacts).
  16906. */
  16907. get useBlurCloseExponentialShadowMap(): boolean;
  16908. /**
  16909. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16910. * exponential to prevent steep falloff artifacts).
  16911. */
  16912. set useBlurCloseExponentialShadowMap(value: boolean);
  16913. /**
  16914. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16915. */
  16916. get usePercentageCloserFiltering(): boolean;
  16917. /**
  16918. * Sets the current filter to "PCF" (percentage closer filtering).
  16919. */
  16920. set usePercentageCloserFiltering(value: boolean);
  16921. protected _filteringQuality: number;
  16922. /**
  16923. * Gets the PCF or PCSS Quality.
  16924. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16925. */
  16926. get filteringQuality(): number;
  16927. /**
  16928. * Sets the PCF or PCSS Quality.
  16929. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16930. */
  16931. set filteringQuality(filteringQuality: number);
  16932. /**
  16933. * Gets if the current filter is set to "PCSS" (contact hardening).
  16934. */
  16935. get useContactHardeningShadow(): boolean;
  16936. /**
  16937. * Sets the current filter to "PCSS" (contact hardening).
  16938. */
  16939. set useContactHardeningShadow(value: boolean);
  16940. protected _contactHardeningLightSizeUVRatio: number;
  16941. /**
  16942. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16943. * Using a ratio helps keeping shape stability independently of the map size.
  16944. *
  16945. * It does not account for the light projection as it was having too much
  16946. * instability during the light setup or during light position changes.
  16947. *
  16948. * Only valid if useContactHardeningShadow is true.
  16949. */
  16950. get contactHardeningLightSizeUVRatio(): number;
  16951. /**
  16952. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16953. * Using a ratio helps keeping shape stability independently of the map size.
  16954. *
  16955. * It does not account for the light projection as it was having too much
  16956. * instability during the light setup or during light position changes.
  16957. *
  16958. * Only valid if useContactHardeningShadow is true.
  16959. */
  16960. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16961. protected _darkness: number;
  16962. /** Gets or sets the actual darkness of a shadow */
  16963. get darkness(): number;
  16964. set darkness(value: number);
  16965. /**
  16966. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16967. * 0 means strongest and 1 would means no shadow.
  16968. * @returns the darkness.
  16969. */
  16970. getDarkness(): number;
  16971. /**
  16972. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16973. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16974. * @returns the shadow generator allowing fluent coding.
  16975. */
  16976. setDarkness(darkness: number): ShadowGenerator;
  16977. protected _transparencyShadow: boolean;
  16978. /** Gets or sets the ability to have transparent shadow */
  16979. get transparencyShadow(): boolean;
  16980. set transparencyShadow(value: boolean);
  16981. /**
  16982. * Sets the ability to have transparent shadow (boolean).
  16983. * @param transparent True if transparent else False
  16984. * @returns the shadow generator allowing fluent coding
  16985. */
  16986. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16987. protected _shadowMap: Nullable<RenderTargetTexture>;
  16988. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16989. /**
  16990. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16991. * @returns The render target texture if present otherwise, null
  16992. */
  16993. getShadowMap(): Nullable<RenderTargetTexture>;
  16994. /**
  16995. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16996. * @returns The render target texture if the shadow map is present otherwise, null
  16997. */
  16998. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16999. /**
  17000. * Gets the class name of that object
  17001. * @returns "ShadowGenerator"
  17002. */
  17003. getClassName(): string;
  17004. /**
  17005. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17006. * @param mesh Mesh to add
  17007. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17008. * @returns the Shadow Generator itself
  17009. */
  17010. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17011. /**
  17012. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17013. * @param mesh Mesh to remove
  17014. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17015. * @returns the Shadow Generator itself
  17016. */
  17017. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17018. /**
  17019. * Controls the extent to which the shadows fade out at the edge of the frustum
  17020. */
  17021. frustumEdgeFalloff: number;
  17022. protected _light: IShadowLight;
  17023. /**
  17024. * Returns the associated light object.
  17025. * @returns the light generating the shadow
  17026. */
  17027. getLight(): IShadowLight;
  17028. /**
  17029. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17030. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17031. * It might on the other hand introduce peter panning.
  17032. */
  17033. forceBackFacesOnly: boolean;
  17034. protected _scene: Scene;
  17035. protected _lightDirection: Vector3;
  17036. protected _effect: Effect;
  17037. protected _viewMatrix: Matrix;
  17038. protected _projectionMatrix: Matrix;
  17039. protected _transformMatrix: Matrix;
  17040. protected _cachedPosition: Vector3;
  17041. protected _cachedDirection: Vector3;
  17042. protected _cachedDefines: string;
  17043. protected _currentRenderID: number;
  17044. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17045. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17046. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17047. protected _blurPostProcesses: PostProcess[];
  17048. protected _mapSize: number;
  17049. protected _currentFaceIndex: number;
  17050. protected _currentFaceIndexCache: number;
  17051. protected _textureType: number;
  17052. protected _defaultTextureMatrix: Matrix;
  17053. protected _storedUniqueId: Nullable<number>;
  17054. /** @hidden */
  17055. static _SceneComponentInitialization: (scene: Scene) => void;
  17056. /**
  17057. * Creates a ShadowGenerator object.
  17058. * A ShadowGenerator is the required tool to use the shadows.
  17059. * Each light casting shadows needs to use its own ShadowGenerator.
  17060. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17061. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17062. * @param light The light object generating the shadows.
  17063. * @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.
  17064. */
  17065. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17066. protected _initializeGenerator(): void;
  17067. protected _createTargetRenderTexture(): void;
  17068. protected _initializeShadowMap(): void;
  17069. protected _initializeBlurRTTAndPostProcesses(): void;
  17070. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17071. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17072. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17073. protected _applyFilterValues(): void;
  17074. /**
  17075. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17076. * @param onCompiled Callback triggered at the and of the effects compilation
  17077. * @param options Sets of optional options forcing the compilation with different modes
  17078. */
  17079. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17080. useInstances: boolean;
  17081. }>): void;
  17082. /**
  17083. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17084. * @param options Sets of optional options forcing the compilation with different modes
  17085. * @returns A promise that resolves when the compilation completes
  17086. */
  17087. forceCompilationAsync(options?: Partial<{
  17088. useInstances: boolean;
  17089. }>): Promise<void>;
  17090. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17091. /**
  17092. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17093. * @param subMesh The submesh we want to render in the shadow map
  17094. * @param useInstances Defines wether will draw in the map using instances
  17095. * @returns true if ready otherwise, false
  17096. */
  17097. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17098. /**
  17099. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17100. * @param defines Defines of the material we want to update
  17101. * @param lightIndex Index of the light in the enabled light list of the material
  17102. */
  17103. prepareDefines(defines: any, lightIndex: number): void;
  17104. /**
  17105. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17106. * defined in the generator but impacting the effect).
  17107. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17108. * @param effect The effect we are binfing the information for
  17109. */
  17110. bindShadowLight(lightIndex: string, effect: Effect): void;
  17111. /**
  17112. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17113. * (eq to shadow prjection matrix * light transform matrix)
  17114. * @returns The transform matrix used to create the shadow map
  17115. */
  17116. getTransformMatrix(): Matrix;
  17117. /**
  17118. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17119. * Cube and 2D textures for instance.
  17120. */
  17121. recreateShadowMap(): void;
  17122. protected _disposeBlurPostProcesses(): void;
  17123. protected _disposeRTTandPostProcesses(): void;
  17124. /**
  17125. * Disposes the ShadowGenerator.
  17126. * Returns nothing.
  17127. */
  17128. dispose(): void;
  17129. /**
  17130. * Serializes the shadow generator setup to a json object.
  17131. * @returns The serialized JSON object
  17132. */
  17133. serialize(): any;
  17134. /**
  17135. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17136. * @param parsedShadowGenerator The JSON object to parse
  17137. * @param scene The scene to create the shadow map for
  17138. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17139. * @returns The parsed shadow generator
  17140. */
  17141. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17142. }
  17143. }
  17144. declare module "babylonjs/Lights/light" {
  17145. import { Nullable } from "babylonjs/types";
  17146. import { Scene } from "babylonjs/scene";
  17147. import { Vector3 } from "babylonjs/Maths/math.vector";
  17148. import { Color3 } from "babylonjs/Maths/math.color";
  17149. import { Node } from "babylonjs/node";
  17150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17151. import { Effect } from "babylonjs/Materials/effect";
  17152. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17153. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17154. /**
  17155. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17156. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17157. * 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.
  17158. */
  17159. export abstract class Light extends Node {
  17160. /**
  17161. * Falloff Default: light is falling off following the material specification:
  17162. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17163. */
  17164. static readonly FALLOFF_DEFAULT: number;
  17165. /**
  17166. * Falloff Physical: light is falling off following the inverse squared distance law.
  17167. */
  17168. static readonly FALLOFF_PHYSICAL: number;
  17169. /**
  17170. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17171. * to enhance interoperability with other engines.
  17172. */
  17173. static readonly FALLOFF_GLTF: number;
  17174. /**
  17175. * Falloff Standard: light is falling off like in the standard material
  17176. * to enhance interoperability with other materials.
  17177. */
  17178. static readonly FALLOFF_STANDARD: number;
  17179. /**
  17180. * If every light affecting the material is in this lightmapMode,
  17181. * material.lightmapTexture adds or multiplies
  17182. * (depends on material.useLightmapAsShadowmap)
  17183. * after every other light calculations.
  17184. */
  17185. static readonly LIGHTMAP_DEFAULT: number;
  17186. /**
  17187. * material.lightmapTexture as only diffuse lighting from this light
  17188. * adds only specular lighting from this light
  17189. * adds dynamic shadows
  17190. */
  17191. static readonly LIGHTMAP_SPECULAR: number;
  17192. /**
  17193. * material.lightmapTexture as only lighting
  17194. * no light calculation from this light
  17195. * only adds dynamic shadows from this light
  17196. */
  17197. static readonly LIGHTMAP_SHADOWSONLY: number;
  17198. /**
  17199. * Each light type uses the default quantity according to its type:
  17200. * point/spot lights use luminous intensity
  17201. * directional lights use illuminance
  17202. */
  17203. static readonly INTENSITYMODE_AUTOMATIC: number;
  17204. /**
  17205. * lumen (lm)
  17206. */
  17207. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17208. /**
  17209. * candela (lm/sr)
  17210. */
  17211. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17212. /**
  17213. * lux (lm/m^2)
  17214. */
  17215. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17216. /**
  17217. * nit (cd/m^2)
  17218. */
  17219. static readonly INTENSITYMODE_LUMINANCE: number;
  17220. /**
  17221. * Light type const id of the point light.
  17222. */
  17223. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17224. /**
  17225. * Light type const id of the directional light.
  17226. */
  17227. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17228. /**
  17229. * Light type const id of the spot light.
  17230. */
  17231. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17232. /**
  17233. * Light type const id of the hemispheric light.
  17234. */
  17235. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17236. /**
  17237. * Diffuse gives the basic color to an object.
  17238. */
  17239. diffuse: Color3;
  17240. /**
  17241. * Specular produces a highlight color on an object.
  17242. * Note: This is note affecting PBR materials.
  17243. */
  17244. specular: Color3;
  17245. /**
  17246. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17247. * falling off base on range or angle.
  17248. * This can be set to any values in Light.FALLOFF_x.
  17249. *
  17250. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17251. * other types of materials.
  17252. */
  17253. falloffType: number;
  17254. /**
  17255. * Strength of the light.
  17256. * Note: By default it is define in the framework own unit.
  17257. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17258. */
  17259. intensity: number;
  17260. private _range;
  17261. protected _inverseSquaredRange: number;
  17262. /**
  17263. * Defines how far from the source the light is impacting in scene units.
  17264. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17265. */
  17266. get range(): number;
  17267. /**
  17268. * Defines how far from the source the light is impacting in scene units.
  17269. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17270. */
  17271. set range(value: number);
  17272. /**
  17273. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17274. * of light.
  17275. */
  17276. private _photometricScale;
  17277. private _intensityMode;
  17278. /**
  17279. * Gets the photometric scale used to interpret the intensity.
  17280. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17281. */
  17282. get intensityMode(): number;
  17283. /**
  17284. * Sets the photometric scale used to interpret the intensity.
  17285. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17286. */
  17287. set intensityMode(value: number);
  17288. private _radius;
  17289. /**
  17290. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17291. */
  17292. get radius(): number;
  17293. /**
  17294. * sets the light radius used by PBR Materials to simulate soft area lights.
  17295. */
  17296. set radius(value: number);
  17297. private _renderPriority;
  17298. /**
  17299. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17300. * exceeding the number allowed of the materials.
  17301. */
  17302. renderPriority: number;
  17303. private _shadowEnabled;
  17304. /**
  17305. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17306. * the current shadow generator.
  17307. */
  17308. get shadowEnabled(): boolean;
  17309. /**
  17310. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17311. * the current shadow generator.
  17312. */
  17313. set shadowEnabled(value: boolean);
  17314. private _includedOnlyMeshes;
  17315. /**
  17316. * Gets the only meshes impacted by this light.
  17317. */
  17318. get includedOnlyMeshes(): AbstractMesh[];
  17319. /**
  17320. * Sets the only meshes impacted by this light.
  17321. */
  17322. set includedOnlyMeshes(value: AbstractMesh[]);
  17323. private _excludedMeshes;
  17324. /**
  17325. * Gets the meshes not impacted by this light.
  17326. */
  17327. get excludedMeshes(): AbstractMesh[];
  17328. /**
  17329. * Sets the meshes not impacted by this light.
  17330. */
  17331. set excludedMeshes(value: AbstractMesh[]);
  17332. private _excludeWithLayerMask;
  17333. /**
  17334. * Gets the layer id use to find what meshes are not impacted by the light.
  17335. * Inactive if 0
  17336. */
  17337. get excludeWithLayerMask(): number;
  17338. /**
  17339. * Sets the layer id use to find what meshes are not impacted by the light.
  17340. * Inactive if 0
  17341. */
  17342. set excludeWithLayerMask(value: number);
  17343. private _includeOnlyWithLayerMask;
  17344. /**
  17345. * Gets the layer id use to find what meshes are impacted by the light.
  17346. * Inactive if 0
  17347. */
  17348. get includeOnlyWithLayerMask(): number;
  17349. /**
  17350. * Sets the layer id use to find what meshes are impacted by the light.
  17351. * Inactive if 0
  17352. */
  17353. set includeOnlyWithLayerMask(value: number);
  17354. private _lightmapMode;
  17355. /**
  17356. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17357. */
  17358. get lightmapMode(): number;
  17359. /**
  17360. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17361. */
  17362. set lightmapMode(value: number);
  17363. /**
  17364. * Shadow generator associted to the light.
  17365. * @hidden Internal use only.
  17366. */
  17367. _shadowGenerator: Nullable<IShadowGenerator>;
  17368. /**
  17369. * @hidden Internal use only.
  17370. */
  17371. _excludedMeshesIds: string[];
  17372. /**
  17373. * @hidden Internal use only.
  17374. */
  17375. _includedOnlyMeshesIds: string[];
  17376. /**
  17377. * The current light unifom buffer.
  17378. * @hidden Internal use only.
  17379. */
  17380. _uniformBuffer: UniformBuffer;
  17381. /** @hidden */
  17382. _renderId: number;
  17383. /**
  17384. * Creates a Light object in the scene.
  17385. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17386. * @param name The firendly name of the light
  17387. * @param scene The scene the light belongs too
  17388. */
  17389. constructor(name: string, scene: Scene);
  17390. protected abstract _buildUniformLayout(): void;
  17391. /**
  17392. * Sets the passed Effect "effect" with the Light information.
  17393. * @param effect The effect to update
  17394. * @param lightIndex The index of the light in the effect to update
  17395. * @returns The light
  17396. */
  17397. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17398. /**
  17399. * Sets the passed Effect "effect" with the Light textures.
  17400. * @param effect The effect to update
  17401. * @param lightIndex The index of the light in the effect to update
  17402. * @returns The light
  17403. */
  17404. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17405. /**
  17406. * Binds the lights information from the scene to the effect for the given mesh.
  17407. * @param lightIndex Light index
  17408. * @param scene The scene where the light belongs to
  17409. * @param effect The effect we are binding the data to
  17410. * @param useSpecular Defines if specular is supported
  17411. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17412. */
  17413. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17414. /**
  17415. * Sets the passed Effect "effect" with the Light information.
  17416. * @param effect The effect to update
  17417. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17418. * @returns The light
  17419. */
  17420. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17421. /**
  17422. * Returns the string "Light".
  17423. * @returns the class name
  17424. */
  17425. getClassName(): string;
  17426. /** @hidden */
  17427. readonly _isLight: boolean;
  17428. /**
  17429. * Converts the light information to a readable string for debug purpose.
  17430. * @param fullDetails Supports for multiple levels of logging within scene loading
  17431. * @returns the human readable light info
  17432. */
  17433. toString(fullDetails?: boolean): string;
  17434. /** @hidden */
  17435. protected _syncParentEnabledState(): void;
  17436. /**
  17437. * Set the enabled state of this node.
  17438. * @param value - the new enabled state
  17439. */
  17440. setEnabled(value: boolean): void;
  17441. /**
  17442. * Returns the Light associated shadow generator if any.
  17443. * @return the associated shadow generator.
  17444. */
  17445. getShadowGenerator(): Nullable<IShadowGenerator>;
  17446. /**
  17447. * Returns a Vector3, the absolute light position in the World.
  17448. * @returns the world space position of the light
  17449. */
  17450. getAbsolutePosition(): Vector3;
  17451. /**
  17452. * Specifies if the light will affect the passed mesh.
  17453. * @param mesh The mesh to test against the light
  17454. * @return true the mesh is affected otherwise, false.
  17455. */
  17456. canAffectMesh(mesh: AbstractMesh): boolean;
  17457. /**
  17458. * Sort function to order lights for rendering.
  17459. * @param a First Light object to compare to second.
  17460. * @param b Second Light object to compare first.
  17461. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17462. */
  17463. static CompareLightsPriority(a: Light, b: Light): number;
  17464. /**
  17465. * Releases resources associated with this node.
  17466. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17467. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17468. */
  17469. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17470. /**
  17471. * Returns the light type ID (integer).
  17472. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17473. */
  17474. getTypeID(): number;
  17475. /**
  17476. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17477. * @returns the scaled intensity in intensity mode unit
  17478. */
  17479. getScaledIntensity(): number;
  17480. /**
  17481. * Returns a new Light object, named "name", from the current one.
  17482. * @param name The name of the cloned light
  17483. * @returns the new created light
  17484. */
  17485. clone(name: string): Nullable<Light>;
  17486. /**
  17487. * Serializes the current light into a Serialization object.
  17488. * @returns the serialized object.
  17489. */
  17490. serialize(): any;
  17491. /**
  17492. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17493. * This new light is named "name" and added to the passed scene.
  17494. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17495. * @param name The friendly name of the light
  17496. * @param scene The scene the new light will belong to
  17497. * @returns the constructor function
  17498. */
  17499. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17500. /**
  17501. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17502. * @param parsedLight The JSON representation of the light
  17503. * @param scene The scene to create the parsed light in
  17504. * @returns the created light after parsing
  17505. */
  17506. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17507. private _hookArrayForExcluded;
  17508. private _hookArrayForIncludedOnly;
  17509. private _resyncMeshes;
  17510. /**
  17511. * Forces the meshes to update their light related information in their rendering used effects
  17512. * @hidden Internal Use Only
  17513. */
  17514. _markMeshesAsLightDirty(): void;
  17515. /**
  17516. * Recomputes the cached photometric scale if needed.
  17517. */
  17518. private _computePhotometricScale;
  17519. /**
  17520. * Returns the Photometric Scale according to the light type and intensity mode.
  17521. */
  17522. private _getPhotometricScale;
  17523. /**
  17524. * Reorder the light in the scene according to their defined priority.
  17525. * @hidden Internal Use Only
  17526. */
  17527. _reorderLightsInScene(): void;
  17528. /**
  17529. * Prepares the list of defines specific to the light type.
  17530. * @param defines the list of defines
  17531. * @param lightIndex defines the index of the light for the effect
  17532. */
  17533. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17534. }
  17535. }
  17536. declare module "babylonjs/Actions/action" {
  17537. import { Observable } from "babylonjs/Misc/observable";
  17538. import { Condition } from "babylonjs/Actions/condition";
  17539. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17540. import { ActionManager } from "babylonjs/Actions/actionManager";
  17541. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17542. /**
  17543. * Interface used to define Action
  17544. */
  17545. export interface IAction {
  17546. /**
  17547. * Trigger for the action
  17548. */
  17549. trigger: number;
  17550. /** Options of the trigger */
  17551. triggerOptions: any;
  17552. /**
  17553. * Gets the trigger parameters
  17554. * @returns the trigger parameters
  17555. */
  17556. getTriggerParameter(): any;
  17557. /**
  17558. * Internal only - executes current action event
  17559. * @hidden
  17560. */
  17561. _executeCurrent(evt?: ActionEvent): void;
  17562. /**
  17563. * Serialize placeholder for child classes
  17564. * @param parent of child
  17565. * @returns the serialized object
  17566. */
  17567. serialize(parent: any): any;
  17568. /**
  17569. * Internal only
  17570. * @hidden
  17571. */
  17572. _prepare(): void;
  17573. /**
  17574. * Internal only - manager for action
  17575. * @hidden
  17576. */
  17577. _actionManager: AbstractActionManager;
  17578. /**
  17579. * Adds action to chain of actions, may be a DoNothingAction
  17580. * @param action defines the next action to execute
  17581. * @returns The action passed in
  17582. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17583. */
  17584. then(action: IAction): IAction;
  17585. }
  17586. /**
  17587. * The action to be carried out following a trigger
  17588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17589. */
  17590. export class Action implements IAction {
  17591. /** the trigger, with or without parameters, for the action */
  17592. triggerOptions: any;
  17593. /**
  17594. * Trigger for the action
  17595. */
  17596. trigger: number;
  17597. /**
  17598. * Internal only - manager for action
  17599. * @hidden
  17600. */
  17601. _actionManager: ActionManager;
  17602. private _nextActiveAction;
  17603. private _child;
  17604. private _condition?;
  17605. private _triggerParameter;
  17606. /**
  17607. * An event triggered prior to action being executed.
  17608. */
  17609. onBeforeExecuteObservable: Observable<Action>;
  17610. /**
  17611. * Creates a new Action
  17612. * @param triggerOptions the trigger, with or without parameters, for the action
  17613. * @param condition an optional determinant of action
  17614. */
  17615. constructor(
  17616. /** the trigger, with or without parameters, for the action */
  17617. triggerOptions: any, condition?: Condition);
  17618. /**
  17619. * Internal only
  17620. * @hidden
  17621. */
  17622. _prepare(): void;
  17623. /**
  17624. * Gets the trigger parameters
  17625. * @returns the trigger parameters
  17626. */
  17627. getTriggerParameter(): any;
  17628. /**
  17629. * Internal only - executes current action event
  17630. * @hidden
  17631. */
  17632. _executeCurrent(evt?: ActionEvent): void;
  17633. /**
  17634. * Execute placeholder for child classes
  17635. * @param evt optional action event
  17636. */
  17637. execute(evt?: ActionEvent): void;
  17638. /**
  17639. * Skips to next active action
  17640. */
  17641. skipToNextActiveAction(): void;
  17642. /**
  17643. * Adds action to chain of actions, may be a DoNothingAction
  17644. * @param action defines the next action to execute
  17645. * @returns The action passed in
  17646. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17647. */
  17648. then(action: Action): Action;
  17649. /**
  17650. * Internal only
  17651. * @hidden
  17652. */
  17653. _getProperty(propertyPath: string): string;
  17654. /**
  17655. * Internal only
  17656. * @hidden
  17657. */
  17658. _getEffectiveTarget(target: any, propertyPath: string): any;
  17659. /**
  17660. * Serialize placeholder for child classes
  17661. * @param parent of child
  17662. * @returns the serialized object
  17663. */
  17664. serialize(parent: any): any;
  17665. /**
  17666. * Internal only called by serialize
  17667. * @hidden
  17668. */
  17669. protected _serialize(serializedAction: any, parent?: any): any;
  17670. /**
  17671. * Internal only
  17672. * @hidden
  17673. */
  17674. static _SerializeValueAsString: (value: any) => string;
  17675. /**
  17676. * Internal only
  17677. * @hidden
  17678. */
  17679. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17680. name: string;
  17681. targetType: string;
  17682. value: string;
  17683. };
  17684. }
  17685. }
  17686. declare module "babylonjs/Actions/condition" {
  17687. import { ActionManager } from "babylonjs/Actions/actionManager";
  17688. /**
  17689. * A Condition applied to an Action
  17690. */
  17691. export class Condition {
  17692. /**
  17693. * Internal only - manager for action
  17694. * @hidden
  17695. */
  17696. _actionManager: ActionManager;
  17697. /**
  17698. * Internal only
  17699. * @hidden
  17700. */
  17701. _evaluationId: number;
  17702. /**
  17703. * Internal only
  17704. * @hidden
  17705. */
  17706. _currentResult: boolean;
  17707. /**
  17708. * Creates a new Condition
  17709. * @param actionManager the manager of the action the condition is applied to
  17710. */
  17711. constructor(actionManager: ActionManager);
  17712. /**
  17713. * Check if the current condition is valid
  17714. * @returns a boolean
  17715. */
  17716. isValid(): boolean;
  17717. /**
  17718. * Internal only
  17719. * @hidden
  17720. */
  17721. _getProperty(propertyPath: string): string;
  17722. /**
  17723. * Internal only
  17724. * @hidden
  17725. */
  17726. _getEffectiveTarget(target: any, propertyPath: string): any;
  17727. /**
  17728. * Serialize placeholder for child classes
  17729. * @returns the serialized object
  17730. */
  17731. serialize(): any;
  17732. /**
  17733. * Internal only
  17734. * @hidden
  17735. */
  17736. protected _serialize(serializedCondition: any): any;
  17737. }
  17738. /**
  17739. * Defines specific conditional operators as extensions of Condition
  17740. */
  17741. export class ValueCondition extends Condition {
  17742. /** path to specify the property of the target the conditional operator uses */
  17743. propertyPath: string;
  17744. /** the value compared by the conditional operator against the current value of the property */
  17745. value: any;
  17746. /** the conditional operator, default ValueCondition.IsEqual */
  17747. operator: number;
  17748. /**
  17749. * Internal only
  17750. * @hidden
  17751. */
  17752. private static _IsEqual;
  17753. /**
  17754. * Internal only
  17755. * @hidden
  17756. */
  17757. private static _IsDifferent;
  17758. /**
  17759. * Internal only
  17760. * @hidden
  17761. */
  17762. private static _IsGreater;
  17763. /**
  17764. * Internal only
  17765. * @hidden
  17766. */
  17767. private static _IsLesser;
  17768. /**
  17769. * returns the number for IsEqual
  17770. */
  17771. static get IsEqual(): number;
  17772. /**
  17773. * Returns the number for IsDifferent
  17774. */
  17775. static get IsDifferent(): number;
  17776. /**
  17777. * Returns the number for IsGreater
  17778. */
  17779. static get IsGreater(): number;
  17780. /**
  17781. * Returns the number for IsLesser
  17782. */
  17783. static get IsLesser(): number;
  17784. /**
  17785. * Internal only The action manager for the condition
  17786. * @hidden
  17787. */
  17788. _actionManager: ActionManager;
  17789. /**
  17790. * Internal only
  17791. * @hidden
  17792. */
  17793. private _target;
  17794. /**
  17795. * Internal only
  17796. * @hidden
  17797. */
  17798. private _effectiveTarget;
  17799. /**
  17800. * Internal only
  17801. * @hidden
  17802. */
  17803. private _property;
  17804. /**
  17805. * Creates a new ValueCondition
  17806. * @param actionManager manager for the action the condition applies to
  17807. * @param target for the action
  17808. * @param propertyPath path to specify the property of the target the conditional operator uses
  17809. * @param value the value compared by the conditional operator against the current value of the property
  17810. * @param operator the conditional operator, default ValueCondition.IsEqual
  17811. */
  17812. constructor(actionManager: ActionManager, target: any,
  17813. /** path to specify the property of the target the conditional operator uses */
  17814. propertyPath: string,
  17815. /** the value compared by the conditional operator against the current value of the property */
  17816. value: any,
  17817. /** the conditional operator, default ValueCondition.IsEqual */
  17818. operator?: number);
  17819. /**
  17820. * Compares the given value with the property value for the specified conditional operator
  17821. * @returns the result of the comparison
  17822. */
  17823. isValid(): boolean;
  17824. /**
  17825. * Serialize the ValueCondition into a JSON compatible object
  17826. * @returns serialization object
  17827. */
  17828. serialize(): any;
  17829. /**
  17830. * Gets the name of the conditional operator for the ValueCondition
  17831. * @param operator the conditional operator
  17832. * @returns the name
  17833. */
  17834. static GetOperatorName(operator: number): string;
  17835. }
  17836. /**
  17837. * Defines a predicate condition as an extension of Condition
  17838. */
  17839. export class PredicateCondition extends Condition {
  17840. /** defines the predicate function used to validate the condition */
  17841. predicate: () => boolean;
  17842. /**
  17843. * Internal only - manager for action
  17844. * @hidden
  17845. */
  17846. _actionManager: ActionManager;
  17847. /**
  17848. * Creates a new PredicateCondition
  17849. * @param actionManager manager for the action the condition applies to
  17850. * @param predicate defines the predicate function used to validate the condition
  17851. */
  17852. constructor(actionManager: ActionManager,
  17853. /** defines the predicate function used to validate the condition */
  17854. predicate: () => boolean);
  17855. /**
  17856. * @returns the validity of the predicate condition
  17857. */
  17858. isValid(): boolean;
  17859. }
  17860. /**
  17861. * Defines a state condition as an extension of Condition
  17862. */
  17863. export class StateCondition extends Condition {
  17864. /** Value to compare with target state */
  17865. value: string;
  17866. /**
  17867. * Internal only - manager for action
  17868. * @hidden
  17869. */
  17870. _actionManager: ActionManager;
  17871. /**
  17872. * Internal only
  17873. * @hidden
  17874. */
  17875. private _target;
  17876. /**
  17877. * Creates a new StateCondition
  17878. * @param actionManager manager for the action the condition applies to
  17879. * @param target of the condition
  17880. * @param value to compare with target state
  17881. */
  17882. constructor(actionManager: ActionManager, target: any,
  17883. /** Value to compare with target state */
  17884. value: string);
  17885. /**
  17886. * Gets a boolean indicating if the current condition is met
  17887. * @returns the validity of the state
  17888. */
  17889. isValid(): boolean;
  17890. /**
  17891. * Serialize the StateCondition into a JSON compatible object
  17892. * @returns serialization object
  17893. */
  17894. serialize(): any;
  17895. }
  17896. }
  17897. declare module "babylonjs/Actions/directActions" {
  17898. import { Action } from "babylonjs/Actions/action";
  17899. import { Condition } from "babylonjs/Actions/condition";
  17900. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17901. /**
  17902. * This defines an action responsible to toggle a boolean once triggered.
  17903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17904. */
  17905. export class SwitchBooleanAction extends Action {
  17906. /**
  17907. * The path to the boolean property in the target object
  17908. */
  17909. propertyPath: string;
  17910. private _target;
  17911. private _effectiveTarget;
  17912. private _property;
  17913. /**
  17914. * Instantiate the action
  17915. * @param triggerOptions defines the trigger options
  17916. * @param target defines the object containing the boolean
  17917. * @param propertyPath defines the path to the boolean property in the target object
  17918. * @param condition defines the trigger related conditions
  17919. */
  17920. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17921. /** @hidden */
  17922. _prepare(): void;
  17923. /**
  17924. * Execute the action toggle the boolean value.
  17925. */
  17926. execute(): void;
  17927. /**
  17928. * Serializes the actions and its related information.
  17929. * @param parent defines the object to serialize in
  17930. * @returns the serialized object
  17931. */
  17932. serialize(parent: any): any;
  17933. }
  17934. /**
  17935. * This defines an action responsible to set a the state field of the target
  17936. * to a desired value once triggered.
  17937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17938. */
  17939. export class SetStateAction extends Action {
  17940. /**
  17941. * The value to store in the state field.
  17942. */
  17943. value: string;
  17944. private _target;
  17945. /**
  17946. * Instantiate the action
  17947. * @param triggerOptions defines the trigger options
  17948. * @param target defines the object containing the state property
  17949. * @param value defines the value to store in the state field
  17950. * @param condition defines the trigger related conditions
  17951. */
  17952. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17953. /**
  17954. * Execute the action and store the value on the target state property.
  17955. */
  17956. execute(): void;
  17957. /**
  17958. * Serializes the actions and its related information.
  17959. * @param parent defines the object to serialize in
  17960. * @returns the serialized object
  17961. */
  17962. serialize(parent: any): any;
  17963. }
  17964. /**
  17965. * This defines an action responsible to set a property of the target
  17966. * to a desired value once triggered.
  17967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17968. */
  17969. export class SetValueAction extends Action {
  17970. /**
  17971. * The path of the property to set in the target.
  17972. */
  17973. propertyPath: string;
  17974. /**
  17975. * The value to set in the property
  17976. */
  17977. value: any;
  17978. private _target;
  17979. private _effectiveTarget;
  17980. private _property;
  17981. /**
  17982. * Instantiate the action
  17983. * @param triggerOptions defines the trigger options
  17984. * @param target defines the object containing the property
  17985. * @param propertyPath defines the path of the property to set in the target
  17986. * @param value defines the value to set in the property
  17987. * @param condition defines the trigger related conditions
  17988. */
  17989. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17990. /** @hidden */
  17991. _prepare(): void;
  17992. /**
  17993. * Execute the action and set the targetted property to the desired value.
  17994. */
  17995. execute(): void;
  17996. /**
  17997. * Serializes the actions and its related information.
  17998. * @param parent defines the object to serialize in
  17999. * @returns the serialized object
  18000. */
  18001. serialize(parent: any): any;
  18002. }
  18003. /**
  18004. * This defines an action responsible to increment the target value
  18005. * to a desired value once triggered.
  18006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18007. */
  18008. export class IncrementValueAction extends Action {
  18009. /**
  18010. * The path of the property to increment in the target.
  18011. */
  18012. propertyPath: string;
  18013. /**
  18014. * The value we should increment the property by.
  18015. */
  18016. value: any;
  18017. private _target;
  18018. private _effectiveTarget;
  18019. private _property;
  18020. /**
  18021. * Instantiate the action
  18022. * @param triggerOptions defines the trigger options
  18023. * @param target defines the object containing the property
  18024. * @param propertyPath defines the path of the property to increment in the target
  18025. * @param value defines the value value we should increment the property by
  18026. * @param condition defines the trigger related conditions
  18027. */
  18028. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18029. /** @hidden */
  18030. _prepare(): void;
  18031. /**
  18032. * Execute the action and increment the target of the value amount.
  18033. */
  18034. execute(): void;
  18035. /**
  18036. * Serializes the actions and its related information.
  18037. * @param parent defines the object to serialize in
  18038. * @returns the serialized object
  18039. */
  18040. serialize(parent: any): any;
  18041. }
  18042. /**
  18043. * This defines an action responsible to start an animation once triggered.
  18044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18045. */
  18046. export class PlayAnimationAction extends Action {
  18047. /**
  18048. * Where the animation should start (animation frame)
  18049. */
  18050. from: number;
  18051. /**
  18052. * Where the animation should stop (animation frame)
  18053. */
  18054. to: number;
  18055. /**
  18056. * Define if the animation should loop or stop after the first play.
  18057. */
  18058. loop?: boolean;
  18059. private _target;
  18060. /**
  18061. * Instantiate the action
  18062. * @param triggerOptions defines the trigger options
  18063. * @param target defines the target animation or animation name
  18064. * @param from defines from where the animation should start (animation frame)
  18065. * @param end defines where the animation should stop (animation frame)
  18066. * @param loop defines if the animation should loop or stop after the first play
  18067. * @param condition defines the trigger related conditions
  18068. */
  18069. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18070. /** @hidden */
  18071. _prepare(): void;
  18072. /**
  18073. * Execute the action and play the animation.
  18074. */
  18075. execute(): void;
  18076. /**
  18077. * Serializes the actions and its related information.
  18078. * @param parent defines the object to serialize in
  18079. * @returns the serialized object
  18080. */
  18081. serialize(parent: any): any;
  18082. }
  18083. /**
  18084. * This defines an action responsible to stop an animation once triggered.
  18085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18086. */
  18087. export class StopAnimationAction extends Action {
  18088. private _target;
  18089. /**
  18090. * Instantiate the action
  18091. * @param triggerOptions defines the trigger options
  18092. * @param target defines the target animation or animation name
  18093. * @param condition defines the trigger related conditions
  18094. */
  18095. constructor(triggerOptions: any, target: any, condition?: Condition);
  18096. /** @hidden */
  18097. _prepare(): void;
  18098. /**
  18099. * Execute the action and stop the animation.
  18100. */
  18101. execute(): void;
  18102. /**
  18103. * Serializes the actions and its related information.
  18104. * @param parent defines the object to serialize in
  18105. * @returns the serialized object
  18106. */
  18107. serialize(parent: any): any;
  18108. }
  18109. /**
  18110. * This defines an action responsible that does nothing once triggered.
  18111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18112. */
  18113. export class DoNothingAction extends Action {
  18114. /**
  18115. * Instantiate the action
  18116. * @param triggerOptions defines the trigger options
  18117. * @param condition defines the trigger related conditions
  18118. */
  18119. constructor(triggerOptions?: any, condition?: Condition);
  18120. /**
  18121. * Execute the action and do nothing.
  18122. */
  18123. execute(): void;
  18124. /**
  18125. * Serializes the actions and its related information.
  18126. * @param parent defines the object to serialize in
  18127. * @returns the serialized object
  18128. */
  18129. serialize(parent: any): any;
  18130. }
  18131. /**
  18132. * This defines an action responsible to trigger several actions once triggered.
  18133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18134. */
  18135. export class CombineAction extends Action {
  18136. /**
  18137. * The list of aggregated animations to run.
  18138. */
  18139. children: Action[];
  18140. /**
  18141. * Instantiate the action
  18142. * @param triggerOptions defines the trigger options
  18143. * @param children defines the list of aggregated animations to run
  18144. * @param condition defines the trigger related conditions
  18145. */
  18146. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18147. /** @hidden */
  18148. _prepare(): void;
  18149. /**
  18150. * Execute the action and executes all the aggregated actions.
  18151. */
  18152. execute(evt: ActionEvent): void;
  18153. /**
  18154. * Serializes the actions and its related information.
  18155. * @param parent defines the object to serialize in
  18156. * @returns the serialized object
  18157. */
  18158. serialize(parent: any): any;
  18159. }
  18160. /**
  18161. * This defines an action responsible to run code (external event) once triggered.
  18162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18163. */
  18164. export class ExecuteCodeAction extends Action {
  18165. /**
  18166. * The callback function to run.
  18167. */
  18168. func: (evt: ActionEvent) => void;
  18169. /**
  18170. * Instantiate the action
  18171. * @param triggerOptions defines the trigger options
  18172. * @param func defines the callback function to run
  18173. * @param condition defines the trigger related conditions
  18174. */
  18175. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18176. /**
  18177. * Execute the action and run the attached code.
  18178. */
  18179. execute(evt: ActionEvent): void;
  18180. }
  18181. /**
  18182. * This defines an action responsible to set the parent property of the target once triggered.
  18183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18184. */
  18185. export class SetParentAction extends Action {
  18186. private _parent;
  18187. private _target;
  18188. /**
  18189. * Instantiate the action
  18190. * @param triggerOptions defines the trigger options
  18191. * @param target defines the target containing the parent property
  18192. * @param parent defines from where the animation should start (animation frame)
  18193. * @param condition defines the trigger related conditions
  18194. */
  18195. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18196. /** @hidden */
  18197. _prepare(): void;
  18198. /**
  18199. * Execute the action and set the parent property.
  18200. */
  18201. execute(): void;
  18202. /**
  18203. * Serializes the actions and its related information.
  18204. * @param parent defines the object to serialize in
  18205. * @returns the serialized object
  18206. */
  18207. serialize(parent: any): any;
  18208. }
  18209. }
  18210. declare module "babylonjs/Actions/actionManager" {
  18211. import { Nullable } from "babylonjs/types";
  18212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18213. import { Scene } from "babylonjs/scene";
  18214. import { IAction } from "babylonjs/Actions/action";
  18215. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18216. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18217. /**
  18218. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18219. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18221. */
  18222. export class ActionManager extends AbstractActionManager {
  18223. /**
  18224. * Nothing
  18225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18226. */
  18227. static readonly NothingTrigger: number;
  18228. /**
  18229. * On pick
  18230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18231. */
  18232. static readonly OnPickTrigger: number;
  18233. /**
  18234. * On left pick
  18235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18236. */
  18237. static readonly OnLeftPickTrigger: number;
  18238. /**
  18239. * On right pick
  18240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18241. */
  18242. static readonly OnRightPickTrigger: number;
  18243. /**
  18244. * On center pick
  18245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18246. */
  18247. static readonly OnCenterPickTrigger: number;
  18248. /**
  18249. * On pick down
  18250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18251. */
  18252. static readonly OnPickDownTrigger: number;
  18253. /**
  18254. * On double pick
  18255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18256. */
  18257. static readonly OnDoublePickTrigger: number;
  18258. /**
  18259. * On pick up
  18260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18261. */
  18262. static readonly OnPickUpTrigger: number;
  18263. /**
  18264. * On pick out.
  18265. * This trigger will only be raised if you also declared a OnPickDown
  18266. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18267. */
  18268. static readonly OnPickOutTrigger: number;
  18269. /**
  18270. * On long press
  18271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18272. */
  18273. static readonly OnLongPressTrigger: number;
  18274. /**
  18275. * On pointer over
  18276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18277. */
  18278. static readonly OnPointerOverTrigger: number;
  18279. /**
  18280. * On pointer out
  18281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18282. */
  18283. static readonly OnPointerOutTrigger: number;
  18284. /**
  18285. * On every frame
  18286. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18287. */
  18288. static readonly OnEveryFrameTrigger: number;
  18289. /**
  18290. * On intersection enter
  18291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18292. */
  18293. static readonly OnIntersectionEnterTrigger: number;
  18294. /**
  18295. * On intersection exit
  18296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18297. */
  18298. static readonly OnIntersectionExitTrigger: number;
  18299. /**
  18300. * On key down
  18301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18302. */
  18303. static readonly OnKeyDownTrigger: number;
  18304. /**
  18305. * On key up
  18306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18307. */
  18308. static readonly OnKeyUpTrigger: number;
  18309. private _scene;
  18310. /**
  18311. * Creates a new action manager
  18312. * @param scene defines the hosting scene
  18313. */
  18314. constructor(scene: Scene);
  18315. /**
  18316. * Releases all associated resources
  18317. */
  18318. dispose(): void;
  18319. /**
  18320. * Gets hosting scene
  18321. * @returns the hosting scene
  18322. */
  18323. getScene(): Scene;
  18324. /**
  18325. * Does this action manager handles actions of any of the given triggers
  18326. * @param triggers defines the triggers to be tested
  18327. * @return a boolean indicating whether one (or more) of the triggers is handled
  18328. */
  18329. hasSpecificTriggers(triggers: number[]): boolean;
  18330. /**
  18331. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18332. * speed.
  18333. * @param triggerA defines the trigger to be tested
  18334. * @param triggerB defines the trigger to be tested
  18335. * @return a boolean indicating whether one (or more) of the triggers is handled
  18336. */
  18337. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18338. /**
  18339. * Does this action manager handles actions of a given trigger
  18340. * @param trigger defines the trigger to be tested
  18341. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18342. * @return whether the trigger is handled
  18343. */
  18344. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18345. /**
  18346. * Does this action manager has pointer triggers
  18347. */
  18348. get hasPointerTriggers(): boolean;
  18349. /**
  18350. * Does this action manager has pick triggers
  18351. */
  18352. get hasPickTriggers(): boolean;
  18353. /**
  18354. * Registers an action to this action manager
  18355. * @param action defines the action to be registered
  18356. * @return the action amended (prepared) after registration
  18357. */
  18358. registerAction(action: IAction): Nullable<IAction>;
  18359. /**
  18360. * Unregisters an action to this action manager
  18361. * @param action defines the action to be unregistered
  18362. * @return a boolean indicating whether the action has been unregistered
  18363. */
  18364. unregisterAction(action: IAction): Boolean;
  18365. /**
  18366. * Process a specific trigger
  18367. * @param trigger defines the trigger to process
  18368. * @param evt defines the event details to be processed
  18369. */
  18370. processTrigger(trigger: number, evt?: IActionEvent): void;
  18371. /** @hidden */
  18372. _getEffectiveTarget(target: any, propertyPath: string): any;
  18373. /** @hidden */
  18374. _getProperty(propertyPath: string): string;
  18375. /**
  18376. * Serialize this manager to a JSON object
  18377. * @param name defines the property name to store this manager
  18378. * @returns a JSON representation of this manager
  18379. */
  18380. serialize(name: string): any;
  18381. /**
  18382. * Creates a new ActionManager from a JSON data
  18383. * @param parsedActions defines the JSON data to read from
  18384. * @param object defines the hosting mesh
  18385. * @param scene defines the hosting scene
  18386. */
  18387. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18388. /**
  18389. * Get a trigger name by index
  18390. * @param trigger defines the trigger index
  18391. * @returns a trigger name
  18392. */
  18393. static GetTriggerName(trigger: number): string;
  18394. }
  18395. }
  18396. declare module "babylonjs/Sprites/sprite" {
  18397. import { Vector3 } from "babylonjs/Maths/math.vector";
  18398. import { Nullable } from "babylonjs/types";
  18399. import { ActionManager } from "babylonjs/Actions/actionManager";
  18400. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18401. import { Color4 } from "babylonjs/Maths/math.color";
  18402. /**
  18403. * Class used to represent a sprite
  18404. * @see http://doc.babylonjs.com/babylon101/sprites
  18405. */
  18406. export class Sprite {
  18407. /** defines the name */
  18408. name: string;
  18409. /** Gets or sets the current world position */
  18410. position: Vector3;
  18411. /** Gets or sets the main color */
  18412. color: Color4;
  18413. /** Gets or sets the width */
  18414. width: number;
  18415. /** Gets or sets the height */
  18416. height: number;
  18417. /** Gets or sets rotation angle */
  18418. angle: number;
  18419. /** Gets or sets the cell index in the sprite sheet */
  18420. cellIndex: number;
  18421. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18422. cellRef: string;
  18423. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18424. invertU: number;
  18425. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18426. invertV: number;
  18427. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18428. disposeWhenFinishedAnimating: boolean;
  18429. /** Gets the list of attached animations */
  18430. animations: Animation[];
  18431. /** Gets or sets a boolean indicating if the sprite can be picked */
  18432. isPickable: boolean;
  18433. /**
  18434. * Gets or sets the associated action manager
  18435. */
  18436. actionManager: Nullable<ActionManager>;
  18437. private _animationStarted;
  18438. private _loopAnimation;
  18439. private _fromIndex;
  18440. private _toIndex;
  18441. private _delay;
  18442. private _direction;
  18443. private _manager;
  18444. private _time;
  18445. private _onAnimationEnd;
  18446. /**
  18447. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18448. */
  18449. isVisible: boolean;
  18450. /**
  18451. * Gets or sets the sprite size
  18452. */
  18453. get size(): number;
  18454. set size(value: number);
  18455. /**
  18456. * Creates a new Sprite
  18457. * @param name defines the name
  18458. * @param manager defines the manager
  18459. */
  18460. constructor(
  18461. /** defines the name */
  18462. name: string, manager: ISpriteManager);
  18463. /**
  18464. * Starts an animation
  18465. * @param from defines the initial key
  18466. * @param to defines the end key
  18467. * @param loop defines if the animation must loop
  18468. * @param delay defines the start delay (in ms)
  18469. * @param onAnimationEnd defines a callback to call when animation ends
  18470. */
  18471. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18472. /** Stops current animation (if any) */
  18473. stopAnimation(): void;
  18474. /** @hidden */
  18475. _animate(deltaTime: number): void;
  18476. /** Release associated resources */
  18477. dispose(): void;
  18478. }
  18479. }
  18480. declare module "babylonjs/Collisions/pickingInfo" {
  18481. import { Nullable } from "babylonjs/types";
  18482. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18484. import { Sprite } from "babylonjs/Sprites/sprite";
  18485. import { Ray } from "babylonjs/Culling/ray";
  18486. /**
  18487. * Information about the result of picking within a scene
  18488. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18489. */
  18490. export class PickingInfo {
  18491. /** @hidden */
  18492. _pickingUnavailable: boolean;
  18493. /**
  18494. * If the pick collided with an object
  18495. */
  18496. hit: boolean;
  18497. /**
  18498. * Distance away where the pick collided
  18499. */
  18500. distance: number;
  18501. /**
  18502. * The location of pick collision
  18503. */
  18504. pickedPoint: Nullable<Vector3>;
  18505. /**
  18506. * The mesh corresponding the the pick collision
  18507. */
  18508. pickedMesh: Nullable<AbstractMesh>;
  18509. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18510. bu: number;
  18511. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18512. bv: number;
  18513. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18514. faceId: number;
  18515. /** Id of the the submesh that was picked */
  18516. subMeshId: number;
  18517. /** If a sprite was picked, this will be the sprite the pick collided with */
  18518. pickedSprite: Nullable<Sprite>;
  18519. /**
  18520. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18521. */
  18522. originMesh: Nullable<AbstractMesh>;
  18523. /**
  18524. * The ray that was used to perform the picking.
  18525. */
  18526. ray: Nullable<Ray>;
  18527. /**
  18528. * Gets the normal correspodning to the face the pick collided with
  18529. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18530. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18531. * @returns The normal correspodning to the face the pick collided with
  18532. */
  18533. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18534. /**
  18535. * Gets the texture coordinates of where the pick occured
  18536. * @returns the vector containing the coordnates of the texture
  18537. */
  18538. getTextureCoordinates(): Nullable<Vector2>;
  18539. }
  18540. }
  18541. declare module "babylonjs/Events/pointerEvents" {
  18542. import { Nullable } from "babylonjs/types";
  18543. import { Vector2 } from "babylonjs/Maths/math.vector";
  18544. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18545. import { Ray } from "babylonjs/Culling/ray";
  18546. /**
  18547. * Gather the list of pointer event types as constants.
  18548. */
  18549. export class PointerEventTypes {
  18550. /**
  18551. * 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.
  18552. */
  18553. static readonly POINTERDOWN: number;
  18554. /**
  18555. * The pointerup event is fired when a pointer is no longer active.
  18556. */
  18557. static readonly POINTERUP: number;
  18558. /**
  18559. * The pointermove event is fired when a pointer changes coordinates.
  18560. */
  18561. static readonly POINTERMOVE: number;
  18562. /**
  18563. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18564. */
  18565. static readonly POINTERWHEEL: number;
  18566. /**
  18567. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18568. */
  18569. static readonly POINTERPICK: number;
  18570. /**
  18571. * The pointertap event is fired when a the object has been touched and released without drag.
  18572. */
  18573. static readonly POINTERTAP: number;
  18574. /**
  18575. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18576. */
  18577. static readonly POINTERDOUBLETAP: number;
  18578. }
  18579. /**
  18580. * Base class of pointer info types.
  18581. */
  18582. export class PointerInfoBase {
  18583. /**
  18584. * Defines the type of event (PointerEventTypes)
  18585. */
  18586. type: number;
  18587. /**
  18588. * Defines the related dom event
  18589. */
  18590. event: PointerEvent | MouseWheelEvent;
  18591. /**
  18592. * Instantiates the base class of pointers info.
  18593. * @param type Defines the type of event (PointerEventTypes)
  18594. * @param event Defines the related dom event
  18595. */
  18596. constructor(
  18597. /**
  18598. * Defines the type of event (PointerEventTypes)
  18599. */
  18600. type: number,
  18601. /**
  18602. * Defines the related dom event
  18603. */
  18604. event: PointerEvent | MouseWheelEvent);
  18605. }
  18606. /**
  18607. * This class is used to store pointer related info for the onPrePointerObservable event.
  18608. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18609. */
  18610. export class PointerInfoPre extends PointerInfoBase {
  18611. /**
  18612. * Ray from a pointer if availible (eg. 6dof controller)
  18613. */
  18614. ray: Nullable<Ray>;
  18615. /**
  18616. * Defines the local position of the pointer on the canvas.
  18617. */
  18618. localPosition: Vector2;
  18619. /**
  18620. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18621. */
  18622. skipOnPointerObservable: boolean;
  18623. /**
  18624. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18625. * @param type Defines the type of event (PointerEventTypes)
  18626. * @param event Defines the related dom event
  18627. * @param localX Defines the local x coordinates of the pointer when the event occured
  18628. * @param localY Defines the local y coordinates of the pointer when the event occured
  18629. */
  18630. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18631. }
  18632. /**
  18633. * This type contains all the data related to a pointer event in Babylon.js.
  18634. * 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.
  18635. */
  18636. export class PointerInfo extends PointerInfoBase {
  18637. /**
  18638. * Defines the picking info associated to the info (if any)\
  18639. */
  18640. pickInfo: Nullable<PickingInfo>;
  18641. /**
  18642. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18643. * @param type Defines the type of event (PointerEventTypes)
  18644. * @param event Defines the related dom event
  18645. * @param pickInfo Defines the picking info associated to the info (if any)\
  18646. */
  18647. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18648. /**
  18649. * Defines the picking info associated to the info (if any)\
  18650. */
  18651. pickInfo: Nullable<PickingInfo>);
  18652. }
  18653. /**
  18654. * Data relating to a touch event on the screen.
  18655. */
  18656. export interface PointerTouch {
  18657. /**
  18658. * X coordinate of touch.
  18659. */
  18660. x: number;
  18661. /**
  18662. * Y coordinate of touch.
  18663. */
  18664. y: number;
  18665. /**
  18666. * Id of touch. Unique for each finger.
  18667. */
  18668. pointerId: number;
  18669. /**
  18670. * Event type passed from DOM.
  18671. */
  18672. type: any;
  18673. }
  18674. }
  18675. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18676. import { Observable } from "babylonjs/Misc/observable";
  18677. import { Nullable } from "babylonjs/types";
  18678. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18679. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18680. /**
  18681. * Manage the mouse inputs to control the movement of a free camera.
  18682. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18683. */
  18684. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18685. /**
  18686. * Define if touch is enabled in the mouse input
  18687. */
  18688. touchEnabled: boolean;
  18689. /**
  18690. * Defines the camera the input is attached to.
  18691. */
  18692. camera: FreeCamera;
  18693. /**
  18694. * Defines the buttons associated with the input to handle camera move.
  18695. */
  18696. buttons: number[];
  18697. /**
  18698. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18699. */
  18700. angularSensibility: number;
  18701. private _pointerInput;
  18702. private _onMouseMove;
  18703. private _observer;
  18704. private previousPosition;
  18705. /**
  18706. * Observable for when a pointer move event occurs containing the move offset
  18707. */
  18708. onPointerMovedObservable: Observable<{
  18709. offsetX: number;
  18710. offsetY: number;
  18711. }>;
  18712. /**
  18713. * @hidden
  18714. * If the camera should be rotated automatically based on pointer movement
  18715. */
  18716. _allowCameraRotation: boolean;
  18717. /**
  18718. * Manage the mouse inputs to control the movement of a free camera.
  18719. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18720. * @param touchEnabled Defines if touch is enabled or not
  18721. */
  18722. constructor(
  18723. /**
  18724. * Define if touch is enabled in the mouse input
  18725. */
  18726. touchEnabled?: boolean);
  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. * Called on JS contextmenu event.
  18735. * Override this method to provide functionality.
  18736. */
  18737. protected onContextMenu(evt: PointerEvent): void;
  18738. /**
  18739. * Detach the current controls from the specified dom element.
  18740. * @param element Defines the element to stop listening the inputs from
  18741. */
  18742. detachControl(element: Nullable<HTMLElement>): 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/Inputs/freeCameraTouchInput" {
  18756. import { Nullable } from "babylonjs/types";
  18757. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18758. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18759. /**
  18760. * Manage the touch inputs to control the movement of a free camera.
  18761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18762. */
  18763. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18764. /**
  18765. * Defines the camera the input is attached to.
  18766. */
  18767. camera: FreeCamera;
  18768. /**
  18769. * Defines the touch sensibility for rotation.
  18770. * The higher the faster.
  18771. */
  18772. touchAngularSensibility: number;
  18773. /**
  18774. * Defines the touch sensibility for move.
  18775. * The higher the faster.
  18776. */
  18777. touchMoveSensibility: number;
  18778. private _offsetX;
  18779. private _offsetY;
  18780. private _pointerPressed;
  18781. private _pointerInput;
  18782. private _observer;
  18783. private _onLostFocus;
  18784. /**
  18785. * Attach the input controls to a specific dom element to get the input from.
  18786. * @param element Defines the element the controls should be listened from
  18787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18788. */
  18789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18790. /**
  18791. * Detach the current controls from the specified dom element.
  18792. * @param element Defines the element to stop listening the inputs from
  18793. */
  18794. detachControl(element: Nullable<HTMLElement>): void;
  18795. /**
  18796. * Update the current camera state depending on the inputs that have been used this frame.
  18797. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18798. */
  18799. checkInputs(): void;
  18800. /**
  18801. * Gets the class name of the current intput.
  18802. * @returns the class name
  18803. */
  18804. getClassName(): string;
  18805. /**
  18806. * Get the friendly name associated with the input class.
  18807. * @returns the input friendly name
  18808. */
  18809. getSimpleName(): string;
  18810. }
  18811. }
  18812. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18813. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18814. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18815. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18816. import { Nullable } from "babylonjs/types";
  18817. /**
  18818. * Default Inputs manager for the FreeCamera.
  18819. * It groups all the default supported inputs for ease of use.
  18820. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18821. */
  18822. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18823. /**
  18824. * @hidden
  18825. */
  18826. _mouseInput: Nullable<FreeCameraMouseInput>;
  18827. /**
  18828. * Instantiates a new FreeCameraInputsManager.
  18829. * @param camera Defines the camera the inputs belong to
  18830. */
  18831. constructor(camera: FreeCamera);
  18832. /**
  18833. * Add keyboard input support to the input manager.
  18834. * @returns the current input manager
  18835. */
  18836. addKeyboard(): FreeCameraInputsManager;
  18837. /**
  18838. * Add mouse input support to the input manager.
  18839. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18840. * @returns the current input manager
  18841. */
  18842. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18843. /**
  18844. * Removes the mouse input support from the manager
  18845. * @returns the current input manager
  18846. */
  18847. removeMouse(): FreeCameraInputsManager;
  18848. /**
  18849. * Add touch input support to the input manager.
  18850. * @returns the current input manager
  18851. */
  18852. addTouch(): FreeCameraInputsManager;
  18853. /**
  18854. * Remove all attached input methods from a camera
  18855. */
  18856. clear(): void;
  18857. }
  18858. }
  18859. declare module "babylonjs/Cameras/freeCamera" {
  18860. import { Vector3 } from "babylonjs/Maths/math.vector";
  18861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18862. import { Scene } from "babylonjs/scene";
  18863. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18864. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18865. /**
  18866. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18867. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18868. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18869. */
  18870. export class FreeCamera extends TargetCamera {
  18871. /**
  18872. * Define the collision ellipsoid of the camera.
  18873. * This is helpful to simulate a camera body like the player body around the camera
  18874. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18875. */
  18876. ellipsoid: Vector3;
  18877. /**
  18878. * Define an offset for the position of the ellipsoid around the camera.
  18879. * This can be helpful to determine the center of the body near the gravity center of the body
  18880. * instead of its head.
  18881. */
  18882. ellipsoidOffset: Vector3;
  18883. /**
  18884. * Enable or disable collisions of the camera with the rest of the scene objects.
  18885. */
  18886. checkCollisions: boolean;
  18887. /**
  18888. * Enable or disable gravity on the camera.
  18889. */
  18890. applyGravity: boolean;
  18891. /**
  18892. * Define the input manager associated to the camera.
  18893. */
  18894. inputs: FreeCameraInputsManager;
  18895. /**
  18896. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18897. * Higher values reduce sensitivity.
  18898. */
  18899. get angularSensibility(): number;
  18900. /**
  18901. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18902. * Higher values reduce sensitivity.
  18903. */
  18904. set angularSensibility(value: number);
  18905. /**
  18906. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18907. */
  18908. get keysUp(): number[];
  18909. set keysUp(value: number[]);
  18910. /**
  18911. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18912. */
  18913. get keysDown(): number[];
  18914. set keysDown(value: number[]);
  18915. /**
  18916. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18917. */
  18918. get keysLeft(): number[];
  18919. set keysLeft(value: number[]);
  18920. /**
  18921. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18922. */
  18923. get keysRight(): number[];
  18924. set keysRight(value: number[]);
  18925. /**
  18926. * Event raised when the camera collide with a mesh in the scene.
  18927. */
  18928. onCollide: (collidedMesh: AbstractMesh) => void;
  18929. private _collider;
  18930. private _needMoveForGravity;
  18931. private _oldPosition;
  18932. private _diffPosition;
  18933. private _newPosition;
  18934. /** @hidden */
  18935. _localDirection: Vector3;
  18936. /** @hidden */
  18937. _transformedDirection: Vector3;
  18938. /**
  18939. * Instantiates a Free Camera.
  18940. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18941. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18942. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18943. * @param name Define the name of the camera in the scene
  18944. * @param position Define the start position of the camera in the scene
  18945. * @param scene Define the scene the camera belongs to
  18946. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18947. */
  18948. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18949. /**
  18950. * Attached controls to the current camera.
  18951. * @param element Defines the element the controls should be listened from
  18952. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18953. */
  18954. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18955. /**
  18956. * Detach the current controls from the camera.
  18957. * The camera will stop reacting to inputs.
  18958. * @param element Defines the element to stop listening the inputs from
  18959. */
  18960. detachControl(element: HTMLElement): void;
  18961. private _collisionMask;
  18962. /**
  18963. * Define a collision mask to limit the list of object the camera can collide with
  18964. */
  18965. get collisionMask(): number;
  18966. set collisionMask(mask: number);
  18967. /** @hidden */
  18968. _collideWithWorld(displacement: Vector3): void;
  18969. private _onCollisionPositionChange;
  18970. /** @hidden */
  18971. _checkInputs(): void;
  18972. /** @hidden */
  18973. _decideIfNeedsToMove(): boolean;
  18974. /** @hidden */
  18975. _updatePosition(): void;
  18976. /**
  18977. * Destroy the camera and release the current resources hold by it.
  18978. */
  18979. dispose(): void;
  18980. /**
  18981. * Gets the current object class name.
  18982. * @return the class name
  18983. */
  18984. getClassName(): string;
  18985. }
  18986. }
  18987. declare module "babylonjs/Gamepads/gamepad" {
  18988. import { Observable } from "babylonjs/Misc/observable";
  18989. /**
  18990. * Represents a gamepad control stick position
  18991. */
  18992. export class StickValues {
  18993. /**
  18994. * The x component of the control stick
  18995. */
  18996. x: number;
  18997. /**
  18998. * The y component of the control stick
  18999. */
  19000. y: number;
  19001. /**
  19002. * Initializes the gamepad x and y control stick values
  19003. * @param x The x component of the gamepad control stick value
  19004. * @param y The y component of the gamepad control stick value
  19005. */
  19006. constructor(
  19007. /**
  19008. * The x component of the control stick
  19009. */
  19010. x: number,
  19011. /**
  19012. * The y component of the control stick
  19013. */
  19014. y: number);
  19015. }
  19016. /**
  19017. * An interface which manages callbacks for gamepad button changes
  19018. */
  19019. export interface GamepadButtonChanges {
  19020. /**
  19021. * Called when a gamepad has been changed
  19022. */
  19023. changed: boolean;
  19024. /**
  19025. * Called when a gamepad press event has been triggered
  19026. */
  19027. pressChanged: boolean;
  19028. /**
  19029. * Called when a touch event has been triggered
  19030. */
  19031. touchChanged: boolean;
  19032. /**
  19033. * Called when a value has changed
  19034. */
  19035. valueChanged: boolean;
  19036. }
  19037. /**
  19038. * Represents a gamepad
  19039. */
  19040. export class Gamepad {
  19041. /**
  19042. * The id of the gamepad
  19043. */
  19044. id: string;
  19045. /**
  19046. * The index of the gamepad
  19047. */
  19048. index: number;
  19049. /**
  19050. * The browser gamepad
  19051. */
  19052. browserGamepad: any;
  19053. /**
  19054. * Specifies what type of gamepad this represents
  19055. */
  19056. type: number;
  19057. private _leftStick;
  19058. private _rightStick;
  19059. /** @hidden */
  19060. _isConnected: boolean;
  19061. private _leftStickAxisX;
  19062. private _leftStickAxisY;
  19063. private _rightStickAxisX;
  19064. private _rightStickAxisY;
  19065. /**
  19066. * Triggered when the left control stick has been changed
  19067. */
  19068. private _onleftstickchanged;
  19069. /**
  19070. * Triggered when the right control stick has been changed
  19071. */
  19072. private _onrightstickchanged;
  19073. /**
  19074. * Represents a gamepad controller
  19075. */
  19076. static GAMEPAD: number;
  19077. /**
  19078. * Represents a generic controller
  19079. */
  19080. static GENERIC: number;
  19081. /**
  19082. * Represents an XBox controller
  19083. */
  19084. static XBOX: number;
  19085. /**
  19086. * Represents a pose-enabled controller
  19087. */
  19088. static POSE_ENABLED: number;
  19089. /**
  19090. * Represents an Dual Shock controller
  19091. */
  19092. static DUALSHOCK: number;
  19093. /**
  19094. * Specifies whether the left control stick should be Y-inverted
  19095. */
  19096. protected _invertLeftStickY: boolean;
  19097. /**
  19098. * Specifies if the gamepad has been connected
  19099. */
  19100. get isConnected(): boolean;
  19101. /**
  19102. * Initializes the gamepad
  19103. * @param id The id of the gamepad
  19104. * @param index The index of the gamepad
  19105. * @param browserGamepad The browser gamepad
  19106. * @param leftStickX The x component of the left joystick
  19107. * @param leftStickY The y component of the left joystick
  19108. * @param rightStickX The x component of the right joystick
  19109. * @param rightStickY The y component of the right joystick
  19110. */
  19111. constructor(
  19112. /**
  19113. * The id of the gamepad
  19114. */
  19115. id: string,
  19116. /**
  19117. * The index of the gamepad
  19118. */
  19119. index: number,
  19120. /**
  19121. * The browser gamepad
  19122. */
  19123. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19124. /**
  19125. * Callback triggered when the left joystick has changed
  19126. * @param callback
  19127. */
  19128. onleftstickchanged(callback: (values: StickValues) => void): void;
  19129. /**
  19130. * Callback triggered when the right joystick has changed
  19131. * @param callback
  19132. */
  19133. onrightstickchanged(callback: (values: StickValues) => void): void;
  19134. /**
  19135. * Gets the left joystick
  19136. */
  19137. get leftStick(): StickValues;
  19138. /**
  19139. * Sets the left joystick values
  19140. */
  19141. set leftStick(newValues: StickValues);
  19142. /**
  19143. * Gets the right joystick
  19144. */
  19145. get rightStick(): StickValues;
  19146. /**
  19147. * Sets the right joystick value
  19148. */
  19149. set rightStick(newValues: StickValues);
  19150. /**
  19151. * Updates the gamepad joystick positions
  19152. */
  19153. update(): void;
  19154. /**
  19155. * Disposes the gamepad
  19156. */
  19157. dispose(): void;
  19158. }
  19159. /**
  19160. * Represents a generic gamepad
  19161. */
  19162. export class GenericPad extends Gamepad {
  19163. private _buttons;
  19164. private _onbuttondown;
  19165. private _onbuttonup;
  19166. /**
  19167. * Observable triggered when a button has been pressed
  19168. */
  19169. onButtonDownObservable: Observable<number>;
  19170. /**
  19171. * Observable triggered when a button has been released
  19172. */
  19173. onButtonUpObservable: Observable<number>;
  19174. /**
  19175. * Callback triggered when a button has been pressed
  19176. * @param callback Called when a button has been pressed
  19177. */
  19178. onbuttondown(callback: (buttonPressed: number) => void): void;
  19179. /**
  19180. * Callback triggered when a button has been released
  19181. * @param callback Called when a button has been released
  19182. */
  19183. onbuttonup(callback: (buttonReleased: number) => void): void;
  19184. /**
  19185. * Initializes the generic gamepad
  19186. * @param id The id of the generic gamepad
  19187. * @param index The index of the generic gamepad
  19188. * @param browserGamepad The browser gamepad
  19189. */
  19190. constructor(id: string, index: number, browserGamepad: any);
  19191. private _setButtonValue;
  19192. /**
  19193. * Updates the generic gamepad
  19194. */
  19195. update(): void;
  19196. /**
  19197. * Disposes the generic gamepad
  19198. */
  19199. dispose(): void;
  19200. }
  19201. }
  19202. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19203. import { Observable } from "babylonjs/Misc/observable";
  19204. import { Nullable } from "babylonjs/types";
  19205. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19206. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19208. import { Ray } from "babylonjs/Culling/ray";
  19209. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19210. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19211. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19212. /**
  19213. * Defines the types of pose enabled controllers that are supported
  19214. */
  19215. export enum PoseEnabledControllerType {
  19216. /**
  19217. * HTC Vive
  19218. */
  19219. VIVE = 0,
  19220. /**
  19221. * Oculus Rift
  19222. */
  19223. OCULUS = 1,
  19224. /**
  19225. * Windows mixed reality
  19226. */
  19227. WINDOWS = 2,
  19228. /**
  19229. * Samsung gear VR
  19230. */
  19231. GEAR_VR = 3,
  19232. /**
  19233. * Google Daydream
  19234. */
  19235. DAYDREAM = 4,
  19236. /**
  19237. * Generic
  19238. */
  19239. GENERIC = 5
  19240. }
  19241. /**
  19242. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19243. */
  19244. export interface MutableGamepadButton {
  19245. /**
  19246. * Value of the button/trigger
  19247. */
  19248. value: number;
  19249. /**
  19250. * If the button/trigger is currently touched
  19251. */
  19252. touched: boolean;
  19253. /**
  19254. * If the button/trigger is currently pressed
  19255. */
  19256. pressed: boolean;
  19257. }
  19258. /**
  19259. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19260. * @hidden
  19261. */
  19262. export interface ExtendedGamepadButton extends GamepadButton {
  19263. /**
  19264. * If the button/trigger is currently pressed
  19265. */
  19266. readonly pressed: boolean;
  19267. /**
  19268. * If the button/trigger is currently touched
  19269. */
  19270. readonly touched: boolean;
  19271. /**
  19272. * Value of the button/trigger
  19273. */
  19274. readonly value: number;
  19275. }
  19276. /** @hidden */
  19277. export interface _GamePadFactory {
  19278. /**
  19279. * Returns whether or not the current gamepad can be created for this type of controller.
  19280. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19281. * @returns true if it can be created, otherwise false
  19282. */
  19283. canCreate(gamepadInfo: any): boolean;
  19284. /**
  19285. * Creates a new instance of the Gamepad.
  19286. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19287. * @returns the new gamepad instance
  19288. */
  19289. create(gamepadInfo: any): Gamepad;
  19290. }
  19291. /**
  19292. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19293. */
  19294. export class PoseEnabledControllerHelper {
  19295. /** @hidden */
  19296. static _ControllerFactories: _GamePadFactory[];
  19297. /** @hidden */
  19298. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19299. /**
  19300. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19301. * @param vrGamepad the gamepad to initialized
  19302. * @returns a vr controller of the type the gamepad identified as
  19303. */
  19304. static InitiateController(vrGamepad: any): Gamepad;
  19305. }
  19306. /**
  19307. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19308. */
  19309. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19310. /**
  19311. * If the controller is used in a webXR session
  19312. */
  19313. isXR: boolean;
  19314. private _deviceRoomPosition;
  19315. private _deviceRoomRotationQuaternion;
  19316. /**
  19317. * The device position in babylon space
  19318. */
  19319. devicePosition: Vector3;
  19320. /**
  19321. * The device rotation in babylon space
  19322. */
  19323. deviceRotationQuaternion: Quaternion;
  19324. /**
  19325. * The scale factor of the device in babylon space
  19326. */
  19327. deviceScaleFactor: number;
  19328. /**
  19329. * (Likely devicePosition should be used instead) The device position in its room space
  19330. */
  19331. position: Vector3;
  19332. /**
  19333. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19334. */
  19335. rotationQuaternion: Quaternion;
  19336. /**
  19337. * The type of controller (Eg. Windows mixed reality)
  19338. */
  19339. controllerType: PoseEnabledControllerType;
  19340. protected _calculatedPosition: Vector3;
  19341. private _calculatedRotation;
  19342. /**
  19343. * The raw pose from the device
  19344. */
  19345. rawPose: DevicePose;
  19346. private _trackPosition;
  19347. private _maxRotationDistFromHeadset;
  19348. private _draggedRoomRotation;
  19349. /**
  19350. * @hidden
  19351. */
  19352. _disableTrackPosition(fixedPosition: Vector3): void;
  19353. /**
  19354. * Internal, the mesh attached to the controller
  19355. * @hidden
  19356. */
  19357. _mesh: Nullable<AbstractMesh>;
  19358. private _poseControlledCamera;
  19359. private _leftHandSystemQuaternion;
  19360. /**
  19361. * Internal, matrix used to convert room space to babylon space
  19362. * @hidden
  19363. */
  19364. _deviceToWorld: Matrix;
  19365. /**
  19366. * Node to be used when casting a ray from the controller
  19367. * @hidden
  19368. */
  19369. _pointingPoseNode: Nullable<TransformNode>;
  19370. /**
  19371. * Name of the child mesh that can be used to cast a ray from the controller
  19372. */
  19373. static readonly POINTING_POSE: string;
  19374. /**
  19375. * Creates a new PoseEnabledController from a gamepad
  19376. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19377. */
  19378. constructor(browserGamepad: any);
  19379. private _workingMatrix;
  19380. /**
  19381. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19382. */
  19383. update(): void;
  19384. /**
  19385. * Updates only the pose device and mesh without doing any button event checking
  19386. */
  19387. protected _updatePoseAndMesh(): void;
  19388. /**
  19389. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19390. * @param poseData raw pose fromthe device
  19391. */
  19392. updateFromDevice(poseData: DevicePose): void;
  19393. /**
  19394. * @hidden
  19395. */
  19396. _meshAttachedObservable: Observable<AbstractMesh>;
  19397. /**
  19398. * Attaches a mesh to the controller
  19399. * @param mesh the mesh to be attached
  19400. */
  19401. attachToMesh(mesh: AbstractMesh): void;
  19402. /**
  19403. * Attaches the controllers mesh to a camera
  19404. * @param camera the camera the mesh should be attached to
  19405. */
  19406. attachToPoseControlledCamera(camera: TargetCamera): void;
  19407. /**
  19408. * Disposes of the controller
  19409. */
  19410. dispose(): void;
  19411. /**
  19412. * The mesh that is attached to the controller
  19413. */
  19414. get mesh(): Nullable<AbstractMesh>;
  19415. /**
  19416. * Gets the ray of the controller in the direction the controller is pointing
  19417. * @param length the length the resulting ray should be
  19418. * @returns a ray in the direction the controller is pointing
  19419. */
  19420. getForwardRay(length?: number): Ray;
  19421. }
  19422. }
  19423. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19424. import { Observable } from "babylonjs/Misc/observable";
  19425. import { Scene } from "babylonjs/scene";
  19426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19427. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19428. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19429. import { Nullable } from "babylonjs/types";
  19430. /**
  19431. * Defines the WebVRController object that represents controllers tracked in 3D space
  19432. */
  19433. export abstract class WebVRController extends PoseEnabledController {
  19434. /**
  19435. * Internal, the default controller model for the controller
  19436. */
  19437. protected _defaultModel: Nullable<AbstractMesh>;
  19438. /**
  19439. * Fired when the trigger state has changed
  19440. */
  19441. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19442. /**
  19443. * Fired when the main button state has changed
  19444. */
  19445. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19446. /**
  19447. * Fired when the secondary button state has changed
  19448. */
  19449. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19450. /**
  19451. * Fired when the pad state has changed
  19452. */
  19453. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19454. /**
  19455. * Fired when controllers stick values have changed
  19456. */
  19457. onPadValuesChangedObservable: Observable<StickValues>;
  19458. /**
  19459. * Array of button availible on the controller
  19460. */
  19461. protected _buttons: Array<MutableGamepadButton>;
  19462. private _onButtonStateChange;
  19463. /**
  19464. * Fired when a controller button's state has changed
  19465. * @param callback the callback containing the button that was modified
  19466. */
  19467. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19468. /**
  19469. * X and Y axis corresponding to the controllers joystick
  19470. */
  19471. pad: StickValues;
  19472. /**
  19473. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19474. */
  19475. hand: string;
  19476. /**
  19477. * The default controller model for the controller
  19478. */
  19479. get defaultModel(): Nullable<AbstractMesh>;
  19480. /**
  19481. * Creates a new WebVRController from a gamepad
  19482. * @param vrGamepad the gamepad that the WebVRController should be created from
  19483. */
  19484. constructor(vrGamepad: any);
  19485. /**
  19486. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19487. */
  19488. update(): void;
  19489. /**
  19490. * Function to be called when a button is modified
  19491. */
  19492. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19493. /**
  19494. * Loads a mesh and attaches it to the controller
  19495. * @param scene the scene the mesh should be added to
  19496. * @param meshLoaded callback for when the mesh has been loaded
  19497. */
  19498. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19499. private _setButtonValue;
  19500. private _changes;
  19501. private _checkChanges;
  19502. /**
  19503. * Disposes of th webVRCOntroller
  19504. */
  19505. dispose(): void;
  19506. }
  19507. }
  19508. declare module "babylonjs/Lights/hemisphericLight" {
  19509. import { Nullable } from "babylonjs/types";
  19510. import { Scene } from "babylonjs/scene";
  19511. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19512. import { Color3 } from "babylonjs/Maths/math.color";
  19513. import { Effect } from "babylonjs/Materials/effect";
  19514. import { Light } from "babylonjs/Lights/light";
  19515. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19516. /**
  19517. * The HemisphericLight simulates the ambient environment light,
  19518. * so the passed direction is the light reflection direction, not the incoming direction.
  19519. */
  19520. export class HemisphericLight extends Light {
  19521. /**
  19522. * The groundColor is the light in the opposite direction to the one specified during creation.
  19523. * 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.
  19524. */
  19525. groundColor: Color3;
  19526. /**
  19527. * The light reflection direction, not the incoming direction.
  19528. */
  19529. direction: Vector3;
  19530. /**
  19531. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19532. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19533. * The HemisphericLight can't cast shadows.
  19534. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19535. * @param name The friendly name of the light
  19536. * @param direction The direction of the light reflection
  19537. * @param scene The scene the light belongs to
  19538. */
  19539. constructor(name: string, direction: Vector3, scene: Scene);
  19540. protected _buildUniformLayout(): void;
  19541. /**
  19542. * Returns the string "HemisphericLight".
  19543. * @return The class name
  19544. */
  19545. getClassName(): string;
  19546. /**
  19547. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19548. * Returns the updated direction.
  19549. * @param target The target the direction should point to
  19550. * @return The computed direction
  19551. */
  19552. setDirectionToTarget(target: Vector3): Vector3;
  19553. /**
  19554. * Returns the shadow generator associated to the light.
  19555. * @returns Always null for hemispheric lights because it does not support shadows.
  19556. */
  19557. getShadowGenerator(): Nullable<IShadowGenerator>;
  19558. /**
  19559. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19560. * @param effect The effect to update
  19561. * @param lightIndex The index of the light in the effect to update
  19562. * @returns The hemispheric light
  19563. */
  19564. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19565. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19566. /**
  19567. * Computes the world matrix of the node
  19568. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19569. * @param useWasUpdatedFlag defines a reserved property
  19570. * @returns the world matrix
  19571. */
  19572. computeWorldMatrix(): Matrix;
  19573. /**
  19574. * Returns the integer 3.
  19575. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19576. */
  19577. getTypeID(): number;
  19578. /**
  19579. * Prepares the list of defines specific to the light type.
  19580. * @param defines the list of defines
  19581. * @param lightIndex defines the index of the light for the effect
  19582. */
  19583. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19584. }
  19585. }
  19586. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19587. /** @hidden */
  19588. export var vrMultiviewToSingleviewPixelShader: {
  19589. name: string;
  19590. shader: string;
  19591. };
  19592. }
  19593. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19594. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19595. import { Scene } from "babylonjs/scene";
  19596. /**
  19597. * Renders to multiple views with a single draw call
  19598. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19599. */
  19600. export class MultiviewRenderTarget extends RenderTargetTexture {
  19601. /**
  19602. * Creates a multiview render target
  19603. * @param scene scene used with the render target
  19604. * @param size the size of the render target (used for each view)
  19605. */
  19606. constructor(scene: Scene, size?: number | {
  19607. width: number;
  19608. height: number;
  19609. } | {
  19610. ratio: number;
  19611. });
  19612. /**
  19613. * @hidden
  19614. * @param faceIndex the face index, if its a cube texture
  19615. */
  19616. _bindFrameBuffer(faceIndex?: number): void;
  19617. /**
  19618. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19619. * @returns the view count
  19620. */
  19621. getViewCount(): number;
  19622. }
  19623. }
  19624. declare module "babylonjs/Maths/math.frustum" {
  19625. import { Matrix } from "babylonjs/Maths/math.vector";
  19626. import { DeepImmutable } from "babylonjs/types";
  19627. import { Plane } from "babylonjs/Maths/math.plane";
  19628. /**
  19629. * Represents a camera frustum
  19630. */
  19631. export class Frustum {
  19632. /**
  19633. * Gets the planes representing the frustum
  19634. * @param transform matrix to be applied to the returned planes
  19635. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19636. */
  19637. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19638. /**
  19639. * Gets the near frustum plane transformed by the transform matrix
  19640. * @param transform transformation matrix to be applied to the resulting frustum plane
  19641. * @param frustumPlane the resuling frustum plane
  19642. */
  19643. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19644. /**
  19645. * Gets the far frustum plane transformed by the transform matrix
  19646. * @param transform transformation matrix to be applied to the resulting frustum plane
  19647. * @param frustumPlane the resuling frustum plane
  19648. */
  19649. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19650. /**
  19651. * Gets the left frustum plane transformed by the transform matrix
  19652. * @param transform transformation matrix to be applied to the resulting frustum plane
  19653. * @param frustumPlane the resuling frustum plane
  19654. */
  19655. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19656. /**
  19657. * Gets the right frustum plane transformed by the transform matrix
  19658. * @param transform transformation matrix to be applied to the resulting frustum plane
  19659. * @param frustumPlane the resuling frustum plane
  19660. */
  19661. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19662. /**
  19663. * Gets the top frustum plane transformed by the transform matrix
  19664. * @param transform transformation matrix to be applied to the resulting frustum plane
  19665. * @param frustumPlane the resuling frustum plane
  19666. */
  19667. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19668. /**
  19669. * Gets the bottom frustum plane transformed by the transform matrix
  19670. * @param transform transformation matrix to be applied to the resulting frustum plane
  19671. * @param frustumPlane the resuling frustum plane
  19672. */
  19673. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19674. /**
  19675. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19676. * @param transform transformation matrix to be applied to the resulting frustum planes
  19677. * @param frustumPlanes the resuling frustum planes
  19678. */
  19679. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19680. }
  19681. }
  19682. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19683. import { Camera } from "babylonjs/Cameras/camera";
  19684. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19685. import { Nullable } from "babylonjs/types";
  19686. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19687. import { Matrix } from "babylonjs/Maths/math.vector";
  19688. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19689. module "babylonjs/Engines/engine" {
  19690. interface Engine {
  19691. /**
  19692. * Creates a new multiview render target
  19693. * @param width defines the width of the texture
  19694. * @param height defines the height of the texture
  19695. * @returns the created multiview texture
  19696. */
  19697. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19698. /**
  19699. * Binds a multiview framebuffer to be drawn to
  19700. * @param multiviewTexture texture to bind
  19701. */
  19702. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19703. }
  19704. }
  19705. module "babylonjs/Cameras/camera" {
  19706. interface Camera {
  19707. /**
  19708. * @hidden
  19709. * 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)
  19710. */
  19711. _useMultiviewToSingleView: boolean;
  19712. /**
  19713. * @hidden
  19714. * 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)
  19715. */
  19716. _multiviewTexture: Nullable<RenderTargetTexture>;
  19717. /**
  19718. * @hidden
  19719. * ensures the multiview texture of the camera exists and has the specified width/height
  19720. * @param width height to set on the multiview texture
  19721. * @param height width to set on the multiview texture
  19722. */
  19723. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19724. }
  19725. }
  19726. module "babylonjs/scene" {
  19727. interface Scene {
  19728. /** @hidden */
  19729. _transformMatrixR: Matrix;
  19730. /** @hidden */
  19731. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19732. /** @hidden */
  19733. _createMultiviewUbo(): void;
  19734. /** @hidden */
  19735. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19736. /** @hidden */
  19737. _renderMultiviewToSingleView(camera: Camera): void;
  19738. }
  19739. }
  19740. }
  19741. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19742. import { Camera } from "babylonjs/Cameras/camera";
  19743. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19744. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19745. import "babylonjs/Engines/Extensions/engine.multiview";
  19746. /**
  19747. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19748. * This will not be used for webXR as it supports displaying texture arrays directly
  19749. */
  19750. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19751. /**
  19752. * Initializes a VRMultiviewToSingleview
  19753. * @param name name of the post process
  19754. * @param camera camera to be applied to
  19755. * @param scaleFactor scaling factor to the size of the output texture
  19756. */
  19757. constructor(name: string, camera: Camera, scaleFactor: number);
  19758. }
  19759. }
  19760. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19761. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19762. import { Nullable } from "babylonjs/types";
  19763. import { Size } from "babylonjs/Maths/math.size";
  19764. import { Observable } from "babylonjs/Misc/observable";
  19765. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19766. /**
  19767. * Interface used to define additional presentation attributes
  19768. */
  19769. export interface IVRPresentationAttributes {
  19770. /**
  19771. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19772. */
  19773. highRefreshRate: boolean;
  19774. /**
  19775. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19776. */
  19777. foveationLevel: number;
  19778. }
  19779. module "babylonjs/Engines/engine" {
  19780. interface Engine {
  19781. /** @hidden */
  19782. _vrDisplay: any;
  19783. /** @hidden */
  19784. _vrSupported: boolean;
  19785. /** @hidden */
  19786. _oldSize: Size;
  19787. /** @hidden */
  19788. _oldHardwareScaleFactor: number;
  19789. /** @hidden */
  19790. _vrExclusivePointerMode: boolean;
  19791. /** @hidden */
  19792. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19793. /** @hidden */
  19794. _onVRDisplayPointerRestricted: () => void;
  19795. /** @hidden */
  19796. _onVRDisplayPointerUnrestricted: () => void;
  19797. /** @hidden */
  19798. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19799. /** @hidden */
  19800. _onVrDisplayDisconnect: Nullable<() => void>;
  19801. /** @hidden */
  19802. _onVrDisplayPresentChange: Nullable<() => void>;
  19803. /**
  19804. * Observable signaled when VR display mode changes
  19805. */
  19806. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19807. /**
  19808. * Observable signaled when VR request present is complete
  19809. */
  19810. onVRRequestPresentComplete: Observable<boolean>;
  19811. /**
  19812. * Observable signaled when VR request present starts
  19813. */
  19814. onVRRequestPresentStart: Observable<Engine>;
  19815. /**
  19816. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19817. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19818. */
  19819. isInVRExclusivePointerMode: boolean;
  19820. /**
  19821. * Gets a boolean indicating if a webVR device was detected
  19822. * @returns true if a webVR device was detected
  19823. */
  19824. isVRDevicePresent(): boolean;
  19825. /**
  19826. * Gets the current webVR device
  19827. * @returns the current webVR device (or null)
  19828. */
  19829. getVRDevice(): any;
  19830. /**
  19831. * Initializes a webVR display and starts listening to display change events
  19832. * The onVRDisplayChangedObservable will be notified upon these changes
  19833. * @returns A promise containing a VRDisplay and if vr is supported
  19834. */
  19835. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19836. /** @hidden */
  19837. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19838. /**
  19839. * Gets or sets the presentation attributes used to configure VR rendering
  19840. */
  19841. vrPresentationAttributes?: IVRPresentationAttributes;
  19842. /**
  19843. * Call this function to switch to webVR mode
  19844. * Will do nothing if webVR is not supported or if there is no webVR device
  19845. * @param options the webvr options provided to the camera. mainly used for multiview
  19846. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19847. */
  19848. enableVR(options: WebVROptions): void;
  19849. /** @hidden */
  19850. _onVRFullScreenTriggered(): void;
  19851. }
  19852. }
  19853. }
  19854. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19855. import { Nullable } from "babylonjs/types";
  19856. import { Observable } from "babylonjs/Misc/observable";
  19857. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19858. import { Scene } from "babylonjs/scene";
  19859. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19860. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19861. import { Node } from "babylonjs/node";
  19862. import { Ray } from "babylonjs/Culling/ray";
  19863. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19864. import "babylonjs/Engines/Extensions/engine.webVR";
  19865. /**
  19866. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19867. * IMPORTANT!! The data is right-hand data.
  19868. * @export
  19869. * @interface DevicePose
  19870. */
  19871. export interface DevicePose {
  19872. /**
  19873. * The position of the device, values in array are [x,y,z].
  19874. */
  19875. readonly position: Nullable<Float32Array>;
  19876. /**
  19877. * The linearVelocity of the device, values in array are [x,y,z].
  19878. */
  19879. readonly linearVelocity: Nullable<Float32Array>;
  19880. /**
  19881. * The linearAcceleration of the device, values in array are [x,y,z].
  19882. */
  19883. readonly linearAcceleration: Nullable<Float32Array>;
  19884. /**
  19885. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19886. */
  19887. readonly orientation: Nullable<Float32Array>;
  19888. /**
  19889. * The angularVelocity of the device, values in array are [x,y,z].
  19890. */
  19891. readonly angularVelocity: Nullable<Float32Array>;
  19892. /**
  19893. * The angularAcceleration of the device, values in array are [x,y,z].
  19894. */
  19895. readonly angularAcceleration: Nullable<Float32Array>;
  19896. }
  19897. /**
  19898. * Interface representing a pose controlled object in Babylon.
  19899. * A pose controlled object has both regular pose values as well as pose values
  19900. * from an external device such as a VR head mounted display
  19901. */
  19902. export interface PoseControlled {
  19903. /**
  19904. * The position of the object in babylon space.
  19905. */
  19906. position: Vector3;
  19907. /**
  19908. * The rotation quaternion of the object in babylon space.
  19909. */
  19910. rotationQuaternion: Quaternion;
  19911. /**
  19912. * The position of the device in babylon space.
  19913. */
  19914. devicePosition?: Vector3;
  19915. /**
  19916. * The rotation quaternion of the device in babylon space.
  19917. */
  19918. deviceRotationQuaternion: Quaternion;
  19919. /**
  19920. * The raw pose coming from the device.
  19921. */
  19922. rawPose: Nullable<DevicePose>;
  19923. /**
  19924. * The scale of the device to be used when translating from device space to babylon space.
  19925. */
  19926. deviceScaleFactor: number;
  19927. /**
  19928. * Updates the poseControlled values based on the input device pose.
  19929. * @param poseData the pose data to update the object with
  19930. */
  19931. updateFromDevice(poseData: DevicePose): void;
  19932. }
  19933. /**
  19934. * Set of options to customize the webVRCamera
  19935. */
  19936. export interface WebVROptions {
  19937. /**
  19938. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19939. */
  19940. trackPosition?: boolean;
  19941. /**
  19942. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19943. */
  19944. positionScale?: number;
  19945. /**
  19946. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19947. */
  19948. displayName?: string;
  19949. /**
  19950. * Should the native controller meshes be initialized. (default: true)
  19951. */
  19952. controllerMeshes?: boolean;
  19953. /**
  19954. * Creating a default HemiLight only on controllers. (default: true)
  19955. */
  19956. defaultLightingOnControllers?: boolean;
  19957. /**
  19958. * If you don't want to use the default VR button of the helper. (default: false)
  19959. */
  19960. useCustomVRButton?: boolean;
  19961. /**
  19962. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19963. */
  19964. customVRButton?: HTMLButtonElement;
  19965. /**
  19966. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19967. */
  19968. rayLength?: number;
  19969. /**
  19970. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19971. */
  19972. defaultHeight?: number;
  19973. /**
  19974. * If multiview should be used if availible (default: false)
  19975. */
  19976. useMultiview?: boolean;
  19977. }
  19978. /**
  19979. * This represents a WebVR camera.
  19980. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19981. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19982. */
  19983. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19984. private webVROptions;
  19985. /**
  19986. * @hidden
  19987. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19988. */
  19989. _vrDevice: any;
  19990. /**
  19991. * The rawPose of the vrDevice.
  19992. */
  19993. rawPose: Nullable<DevicePose>;
  19994. private _onVREnabled;
  19995. private _specsVersion;
  19996. private _attached;
  19997. private _frameData;
  19998. protected _descendants: Array<Node>;
  19999. private _deviceRoomPosition;
  20000. /** @hidden */
  20001. _deviceRoomRotationQuaternion: Quaternion;
  20002. private _standingMatrix;
  20003. /**
  20004. * Represents device position in babylon space.
  20005. */
  20006. devicePosition: Vector3;
  20007. /**
  20008. * Represents device rotation in babylon space.
  20009. */
  20010. deviceRotationQuaternion: Quaternion;
  20011. /**
  20012. * The scale of the device to be used when translating from device space to babylon space.
  20013. */
  20014. deviceScaleFactor: number;
  20015. private _deviceToWorld;
  20016. private _worldToDevice;
  20017. /**
  20018. * References to the webVR controllers for the vrDevice.
  20019. */
  20020. controllers: Array<WebVRController>;
  20021. /**
  20022. * Emits an event when a controller is attached.
  20023. */
  20024. onControllersAttachedObservable: Observable<WebVRController[]>;
  20025. /**
  20026. * Emits an event when a controller's mesh has been loaded;
  20027. */
  20028. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20029. /**
  20030. * Emits an event when the HMD's pose has been updated.
  20031. */
  20032. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20033. private _poseSet;
  20034. /**
  20035. * If the rig cameras be used as parent instead of this camera.
  20036. */
  20037. rigParenting: boolean;
  20038. private _lightOnControllers;
  20039. private _defaultHeight?;
  20040. /**
  20041. * Instantiates a WebVRFreeCamera.
  20042. * @param name The name of the WebVRFreeCamera
  20043. * @param position The starting anchor position for the camera
  20044. * @param scene The scene the camera belongs to
  20045. * @param webVROptions a set of customizable options for the webVRCamera
  20046. */
  20047. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20048. /**
  20049. * Gets the device distance from the ground in meters.
  20050. * @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.
  20051. */
  20052. deviceDistanceToRoomGround(): number;
  20053. /**
  20054. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20055. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20056. */
  20057. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20058. /**
  20059. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20060. * @returns A promise with a boolean set to if the standing matrix is supported.
  20061. */
  20062. useStandingMatrixAsync(): Promise<boolean>;
  20063. /**
  20064. * Disposes the camera
  20065. */
  20066. dispose(): void;
  20067. /**
  20068. * Gets a vrController by name.
  20069. * @param name The name of the controller to retreive
  20070. * @returns the controller matching the name specified or null if not found
  20071. */
  20072. getControllerByName(name: string): Nullable<WebVRController>;
  20073. private _leftController;
  20074. /**
  20075. * The controller corresponding to the users left hand.
  20076. */
  20077. get leftController(): Nullable<WebVRController>;
  20078. private _rightController;
  20079. /**
  20080. * The controller corresponding to the users right hand.
  20081. */
  20082. get rightController(): Nullable<WebVRController>;
  20083. /**
  20084. * Casts a ray forward from the vrCamera's gaze.
  20085. * @param length Length of the ray (default: 100)
  20086. * @returns the ray corresponding to the gaze
  20087. */
  20088. getForwardRay(length?: number): Ray;
  20089. /**
  20090. * @hidden
  20091. * Updates the camera based on device's frame data
  20092. */
  20093. _checkInputs(): void;
  20094. /**
  20095. * Updates the poseControlled values based on the input device pose.
  20096. * @param poseData Pose coming from the device
  20097. */
  20098. updateFromDevice(poseData: DevicePose): void;
  20099. private _htmlElementAttached;
  20100. private _detachIfAttached;
  20101. /**
  20102. * WebVR's attach control will start broadcasting frames to the device.
  20103. * Note that in certain browsers (chrome for example) this function must be called
  20104. * within a user-interaction callback. Example:
  20105. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20106. *
  20107. * @param element html element to attach the vrDevice to
  20108. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20109. */
  20110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20111. /**
  20112. * Detaches the camera from the html element and disables VR
  20113. *
  20114. * @param element html element to detach from
  20115. */
  20116. detachControl(element: HTMLElement): void;
  20117. /**
  20118. * @returns the name of this class
  20119. */
  20120. getClassName(): string;
  20121. /**
  20122. * Calls resetPose on the vrDisplay
  20123. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20124. */
  20125. resetToCurrentRotation(): void;
  20126. /**
  20127. * @hidden
  20128. * Updates the rig cameras (left and right eye)
  20129. */
  20130. _updateRigCameras(): void;
  20131. private _workingVector;
  20132. private _oneVector;
  20133. private _workingMatrix;
  20134. private updateCacheCalled;
  20135. private _correctPositionIfNotTrackPosition;
  20136. /**
  20137. * @hidden
  20138. * Updates the cached values of the camera
  20139. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20140. */
  20141. _updateCache(ignoreParentClass?: boolean): void;
  20142. /**
  20143. * @hidden
  20144. * Get current device position in babylon world
  20145. */
  20146. _computeDevicePosition(): void;
  20147. /**
  20148. * Updates the current device position and rotation in the babylon world
  20149. */
  20150. update(): void;
  20151. /**
  20152. * @hidden
  20153. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20154. * @returns an identity matrix
  20155. */
  20156. _getViewMatrix(): Matrix;
  20157. private _tmpMatrix;
  20158. /**
  20159. * This function is called by the two RIG cameras.
  20160. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20161. * @hidden
  20162. */
  20163. _getWebVRViewMatrix(): Matrix;
  20164. /** @hidden */
  20165. _getWebVRProjectionMatrix(): Matrix;
  20166. private _onGamepadConnectedObserver;
  20167. private _onGamepadDisconnectedObserver;
  20168. private _updateCacheWhenTrackingDisabledObserver;
  20169. /**
  20170. * Initializes the controllers and their meshes
  20171. */
  20172. initControllers(): void;
  20173. }
  20174. }
  20175. declare module "babylonjs/PostProcesses/postProcess" {
  20176. import { Nullable } from "babylonjs/types";
  20177. import { SmartArray } from "babylonjs/Misc/smartArray";
  20178. import { Observable } from "babylonjs/Misc/observable";
  20179. import { Vector2 } from "babylonjs/Maths/math.vector";
  20180. import { Camera } from "babylonjs/Cameras/camera";
  20181. import { Effect } from "babylonjs/Materials/effect";
  20182. import "babylonjs/Shaders/postprocess.vertex";
  20183. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20184. import { Engine } from "babylonjs/Engines/engine";
  20185. import { Color4 } from "babylonjs/Maths/math.color";
  20186. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20187. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20188. /**
  20189. * Size options for a post process
  20190. */
  20191. export type PostProcessOptions = {
  20192. width: number;
  20193. height: number;
  20194. };
  20195. /**
  20196. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20197. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20198. */
  20199. export class PostProcess {
  20200. /** Name of the PostProcess. */
  20201. name: string;
  20202. /**
  20203. * Gets or sets the unique id of the post process
  20204. */
  20205. uniqueId: number;
  20206. /**
  20207. * Width of the texture to apply the post process on
  20208. */
  20209. width: number;
  20210. /**
  20211. * Height of the texture to apply the post process on
  20212. */
  20213. height: number;
  20214. /**
  20215. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20216. * @hidden
  20217. */
  20218. _outputTexture: Nullable<InternalTexture>;
  20219. /**
  20220. * Sampling mode used by the shader
  20221. * See https://doc.babylonjs.com/classes/3.1/texture
  20222. */
  20223. renderTargetSamplingMode: number;
  20224. /**
  20225. * Clear color to use when screen clearing
  20226. */
  20227. clearColor: Color4;
  20228. /**
  20229. * If the buffer needs to be cleared before applying the post process. (default: true)
  20230. * Should be set to false if shader will overwrite all previous pixels.
  20231. */
  20232. autoClear: boolean;
  20233. /**
  20234. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20235. */
  20236. alphaMode: number;
  20237. /**
  20238. * Sets the setAlphaBlendConstants of the babylon engine
  20239. */
  20240. alphaConstants: Color4;
  20241. /**
  20242. * Animations to be used for the post processing
  20243. */
  20244. animations: import("babylonjs/Animations/animation").Animation[];
  20245. /**
  20246. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20247. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20248. */
  20249. enablePixelPerfectMode: boolean;
  20250. /**
  20251. * Force the postprocess to be applied without taking in account viewport
  20252. */
  20253. forceFullscreenViewport: boolean;
  20254. /**
  20255. * List of inspectable custom properties (used by the Inspector)
  20256. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20257. */
  20258. inspectableCustomProperties: IInspectable[];
  20259. /**
  20260. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20261. *
  20262. * | Value | Type | Description |
  20263. * | ----- | ----------------------------------- | ----------- |
  20264. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20265. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20266. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20267. *
  20268. */
  20269. scaleMode: number;
  20270. /**
  20271. * Force textures to be a power of two (default: false)
  20272. */
  20273. alwaysForcePOT: boolean;
  20274. private _samples;
  20275. /**
  20276. * Number of sample textures (default: 1)
  20277. */
  20278. get samples(): number;
  20279. set samples(n: number);
  20280. /**
  20281. * Modify the scale of the post process to be the same as the viewport (default: false)
  20282. */
  20283. adaptScaleToCurrentViewport: boolean;
  20284. private _camera;
  20285. private _scene;
  20286. private _engine;
  20287. private _options;
  20288. private _reusable;
  20289. private _textureType;
  20290. private _textureFormat;
  20291. /**
  20292. * Smart array of input and output textures for the post process.
  20293. * @hidden
  20294. */
  20295. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20296. /**
  20297. * The index in _textures that corresponds to the output texture.
  20298. * @hidden
  20299. */
  20300. _currentRenderTextureInd: number;
  20301. private _effect;
  20302. private _samplers;
  20303. private _fragmentUrl;
  20304. private _vertexUrl;
  20305. private _parameters;
  20306. private _scaleRatio;
  20307. protected _indexParameters: any;
  20308. private _shareOutputWithPostProcess;
  20309. private _texelSize;
  20310. private _forcedOutputTexture;
  20311. /**
  20312. * Returns the fragment url or shader name used in the post process.
  20313. * @returns the fragment url or name in the shader store.
  20314. */
  20315. getEffectName(): string;
  20316. /**
  20317. * An event triggered when the postprocess is activated.
  20318. */
  20319. onActivateObservable: Observable<Camera>;
  20320. private _onActivateObserver;
  20321. /**
  20322. * A function that is added to the onActivateObservable
  20323. */
  20324. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20325. /**
  20326. * An event triggered when the postprocess changes its size.
  20327. */
  20328. onSizeChangedObservable: Observable<PostProcess>;
  20329. private _onSizeChangedObserver;
  20330. /**
  20331. * A function that is added to the onSizeChangedObservable
  20332. */
  20333. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20334. /**
  20335. * An event triggered when the postprocess applies its effect.
  20336. */
  20337. onApplyObservable: Observable<Effect>;
  20338. private _onApplyObserver;
  20339. /**
  20340. * A function that is added to the onApplyObservable
  20341. */
  20342. set onApply(callback: (effect: Effect) => void);
  20343. /**
  20344. * An event triggered before rendering the postprocess
  20345. */
  20346. onBeforeRenderObservable: Observable<Effect>;
  20347. private _onBeforeRenderObserver;
  20348. /**
  20349. * A function that is added to the onBeforeRenderObservable
  20350. */
  20351. set onBeforeRender(callback: (effect: Effect) => void);
  20352. /**
  20353. * An event triggered after rendering the postprocess
  20354. */
  20355. onAfterRenderObservable: Observable<Effect>;
  20356. private _onAfterRenderObserver;
  20357. /**
  20358. * A function that is added to the onAfterRenderObservable
  20359. */
  20360. set onAfterRender(callback: (efect: Effect) => void);
  20361. /**
  20362. * 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
  20363. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20364. */
  20365. get inputTexture(): InternalTexture;
  20366. set inputTexture(value: InternalTexture);
  20367. /**
  20368. * Gets the camera which post process is applied to.
  20369. * @returns The camera the post process is applied to.
  20370. */
  20371. getCamera(): Camera;
  20372. /**
  20373. * Gets the texel size of the postprocess.
  20374. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20375. */
  20376. get texelSize(): Vector2;
  20377. /**
  20378. * Creates a new instance PostProcess
  20379. * @param name The name of the PostProcess.
  20380. * @param fragmentUrl The url of the fragment shader to be used.
  20381. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20382. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20383. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20384. * @param camera The camera to apply the render pass to.
  20385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20386. * @param engine The engine which the post process will be applied. (default: current engine)
  20387. * @param reusable If the post process can be reused on the same frame. (default: false)
  20388. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20389. * @param textureType Type of textures used when performing the post process. (default: 0)
  20390. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20391. * @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
  20392. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20393. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20394. */
  20395. constructor(
  20396. /** Name of the PostProcess. */
  20397. 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);
  20398. /**
  20399. * Gets a string idenfifying the name of the class
  20400. * @returns "PostProcess" string
  20401. */
  20402. getClassName(): string;
  20403. /**
  20404. * Gets the engine which this post process belongs to.
  20405. * @returns The engine the post process was enabled with.
  20406. */
  20407. getEngine(): Engine;
  20408. /**
  20409. * The effect that is created when initializing the post process.
  20410. * @returns The created effect corresponding the the postprocess.
  20411. */
  20412. getEffect(): Effect;
  20413. /**
  20414. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20415. * @param postProcess The post process to share the output with.
  20416. * @returns This post process.
  20417. */
  20418. shareOutputWith(postProcess: PostProcess): PostProcess;
  20419. /**
  20420. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20421. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20422. */
  20423. useOwnOutput(): void;
  20424. /**
  20425. * Updates the effect with the current post process compile time values and recompiles the shader.
  20426. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20427. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20428. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20429. * @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
  20430. * @param onCompiled Called when the shader has been compiled.
  20431. * @param onError Called if there is an error when compiling a shader.
  20432. */
  20433. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20434. /**
  20435. * The post process is reusable if it can be used multiple times within one frame.
  20436. * @returns If the post process is reusable
  20437. */
  20438. isReusable(): boolean;
  20439. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20440. markTextureDirty(): void;
  20441. /**
  20442. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20443. * 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.
  20444. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20445. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20446. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20447. * @returns The target texture that was bound to be written to.
  20448. */
  20449. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20450. /**
  20451. * If the post process is supported.
  20452. */
  20453. get isSupported(): boolean;
  20454. /**
  20455. * The aspect ratio of the output texture.
  20456. */
  20457. get aspectRatio(): number;
  20458. /**
  20459. * Get a value indicating if the post-process is ready to be used
  20460. * @returns true if the post-process is ready (shader is compiled)
  20461. */
  20462. isReady(): boolean;
  20463. /**
  20464. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20465. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20466. */
  20467. apply(): Nullable<Effect>;
  20468. private _disposeTextures;
  20469. /**
  20470. * Disposes the post process.
  20471. * @param camera The camera to dispose the post process on.
  20472. */
  20473. dispose(camera?: Camera): void;
  20474. }
  20475. }
  20476. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20477. /** @hidden */
  20478. export var kernelBlurVaryingDeclaration: {
  20479. name: string;
  20480. shader: string;
  20481. };
  20482. }
  20483. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20484. /** @hidden */
  20485. export var kernelBlurFragment: {
  20486. name: string;
  20487. shader: string;
  20488. };
  20489. }
  20490. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20491. /** @hidden */
  20492. export var kernelBlurFragment2: {
  20493. name: string;
  20494. shader: string;
  20495. };
  20496. }
  20497. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20498. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20499. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20500. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20501. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20502. /** @hidden */
  20503. export var kernelBlurPixelShader: {
  20504. name: string;
  20505. shader: string;
  20506. };
  20507. }
  20508. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20509. /** @hidden */
  20510. export var kernelBlurVertex: {
  20511. name: string;
  20512. shader: string;
  20513. };
  20514. }
  20515. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20516. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20517. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20518. /** @hidden */
  20519. export var kernelBlurVertexShader: {
  20520. name: string;
  20521. shader: string;
  20522. };
  20523. }
  20524. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20525. import { Vector2 } from "babylonjs/Maths/math.vector";
  20526. import { Nullable } from "babylonjs/types";
  20527. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20528. import { Camera } from "babylonjs/Cameras/camera";
  20529. import { Effect } from "babylonjs/Materials/effect";
  20530. import { Engine } from "babylonjs/Engines/engine";
  20531. import "babylonjs/Shaders/kernelBlur.fragment";
  20532. import "babylonjs/Shaders/kernelBlur.vertex";
  20533. /**
  20534. * The Blur Post Process which blurs an image based on a kernel and direction.
  20535. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20536. */
  20537. export class BlurPostProcess extends PostProcess {
  20538. /** The direction in which to blur the image. */
  20539. direction: Vector2;
  20540. private blockCompilation;
  20541. protected _kernel: number;
  20542. protected _idealKernel: number;
  20543. protected _packedFloat: boolean;
  20544. private _staticDefines;
  20545. /**
  20546. * Sets the length in pixels of the blur sample region
  20547. */
  20548. set kernel(v: number);
  20549. /**
  20550. * Gets the length in pixels of the blur sample region
  20551. */
  20552. get kernel(): number;
  20553. /**
  20554. * Sets wether or not the blur needs to unpack/repack floats
  20555. */
  20556. set packedFloat(v: boolean);
  20557. /**
  20558. * Gets wether or not the blur is unpacking/repacking floats
  20559. */
  20560. get packedFloat(): boolean;
  20561. /**
  20562. * Creates a new instance BlurPostProcess
  20563. * @param name The name of the effect.
  20564. * @param direction The direction in which to blur the image.
  20565. * @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.
  20566. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20567. * @param camera The camera to apply the render pass to.
  20568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20569. * @param engine The engine which the post process will be applied. (default: current engine)
  20570. * @param reusable If the post process can be reused on the same frame. (default: false)
  20571. * @param textureType Type of textures used when performing the post process. (default: 0)
  20572. * @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)
  20573. */
  20574. constructor(name: string,
  20575. /** The direction in which to blur the image. */
  20576. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20577. /**
  20578. * Updates the effect with the current post process compile time values and recompiles the shader.
  20579. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20580. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20581. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20582. * @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
  20583. * @param onCompiled Called when the shader has been compiled.
  20584. * @param onError Called if there is an error when compiling a shader.
  20585. */
  20586. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20587. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20588. /**
  20589. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20590. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20591. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20592. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20593. * The gaps between physical kernels are compensated for in the weighting of the samples
  20594. * @param idealKernel Ideal blur kernel.
  20595. * @return Nearest best kernel.
  20596. */
  20597. protected _nearestBestKernel(idealKernel: number): number;
  20598. /**
  20599. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20600. * @param x The point on the Gaussian distribution to sample.
  20601. * @return the value of the Gaussian function at x.
  20602. */
  20603. protected _gaussianWeight(x: number): number;
  20604. /**
  20605. * Generates a string that can be used as a floating point number in GLSL.
  20606. * @param x Value to print.
  20607. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20608. * @return GLSL float string.
  20609. */
  20610. protected _glslFloat(x: number, decimalFigures?: number): string;
  20611. }
  20612. }
  20613. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20614. import { Scene } from "babylonjs/scene";
  20615. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20616. import { Plane } from "babylonjs/Maths/math.plane";
  20617. /**
  20618. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20619. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20620. * You can then easily use it as a reflectionTexture on a flat surface.
  20621. * In case the surface is not a plane, please consider relying on reflection probes.
  20622. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20623. */
  20624. export class MirrorTexture extends RenderTargetTexture {
  20625. private scene;
  20626. /**
  20627. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20628. * 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.
  20629. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20630. */
  20631. mirrorPlane: Plane;
  20632. /**
  20633. * Define the blur ratio used to blur the reflection if needed.
  20634. */
  20635. set blurRatio(value: number);
  20636. get blurRatio(): number;
  20637. /**
  20638. * Define the adaptive blur kernel used to blur the reflection if needed.
  20639. * This will autocompute the closest best match for the `blurKernel`
  20640. */
  20641. set adaptiveBlurKernel(value: number);
  20642. /**
  20643. * Define the blur kernel used to blur the reflection if needed.
  20644. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20645. */
  20646. set blurKernel(value: number);
  20647. /**
  20648. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20649. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20650. */
  20651. set blurKernelX(value: number);
  20652. get blurKernelX(): number;
  20653. /**
  20654. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20655. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20656. */
  20657. set blurKernelY(value: number);
  20658. get blurKernelY(): number;
  20659. private _autoComputeBlurKernel;
  20660. protected _onRatioRescale(): void;
  20661. private _updateGammaSpace;
  20662. private _imageProcessingConfigChangeObserver;
  20663. private _transformMatrix;
  20664. private _mirrorMatrix;
  20665. private _savedViewMatrix;
  20666. private _blurX;
  20667. private _blurY;
  20668. private _adaptiveBlurKernel;
  20669. private _blurKernelX;
  20670. private _blurKernelY;
  20671. private _blurRatio;
  20672. /**
  20673. * Instantiates a Mirror Texture.
  20674. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20675. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20676. * You can then easily use it as a reflectionTexture on a flat surface.
  20677. * In case the surface is not a plane, please consider relying on reflection probes.
  20678. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20679. * @param name
  20680. * @param size
  20681. * @param scene
  20682. * @param generateMipMaps
  20683. * @param type
  20684. * @param samplingMode
  20685. * @param generateDepthBuffer
  20686. */
  20687. constructor(name: string, size: number | {
  20688. width: number;
  20689. height: number;
  20690. } | {
  20691. ratio: number;
  20692. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20693. private _preparePostProcesses;
  20694. /**
  20695. * Clone the mirror texture.
  20696. * @returns the cloned texture
  20697. */
  20698. clone(): MirrorTexture;
  20699. /**
  20700. * Serialize the texture to a JSON representation you could use in Parse later on
  20701. * @returns the serialized JSON representation
  20702. */
  20703. serialize(): any;
  20704. /**
  20705. * Dispose the texture and release its associated resources.
  20706. */
  20707. dispose(): void;
  20708. }
  20709. }
  20710. declare module "babylonjs/Materials/Textures/texture" {
  20711. import { Observable } from "babylonjs/Misc/observable";
  20712. import { Nullable } from "babylonjs/types";
  20713. import { Matrix } from "babylonjs/Maths/math.vector";
  20714. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20715. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20716. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20717. import { Scene } from "babylonjs/scene";
  20718. /**
  20719. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20720. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20721. */
  20722. export class Texture extends BaseTexture {
  20723. /**
  20724. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20725. */
  20726. static SerializeBuffers: boolean;
  20727. /** @hidden */
  20728. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20729. /** @hidden */
  20730. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20731. /** @hidden */
  20732. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20733. /** nearest is mag = nearest and min = nearest and mip = linear */
  20734. static readonly NEAREST_SAMPLINGMODE: number;
  20735. /** nearest is mag = nearest and min = nearest and mip = linear */
  20736. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20737. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20738. static readonly BILINEAR_SAMPLINGMODE: number;
  20739. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20740. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20741. /** Trilinear is mag = linear and min = linear and mip = linear */
  20742. static readonly TRILINEAR_SAMPLINGMODE: number;
  20743. /** Trilinear is mag = linear and min = linear and mip = linear */
  20744. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20745. /** mag = nearest and min = nearest and mip = nearest */
  20746. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20747. /** mag = nearest and min = linear and mip = nearest */
  20748. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20749. /** mag = nearest and min = linear and mip = linear */
  20750. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20751. /** mag = nearest and min = linear and mip = none */
  20752. static readonly NEAREST_LINEAR: number;
  20753. /** mag = nearest and min = nearest and mip = none */
  20754. static readonly NEAREST_NEAREST: number;
  20755. /** mag = linear and min = nearest and mip = nearest */
  20756. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20757. /** mag = linear and min = nearest and mip = linear */
  20758. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20759. /** mag = linear and min = linear and mip = none */
  20760. static readonly LINEAR_LINEAR: number;
  20761. /** mag = linear and min = nearest and mip = none */
  20762. static readonly LINEAR_NEAREST: number;
  20763. /** Explicit coordinates mode */
  20764. static readonly EXPLICIT_MODE: number;
  20765. /** Spherical coordinates mode */
  20766. static readonly SPHERICAL_MODE: number;
  20767. /** Planar coordinates mode */
  20768. static readonly PLANAR_MODE: number;
  20769. /** Cubic coordinates mode */
  20770. static readonly CUBIC_MODE: number;
  20771. /** Projection coordinates mode */
  20772. static readonly PROJECTION_MODE: number;
  20773. /** Inverse Cubic coordinates mode */
  20774. static readonly SKYBOX_MODE: number;
  20775. /** Inverse Cubic coordinates mode */
  20776. static readonly INVCUBIC_MODE: number;
  20777. /** Equirectangular coordinates mode */
  20778. static readonly EQUIRECTANGULAR_MODE: number;
  20779. /** Equirectangular Fixed coordinates mode */
  20780. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20781. /** Equirectangular Fixed Mirrored coordinates mode */
  20782. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20783. /** Texture is not repeating outside of 0..1 UVs */
  20784. static readonly CLAMP_ADDRESSMODE: number;
  20785. /** Texture is repeating outside of 0..1 UVs */
  20786. static readonly WRAP_ADDRESSMODE: number;
  20787. /** Texture is repeating and mirrored */
  20788. static readonly MIRROR_ADDRESSMODE: number;
  20789. /**
  20790. * 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
  20791. */
  20792. static UseSerializedUrlIfAny: boolean;
  20793. /**
  20794. * Define the url of the texture.
  20795. */
  20796. url: Nullable<string>;
  20797. /**
  20798. * Define an offset on the texture to offset the u coordinates of the UVs
  20799. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20800. */
  20801. uOffset: number;
  20802. /**
  20803. * Define an offset on the texture to offset the v coordinates of the UVs
  20804. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20805. */
  20806. vOffset: number;
  20807. /**
  20808. * Define an offset on the texture to scale the u coordinates of the UVs
  20809. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20810. */
  20811. uScale: number;
  20812. /**
  20813. * Define an offset on the texture to scale the v coordinates of the UVs
  20814. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20815. */
  20816. vScale: number;
  20817. /**
  20818. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20819. * @see http://doc.babylonjs.com/how_to/more_materials
  20820. */
  20821. uAng: number;
  20822. /**
  20823. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20824. * @see http://doc.babylonjs.com/how_to/more_materials
  20825. */
  20826. vAng: number;
  20827. /**
  20828. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20829. * @see http://doc.babylonjs.com/how_to/more_materials
  20830. */
  20831. wAng: number;
  20832. /**
  20833. * Defines the center of rotation (U)
  20834. */
  20835. uRotationCenter: number;
  20836. /**
  20837. * Defines the center of rotation (V)
  20838. */
  20839. vRotationCenter: number;
  20840. /**
  20841. * Defines the center of rotation (W)
  20842. */
  20843. wRotationCenter: number;
  20844. /**
  20845. * Are mip maps generated for this texture or not.
  20846. */
  20847. get noMipmap(): boolean;
  20848. /**
  20849. * List of inspectable custom properties (used by the Inspector)
  20850. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20851. */
  20852. inspectableCustomProperties: Nullable<IInspectable[]>;
  20853. private _noMipmap;
  20854. /** @hidden */
  20855. _invertY: boolean;
  20856. private _rowGenerationMatrix;
  20857. private _cachedTextureMatrix;
  20858. private _projectionModeMatrix;
  20859. private _t0;
  20860. private _t1;
  20861. private _t2;
  20862. private _cachedUOffset;
  20863. private _cachedVOffset;
  20864. private _cachedUScale;
  20865. private _cachedVScale;
  20866. private _cachedUAng;
  20867. private _cachedVAng;
  20868. private _cachedWAng;
  20869. private _cachedProjectionMatrixId;
  20870. private _cachedCoordinatesMode;
  20871. /** @hidden */
  20872. protected _initialSamplingMode: number;
  20873. /** @hidden */
  20874. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20875. private _deleteBuffer;
  20876. protected _format: Nullable<number>;
  20877. private _delayedOnLoad;
  20878. private _delayedOnError;
  20879. private _mimeType?;
  20880. /**
  20881. * Observable triggered once the texture has been loaded.
  20882. */
  20883. onLoadObservable: Observable<Texture>;
  20884. protected _isBlocking: boolean;
  20885. /**
  20886. * Is the texture preventing material to render while loading.
  20887. * If false, a default texture will be used instead of the loading one during the preparation step.
  20888. */
  20889. set isBlocking(value: boolean);
  20890. get isBlocking(): boolean;
  20891. /**
  20892. * Get the current sampling mode associated with the texture.
  20893. */
  20894. get samplingMode(): number;
  20895. /**
  20896. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20897. */
  20898. get invertY(): boolean;
  20899. /**
  20900. * Instantiates a new texture.
  20901. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20902. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20903. * @param url defines the url of the picture to load as a texture
  20904. * @param scene defines the scene or engine the texture will belong to
  20905. * @param noMipmap defines if the texture will require mip maps or not
  20906. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20907. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20908. * @param onLoad defines a callback triggered when the texture has been loaded
  20909. * @param onError defines a callback triggered when an error occurred during the loading session
  20910. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20911. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20912. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20913. * @param mimeType defines an optional mime type information
  20914. */
  20915. 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);
  20916. /**
  20917. * Update the url (and optional buffer) of this texture if url was null during construction.
  20918. * @param url the url of the texture
  20919. * @param buffer the buffer of the texture (defaults to null)
  20920. * @param onLoad callback called when the texture is loaded (defaults to null)
  20921. */
  20922. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20923. /**
  20924. * Finish the loading sequence of a texture flagged as delayed load.
  20925. * @hidden
  20926. */
  20927. delayLoad(): void;
  20928. private _prepareRowForTextureGeneration;
  20929. /**
  20930. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20931. * @returns the transform matrix of the texture.
  20932. */
  20933. getTextureMatrix(uBase?: number): Matrix;
  20934. /**
  20935. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20936. * @returns The reflection texture transform
  20937. */
  20938. getReflectionTextureMatrix(): Matrix;
  20939. /**
  20940. * Clones the texture.
  20941. * @returns the cloned texture
  20942. */
  20943. clone(): Texture;
  20944. /**
  20945. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20946. * @returns The JSON representation of the texture
  20947. */
  20948. serialize(): any;
  20949. /**
  20950. * Get the current class name of the texture useful for serialization or dynamic coding.
  20951. * @returns "Texture"
  20952. */
  20953. getClassName(): string;
  20954. /**
  20955. * Dispose the texture and release its associated resources.
  20956. */
  20957. dispose(): void;
  20958. /**
  20959. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20960. * @param parsedTexture Define the JSON representation of the texture
  20961. * @param scene Define the scene the parsed texture should be instantiated in
  20962. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20963. * @returns The parsed texture if successful
  20964. */
  20965. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20966. /**
  20967. * Creates a texture from its base 64 representation.
  20968. * @param data Define the base64 payload without the data: prefix
  20969. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20970. * @param scene Define the scene the texture should belong to
  20971. * @param noMipmap Forces the texture to not create mip map information if true
  20972. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20973. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20974. * @param onLoad define a callback triggered when the texture has been loaded
  20975. * @param onError define a callback triggered when an error occurred during the loading session
  20976. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20977. * @returns the created texture
  20978. */
  20979. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20980. /**
  20981. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20982. * @param data Define the base64 payload without the data: prefix
  20983. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20984. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20985. * @param scene Define the scene the texture should belong to
  20986. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20987. * @param noMipmap Forces the texture to not create mip map information if true
  20988. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20989. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20990. * @param onLoad define a callback triggered when the texture has been loaded
  20991. * @param onError define a callback triggered when an error occurred during the loading session
  20992. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20993. * @returns the created texture
  20994. */
  20995. 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;
  20996. }
  20997. }
  20998. declare module "babylonjs/PostProcesses/postProcessManager" {
  20999. import { Nullable } from "babylonjs/types";
  21000. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21001. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21002. import { Scene } from "babylonjs/scene";
  21003. /**
  21004. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21005. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21006. */
  21007. export class PostProcessManager {
  21008. private _scene;
  21009. private _indexBuffer;
  21010. private _vertexBuffers;
  21011. /**
  21012. * Creates a new instance PostProcess
  21013. * @param scene The scene that the post process is associated with.
  21014. */
  21015. constructor(scene: Scene);
  21016. private _prepareBuffers;
  21017. private _buildIndexBuffer;
  21018. /**
  21019. * Rebuilds the vertex buffers of the manager.
  21020. * @hidden
  21021. */
  21022. _rebuild(): void;
  21023. /**
  21024. * Prepares a frame to be run through a post process.
  21025. * @param sourceTexture The input texture to the post procesess. (default: null)
  21026. * @param postProcesses An array of post processes to be run. (default: null)
  21027. * @returns True if the post processes were able to be run.
  21028. * @hidden
  21029. */
  21030. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21031. /**
  21032. * Manually render a set of post processes to a texture.
  21033. * @param postProcesses An array of post processes to be run.
  21034. * @param targetTexture The target texture to render to.
  21035. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21036. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21037. * @param lodLevel defines which lod of the texture to render to
  21038. */
  21039. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21040. /**
  21041. * Finalize the result of the output of the postprocesses.
  21042. * @param doNotPresent If true the result will not be displayed to the screen.
  21043. * @param targetTexture The target texture to render to.
  21044. * @param faceIndex The index of the face to bind the target texture to.
  21045. * @param postProcesses The array of post processes to render.
  21046. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21047. * @hidden
  21048. */
  21049. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21050. /**
  21051. * Disposes of the post process manager.
  21052. */
  21053. dispose(): void;
  21054. }
  21055. }
  21056. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21057. import { Observable } from "babylonjs/Misc/observable";
  21058. import { SmartArray } from "babylonjs/Misc/smartArray";
  21059. import { Nullable, Immutable } from "babylonjs/types";
  21060. import { Camera } from "babylonjs/Cameras/camera";
  21061. import { Scene } from "babylonjs/scene";
  21062. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21063. import { Color4 } from "babylonjs/Maths/math.color";
  21064. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21066. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21067. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21068. import { Texture } from "babylonjs/Materials/Textures/texture";
  21069. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21070. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21071. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21072. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21073. import { Engine } from "babylonjs/Engines/engine";
  21074. /**
  21075. * This Helps creating a texture that will be created from a camera in your scene.
  21076. * It is basically a dynamic texture that could be used to create special effects for instance.
  21077. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21078. */
  21079. export class RenderTargetTexture extends Texture {
  21080. isCube: boolean;
  21081. /**
  21082. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21083. */
  21084. static readonly REFRESHRATE_RENDER_ONCE: number;
  21085. /**
  21086. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21087. */
  21088. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21089. /**
  21090. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21091. * the central point of your effect and can save a lot of performances.
  21092. */
  21093. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21094. /**
  21095. * Use this predicate to dynamically define the list of mesh you want to render.
  21096. * If set, the renderList property will be overwritten.
  21097. */
  21098. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21099. private _renderList;
  21100. /**
  21101. * Use this list to define the list of mesh you want to render.
  21102. */
  21103. get renderList(): Nullable<Array<AbstractMesh>>;
  21104. set renderList(value: Nullable<Array<AbstractMesh>>);
  21105. /**
  21106. * Use this function to overload the renderList array at rendering time.
  21107. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21108. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21109. * the cube (if the RTT is a cube, else layerOrFace=0).
  21110. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21111. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21112. * hold dummy elements!
  21113. */
  21114. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21115. private _hookArray;
  21116. /**
  21117. * Define if particles should be rendered in your texture.
  21118. */
  21119. renderParticles: boolean;
  21120. /**
  21121. * Define if sprites should be rendered in your texture.
  21122. */
  21123. renderSprites: boolean;
  21124. /**
  21125. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21126. */
  21127. coordinatesMode: number;
  21128. /**
  21129. * Define the camera used to render the texture.
  21130. */
  21131. activeCamera: Nullable<Camera>;
  21132. /**
  21133. * Override the render function of the texture with your own one.
  21134. */
  21135. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21136. /**
  21137. * Define if camera post processes should be use while rendering the texture.
  21138. */
  21139. useCameraPostProcesses: boolean;
  21140. /**
  21141. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21142. */
  21143. ignoreCameraViewport: boolean;
  21144. private _postProcessManager;
  21145. private _postProcesses;
  21146. private _resizeObserver;
  21147. /**
  21148. * An event triggered when the texture is unbind.
  21149. */
  21150. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21151. /**
  21152. * An event triggered when the texture is unbind.
  21153. */
  21154. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21155. private _onAfterUnbindObserver;
  21156. /**
  21157. * Set a after unbind callback in the texture.
  21158. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21159. */
  21160. set onAfterUnbind(callback: () => void);
  21161. /**
  21162. * An event triggered before rendering the texture
  21163. */
  21164. onBeforeRenderObservable: Observable<number>;
  21165. private _onBeforeRenderObserver;
  21166. /**
  21167. * Set a before render callback in the texture.
  21168. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21169. */
  21170. set onBeforeRender(callback: (faceIndex: number) => void);
  21171. /**
  21172. * An event triggered after rendering the texture
  21173. */
  21174. onAfterRenderObservable: Observable<number>;
  21175. private _onAfterRenderObserver;
  21176. /**
  21177. * Set a after render callback in the texture.
  21178. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21179. */
  21180. set onAfterRender(callback: (faceIndex: number) => void);
  21181. /**
  21182. * An event triggered after the texture clear
  21183. */
  21184. onClearObservable: Observable<Engine>;
  21185. private _onClearObserver;
  21186. /**
  21187. * Set a clear callback in the texture.
  21188. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21189. */
  21190. set onClear(callback: (Engine: Engine) => void);
  21191. /**
  21192. * An event triggered when the texture is resized.
  21193. */
  21194. onResizeObservable: Observable<RenderTargetTexture>;
  21195. /**
  21196. * Define the clear color of the Render Target if it should be different from the scene.
  21197. */
  21198. clearColor: Color4;
  21199. protected _size: number | {
  21200. width: number;
  21201. height: number;
  21202. layers?: number;
  21203. };
  21204. protected _initialSizeParameter: number | {
  21205. width: number;
  21206. height: number;
  21207. } | {
  21208. ratio: number;
  21209. };
  21210. protected _sizeRatio: Nullable<number>;
  21211. /** @hidden */
  21212. _generateMipMaps: boolean;
  21213. protected _renderingManager: RenderingManager;
  21214. /** @hidden */
  21215. _waitingRenderList: string[];
  21216. protected _doNotChangeAspectRatio: boolean;
  21217. protected _currentRefreshId: number;
  21218. protected _refreshRate: number;
  21219. protected _textureMatrix: Matrix;
  21220. protected _samples: number;
  21221. protected _renderTargetOptions: RenderTargetCreationOptions;
  21222. /**
  21223. * Gets render target creation options that were used.
  21224. */
  21225. get renderTargetOptions(): RenderTargetCreationOptions;
  21226. protected _engine: Engine;
  21227. protected _onRatioRescale(): void;
  21228. /**
  21229. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21230. * It must define where the camera used to render the texture is set
  21231. */
  21232. boundingBoxPosition: Vector3;
  21233. private _boundingBoxSize;
  21234. /**
  21235. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21236. * When defined, the cubemap will switch to local mode
  21237. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21238. * @example https://www.babylonjs-playground.com/#RNASML
  21239. */
  21240. set boundingBoxSize(value: Vector3);
  21241. get boundingBoxSize(): Vector3;
  21242. /**
  21243. * In case the RTT has been created with a depth texture, get the associated
  21244. * depth texture.
  21245. * Otherwise, return null.
  21246. */
  21247. get depthStencilTexture(): Nullable<InternalTexture>;
  21248. /**
  21249. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21250. * or used a shadow, depth texture...
  21251. * @param name The friendly name of the texture
  21252. * @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)
  21253. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21254. * @param generateMipMaps True if mip maps need to be generated after render.
  21255. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21256. * @param type The type of the buffer in the RTT (int, half float, float...)
  21257. * @param isCube True if a cube texture needs to be created
  21258. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21259. * @param generateDepthBuffer True to generate a depth buffer
  21260. * @param generateStencilBuffer True to generate a stencil buffer
  21261. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21262. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21263. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21264. */
  21265. constructor(name: string, size: number | {
  21266. width: number;
  21267. height: number;
  21268. layers?: number;
  21269. } | {
  21270. ratio: number;
  21271. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21272. /**
  21273. * Creates a depth stencil texture.
  21274. * This is only available in WebGL 2 or with the depth texture extension available.
  21275. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21276. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21277. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21278. */
  21279. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21280. private _processSizeParameter;
  21281. /**
  21282. * Define the number of samples to use in case of MSAA.
  21283. * It defaults to one meaning no MSAA has been enabled.
  21284. */
  21285. get samples(): number;
  21286. set samples(value: number);
  21287. /**
  21288. * Resets the refresh counter of the texture and start bak from scratch.
  21289. * Could be useful to regenerate the texture if it is setup to render only once.
  21290. */
  21291. resetRefreshCounter(): void;
  21292. /**
  21293. * Define the refresh rate of the texture or the rendering frequency.
  21294. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21295. */
  21296. get refreshRate(): number;
  21297. set refreshRate(value: number);
  21298. /**
  21299. * Adds a post process to the render target rendering passes.
  21300. * @param postProcess define the post process to add
  21301. */
  21302. addPostProcess(postProcess: PostProcess): void;
  21303. /**
  21304. * Clear all the post processes attached to the render target
  21305. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21306. */
  21307. clearPostProcesses(dispose?: boolean): void;
  21308. /**
  21309. * Remove one of the post process from the list of attached post processes to the texture
  21310. * @param postProcess define the post process to remove from the list
  21311. */
  21312. removePostProcess(postProcess: PostProcess): void;
  21313. /** @hidden */
  21314. _shouldRender(): boolean;
  21315. /**
  21316. * Gets the actual render size of the texture.
  21317. * @returns the width of the render size
  21318. */
  21319. getRenderSize(): number;
  21320. /**
  21321. * Gets the actual render width of the texture.
  21322. * @returns the width of the render size
  21323. */
  21324. getRenderWidth(): number;
  21325. /**
  21326. * Gets the actual render height of the texture.
  21327. * @returns the height of the render size
  21328. */
  21329. getRenderHeight(): number;
  21330. /**
  21331. * Gets the actual number of layers of the texture.
  21332. * @returns the number of layers
  21333. */
  21334. getRenderLayers(): number;
  21335. /**
  21336. * Get if the texture can be rescaled or not.
  21337. */
  21338. get canRescale(): boolean;
  21339. /**
  21340. * Resize the texture using a ratio.
  21341. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21342. */
  21343. scale(ratio: number): void;
  21344. /**
  21345. * Get the texture reflection matrix used to rotate/transform the reflection.
  21346. * @returns the reflection matrix
  21347. */
  21348. getReflectionTextureMatrix(): Matrix;
  21349. /**
  21350. * Resize the texture to a new desired size.
  21351. * Be carrefull as it will recreate all the data in the new texture.
  21352. * @param size Define the new size. It can be:
  21353. * - a number for squared texture,
  21354. * - an object containing { width: number, height: number }
  21355. * - or an object containing a ratio { ratio: number }
  21356. */
  21357. resize(size: number | {
  21358. width: number;
  21359. height: number;
  21360. } | {
  21361. ratio: number;
  21362. }): void;
  21363. private _defaultRenderListPrepared;
  21364. /**
  21365. * Renders all the objects from the render list into the texture.
  21366. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21367. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21368. */
  21369. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21370. private _bestReflectionRenderTargetDimension;
  21371. private _prepareRenderingManager;
  21372. /**
  21373. * @hidden
  21374. * @param faceIndex face index to bind to if this is a cubetexture
  21375. * @param layer defines the index of the texture to bind in the array
  21376. */
  21377. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21378. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21379. private renderToTarget;
  21380. /**
  21381. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21382. * This allowed control for front to back rendering or reversly depending of the special needs.
  21383. *
  21384. * @param renderingGroupId The rendering group id corresponding to its index
  21385. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21386. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21387. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21388. */
  21389. 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;
  21390. /**
  21391. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21392. *
  21393. * @param renderingGroupId The rendering group id corresponding to its index
  21394. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21395. */
  21396. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21397. /**
  21398. * Clones the texture.
  21399. * @returns the cloned texture
  21400. */
  21401. clone(): RenderTargetTexture;
  21402. /**
  21403. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21404. * @returns The JSON representation of the texture
  21405. */
  21406. serialize(): any;
  21407. /**
  21408. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21409. */
  21410. disposeFramebufferObjects(): void;
  21411. /**
  21412. * Dispose the texture and release its associated resources.
  21413. */
  21414. dispose(): void;
  21415. /** @hidden */
  21416. _rebuild(): void;
  21417. /**
  21418. * Clear the info related to rendering groups preventing retention point in material dispose.
  21419. */
  21420. freeRenderingGroups(): void;
  21421. /**
  21422. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21423. * @returns the view count
  21424. */
  21425. getViewCount(): number;
  21426. }
  21427. }
  21428. declare module "babylonjs/Materials/material" {
  21429. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21430. import { SmartArray } from "babylonjs/Misc/smartArray";
  21431. import { Observable } from "babylonjs/Misc/observable";
  21432. import { Nullable } from "babylonjs/types";
  21433. import { Scene } from "babylonjs/scene";
  21434. import { Matrix } from "babylonjs/Maths/math.vector";
  21435. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21437. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21438. import { Effect } from "babylonjs/Materials/effect";
  21439. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21440. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21441. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21442. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21443. import { Mesh } from "babylonjs/Meshes/mesh";
  21444. import { Animation } from "babylonjs/Animations/animation";
  21445. /**
  21446. * Options for compiling materials.
  21447. */
  21448. export interface IMaterialCompilationOptions {
  21449. /**
  21450. * Defines whether clip planes are enabled.
  21451. */
  21452. clipPlane: boolean;
  21453. /**
  21454. * Defines whether instances are enabled.
  21455. */
  21456. useInstances: boolean;
  21457. }
  21458. /**
  21459. * Base class for the main features of a material in Babylon.js
  21460. */
  21461. export class Material implements IAnimatable {
  21462. /**
  21463. * Returns the triangle fill mode
  21464. */
  21465. static readonly TriangleFillMode: number;
  21466. /**
  21467. * Returns the wireframe mode
  21468. */
  21469. static readonly WireFrameFillMode: number;
  21470. /**
  21471. * Returns the point fill mode
  21472. */
  21473. static readonly PointFillMode: number;
  21474. /**
  21475. * Returns the point list draw mode
  21476. */
  21477. static readonly PointListDrawMode: number;
  21478. /**
  21479. * Returns the line list draw mode
  21480. */
  21481. static readonly LineListDrawMode: number;
  21482. /**
  21483. * Returns the line loop draw mode
  21484. */
  21485. static readonly LineLoopDrawMode: number;
  21486. /**
  21487. * Returns the line strip draw mode
  21488. */
  21489. static readonly LineStripDrawMode: number;
  21490. /**
  21491. * Returns the triangle strip draw mode
  21492. */
  21493. static readonly TriangleStripDrawMode: number;
  21494. /**
  21495. * Returns the triangle fan draw mode
  21496. */
  21497. static readonly TriangleFanDrawMode: number;
  21498. /**
  21499. * Stores the clock-wise side orientation
  21500. */
  21501. static readonly ClockWiseSideOrientation: number;
  21502. /**
  21503. * Stores the counter clock-wise side orientation
  21504. */
  21505. static readonly CounterClockWiseSideOrientation: number;
  21506. /**
  21507. * The dirty texture flag value
  21508. */
  21509. static readonly TextureDirtyFlag: number;
  21510. /**
  21511. * The dirty light flag value
  21512. */
  21513. static readonly LightDirtyFlag: number;
  21514. /**
  21515. * The dirty fresnel flag value
  21516. */
  21517. static readonly FresnelDirtyFlag: number;
  21518. /**
  21519. * The dirty attribute flag value
  21520. */
  21521. static readonly AttributesDirtyFlag: number;
  21522. /**
  21523. * The dirty misc flag value
  21524. */
  21525. static readonly MiscDirtyFlag: number;
  21526. /**
  21527. * The all dirty flag value
  21528. */
  21529. static readonly AllDirtyFlag: number;
  21530. /**
  21531. * The ID of the material
  21532. */
  21533. id: string;
  21534. /**
  21535. * Gets or sets the unique id of the material
  21536. */
  21537. uniqueId: number;
  21538. /**
  21539. * The name of the material
  21540. */
  21541. name: string;
  21542. /**
  21543. * Gets or sets user defined metadata
  21544. */
  21545. metadata: any;
  21546. /**
  21547. * For internal use only. Please do not use.
  21548. */
  21549. reservedDataStore: any;
  21550. /**
  21551. * Specifies if the ready state should be checked on each call
  21552. */
  21553. checkReadyOnEveryCall: boolean;
  21554. /**
  21555. * Specifies if the ready state should be checked once
  21556. */
  21557. checkReadyOnlyOnce: boolean;
  21558. /**
  21559. * The state of the material
  21560. */
  21561. state: string;
  21562. /**
  21563. * The alpha value of the material
  21564. */
  21565. protected _alpha: number;
  21566. /**
  21567. * List of inspectable custom properties (used by the Inspector)
  21568. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21569. */
  21570. inspectableCustomProperties: IInspectable[];
  21571. /**
  21572. * Sets the alpha value of the material
  21573. */
  21574. set alpha(value: number);
  21575. /**
  21576. * Gets the alpha value of the material
  21577. */
  21578. get alpha(): number;
  21579. /**
  21580. * Specifies if back face culling is enabled
  21581. */
  21582. protected _backFaceCulling: boolean;
  21583. /**
  21584. * Sets the back-face culling state
  21585. */
  21586. set backFaceCulling(value: boolean);
  21587. /**
  21588. * Gets the back-face culling state
  21589. */
  21590. get backFaceCulling(): boolean;
  21591. /**
  21592. * Stores the value for side orientation
  21593. */
  21594. sideOrientation: number;
  21595. /**
  21596. * Callback triggered when the material is compiled
  21597. */
  21598. onCompiled: Nullable<(effect: Effect) => void>;
  21599. /**
  21600. * Callback triggered when an error occurs
  21601. */
  21602. onError: Nullable<(effect: Effect, errors: string) => void>;
  21603. /**
  21604. * Callback triggered to get the render target textures
  21605. */
  21606. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21607. /**
  21608. * Gets a boolean indicating that current material needs to register RTT
  21609. */
  21610. get hasRenderTargetTextures(): boolean;
  21611. /**
  21612. * Specifies if the material should be serialized
  21613. */
  21614. doNotSerialize: boolean;
  21615. /**
  21616. * @hidden
  21617. */
  21618. _storeEffectOnSubMeshes: boolean;
  21619. /**
  21620. * Stores the animations for the material
  21621. */
  21622. animations: Nullable<Array<Animation>>;
  21623. /**
  21624. * An event triggered when the material is disposed
  21625. */
  21626. onDisposeObservable: Observable<Material>;
  21627. /**
  21628. * An observer which watches for dispose events
  21629. */
  21630. private _onDisposeObserver;
  21631. private _onUnBindObservable;
  21632. /**
  21633. * Called during a dispose event
  21634. */
  21635. set onDispose(callback: () => void);
  21636. private _onBindObservable;
  21637. /**
  21638. * An event triggered when the material is bound
  21639. */
  21640. get onBindObservable(): Observable<AbstractMesh>;
  21641. /**
  21642. * An observer which watches for bind events
  21643. */
  21644. private _onBindObserver;
  21645. /**
  21646. * Called during a bind event
  21647. */
  21648. set onBind(callback: (Mesh: AbstractMesh) => void);
  21649. /**
  21650. * An event triggered when the material is unbound
  21651. */
  21652. get onUnBindObservable(): Observable<Material>;
  21653. /**
  21654. * Stores the value of the alpha mode
  21655. */
  21656. private _alphaMode;
  21657. /**
  21658. * Sets the value of the alpha mode.
  21659. *
  21660. * | Value | Type | Description |
  21661. * | --- | --- | --- |
  21662. * | 0 | ALPHA_DISABLE | |
  21663. * | 1 | ALPHA_ADD | |
  21664. * | 2 | ALPHA_COMBINE | |
  21665. * | 3 | ALPHA_SUBTRACT | |
  21666. * | 4 | ALPHA_MULTIPLY | |
  21667. * | 5 | ALPHA_MAXIMIZED | |
  21668. * | 6 | ALPHA_ONEONE | |
  21669. * | 7 | ALPHA_PREMULTIPLIED | |
  21670. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21671. * | 9 | ALPHA_INTERPOLATE | |
  21672. * | 10 | ALPHA_SCREENMODE | |
  21673. *
  21674. */
  21675. set alphaMode(value: number);
  21676. /**
  21677. * Gets the value of the alpha mode
  21678. */
  21679. get alphaMode(): number;
  21680. /**
  21681. * Stores the state of the need depth pre-pass value
  21682. */
  21683. private _needDepthPrePass;
  21684. /**
  21685. * Sets the need depth pre-pass value
  21686. */
  21687. set needDepthPrePass(value: boolean);
  21688. /**
  21689. * Gets the depth pre-pass value
  21690. */
  21691. get needDepthPrePass(): boolean;
  21692. /**
  21693. * Specifies if depth writing should be disabled
  21694. */
  21695. disableDepthWrite: boolean;
  21696. /**
  21697. * Specifies if depth writing should be forced
  21698. */
  21699. forceDepthWrite: boolean;
  21700. /**
  21701. * Specifies the depth function that should be used. 0 means the default engine function
  21702. */
  21703. depthFunction: number;
  21704. /**
  21705. * Specifies if there should be a separate pass for culling
  21706. */
  21707. separateCullingPass: boolean;
  21708. /**
  21709. * Stores the state specifing if fog should be enabled
  21710. */
  21711. private _fogEnabled;
  21712. /**
  21713. * Sets the state for enabling fog
  21714. */
  21715. set fogEnabled(value: boolean);
  21716. /**
  21717. * Gets the value of the fog enabled state
  21718. */
  21719. get fogEnabled(): boolean;
  21720. /**
  21721. * Stores the size of points
  21722. */
  21723. pointSize: number;
  21724. /**
  21725. * Stores the z offset value
  21726. */
  21727. zOffset: number;
  21728. /**
  21729. * Gets a value specifying if wireframe mode is enabled
  21730. */
  21731. get wireframe(): boolean;
  21732. /**
  21733. * Sets the state of wireframe mode
  21734. */
  21735. set wireframe(value: boolean);
  21736. /**
  21737. * Gets the value specifying if point clouds are enabled
  21738. */
  21739. get pointsCloud(): boolean;
  21740. /**
  21741. * Sets the state of point cloud mode
  21742. */
  21743. set pointsCloud(value: boolean);
  21744. /**
  21745. * Gets the material fill mode
  21746. */
  21747. get fillMode(): number;
  21748. /**
  21749. * Sets the material fill mode
  21750. */
  21751. set fillMode(value: number);
  21752. /**
  21753. * @hidden
  21754. * Stores the effects for the material
  21755. */
  21756. _effect: Nullable<Effect>;
  21757. /**
  21758. * Specifies if uniform buffers should be used
  21759. */
  21760. private _useUBO;
  21761. /**
  21762. * Stores a reference to the scene
  21763. */
  21764. private _scene;
  21765. /**
  21766. * Stores the fill mode state
  21767. */
  21768. private _fillMode;
  21769. /**
  21770. * Specifies if the depth write state should be cached
  21771. */
  21772. private _cachedDepthWriteState;
  21773. /**
  21774. * Specifies if the depth function state should be cached
  21775. */
  21776. private _cachedDepthFunctionState;
  21777. /**
  21778. * Stores the uniform buffer
  21779. */
  21780. protected _uniformBuffer: UniformBuffer;
  21781. /** @hidden */
  21782. _indexInSceneMaterialArray: number;
  21783. /** @hidden */
  21784. meshMap: Nullable<{
  21785. [id: string]: AbstractMesh | undefined;
  21786. }>;
  21787. /**
  21788. * Creates a material instance
  21789. * @param name defines the name of the material
  21790. * @param scene defines the scene to reference
  21791. * @param doNotAdd specifies if the material should be added to the scene
  21792. */
  21793. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21794. /**
  21795. * Returns a string representation of the current material
  21796. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21797. * @returns a string with material information
  21798. */
  21799. toString(fullDetails?: boolean): string;
  21800. /**
  21801. * Gets the class name of the material
  21802. * @returns a string with the class name of the material
  21803. */
  21804. getClassName(): string;
  21805. /**
  21806. * Specifies if updates for the material been locked
  21807. */
  21808. get isFrozen(): boolean;
  21809. /**
  21810. * Locks updates for the material
  21811. */
  21812. freeze(): void;
  21813. /**
  21814. * Unlocks updates for the material
  21815. */
  21816. unfreeze(): void;
  21817. /**
  21818. * Specifies if the material is ready to be used
  21819. * @param mesh defines the mesh to check
  21820. * @param useInstances specifies if instances should be used
  21821. * @returns a boolean indicating if the material is ready to be used
  21822. */
  21823. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21824. /**
  21825. * Specifies that the submesh is ready to be used
  21826. * @param mesh defines the mesh to check
  21827. * @param subMesh defines which submesh to check
  21828. * @param useInstances specifies that instances should be used
  21829. * @returns a boolean indicating that the submesh is ready or not
  21830. */
  21831. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21832. /**
  21833. * Returns the material effect
  21834. * @returns the effect associated with the material
  21835. */
  21836. getEffect(): Nullable<Effect>;
  21837. /**
  21838. * Returns the current scene
  21839. * @returns a Scene
  21840. */
  21841. getScene(): Scene;
  21842. /**
  21843. * Specifies if the material will require alpha blending
  21844. * @returns a boolean specifying if alpha blending is needed
  21845. */
  21846. needAlphaBlending(): boolean;
  21847. /**
  21848. * Specifies if the mesh will require alpha blending
  21849. * @param mesh defines the mesh to check
  21850. * @returns a boolean specifying if alpha blending is needed for the mesh
  21851. */
  21852. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21853. /**
  21854. * Specifies if this material should be rendered in alpha test mode
  21855. * @returns a boolean specifying if an alpha test is needed.
  21856. */
  21857. needAlphaTesting(): boolean;
  21858. /**
  21859. * Gets the texture used for the alpha test
  21860. * @returns the texture to use for alpha testing
  21861. */
  21862. getAlphaTestTexture(): Nullable<BaseTexture>;
  21863. /**
  21864. * Marks the material to indicate that it needs to be re-calculated
  21865. */
  21866. markDirty(): void;
  21867. /** @hidden */
  21868. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21869. /**
  21870. * Binds the material to the mesh
  21871. * @param world defines the world transformation matrix
  21872. * @param mesh defines the mesh to bind the material to
  21873. */
  21874. bind(world: Matrix, mesh?: Mesh): void;
  21875. /**
  21876. * Binds the submesh to the material
  21877. * @param world defines the world transformation matrix
  21878. * @param mesh defines the mesh containing the submesh
  21879. * @param subMesh defines the submesh to bind the material to
  21880. */
  21881. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21882. /**
  21883. * Binds the world matrix to the material
  21884. * @param world defines the world transformation matrix
  21885. */
  21886. bindOnlyWorldMatrix(world: Matrix): void;
  21887. /**
  21888. * Binds the scene's uniform buffer to the effect.
  21889. * @param effect defines the effect to bind to the scene uniform buffer
  21890. * @param sceneUbo defines the uniform buffer storing scene data
  21891. */
  21892. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21893. /**
  21894. * Binds the view matrix to the effect
  21895. * @param effect defines the effect to bind the view matrix to
  21896. */
  21897. bindView(effect: Effect): void;
  21898. /**
  21899. * Binds the view projection matrix to the effect
  21900. * @param effect defines the effect to bind the view projection matrix to
  21901. */
  21902. bindViewProjection(effect: Effect): void;
  21903. /**
  21904. * Specifies if material alpha testing should be turned on for the mesh
  21905. * @param mesh defines the mesh to check
  21906. */
  21907. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21908. /**
  21909. * Processes to execute after binding the material to a mesh
  21910. * @param mesh defines the rendered mesh
  21911. */
  21912. protected _afterBind(mesh?: Mesh): void;
  21913. /**
  21914. * Unbinds the material from the mesh
  21915. */
  21916. unbind(): void;
  21917. /**
  21918. * Gets the active textures from the material
  21919. * @returns an array of textures
  21920. */
  21921. getActiveTextures(): BaseTexture[];
  21922. /**
  21923. * Specifies if the material uses a texture
  21924. * @param texture defines the texture to check against the material
  21925. * @returns a boolean specifying if the material uses the texture
  21926. */
  21927. hasTexture(texture: BaseTexture): boolean;
  21928. /**
  21929. * Makes a duplicate of the material, and gives it a new name
  21930. * @param name defines the new name for the duplicated material
  21931. * @returns the cloned material
  21932. */
  21933. clone(name: string): Nullable<Material>;
  21934. /**
  21935. * Gets the meshes bound to the material
  21936. * @returns an array of meshes bound to the material
  21937. */
  21938. getBindedMeshes(): AbstractMesh[];
  21939. /**
  21940. * Force shader compilation
  21941. * @param mesh defines the mesh associated with this material
  21942. * @param onCompiled defines a function to execute once the material is compiled
  21943. * @param options defines the options to configure the compilation
  21944. * @param onError defines a function to execute if the material fails compiling
  21945. */
  21946. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21947. /**
  21948. * Force shader compilation
  21949. * @param mesh defines the mesh that will use this material
  21950. * @param options defines additional options for compiling the shaders
  21951. * @returns a promise that resolves when the compilation completes
  21952. */
  21953. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21954. private static readonly _AllDirtyCallBack;
  21955. private static readonly _ImageProcessingDirtyCallBack;
  21956. private static readonly _TextureDirtyCallBack;
  21957. private static readonly _FresnelDirtyCallBack;
  21958. private static readonly _MiscDirtyCallBack;
  21959. private static readonly _LightsDirtyCallBack;
  21960. private static readonly _AttributeDirtyCallBack;
  21961. private static _FresnelAndMiscDirtyCallBack;
  21962. private static _TextureAndMiscDirtyCallBack;
  21963. private static readonly _DirtyCallbackArray;
  21964. private static readonly _RunDirtyCallBacks;
  21965. /**
  21966. * Marks a define in the material to indicate that it needs to be re-computed
  21967. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21968. */
  21969. markAsDirty(flag: number): void;
  21970. /**
  21971. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21972. * @param func defines a function which checks material defines against the submeshes
  21973. */
  21974. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21975. /**
  21976. * Indicates that we need to re-calculated for all submeshes
  21977. */
  21978. protected _markAllSubMeshesAsAllDirty(): void;
  21979. /**
  21980. * Indicates that image processing needs to be re-calculated for all submeshes
  21981. */
  21982. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21983. /**
  21984. * Indicates that textures need to be re-calculated for all submeshes
  21985. */
  21986. protected _markAllSubMeshesAsTexturesDirty(): void;
  21987. /**
  21988. * Indicates that fresnel needs to be re-calculated for all submeshes
  21989. */
  21990. protected _markAllSubMeshesAsFresnelDirty(): void;
  21991. /**
  21992. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21993. */
  21994. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21995. /**
  21996. * Indicates that lights need to be re-calculated for all submeshes
  21997. */
  21998. protected _markAllSubMeshesAsLightsDirty(): void;
  21999. /**
  22000. * Indicates that attributes need to be re-calculated for all submeshes
  22001. */
  22002. protected _markAllSubMeshesAsAttributesDirty(): void;
  22003. /**
  22004. * Indicates that misc needs to be re-calculated for all submeshes
  22005. */
  22006. protected _markAllSubMeshesAsMiscDirty(): void;
  22007. /**
  22008. * Indicates that textures and misc need to be re-calculated for all submeshes
  22009. */
  22010. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22011. /**
  22012. * Disposes the material
  22013. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22014. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22015. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22016. */
  22017. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22018. /** @hidden */
  22019. private releaseVertexArrayObject;
  22020. /**
  22021. * Serializes this material
  22022. * @returns the serialized material object
  22023. */
  22024. serialize(): any;
  22025. /**
  22026. * Creates a material from parsed material data
  22027. * @param parsedMaterial defines parsed material data
  22028. * @param scene defines the hosting scene
  22029. * @param rootUrl defines the root URL to use to load textures
  22030. * @returns a new material
  22031. */
  22032. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22033. }
  22034. }
  22035. declare module "babylonjs/Materials/multiMaterial" {
  22036. import { Nullable } from "babylonjs/types";
  22037. import { Scene } from "babylonjs/scene";
  22038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22039. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22040. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22041. import { Material } from "babylonjs/Materials/material";
  22042. /**
  22043. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22044. * separate meshes. This can be use to improve performances.
  22045. * @see http://doc.babylonjs.com/how_to/multi_materials
  22046. */
  22047. export class MultiMaterial extends Material {
  22048. private _subMaterials;
  22049. /**
  22050. * Gets or Sets the list of Materials used within the multi material.
  22051. * They need to be ordered according to the submeshes order in the associated mesh
  22052. */
  22053. get subMaterials(): Nullable<Material>[];
  22054. set subMaterials(value: Nullable<Material>[]);
  22055. /**
  22056. * Function used to align with Node.getChildren()
  22057. * @returns the list of Materials used within the multi material
  22058. */
  22059. getChildren(): Nullable<Material>[];
  22060. /**
  22061. * Instantiates a new Multi Material
  22062. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22063. * separate meshes. This can be use to improve performances.
  22064. * @see http://doc.babylonjs.com/how_to/multi_materials
  22065. * @param name Define the name in the scene
  22066. * @param scene Define the scene the material belongs to
  22067. */
  22068. constructor(name: string, scene: Scene);
  22069. private _hookArray;
  22070. /**
  22071. * Get one of the submaterial by its index in the submaterials array
  22072. * @param index The index to look the sub material at
  22073. * @returns The Material if the index has been defined
  22074. */
  22075. getSubMaterial(index: number): Nullable<Material>;
  22076. /**
  22077. * Get the list of active textures for the whole sub materials list.
  22078. * @returns All the textures that will be used during the rendering
  22079. */
  22080. getActiveTextures(): BaseTexture[];
  22081. /**
  22082. * Gets the current class name of the material e.g. "MultiMaterial"
  22083. * Mainly use in serialization.
  22084. * @returns the class name
  22085. */
  22086. getClassName(): string;
  22087. /**
  22088. * Checks if the material is ready to render the requested sub mesh
  22089. * @param mesh Define the mesh the submesh belongs to
  22090. * @param subMesh Define the sub mesh to look readyness for
  22091. * @param useInstances Define whether or not the material is used with instances
  22092. * @returns true if ready, otherwise false
  22093. */
  22094. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22095. /**
  22096. * Clones the current material and its related sub materials
  22097. * @param name Define the name of the newly cloned material
  22098. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22099. * @returns the cloned material
  22100. */
  22101. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22102. /**
  22103. * Serializes the materials into a JSON representation.
  22104. * @returns the JSON representation
  22105. */
  22106. serialize(): any;
  22107. /**
  22108. * Dispose the material and release its associated resources
  22109. * @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)
  22110. * @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)
  22111. * @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)
  22112. */
  22113. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22114. /**
  22115. * Creates a MultiMaterial from parsed MultiMaterial data.
  22116. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22117. * @param scene defines the hosting scene
  22118. * @returns a new MultiMaterial
  22119. */
  22120. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22121. }
  22122. }
  22123. declare module "babylonjs/Meshes/subMesh" {
  22124. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22125. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22126. import { Engine } from "babylonjs/Engines/engine";
  22127. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22128. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22129. import { Effect } from "babylonjs/Materials/effect";
  22130. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22131. import { Plane } from "babylonjs/Maths/math.plane";
  22132. import { Collider } from "babylonjs/Collisions/collider";
  22133. import { Material } from "babylonjs/Materials/material";
  22134. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22136. import { Mesh } from "babylonjs/Meshes/mesh";
  22137. import { Ray } from "babylonjs/Culling/ray";
  22138. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22139. /**
  22140. * Base class for submeshes
  22141. */
  22142. export class BaseSubMesh {
  22143. /** @hidden */
  22144. _materialDefines: Nullable<MaterialDefines>;
  22145. /** @hidden */
  22146. _materialEffect: Nullable<Effect>;
  22147. /**
  22148. * Gets material defines used by the effect associated to the sub mesh
  22149. */
  22150. get materialDefines(): Nullable<MaterialDefines>;
  22151. /**
  22152. * Sets material defines used by the effect associated to the sub mesh
  22153. */
  22154. set materialDefines(defines: Nullable<MaterialDefines>);
  22155. /**
  22156. * Gets associated effect
  22157. */
  22158. get effect(): Nullable<Effect>;
  22159. /**
  22160. * Sets associated effect (effect used to render this submesh)
  22161. * @param effect defines the effect to associate with
  22162. * @param defines defines the set of defines used to compile this effect
  22163. */
  22164. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22165. }
  22166. /**
  22167. * Defines a subdivision inside a mesh
  22168. */
  22169. export class SubMesh extends BaseSubMesh implements ICullable {
  22170. /** the material index to use */
  22171. materialIndex: number;
  22172. /** vertex index start */
  22173. verticesStart: number;
  22174. /** vertices count */
  22175. verticesCount: number;
  22176. /** index start */
  22177. indexStart: number;
  22178. /** indices count */
  22179. indexCount: number;
  22180. /** @hidden */
  22181. _linesIndexCount: number;
  22182. private _mesh;
  22183. private _renderingMesh;
  22184. private _boundingInfo;
  22185. private _linesIndexBuffer;
  22186. /** @hidden */
  22187. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22188. /** @hidden */
  22189. _trianglePlanes: Plane[];
  22190. /** @hidden */
  22191. _lastColliderTransformMatrix: Nullable<Matrix>;
  22192. /** @hidden */
  22193. _renderId: number;
  22194. /** @hidden */
  22195. _alphaIndex: number;
  22196. /** @hidden */
  22197. _distanceToCamera: number;
  22198. /** @hidden */
  22199. _id: number;
  22200. private _currentMaterial;
  22201. /**
  22202. * Add a new submesh to a mesh
  22203. * @param materialIndex defines the material index to use
  22204. * @param verticesStart defines vertex index start
  22205. * @param verticesCount defines vertices count
  22206. * @param indexStart defines index start
  22207. * @param indexCount defines indices count
  22208. * @param mesh defines the parent mesh
  22209. * @param renderingMesh defines an optional rendering mesh
  22210. * @param createBoundingBox defines if bounding box should be created for this submesh
  22211. * @returns the new submesh
  22212. */
  22213. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22214. /**
  22215. * Creates a new submesh
  22216. * @param materialIndex defines the material index to use
  22217. * @param verticesStart defines vertex index start
  22218. * @param verticesCount defines vertices count
  22219. * @param indexStart defines index start
  22220. * @param indexCount defines indices count
  22221. * @param mesh defines the parent mesh
  22222. * @param renderingMesh defines an optional rendering mesh
  22223. * @param createBoundingBox defines if bounding box should be created for this submesh
  22224. */
  22225. constructor(
  22226. /** the material index to use */
  22227. materialIndex: number,
  22228. /** vertex index start */
  22229. verticesStart: number,
  22230. /** vertices count */
  22231. verticesCount: number,
  22232. /** index start */
  22233. indexStart: number,
  22234. /** indices count */
  22235. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22236. /**
  22237. * Returns true if this submesh covers the entire parent mesh
  22238. * @ignorenaming
  22239. */
  22240. get IsGlobal(): boolean;
  22241. /**
  22242. * Returns the submesh BoudingInfo object
  22243. * @returns current bounding info (or mesh's one if the submesh is global)
  22244. */
  22245. getBoundingInfo(): BoundingInfo;
  22246. /**
  22247. * Sets the submesh BoundingInfo
  22248. * @param boundingInfo defines the new bounding info to use
  22249. * @returns the SubMesh
  22250. */
  22251. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22252. /**
  22253. * Returns the mesh of the current submesh
  22254. * @return the parent mesh
  22255. */
  22256. getMesh(): AbstractMesh;
  22257. /**
  22258. * Returns the rendering mesh of the submesh
  22259. * @returns the rendering mesh (could be different from parent mesh)
  22260. */
  22261. getRenderingMesh(): Mesh;
  22262. /**
  22263. * Returns the submesh material
  22264. * @returns null or the current material
  22265. */
  22266. getMaterial(): Nullable<Material>;
  22267. /**
  22268. * Sets a new updated BoundingInfo object to the submesh
  22269. * @param data defines an optional position array to use to determine the bounding info
  22270. * @returns the SubMesh
  22271. */
  22272. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22273. /** @hidden */
  22274. _checkCollision(collider: Collider): boolean;
  22275. /**
  22276. * Updates the submesh BoundingInfo
  22277. * @param world defines the world matrix to use to update the bounding info
  22278. * @returns the submesh
  22279. */
  22280. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22281. /**
  22282. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22283. * @param frustumPlanes defines the frustum planes
  22284. * @returns true if the submesh is intersecting with the frustum
  22285. */
  22286. isInFrustum(frustumPlanes: Plane[]): boolean;
  22287. /**
  22288. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22289. * @param frustumPlanes defines the frustum planes
  22290. * @returns true if the submesh is inside the frustum
  22291. */
  22292. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22293. /**
  22294. * Renders the submesh
  22295. * @param enableAlphaMode defines if alpha needs to be used
  22296. * @returns the submesh
  22297. */
  22298. render(enableAlphaMode: boolean): SubMesh;
  22299. /**
  22300. * @hidden
  22301. */
  22302. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22303. /**
  22304. * Checks if the submesh intersects with a ray
  22305. * @param ray defines the ray to test
  22306. * @returns true is the passed ray intersects the submesh bounding box
  22307. */
  22308. canIntersects(ray: Ray): boolean;
  22309. /**
  22310. * Intersects current submesh with a ray
  22311. * @param ray defines the ray to test
  22312. * @param positions defines mesh's positions array
  22313. * @param indices defines mesh's indices array
  22314. * @param fastCheck defines if only bounding info should be used
  22315. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22316. * @returns intersection info or null if no intersection
  22317. */
  22318. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22319. /** @hidden */
  22320. private _intersectLines;
  22321. /** @hidden */
  22322. private _intersectUnIndexedLines;
  22323. /** @hidden */
  22324. private _intersectTriangles;
  22325. /** @hidden */
  22326. private _intersectUnIndexedTriangles;
  22327. /** @hidden */
  22328. _rebuild(): void;
  22329. /**
  22330. * Creates a new submesh from the passed mesh
  22331. * @param newMesh defines the new hosting mesh
  22332. * @param newRenderingMesh defines an optional rendering mesh
  22333. * @returns the new submesh
  22334. */
  22335. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22336. /**
  22337. * Release associated resources
  22338. */
  22339. dispose(): void;
  22340. /**
  22341. * Gets the class name
  22342. * @returns the string "SubMesh".
  22343. */
  22344. getClassName(): string;
  22345. /**
  22346. * Creates a new submesh from indices data
  22347. * @param materialIndex the index of the main mesh material
  22348. * @param startIndex the index where to start the copy in the mesh indices array
  22349. * @param indexCount the number of indices to copy then from the startIndex
  22350. * @param mesh the main mesh to create the submesh from
  22351. * @param renderingMesh the optional rendering mesh
  22352. * @returns a new submesh
  22353. */
  22354. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22355. }
  22356. }
  22357. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22358. /**
  22359. * Class used to represent data loading progression
  22360. */
  22361. export class SceneLoaderFlags {
  22362. private static _ForceFullSceneLoadingForIncremental;
  22363. private static _ShowLoadingScreen;
  22364. private static _CleanBoneMatrixWeights;
  22365. private static _loggingLevel;
  22366. /**
  22367. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22368. */
  22369. static get ForceFullSceneLoadingForIncremental(): boolean;
  22370. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22371. /**
  22372. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22373. */
  22374. static get ShowLoadingScreen(): boolean;
  22375. static set ShowLoadingScreen(value: boolean);
  22376. /**
  22377. * Defines the current logging level (while loading the scene)
  22378. * @ignorenaming
  22379. */
  22380. static get loggingLevel(): number;
  22381. static set loggingLevel(value: number);
  22382. /**
  22383. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22384. */
  22385. static get CleanBoneMatrixWeights(): boolean;
  22386. static set CleanBoneMatrixWeights(value: boolean);
  22387. }
  22388. }
  22389. declare module "babylonjs/Meshes/geometry" {
  22390. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22391. import { Scene } from "babylonjs/scene";
  22392. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22393. import { Engine } from "babylonjs/Engines/engine";
  22394. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22395. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22396. import { Effect } from "babylonjs/Materials/effect";
  22397. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22398. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22399. import { Mesh } from "babylonjs/Meshes/mesh";
  22400. /**
  22401. * Class used to store geometry data (vertex buffers + index buffer)
  22402. */
  22403. export class Geometry implements IGetSetVerticesData {
  22404. /**
  22405. * Gets or sets the ID of the geometry
  22406. */
  22407. id: string;
  22408. /**
  22409. * Gets or sets the unique ID of the geometry
  22410. */
  22411. uniqueId: number;
  22412. /**
  22413. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22414. */
  22415. delayLoadState: number;
  22416. /**
  22417. * Gets the file containing the data to load when running in delay load state
  22418. */
  22419. delayLoadingFile: Nullable<string>;
  22420. /**
  22421. * Callback called when the geometry is updated
  22422. */
  22423. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22424. private _scene;
  22425. private _engine;
  22426. private _meshes;
  22427. private _totalVertices;
  22428. /** @hidden */
  22429. _indices: IndicesArray;
  22430. /** @hidden */
  22431. _vertexBuffers: {
  22432. [key: string]: VertexBuffer;
  22433. };
  22434. private _isDisposed;
  22435. private _extend;
  22436. private _boundingBias;
  22437. /** @hidden */
  22438. _delayInfo: Array<string>;
  22439. private _indexBuffer;
  22440. private _indexBufferIsUpdatable;
  22441. /** @hidden */
  22442. _boundingInfo: Nullable<BoundingInfo>;
  22443. /** @hidden */
  22444. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22445. /** @hidden */
  22446. _softwareSkinningFrameId: number;
  22447. private _vertexArrayObjects;
  22448. private _updatable;
  22449. /** @hidden */
  22450. _positions: Nullable<Vector3[]>;
  22451. /**
  22452. * 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
  22453. */
  22454. get boundingBias(): Vector2;
  22455. /**
  22456. * 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
  22457. */
  22458. set boundingBias(value: Vector2);
  22459. /**
  22460. * Static function used to attach a new empty geometry to a mesh
  22461. * @param mesh defines the mesh to attach the geometry to
  22462. * @returns the new Geometry
  22463. */
  22464. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22465. /**
  22466. * Creates a new geometry
  22467. * @param id defines the unique ID
  22468. * @param scene defines the hosting scene
  22469. * @param vertexData defines the VertexData used to get geometry data
  22470. * @param updatable defines if geometry must be updatable (false by default)
  22471. * @param mesh defines the mesh that will be associated with the geometry
  22472. */
  22473. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22474. /**
  22475. * Gets the current extend of the geometry
  22476. */
  22477. get extend(): {
  22478. minimum: Vector3;
  22479. maximum: Vector3;
  22480. };
  22481. /**
  22482. * Gets the hosting scene
  22483. * @returns the hosting Scene
  22484. */
  22485. getScene(): Scene;
  22486. /**
  22487. * Gets the hosting engine
  22488. * @returns the hosting Engine
  22489. */
  22490. getEngine(): Engine;
  22491. /**
  22492. * Defines if the geometry is ready to use
  22493. * @returns true if the geometry is ready to be used
  22494. */
  22495. isReady(): boolean;
  22496. /**
  22497. * Gets a value indicating that the geometry should not be serialized
  22498. */
  22499. get doNotSerialize(): boolean;
  22500. /** @hidden */
  22501. _rebuild(): void;
  22502. /**
  22503. * Affects all geometry data in one call
  22504. * @param vertexData defines the geometry data
  22505. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22506. */
  22507. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22508. /**
  22509. * Set specific vertex data
  22510. * @param kind defines the data kind (Position, normal, etc...)
  22511. * @param data defines the vertex data to use
  22512. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22513. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22514. */
  22515. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22516. /**
  22517. * Removes a specific vertex data
  22518. * @param kind defines the data kind (Position, normal, etc...)
  22519. */
  22520. removeVerticesData(kind: string): void;
  22521. /**
  22522. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22523. * @param buffer defines the vertex buffer to use
  22524. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22525. */
  22526. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22527. /**
  22528. * Update a specific vertex buffer
  22529. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22530. * It will do nothing if the buffer is not updatable
  22531. * @param kind defines the data kind (Position, normal, etc...)
  22532. * @param data defines the data to use
  22533. * @param offset defines the offset in the target buffer where to store the data
  22534. * @param useBytes set to true if the offset is in bytes
  22535. */
  22536. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22537. /**
  22538. * Update a specific vertex buffer
  22539. * This function will create a new buffer if the current one is not updatable
  22540. * @param kind defines the data kind (Position, normal, etc...)
  22541. * @param data defines the data to use
  22542. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22543. */
  22544. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22545. private _updateBoundingInfo;
  22546. /** @hidden */
  22547. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22548. /**
  22549. * Gets total number of vertices
  22550. * @returns the total number of vertices
  22551. */
  22552. getTotalVertices(): number;
  22553. /**
  22554. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22555. * @param kind defines the data kind (Position, normal, etc...)
  22556. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22557. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22558. * @returns a float array containing vertex data
  22559. */
  22560. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22561. /**
  22562. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22563. * @param kind defines the data kind (Position, normal, etc...)
  22564. * @returns true if the vertex buffer with the specified kind is updatable
  22565. */
  22566. isVertexBufferUpdatable(kind: string): boolean;
  22567. /**
  22568. * Gets a specific vertex buffer
  22569. * @param kind defines the data kind (Position, normal, etc...)
  22570. * @returns a VertexBuffer
  22571. */
  22572. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22573. /**
  22574. * Returns all vertex buffers
  22575. * @return an object holding all vertex buffers indexed by kind
  22576. */
  22577. getVertexBuffers(): Nullable<{
  22578. [key: string]: VertexBuffer;
  22579. }>;
  22580. /**
  22581. * Gets a boolean indicating if specific vertex buffer is present
  22582. * @param kind defines the data kind (Position, normal, etc...)
  22583. * @returns true if data is present
  22584. */
  22585. isVerticesDataPresent(kind: string): boolean;
  22586. /**
  22587. * Gets a list of all attached data kinds (Position, normal, etc...)
  22588. * @returns a list of string containing all kinds
  22589. */
  22590. getVerticesDataKinds(): string[];
  22591. /**
  22592. * Update index buffer
  22593. * @param indices defines the indices to store in the index buffer
  22594. * @param offset defines the offset in the target buffer where to store the data
  22595. * @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)
  22596. */
  22597. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22598. /**
  22599. * Creates a new index buffer
  22600. * @param indices defines the indices to store in the index buffer
  22601. * @param totalVertices defines the total number of vertices (could be null)
  22602. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22603. */
  22604. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22605. /**
  22606. * Return the total number of indices
  22607. * @returns the total number of indices
  22608. */
  22609. getTotalIndices(): number;
  22610. /**
  22611. * Gets the index buffer array
  22612. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22613. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22614. * @returns the index buffer array
  22615. */
  22616. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22617. /**
  22618. * Gets the index buffer
  22619. * @return the index buffer
  22620. */
  22621. getIndexBuffer(): Nullable<DataBuffer>;
  22622. /** @hidden */
  22623. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22624. /**
  22625. * Release the associated resources for a specific mesh
  22626. * @param mesh defines the source mesh
  22627. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22628. */
  22629. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22630. /**
  22631. * Apply current geometry to a given mesh
  22632. * @param mesh defines the mesh to apply geometry to
  22633. */
  22634. applyToMesh(mesh: Mesh): void;
  22635. private _updateExtend;
  22636. private _applyToMesh;
  22637. private notifyUpdate;
  22638. /**
  22639. * Load the geometry if it was flagged as delay loaded
  22640. * @param scene defines the hosting scene
  22641. * @param onLoaded defines a callback called when the geometry is loaded
  22642. */
  22643. load(scene: Scene, onLoaded?: () => void): void;
  22644. private _queueLoad;
  22645. /**
  22646. * Invert the geometry to move from a right handed system to a left handed one.
  22647. */
  22648. toLeftHanded(): void;
  22649. /** @hidden */
  22650. _resetPointsArrayCache(): void;
  22651. /** @hidden */
  22652. _generatePointsArray(): boolean;
  22653. /**
  22654. * Gets a value indicating if the geometry is disposed
  22655. * @returns true if the geometry was disposed
  22656. */
  22657. isDisposed(): boolean;
  22658. private _disposeVertexArrayObjects;
  22659. /**
  22660. * Free all associated resources
  22661. */
  22662. dispose(): void;
  22663. /**
  22664. * Clone the current geometry into a new geometry
  22665. * @param id defines the unique ID of the new geometry
  22666. * @returns a new geometry object
  22667. */
  22668. copy(id: string): Geometry;
  22669. /**
  22670. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22671. * @return a JSON representation of the current geometry data (without the vertices data)
  22672. */
  22673. serialize(): any;
  22674. private toNumberArray;
  22675. /**
  22676. * Serialize all vertices data into a JSON oject
  22677. * @returns a JSON representation of the current geometry data
  22678. */
  22679. serializeVerticeData(): any;
  22680. /**
  22681. * Extracts a clone of a mesh geometry
  22682. * @param mesh defines the source mesh
  22683. * @param id defines the unique ID of the new geometry object
  22684. * @returns the new geometry object
  22685. */
  22686. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22687. /**
  22688. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22689. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22690. * Be aware Math.random() could cause collisions, but:
  22691. * "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"
  22692. * @returns a string containing a new GUID
  22693. */
  22694. static RandomId(): string;
  22695. /** @hidden */
  22696. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22697. private static _CleanMatricesWeights;
  22698. /**
  22699. * Create a new geometry from persisted data (Using .babylon file format)
  22700. * @param parsedVertexData defines the persisted data
  22701. * @param scene defines the hosting scene
  22702. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22703. * @returns the new geometry object
  22704. */
  22705. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22706. }
  22707. }
  22708. declare module "babylonjs/Meshes/mesh.vertexData" {
  22709. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22710. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22711. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22712. import { Geometry } from "babylonjs/Meshes/geometry";
  22713. import { Mesh } from "babylonjs/Meshes/mesh";
  22714. /**
  22715. * Define an interface for all classes that will get and set the data on vertices
  22716. */
  22717. export interface IGetSetVerticesData {
  22718. /**
  22719. * Gets a boolean indicating if specific vertex data is present
  22720. * @param kind defines the vertex data kind to use
  22721. * @returns true is data kind is present
  22722. */
  22723. isVerticesDataPresent(kind: string): boolean;
  22724. /**
  22725. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22726. * @param kind defines the data kind (Position, normal, etc...)
  22727. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22728. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22729. * @returns a float array containing vertex data
  22730. */
  22731. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22732. /**
  22733. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22734. * @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.
  22735. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22736. * @returns the indices array or an empty array if the mesh has no geometry
  22737. */
  22738. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22739. /**
  22740. * Set specific vertex data
  22741. * @param kind defines the data kind (Position, normal, etc...)
  22742. * @param data defines the vertex data to use
  22743. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22744. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22745. */
  22746. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22747. /**
  22748. * Update a specific associated vertex buffer
  22749. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22750. * - VertexBuffer.PositionKind
  22751. * - VertexBuffer.UVKind
  22752. * - VertexBuffer.UV2Kind
  22753. * - VertexBuffer.UV3Kind
  22754. * - VertexBuffer.UV4Kind
  22755. * - VertexBuffer.UV5Kind
  22756. * - VertexBuffer.UV6Kind
  22757. * - VertexBuffer.ColorKind
  22758. * - VertexBuffer.MatricesIndicesKind
  22759. * - VertexBuffer.MatricesIndicesExtraKind
  22760. * - VertexBuffer.MatricesWeightsKind
  22761. * - VertexBuffer.MatricesWeightsExtraKind
  22762. * @param data defines the data source
  22763. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22764. * @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)
  22765. */
  22766. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22767. /**
  22768. * Creates a new index buffer
  22769. * @param indices defines the indices to store in the index buffer
  22770. * @param totalVertices defines the total number of vertices (could be null)
  22771. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22772. */
  22773. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22774. }
  22775. /**
  22776. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22777. */
  22778. export class VertexData {
  22779. /**
  22780. * Mesh side orientation : usually the external or front surface
  22781. */
  22782. static readonly FRONTSIDE: number;
  22783. /**
  22784. * Mesh side orientation : usually the internal or back surface
  22785. */
  22786. static readonly BACKSIDE: number;
  22787. /**
  22788. * Mesh side orientation : both internal and external or front and back surfaces
  22789. */
  22790. static readonly DOUBLESIDE: number;
  22791. /**
  22792. * Mesh side orientation : by default, `FRONTSIDE`
  22793. */
  22794. static readonly DEFAULTSIDE: number;
  22795. /**
  22796. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22797. */
  22798. positions: Nullable<FloatArray>;
  22799. /**
  22800. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22801. */
  22802. normals: Nullable<FloatArray>;
  22803. /**
  22804. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22805. */
  22806. tangents: Nullable<FloatArray>;
  22807. /**
  22808. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22809. */
  22810. uvs: Nullable<FloatArray>;
  22811. /**
  22812. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22813. */
  22814. uvs2: Nullable<FloatArray>;
  22815. /**
  22816. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22817. */
  22818. uvs3: Nullable<FloatArray>;
  22819. /**
  22820. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22821. */
  22822. uvs4: Nullable<FloatArray>;
  22823. /**
  22824. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22825. */
  22826. uvs5: Nullable<FloatArray>;
  22827. /**
  22828. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22829. */
  22830. uvs6: Nullable<FloatArray>;
  22831. /**
  22832. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22833. */
  22834. colors: Nullable<FloatArray>;
  22835. /**
  22836. * 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).
  22837. */
  22838. matricesIndices: Nullable<FloatArray>;
  22839. /**
  22840. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22841. */
  22842. matricesWeights: Nullable<FloatArray>;
  22843. /**
  22844. * An array extending the number of possible indices
  22845. */
  22846. matricesIndicesExtra: Nullable<FloatArray>;
  22847. /**
  22848. * An array extending the number of possible weights when the number of indices is extended
  22849. */
  22850. matricesWeightsExtra: Nullable<FloatArray>;
  22851. /**
  22852. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22853. */
  22854. indices: Nullable<IndicesArray>;
  22855. /**
  22856. * Uses the passed data array to set the set the values for the specified kind of data
  22857. * @param data a linear array of floating numbers
  22858. * @param kind the type of data that is being set, eg positions, colors etc
  22859. */
  22860. set(data: FloatArray, kind: string): void;
  22861. /**
  22862. * Associates the vertexData to the passed Mesh.
  22863. * Sets it as updatable or not (default `false`)
  22864. * @param mesh the mesh the vertexData is applied to
  22865. * @param updatable when used and having the value true allows new data to update the vertexData
  22866. * @returns the VertexData
  22867. */
  22868. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22869. /**
  22870. * Associates the vertexData to the passed Geometry.
  22871. * Sets it as updatable or not (default `false`)
  22872. * @param geometry the geometry the vertexData is applied to
  22873. * @param updatable when used and having the value true allows new data to update the vertexData
  22874. * @returns VertexData
  22875. */
  22876. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22877. /**
  22878. * Updates the associated mesh
  22879. * @param mesh the mesh to be updated
  22880. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22881. * @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
  22882. * @returns VertexData
  22883. */
  22884. updateMesh(mesh: Mesh): VertexData;
  22885. /**
  22886. * Updates the associated geometry
  22887. * @param geometry the geometry to be updated
  22888. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22889. * @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
  22890. * @returns VertexData.
  22891. */
  22892. updateGeometry(geometry: Geometry): VertexData;
  22893. private _applyTo;
  22894. private _update;
  22895. /**
  22896. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22897. * @param matrix the transforming matrix
  22898. * @returns the VertexData
  22899. */
  22900. transform(matrix: Matrix): VertexData;
  22901. /**
  22902. * Merges the passed VertexData into the current one
  22903. * @param other the VertexData to be merged into the current one
  22904. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22905. * @returns the modified VertexData
  22906. */
  22907. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22908. private _mergeElement;
  22909. private _validate;
  22910. /**
  22911. * Serializes the VertexData
  22912. * @returns a serialized object
  22913. */
  22914. serialize(): any;
  22915. /**
  22916. * Extracts the vertexData from a mesh
  22917. * @param mesh the mesh from which to extract the VertexData
  22918. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22919. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22920. * @returns the object VertexData associated to the passed mesh
  22921. */
  22922. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22923. /**
  22924. * Extracts the vertexData from the geometry
  22925. * @param geometry the geometry from which to extract the VertexData
  22926. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22927. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22928. * @returns the object VertexData associated to the passed mesh
  22929. */
  22930. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22931. private static _ExtractFrom;
  22932. /**
  22933. * Creates the VertexData for a Ribbon
  22934. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22935. * * pathArray array of paths, each of which an array of successive Vector3
  22936. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22937. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22938. * * 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
  22939. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22940. * * 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)
  22941. * * 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)
  22942. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22943. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22944. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22945. * @returns the VertexData of the ribbon
  22946. */
  22947. static CreateRibbon(options: {
  22948. pathArray: Vector3[][];
  22949. closeArray?: boolean;
  22950. closePath?: boolean;
  22951. offset?: number;
  22952. sideOrientation?: number;
  22953. frontUVs?: Vector4;
  22954. backUVs?: Vector4;
  22955. invertUV?: boolean;
  22956. uvs?: Vector2[];
  22957. colors?: Color4[];
  22958. }): VertexData;
  22959. /**
  22960. * Creates the VertexData for a box
  22961. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22962. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22963. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22964. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22965. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22966. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22967. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22968. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22969. * * 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)
  22970. * * 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)
  22971. * @returns the VertexData of the box
  22972. */
  22973. static CreateBox(options: {
  22974. size?: number;
  22975. width?: number;
  22976. height?: number;
  22977. depth?: number;
  22978. faceUV?: Vector4[];
  22979. faceColors?: Color4[];
  22980. sideOrientation?: number;
  22981. frontUVs?: Vector4;
  22982. backUVs?: Vector4;
  22983. }): VertexData;
  22984. /**
  22985. * Creates the VertexData for a tiled box
  22986. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22987. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22988. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22989. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22990. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22991. * @returns the VertexData of the box
  22992. */
  22993. static CreateTiledBox(options: {
  22994. pattern?: number;
  22995. width?: number;
  22996. height?: number;
  22997. depth?: number;
  22998. tileSize?: number;
  22999. tileWidth?: number;
  23000. tileHeight?: number;
  23001. alignHorizontal?: number;
  23002. alignVertical?: number;
  23003. faceUV?: Vector4[];
  23004. faceColors?: Color4[];
  23005. sideOrientation?: number;
  23006. }): VertexData;
  23007. /**
  23008. * Creates the VertexData for a tiled plane
  23009. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23010. * * pattern a limited pattern arrangement depending on the number
  23011. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23012. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23013. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23014. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23015. * * 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)
  23016. * * 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)
  23017. * @returns the VertexData of the tiled plane
  23018. */
  23019. static CreateTiledPlane(options: {
  23020. pattern?: number;
  23021. tileSize?: number;
  23022. tileWidth?: number;
  23023. tileHeight?: number;
  23024. size?: number;
  23025. width?: number;
  23026. height?: number;
  23027. alignHorizontal?: number;
  23028. alignVertical?: number;
  23029. sideOrientation?: number;
  23030. frontUVs?: Vector4;
  23031. backUVs?: Vector4;
  23032. }): VertexData;
  23033. /**
  23034. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23035. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23036. * * segments sets the number of horizontal strips optional, default 32
  23037. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23038. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23039. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23040. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23041. * * 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
  23042. * * 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
  23043. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23044. * * 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)
  23045. * * 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)
  23046. * @returns the VertexData of the ellipsoid
  23047. */
  23048. static CreateSphere(options: {
  23049. segments?: number;
  23050. diameter?: number;
  23051. diameterX?: number;
  23052. diameterY?: number;
  23053. diameterZ?: number;
  23054. arc?: number;
  23055. slice?: number;
  23056. sideOrientation?: number;
  23057. frontUVs?: Vector4;
  23058. backUVs?: Vector4;
  23059. }): VertexData;
  23060. /**
  23061. * Creates the VertexData for a cylinder, cone or prism
  23062. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23063. * * height sets the height (y direction) of the cylinder, optional, default 2
  23064. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23065. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23066. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23067. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23068. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23069. * * 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
  23070. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23071. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23072. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23073. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23074. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23075. * * 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)
  23076. * * 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)
  23077. * @returns the VertexData of the cylinder, cone or prism
  23078. */
  23079. static CreateCylinder(options: {
  23080. height?: number;
  23081. diameterTop?: number;
  23082. diameterBottom?: number;
  23083. diameter?: number;
  23084. tessellation?: number;
  23085. subdivisions?: number;
  23086. arc?: number;
  23087. faceColors?: Color4[];
  23088. faceUV?: Vector4[];
  23089. hasRings?: boolean;
  23090. enclose?: boolean;
  23091. sideOrientation?: number;
  23092. frontUVs?: Vector4;
  23093. backUVs?: Vector4;
  23094. }): VertexData;
  23095. /**
  23096. * Creates the VertexData for a torus
  23097. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23098. * * diameter the diameter of the torus, optional default 1
  23099. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23100. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23101. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23102. * * 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)
  23103. * * 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)
  23104. * @returns the VertexData of the torus
  23105. */
  23106. static CreateTorus(options: {
  23107. diameter?: number;
  23108. thickness?: number;
  23109. tessellation?: number;
  23110. sideOrientation?: number;
  23111. frontUVs?: Vector4;
  23112. backUVs?: Vector4;
  23113. }): VertexData;
  23114. /**
  23115. * Creates the VertexData of the LineSystem
  23116. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23117. * - lines an array of lines, each line being an array of successive Vector3
  23118. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23119. * @returns the VertexData of the LineSystem
  23120. */
  23121. static CreateLineSystem(options: {
  23122. lines: Vector3[][];
  23123. colors?: Nullable<Color4[][]>;
  23124. }): VertexData;
  23125. /**
  23126. * Create the VertexData for a DashedLines
  23127. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23128. * - points an array successive Vector3
  23129. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23130. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23131. * - dashNb the intended total number of dashes, optional, default 200
  23132. * @returns the VertexData for the DashedLines
  23133. */
  23134. static CreateDashedLines(options: {
  23135. points: Vector3[];
  23136. dashSize?: number;
  23137. gapSize?: number;
  23138. dashNb?: number;
  23139. }): VertexData;
  23140. /**
  23141. * Creates the VertexData for a Ground
  23142. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23143. * - width the width (x direction) of the ground, optional, default 1
  23144. * - height the height (z direction) of the ground, optional, default 1
  23145. * - subdivisions the number of subdivisions per side, optional, default 1
  23146. * @returns the VertexData of the Ground
  23147. */
  23148. static CreateGround(options: {
  23149. width?: number;
  23150. height?: number;
  23151. subdivisions?: number;
  23152. subdivisionsX?: number;
  23153. subdivisionsY?: number;
  23154. }): VertexData;
  23155. /**
  23156. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23157. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23158. * * xmin the ground minimum X coordinate, optional, default -1
  23159. * * zmin the ground minimum Z coordinate, optional, default -1
  23160. * * xmax the ground maximum X coordinate, optional, default 1
  23161. * * zmax the ground maximum Z coordinate, optional, default 1
  23162. * * 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}
  23163. * * 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}
  23164. * @returns the VertexData of the TiledGround
  23165. */
  23166. static CreateTiledGround(options: {
  23167. xmin: number;
  23168. zmin: number;
  23169. xmax: number;
  23170. zmax: number;
  23171. subdivisions?: {
  23172. w: number;
  23173. h: number;
  23174. };
  23175. precision?: {
  23176. w: number;
  23177. h: number;
  23178. };
  23179. }): VertexData;
  23180. /**
  23181. * Creates the VertexData of the Ground designed from a heightmap
  23182. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23183. * * width the width (x direction) of the ground
  23184. * * height the height (z direction) of the ground
  23185. * * subdivisions the number of subdivisions per side
  23186. * * minHeight the minimum altitude on the ground, optional, default 0
  23187. * * maxHeight the maximum altitude on the ground, optional default 1
  23188. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23189. * * buffer the array holding the image color data
  23190. * * bufferWidth the width of image
  23191. * * bufferHeight the height of image
  23192. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23193. * @returns the VertexData of the Ground designed from a heightmap
  23194. */
  23195. static CreateGroundFromHeightMap(options: {
  23196. width: number;
  23197. height: number;
  23198. subdivisions: number;
  23199. minHeight: number;
  23200. maxHeight: number;
  23201. colorFilter: Color3;
  23202. buffer: Uint8Array;
  23203. bufferWidth: number;
  23204. bufferHeight: number;
  23205. alphaFilter: number;
  23206. }): VertexData;
  23207. /**
  23208. * Creates the VertexData for a Plane
  23209. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23210. * * size sets the width and height of the plane to the value of size, optional default 1
  23211. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23212. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23213. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23214. * * 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)
  23215. * * 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)
  23216. * @returns the VertexData of the box
  23217. */
  23218. static CreatePlane(options: {
  23219. size?: number;
  23220. width?: number;
  23221. height?: number;
  23222. sideOrientation?: number;
  23223. frontUVs?: Vector4;
  23224. backUVs?: Vector4;
  23225. }): VertexData;
  23226. /**
  23227. * Creates the VertexData of the Disc or regular Polygon
  23228. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23229. * * radius the radius of the disc, optional default 0.5
  23230. * * tessellation the number of polygon sides, optional, default 64
  23231. * * 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
  23232. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23233. * * 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)
  23234. * * 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)
  23235. * @returns the VertexData of the box
  23236. */
  23237. static CreateDisc(options: {
  23238. radius?: number;
  23239. tessellation?: number;
  23240. arc?: number;
  23241. sideOrientation?: number;
  23242. frontUVs?: Vector4;
  23243. backUVs?: Vector4;
  23244. }): VertexData;
  23245. /**
  23246. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23247. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23248. * @param polygon a mesh built from polygonTriangulation.build()
  23249. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23250. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23251. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23252. * @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)
  23253. * @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)
  23254. * @returns the VertexData of the Polygon
  23255. */
  23256. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23257. /**
  23258. * Creates the VertexData of the IcoSphere
  23259. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23260. * * radius the radius of the IcoSphere, optional default 1
  23261. * * radiusX allows stretching in the x direction, optional, default radius
  23262. * * radiusY allows stretching in the y direction, optional, default radius
  23263. * * radiusZ allows stretching in the z direction, optional, default radius
  23264. * * flat when true creates a flat shaded mesh, optional, default true
  23265. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  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 IcoSphere
  23270. */
  23271. static CreateIcoSphere(options: {
  23272. radius?: number;
  23273. radiusX?: number;
  23274. radiusY?: number;
  23275. radiusZ?: number;
  23276. flat?: boolean;
  23277. subdivisions?: number;
  23278. sideOrientation?: number;
  23279. frontUVs?: Vector4;
  23280. backUVs?: Vector4;
  23281. }): VertexData;
  23282. /**
  23283. * Creates the VertexData for a Polyhedron
  23284. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23285. * * type provided types are:
  23286. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23287. * * 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)
  23288. * * size the size of the IcoSphere, optional default 1
  23289. * * sizeX allows stretching in the x direction, optional, default size
  23290. * * sizeY allows stretching in the y direction, optional, default size
  23291. * * sizeZ allows stretching in the z direction, optional, default size
  23292. * * 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
  23293. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23294. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23295. * * flat when true creates a flat shaded mesh, optional, default true
  23296. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23298. * * 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)
  23299. * * 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)
  23300. * @returns the VertexData of the Polyhedron
  23301. */
  23302. static CreatePolyhedron(options: {
  23303. type?: number;
  23304. size?: number;
  23305. sizeX?: number;
  23306. sizeY?: number;
  23307. sizeZ?: number;
  23308. custom?: any;
  23309. faceUV?: Vector4[];
  23310. faceColors?: Color4[];
  23311. flat?: boolean;
  23312. sideOrientation?: number;
  23313. frontUVs?: Vector4;
  23314. backUVs?: Vector4;
  23315. }): VertexData;
  23316. /**
  23317. * Creates the VertexData for a TorusKnot
  23318. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23319. * * radius the radius of the torus knot, optional, default 2
  23320. * * tube the thickness of the tube, optional, default 0.5
  23321. * * radialSegments the number of sides on each tube segments, optional, default 32
  23322. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23323. * * p the number of windings around the z axis, optional, default 2
  23324. * * q the number of windings around the x axis, optional, default 3
  23325. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23326. * * 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)
  23327. * * 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)
  23328. * @returns the VertexData of the Torus Knot
  23329. */
  23330. static CreateTorusKnot(options: {
  23331. radius?: number;
  23332. tube?: number;
  23333. radialSegments?: number;
  23334. tubularSegments?: number;
  23335. p?: number;
  23336. q?: number;
  23337. sideOrientation?: number;
  23338. frontUVs?: Vector4;
  23339. backUVs?: Vector4;
  23340. }): VertexData;
  23341. /**
  23342. * Compute normals for given positions and indices
  23343. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23344. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23345. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23346. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23347. * * facetNormals : optional array of facet normals (vector3)
  23348. * * facetPositions : optional array of facet positions (vector3)
  23349. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23350. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23351. * * bInfo : optional bounding info, required for facetPartitioning computation
  23352. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23353. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23354. * * useRightHandedSystem: optional boolean to for right handed system computation
  23355. * * depthSort : optional boolean to enable the facet depth sort computation
  23356. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23357. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23358. */
  23359. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23360. facetNormals?: any;
  23361. facetPositions?: any;
  23362. facetPartitioning?: any;
  23363. ratio?: number;
  23364. bInfo?: any;
  23365. bbSize?: Vector3;
  23366. subDiv?: any;
  23367. useRightHandedSystem?: boolean;
  23368. depthSort?: boolean;
  23369. distanceTo?: Vector3;
  23370. depthSortedFacets?: any;
  23371. }): void;
  23372. /** @hidden */
  23373. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23374. /**
  23375. * Applies VertexData created from the imported parameters to the geometry
  23376. * @param parsedVertexData the parsed data from an imported file
  23377. * @param geometry the geometry to apply the VertexData to
  23378. */
  23379. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23380. }
  23381. }
  23382. declare module "babylonjs/Morph/morphTarget" {
  23383. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23384. import { Observable } from "babylonjs/Misc/observable";
  23385. import { Nullable, FloatArray } from "babylonjs/types";
  23386. import { Scene } from "babylonjs/scene";
  23387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23388. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23389. /**
  23390. * Defines a target to use with MorphTargetManager
  23391. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23392. */
  23393. export class MorphTarget implements IAnimatable {
  23394. /** defines the name of the target */
  23395. name: string;
  23396. /**
  23397. * Gets or sets the list of animations
  23398. */
  23399. animations: import("babylonjs/Animations/animation").Animation[];
  23400. private _scene;
  23401. private _positions;
  23402. private _normals;
  23403. private _tangents;
  23404. private _uvs;
  23405. private _influence;
  23406. private _uniqueId;
  23407. /**
  23408. * Observable raised when the influence changes
  23409. */
  23410. onInfluenceChanged: Observable<boolean>;
  23411. /** @hidden */
  23412. _onDataLayoutChanged: Observable<void>;
  23413. /**
  23414. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23415. */
  23416. get influence(): number;
  23417. set influence(influence: number);
  23418. /**
  23419. * Gets or sets the id of the morph Target
  23420. */
  23421. id: string;
  23422. private _animationPropertiesOverride;
  23423. /**
  23424. * Gets or sets the animation properties override
  23425. */
  23426. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23427. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23428. /**
  23429. * Creates a new MorphTarget
  23430. * @param name defines the name of the target
  23431. * @param influence defines the influence to use
  23432. * @param scene defines the scene the morphtarget belongs to
  23433. */
  23434. constructor(
  23435. /** defines the name of the target */
  23436. name: string, influence?: number, scene?: Nullable<Scene>);
  23437. /**
  23438. * Gets the unique ID of this manager
  23439. */
  23440. get uniqueId(): number;
  23441. /**
  23442. * Gets a boolean defining if the target contains position data
  23443. */
  23444. get hasPositions(): boolean;
  23445. /**
  23446. * Gets a boolean defining if the target contains normal data
  23447. */
  23448. get hasNormals(): boolean;
  23449. /**
  23450. * Gets a boolean defining if the target contains tangent data
  23451. */
  23452. get hasTangents(): boolean;
  23453. /**
  23454. * Gets a boolean defining if the target contains texture coordinates data
  23455. */
  23456. get hasUVs(): boolean;
  23457. /**
  23458. * Affects position data to this target
  23459. * @param data defines the position data to use
  23460. */
  23461. setPositions(data: Nullable<FloatArray>): void;
  23462. /**
  23463. * Gets the position data stored in this target
  23464. * @returns a FloatArray containing the position data (or null if not present)
  23465. */
  23466. getPositions(): Nullable<FloatArray>;
  23467. /**
  23468. * Affects normal data to this target
  23469. * @param data defines the normal data to use
  23470. */
  23471. setNormals(data: Nullable<FloatArray>): void;
  23472. /**
  23473. * Gets the normal data stored in this target
  23474. * @returns a FloatArray containing the normal data (or null if not present)
  23475. */
  23476. getNormals(): Nullable<FloatArray>;
  23477. /**
  23478. * Affects tangent data to this target
  23479. * @param data defines the tangent data to use
  23480. */
  23481. setTangents(data: Nullable<FloatArray>): void;
  23482. /**
  23483. * Gets the tangent data stored in this target
  23484. * @returns a FloatArray containing the tangent data (or null if not present)
  23485. */
  23486. getTangents(): Nullable<FloatArray>;
  23487. /**
  23488. * Affects texture coordinates data to this target
  23489. * @param data defines the texture coordinates data to use
  23490. */
  23491. setUVs(data: Nullable<FloatArray>): void;
  23492. /**
  23493. * Gets the texture coordinates data stored in this target
  23494. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23495. */
  23496. getUVs(): Nullable<FloatArray>;
  23497. /**
  23498. * Clone the current target
  23499. * @returns a new MorphTarget
  23500. */
  23501. clone(): MorphTarget;
  23502. /**
  23503. * Serializes the current target into a Serialization object
  23504. * @returns the serialized object
  23505. */
  23506. serialize(): any;
  23507. /**
  23508. * Returns the string "MorphTarget"
  23509. * @returns "MorphTarget"
  23510. */
  23511. getClassName(): string;
  23512. /**
  23513. * Creates a new target from serialized data
  23514. * @param serializationObject defines the serialized data to use
  23515. * @returns a new MorphTarget
  23516. */
  23517. static Parse(serializationObject: any): MorphTarget;
  23518. /**
  23519. * Creates a MorphTarget from mesh data
  23520. * @param mesh defines the source mesh
  23521. * @param name defines the name to use for the new target
  23522. * @param influence defines the influence to attach to the target
  23523. * @returns a new MorphTarget
  23524. */
  23525. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23526. }
  23527. }
  23528. declare module "babylonjs/Morph/morphTargetManager" {
  23529. import { Nullable } from "babylonjs/types";
  23530. import { Scene } from "babylonjs/scene";
  23531. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23532. /**
  23533. * This class is used to deform meshes using morphing between different targets
  23534. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23535. */
  23536. export class MorphTargetManager {
  23537. private _targets;
  23538. private _targetInfluenceChangedObservers;
  23539. private _targetDataLayoutChangedObservers;
  23540. private _activeTargets;
  23541. private _scene;
  23542. private _influences;
  23543. private _supportsNormals;
  23544. private _supportsTangents;
  23545. private _supportsUVs;
  23546. private _vertexCount;
  23547. private _uniqueId;
  23548. private _tempInfluences;
  23549. /**
  23550. * Gets or sets a boolean indicating if normals must be morphed
  23551. */
  23552. enableNormalMorphing: boolean;
  23553. /**
  23554. * Gets or sets a boolean indicating if tangents must be morphed
  23555. */
  23556. enableTangentMorphing: boolean;
  23557. /**
  23558. * Gets or sets a boolean indicating if UV must be morphed
  23559. */
  23560. enableUVMorphing: boolean;
  23561. /**
  23562. * Creates a new MorphTargetManager
  23563. * @param scene defines the current scene
  23564. */
  23565. constructor(scene?: Nullable<Scene>);
  23566. /**
  23567. * Gets the unique ID of this manager
  23568. */
  23569. get uniqueId(): number;
  23570. /**
  23571. * Gets the number of vertices handled by this manager
  23572. */
  23573. get vertexCount(): number;
  23574. /**
  23575. * Gets a boolean indicating if this manager supports morphing of normals
  23576. */
  23577. get supportsNormals(): boolean;
  23578. /**
  23579. * Gets a boolean indicating if this manager supports morphing of tangents
  23580. */
  23581. get supportsTangents(): boolean;
  23582. /**
  23583. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23584. */
  23585. get supportsUVs(): boolean;
  23586. /**
  23587. * Gets the number of targets stored in this manager
  23588. */
  23589. get numTargets(): number;
  23590. /**
  23591. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23592. */
  23593. get numInfluencers(): number;
  23594. /**
  23595. * Gets the list of influences (one per target)
  23596. */
  23597. get influences(): Float32Array;
  23598. /**
  23599. * Gets the active target at specified index. An active target is a target with an influence > 0
  23600. * @param index defines the index to check
  23601. * @returns the requested target
  23602. */
  23603. getActiveTarget(index: number): MorphTarget;
  23604. /**
  23605. * Gets the target at specified index
  23606. * @param index defines the index to check
  23607. * @returns the requested target
  23608. */
  23609. getTarget(index: number): MorphTarget;
  23610. /**
  23611. * Add a new target to this manager
  23612. * @param target defines the target to add
  23613. */
  23614. addTarget(target: MorphTarget): void;
  23615. /**
  23616. * Removes a target from the manager
  23617. * @param target defines the target to remove
  23618. */
  23619. removeTarget(target: MorphTarget): void;
  23620. /**
  23621. * Clone the current manager
  23622. * @returns a new MorphTargetManager
  23623. */
  23624. clone(): MorphTargetManager;
  23625. /**
  23626. * Serializes the current manager into a Serialization object
  23627. * @returns the serialized object
  23628. */
  23629. serialize(): any;
  23630. private _syncActiveTargets;
  23631. /**
  23632. * Syncrhonize the targets with all the meshes using this morph target manager
  23633. */
  23634. synchronize(): void;
  23635. /**
  23636. * Creates a new MorphTargetManager from serialized data
  23637. * @param serializationObject defines the serialized data
  23638. * @param scene defines the hosting scene
  23639. * @returns the new MorphTargetManager
  23640. */
  23641. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23642. }
  23643. }
  23644. declare module "babylonjs/Meshes/meshLODLevel" {
  23645. import { Mesh } from "babylonjs/Meshes/mesh";
  23646. import { Nullable } from "babylonjs/types";
  23647. /**
  23648. * Class used to represent a specific level of detail of a mesh
  23649. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23650. */
  23651. export class MeshLODLevel {
  23652. /** Defines the distance where this level should start being displayed */
  23653. distance: number;
  23654. /** Defines the mesh to use to render this level */
  23655. mesh: Nullable<Mesh>;
  23656. /**
  23657. * Creates a new LOD level
  23658. * @param distance defines the distance where this level should star being displayed
  23659. * @param mesh defines the mesh to use to render this level
  23660. */
  23661. constructor(
  23662. /** Defines the distance where this level should start being displayed */
  23663. distance: number,
  23664. /** Defines the mesh to use to render this level */
  23665. mesh: Nullable<Mesh>);
  23666. }
  23667. }
  23668. declare module "babylonjs/Meshes/groundMesh" {
  23669. import { Scene } from "babylonjs/scene";
  23670. import { Vector3 } from "babylonjs/Maths/math.vector";
  23671. import { Mesh } from "babylonjs/Meshes/mesh";
  23672. /**
  23673. * Mesh representing the gorund
  23674. */
  23675. export class GroundMesh extends Mesh {
  23676. /** If octree should be generated */
  23677. generateOctree: boolean;
  23678. private _heightQuads;
  23679. /** @hidden */
  23680. _subdivisionsX: number;
  23681. /** @hidden */
  23682. _subdivisionsY: number;
  23683. /** @hidden */
  23684. _width: number;
  23685. /** @hidden */
  23686. _height: number;
  23687. /** @hidden */
  23688. _minX: number;
  23689. /** @hidden */
  23690. _maxX: number;
  23691. /** @hidden */
  23692. _minZ: number;
  23693. /** @hidden */
  23694. _maxZ: number;
  23695. constructor(name: string, scene: Scene);
  23696. /**
  23697. * "GroundMesh"
  23698. * @returns "GroundMesh"
  23699. */
  23700. getClassName(): string;
  23701. /**
  23702. * The minimum of x and y subdivisions
  23703. */
  23704. get subdivisions(): number;
  23705. /**
  23706. * X subdivisions
  23707. */
  23708. get subdivisionsX(): number;
  23709. /**
  23710. * Y subdivisions
  23711. */
  23712. get subdivisionsY(): number;
  23713. /**
  23714. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23715. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23716. * @param chunksCount the number of subdivisions for x and y
  23717. * @param octreeBlocksSize (Default: 32)
  23718. */
  23719. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23720. /**
  23721. * Returns a height (y) value in the Worl system :
  23722. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23723. * @param x x coordinate
  23724. * @param z z coordinate
  23725. * @returns the ground y position if (x, z) are outside the ground surface.
  23726. */
  23727. getHeightAtCoordinates(x: number, z: number): number;
  23728. /**
  23729. * Returns a normalized vector (Vector3) orthogonal to the ground
  23730. * at the ground coordinates (x, z) expressed in the World system.
  23731. * @param x x coordinate
  23732. * @param z z coordinate
  23733. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23734. */
  23735. getNormalAtCoordinates(x: number, z: number): Vector3;
  23736. /**
  23737. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23738. * at the ground coordinates (x, z) expressed in the World system.
  23739. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23740. * @param x x coordinate
  23741. * @param z z coordinate
  23742. * @param ref vector to store the result
  23743. * @returns the GroundMesh.
  23744. */
  23745. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23746. /**
  23747. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23748. * if the ground has been updated.
  23749. * This can be used in the render loop.
  23750. * @returns the GroundMesh.
  23751. */
  23752. updateCoordinateHeights(): GroundMesh;
  23753. private _getFacetAt;
  23754. private _initHeightQuads;
  23755. private _computeHeightQuads;
  23756. /**
  23757. * Serializes this ground mesh
  23758. * @param serializationObject object to write serialization to
  23759. */
  23760. serialize(serializationObject: any): void;
  23761. /**
  23762. * Parses a serialized ground mesh
  23763. * @param parsedMesh the serialized mesh
  23764. * @param scene the scene to create the ground mesh in
  23765. * @returns the created ground mesh
  23766. */
  23767. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23768. }
  23769. }
  23770. declare module "babylonjs/Physics/physicsJoint" {
  23771. import { Vector3 } from "babylonjs/Maths/math.vector";
  23772. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23773. /**
  23774. * Interface for Physics-Joint data
  23775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23776. */
  23777. export interface PhysicsJointData {
  23778. /**
  23779. * The main pivot of the joint
  23780. */
  23781. mainPivot?: Vector3;
  23782. /**
  23783. * The connected pivot of the joint
  23784. */
  23785. connectedPivot?: Vector3;
  23786. /**
  23787. * The main axis of the joint
  23788. */
  23789. mainAxis?: Vector3;
  23790. /**
  23791. * The connected axis of the joint
  23792. */
  23793. connectedAxis?: Vector3;
  23794. /**
  23795. * The collision of the joint
  23796. */
  23797. collision?: boolean;
  23798. /**
  23799. * Native Oimo/Cannon/Energy data
  23800. */
  23801. nativeParams?: any;
  23802. }
  23803. /**
  23804. * This is a holder class for the physics joint created by the physics plugin
  23805. * It holds a set of functions to control the underlying joint
  23806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23807. */
  23808. export class PhysicsJoint {
  23809. /**
  23810. * The type of the physics joint
  23811. */
  23812. type: number;
  23813. /**
  23814. * The data for the physics joint
  23815. */
  23816. jointData: PhysicsJointData;
  23817. private _physicsJoint;
  23818. protected _physicsPlugin: IPhysicsEnginePlugin;
  23819. /**
  23820. * Initializes the physics joint
  23821. * @param type The type of the physics joint
  23822. * @param jointData The data for the physics joint
  23823. */
  23824. constructor(
  23825. /**
  23826. * The type of the physics joint
  23827. */
  23828. type: number,
  23829. /**
  23830. * The data for the physics joint
  23831. */
  23832. jointData: PhysicsJointData);
  23833. /**
  23834. * Gets the physics joint
  23835. */
  23836. get physicsJoint(): any;
  23837. /**
  23838. * Sets the physics joint
  23839. */
  23840. set physicsJoint(newJoint: any);
  23841. /**
  23842. * Sets the physics plugin
  23843. */
  23844. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23845. /**
  23846. * Execute a function that is physics-plugin specific.
  23847. * @param {Function} func the function that will be executed.
  23848. * It accepts two parameters: the physics world and the physics joint
  23849. */
  23850. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23851. /**
  23852. * Distance-Joint type
  23853. */
  23854. static DistanceJoint: number;
  23855. /**
  23856. * Hinge-Joint type
  23857. */
  23858. static HingeJoint: number;
  23859. /**
  23860. * Ball-and-Socket joint type
  23861. */
  23862. static BallAndSocketJoint: number;
  23863. /**
  23864. * Wheel-Joint type
  23865. */
  23866. static WheelJoint: number;
  23867. /**
  23868. * Slider-Joint type
  23869. */
  23870. static SliderJoint: number;
  23871. /**
  23872. * Prismatic-Joint type
  23873. */
  23874. static PrismaticJoint: number;
  23875. /**
  23876. * Universal-Joint type
  23877. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23878. */
  23879. static UniversalJoint: number;
  23880. /**
  23881. * Hinge-Joint 2 type
  23882. */
  23883. static Hinge2Joint: number;
  23884. /**
  23885. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23886. */
  23887. static PointToPointJoint: number;
  23888. /**
  23889. * Spring-Joint type
  23890. */
  23891. static SpringJoint: number;
  23892. /**
  23893. * Lock-Joint type
  23894. */
  23895. static LockJoint: number;
  23896. }
  23897. /**
  23898. * A class representing a physics distance joint
  23899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23900. */
  23901. export class DistanceJoint extends PhysicsJoint {
  23902. /**
  23903. *
  23904. * @param jointData The data for the Distance-Joint
  23905. */
  23906. constructor(jointData: DistanceJointData);
  23907. /**
  23908. * Update the predefined distance.
  23909. * @param maxDistance The maximum preferred distance
  23910. * @param minDistance The minimum preferred distance
  23911. */
  23912. updateDistance(maxDistance: number, minDistance?: number): void;
  23913. }
  23914. /**
  23915. * Represents a Motor-Enabled Joint
  23916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23917. */
  23918. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23919. /**
  23920. * Initializes the Motor-Enabled Joint
  23921. * @param type The type of the joint
  23922. * @param jointData The physica joint data for the joint
  23923. */
  23924. constructor(type: number, jointData: PhysicsJointData);
  23925. /**
  23926. * Set the motor values.
  23927. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23928. * @param force the force to apply
  23929. * @param maxForce max force for this motor.
  23930. */
  23931. setMotor(force?: number, maxForce?: number): void;
  23932. /**
  23933. * Set the motor's limits.
  23934. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23935. * @param upperLimit The upper limit of the motor
  23936. * @param lowerLimit The lower limit of the motor
  23937. */
  23938. setLimit(upperLimit: number, lowerLimit?: number): void;
  23939. }
  23940. /**
  23941. * This class represents a single physics Hinge-Joint
  23942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23943. */
  23944. export class HingeJoint extends MotorEnabledJoint {
  23945. /**
  23946. * Initializes the Hinge-Joint
  23947. * @param jointData The joint data for the Hinge-Joint
  23948. */
  23949. constructor(jointData: PhysicsJointData);
  23950. /**
  23951. * Set the motor values.
  23952. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23953. * @param {number} force the force to apply
  23954. * @param {number} maxForce max force for this motor.
  23955. */
  23956. setMotor(force?: number, maxForce?: number): void;
  23957. /**
  23958. * Set the motor's limits.
  23959. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23960. * @param upperLimit The upper limit of the motor
  23961. * @param lowerLimit The lower limit of the motor
  23962. */
  23963. setLimit(upperLimit: number, lowerLimit?: number): void;
  23964. }
  23965. /**
  23966. * This class represents a dual hinge physics joint (same as wheel joint)
  23967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23968. */
  23969. export class Hinge2Joint extends MotorEnabledJoint {
  23970. /**
  23971. * Initializes the Hinge2-Joint
  23972. * @param jointData The joint data for the Hinge2-Joint
  23973. */
  23974. constructor(jointData: PhysicsJointData);
  23975. /**
  23976. * Set the motor values.
  23977. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23978. * @param {number} targetSpeed the speed the motor is to reach
  23979. * @param {number} maxForce max force for this motor.
  23980. * @param {motorIndex} the motor's index, 0 or 1.
  23981. */
  23982. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23983. /**
  23984. * Set the motor limits.
  23985. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23986. * @param {number} upperLimit the upper limit
  23987. * @param {number} lowerLimit lower limit
  23988. * @param {motorIndex} the motor's index, 0 or 1.
  23989. */
  23990. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23991. }
  23992. /**
  23993. * Interface for a motor enabled joint
  23994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23995. */
  23996. export interface IMotorEnabledJoint {
  23997. /**
  23998. * Physics joint
  23999. */
  24000. physicsJoint: any;
  24001. /**
  24002. * Sets the motor of the motor-enabled joint
  24003. * @param force The force of the motor
  24004. * @param maxForce The maximum force of the motor
  24005. * @param motorIndex The index of the motor
  24006. */
  24007. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24008. /**
  24009. * Sets the limit of the motor
  24010. * @param upperLimit The upper limit of the motor
  24011. * @param lowerLimit The lower limit of the motor
  24012. * @param motorIndex The index of the motor
  24013. */
  24014. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24015. }
  24016. /**
  24017. * Joint data for a Distance-Joint
  24018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24019. */
  24020. export interface DistanceJointData extends PhysicsJointData {
  24021. /**
  24022. * Max distance the 2 joint objects can be apart
  24023. */
  24024. maxDistance: number;
  24025. }
  24026. /**
  24027. * Joint data from a spring joint
  24028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24029. */
  24030. export interface SpringJointData extends PhysicsJointData {
  24031. /**
  24032. * Length of the spring
  24033. */
  24034. length: number;
  24035. /**
  24036. * Stiffness of the spring
  24037. */
  24038. stiffness: number;
  24039. /**
  24040. * Damping of the spring
  24041. */
  24042. damping: number;
  24043. /** this callback will be called when applying the force to the impostors. */
  24044. forceApplicationCallback: () => void;
  24045. }
  24046. }
  24047. declare module "babylonjs/Physics/physicsRaycastResult" {
  24048. import { Vector3 } from "babylonjs/Maths/math.vector";
  24049. /**
  24050. * Holds the data for the raycast result
  24051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24052. */
  24053. export class PhysicsRaycastResult {
  24054. private _hasHit;
  24055. private _hitDistance;
  24056. private _hitNormalWorld;
  24057. private _hitPointWorld;
  24058. private _rayFromWorld;
  24059. private _rayToWorld;
  24060. /**
  24061. * Gets if there was a hit
  24062. */
  24063. get hasHit(): boolean;
  24064. /**
  24065. * Gets the distance from the hit
  24066. */
  24067. get hitDistance(): number;
  24068. /**
  24069. * Gets the hit normal/direction in the world
  24070. */
  24071. get hitNormalWorld(): Vector3;
  24072. /**
  24073. * Gets the hit point in the world
  24074. */
  24075. get hitPointWorld(): Vector3;
  24076. /**
  24077. * Gets the ray "start point" of the ray in the world
  24078. */
  24079. get rayFromWorld(): Vector3;
  24080. /**
  24081. * Gets the ray "end point" of the ray in the world
  24082. */
  24083. get rayToWorld(): Vector3;
  24084. /**
  24085. * Sets the hit data (normal & point in world space)
  24086. * @param hitNormalWorld defines the normal in world space
  24087. * @param hitPointWorld defines the point in world space
  24088. */
  24089. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24090. /**
  24091. * Sets the distance from the start point to the hit point
  24092. * @param distance
  24093. */
  24094. setHitDistance(distance: number): void;
  24095. /**
  24096. * Calculates the distance manually
  24097. */
  24098. calculateHitDistance(): void;
  24099. /**
  24100. * Resets all the values to default
  24101. * @param from The from point on world space
  24102. * @param to The to point on world space
  24103. */
  24104. reset(from?: Vector3, to?: Vector3): void;
  24105. }
  24106. /**
  24107. * Interface for the size containing width and height
  24108. */
  24109. interface IXYZ {
  24110. /**
  24111. * X
  24112. */
  24113. x: number;
  24114. /**
  24115. * Y
  24116. */
  24117. y: number;
  24118. /**
  24119. * Z
  24120. */
  24121. z: number;
  24122. }
  24123. }
  24124. declare module "babylonjs/Physics/IPhysicsEngine" {
  24125. import { Nullable } from "babylonjs/types";
  24126. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24128. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24129. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24130. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24131. /**
  24132. * Interface used to describe a physics joint
  24133. */
  24134. export interface PhysicsImpostorJoint {
  24135. /** Defines the main impostor to which the joint is linked */
  24136. mainImpostor: PhysicsImpostor;
  24137. /** Defines the impostor that is connected to the main impostor using this joint */
  24138. connectedImpostor: PhysicsImpostor;
  24139. /** Defines the joint itself */
  24140. joint: PhysicsJoint;
  24141. }
  24142. /** @hidden */
  24143. export interface IPhysicsEnginePlugin {
  24144. world: any;
  24145. name: string;
  24146. setGravity(gravity: Vector3): void;
  24147. setTimeStep(timeStep: number): void;
  24148. getTimeStep(): number;
  24149. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24150. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24151. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24152. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24153. removePhysicsBody(impostor: PhysicsImpostor): void;
  24154. generateJoint(joint: PhysicsImpostorJoint): void;
  24155. removeJoint(joint: PhysicsImpostorJoint): void;
  24156. isSupported(): boolean;
  24157. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24158. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24159. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24160. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24161. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24162. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24163. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24164. getBodyMass(impostor: PhysicsImpostor): number;
  24165. getBodyFriction(impostor: PhysicsImpostor): number;
  24166. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24167. getBodyRestitution(impostor: PhysicsImpostor): number;
  24168. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24169. getBodyPressure?(impostor: PhysicsImpostor): number;
  24170. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24171. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24172. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24173. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24174. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24175. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24176. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24177. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24178. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24179. sleepBody(impostor: PhysicsImpostor): void;
  24180. wakeUpBody(impostor: PhysicsImpostor): void;
  24181. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24182. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24183. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24184. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24185. getRadius(impostor: PhysicsImpostor): number;
  24186. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24187. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24188. dispose(): void;
  24189. }
  24190. /**
  24191. * Interface used to define a physics engine
  24192. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24193. */
  24194. export interface IPhysicsEngine {
  24195. /**
  24196. * Gets the gravity vector used by the simulation
  24197. */
  24198. gravity: Vector3;
  24199. /**
  24200. * Sets the gravity vector used by the simulation
  24201. * @param gravity defines the gravity vector to use
  24202. */
  24203. setGravity(gravity: Vector3): void;
  24204. /**
  24205. * Set the time step of the physics engine.
  24206. * Default is 1/60.
  24207. * To slow it down, enter 1/600 for example.
  24208. * To speed it up, 1/30
  24209. * @param newTimeStep the new timestep to apply to this world.
  24210. */
  24211. setTimeStep(newTimeStep: number): void;
  24212. /**
  24213. * Get the time step of the physics engine.
  24214. * @returns the current time step
  24215. */
  24216. getTimeStep(): number;
  24217. /**
  24218. * Set the sub time step of the physics engine.
  24219. * Default is 0 meaning there is no sub steps
  24220. * To increase physics resolution precision, set a small value (like 1 ms)
  24221. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24222. */
  24223. setSubTimeStep(subTimeStep: number): void;
  24224. /**
  24225. * Get the sub time step of the physics engine.
  24226. * @returns the current sub time step
  24227. */
  24228. getSubTimeStep(): number;
  24229. /**
  24230. * Release all resources
  24231. */
  24232. dispose(): void;
  24233. /**
  24234. * Gets the name of the current physics plugin
  24235. * @returns the name of the plugin
  24236. */
  24237. getPhysicsPluginName(): string;
  24238. /**
  24239. * Adding a new impostor for the impostor tracking.
  24240. * This will be done by the impostor itself.
  24241. * @param impostor the impostor to add
  24242. */
  24243. addImpostor(impostor: PhysicsImpostor): void;
  24244. /**
  24245. * Remove an impostor from the engine.
  24246. * This impostor and its mesh will not longer be updated by the physics engine.
  24247. * @param impostor the impostor to remove
  24248. */
  24249. removeImpostor(impostor: PhysicsImpostor): void;
  24250. /**
  24251. * Add a joint to the physics engine
  24252. * @param mainImpostor defines the main impostor to which the joint is added.
  24253. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24254. * @param joint defines the joint that will connect both impostors.
  24255. */
  24256. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24257. /**
  24258. * Removes a joint from the simulation
  24259. * @param mainImpostor defines the impostor used with the joint
  24260. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24261. * @param joint defines the joint to remove
  24262. */
  24263. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24264. /**
  24265. * Gets the current plugin used to run the simulation
  24266. * @returns current plugin
  24267. */
  24268. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24269. /**
  24270. * Gets the list of physic impostors
  24271. * @returns an array of PhysicsImpostor
  24272. */
  24273. getImpostors(): Array<PhysicsImpostor>;
  24274. /**
  24275. * Gets the impostor for a physics enabled object
  24276. * @param object defines the object impersonated by the impostor
  24277. * @returns the PhysicsImpostor or null if not found
  24278. */
  24279. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24280. /**
  24281. * Gets the impostor for a physics body object
  24282. * @param body defines physics body used by the impostor
  24283. * @returns the PhysicsImpostor or null if not found
  24284. */
  24285. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24286. /**
  24287. * Does a raycast in the physics world
  24288. * @param from when should the ray start?
  24289. * @param to when should the ray end?
  24290. * @returns PhysicsRaycastResult
  24291. */
  24292. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24293. /**
  24294. * Called by the scene. No need to call it.
  24295. * @param delta defines the timespam between frames
  24296. */
  24297. _step(delta: number): void;
  24298. }
  24299. }
  24300. declare module "babylonjs/Physics/physicsImpostor" {
  24301. import { Nullable, IndicesArray } from "babylonjs/types";
  24302. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24303. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24305. import { Scene } from "babylonjs/scene";
  24306. import { Bone } from "babylonjs/Bones/bone";
  24307. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24308. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24309. import { Space } from "babylonjs/Maths/math.axis";
  24310. /**
  24311. * The interface for the physics imposter parameters
  24312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24313. */
  24314. export interface PhysicsImpostorParameters {
  24315. /**
  24316. * The mass of the physics imposter
  24317. */
  24318. mass: number;
  24319. /**
  24320. * The friction of the physics imposter
  24321. */
  24322. friction?: number;
  24323. /**
  24324. * The coefficient of restitution of the physics imposter
  24325. */
  24326. restitution?: number;
  24327. /**
  24328. * The native options of the physics imposter
  24329. */
  24330. nativeOptions?: any;
  24331. /**
  24332. * Specifies if the parent should be ignored
  24333. */
  24334. ignoreParent?: boolean;
  24335. /**
  24336. * Specifies if bi-directional transformations should be disabled
  24337. */
  24338. disableBidirectionalTransformation?: boolean;
  24339. /**
  24340. * The pressure inside the physics imposter, soft object only
  24341. */
  24342. pressure?: number;
  24343. /**
  24344. * The stiffness the physics imposter, soft object only
  24345. */
  24346. stiffness?: number;
  24347. /**
  24348. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24349. */
  24350. velocityIterations?: number;
  24351. /**
  24352. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24353. */
  24354. positionIterations?: number;
  24355. /**
  24356. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24357. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24358. * Add to fix multiple points
  24359. */
  24360. fixedPoints?: number;
  24361. /**
  24362. * The collision margin around a soft object
  24363. */
  24364. margin?: number;
  24365. /**
  24366. * The collision margin around a soft object
  24367. */
  24368. damping?: number;
  24369. /**
  24370. * The path for a rope based on an extrusion
  24371. */
  24372. path?: any;
  24373. /**
  24374. * The shape of an extrusion used for a rope based on an extrusion
  24375. */
  24376. shape?: any;
  24377. }
  24378. /**
  24379. * Interface for a physics-enabled object
  24380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24381. */
  24382. export interface IPhysicsEnabledObject {
  24383. /**
  24384. * The position of the physics-enabled object
  24385. */
  24386. position: Vector3;
  24387. /**
  24388. * The rotation of the physics-enabled object
  24389. */
  24390. rotationQuaternion: Nullable<Quaternion>;
  24391. /**
  24392. * The scale of the physics-enabled object
  24393. */
  24394. scaling: Vector3;
  24395. /**
  24396. * The rotation of the physics-enabled object
  24397. */
  24398. rotation?: Vector3;
  24399. /**
  24400. * The parent of the physics-enabled object
  24401. */
  24402. parent?: any;
  24403. /**
  24404. * The bounding info of the physics-enabled object
  24405. * @returns The bounding info of the physics-enabled object
  24406. */
  24407. getBoundingInfo(): BoundingInfo;
  24408. /**
  24409. * Computes the world matrix
  24410. * @param force Specifies if the world matrix should be computed by force
  24411. * @returns A world matrix
  24412. */
  24413. computeWorldMatrix(force: boolean): Matrix;
  24414. /**
  24415. * Gets the world matrix
  24416. * @returns A world matrix
  24417. */
  24418. getWorldMatrix?(): Matrix;
  24419. /**
  24420. * Gets the child meshes
  24421. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24422. * @returns An array of abstract meshes
  24423. */
  24424. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24425. /**
  24426. * Gets the vertex data
  24427. * @param kind The type of vertex data
  24428. * @returns A nullable array of numbers, or a float32 array
  24429. */
  24430. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24431. /**
  24432. * Gets the indices from the mesh
  24433. * @returns A nullable array of index arrays
  24434. */
  24435. getIndices?(): Nullable<IndicesArray>;
  24436. /**
  24437. * Gets the scene from the mesh
  24438. * @returns the indices array or null
  24439. */
  24440. getScene?(): Scene;
  24441. /**
  24442. * Gets the absolute position from the mesh
  24443. * @returns the absolute position
  24444. */
  24445. getAbsolutePosition(): Vector3;
  24446. /**
  24447. * Gets the absolute pivot point from the mesh
  24448. * @returns the absolute pivot point
  24449. */
  24450. getAbsolutePivotPoint(): Vector3;
  24451. /**
  24452. * Rotates the mesh
  24453. * @param axis The axis of rotation
  24454. * @param amount The amount of rotation
  24455. * @param space The space of the rotation
  24456. * @returns The rotation transform node
  24457. */
  24458. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24459. /**
  24460. * Translates the mesh
  24461. * @param axis The axis of translation
  24462. * @param distance The distance of translation
  24463. * @param space The space of the translation
  24464. * @returns The transform node
  24465. */
  24466. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24467. /**
  24468. * Sets the absolute position of the mesh
  24469. * @param absolutePosition The absolute position of the mesh
  24470. * @returns The transform node
  24471. */
  24472. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24473. /**
  24474. * Gets the class name of the mesh
  24475. * @returns The class name
  24476. */
  24477. getClassName(): string;
  24478. }
  24479. /**
  24480. * Represents a physics imposter
  24481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24482. */
  24483. export class PhysicsImpostor {
  24484. /**
  24485. * The physics-enabled object used as the physics imposter
  24486. */
  24487. object: IPhysicsEnabledObject;
  24488. /**
  24489. * The type of the physics imposter
  24490. */
  24491. type: number;
  24492. private _options;
  24493. private _scene?;
  24494. /**
  24495. * The default object size of the imposter
  24496. */
  24497. static DEFAULT_OBJECT_SIZE: Vector3;
  24498. /**
  24499. * The identity quaternion of the imposter
  24500. */
  24501. static IDENTITY_QUATERNION: Quaternion;
  24502. /** @hidden */
  24503. _pluginData: any;
  24504. private _physicsEngine;
  24505. private _physicsBody;
  24506. private _bodyUpdateRequired;
  24507. private _onBeforePhysicsStepCallbacks;
  24508. private _onAfterPhysicsStepCallbacks;
  24509. /** @hidden */
  24510. _onPhysicsCollideCallbacks: Array<{
  24511. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24512. otherImpostors: Array<PhysicsImpostor>;
  24513. }>;
  24514. private _deltaPosition;
  24515. private _deltaRotation;
  24516. private _deltaRotationConjugated;
  24517. /** @hidden */
  24518. _isFromLine: boolean;
  24519. private _parent;
  24520. private _isDisposed;
  24521. private static _tmpVecs;
  24522. private static _tmpQuat;
  24523. /**
  24524. * Specifies if the physics imposter is disposed
  24525. */
  24526. get isDisposed(): boolean;
  24527. /**
  24528. * Gets the mass of the physics imposter
  24529. */
  24530. get mass(): number;
  24531. set mass(value: number);
  24532. /**
  24533. * Gets the coefficient of friction
  24534. */
  24535. get friction(): number;
  24536. /**
  24537. * Sets the coefficient of friction
  24538. */
  24539. set friction(value: number);
  24540. /**
  24541. * Gets the coefficient of restitution
  24542. */
  24543. get restitution(): number;
  24544. /**
  24545. * Sets the coefficient of restitution
  24546. */
  24547. set restitution(value: number);
  24548. /**
  24549. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24550. */
  24551. get pressure(): number;
  24552. /**
  24553. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24554. */
  24555. set pressure(value: number);
  24556. /**
  24557. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24558. */
  24559. get stiffness(): number;
  24560. /**
  24561. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24562. */
  24563. set stiffness(value: number);
  24564. /**
  24565. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24566. */
  24567. get velocityIterations(): number;
  24568. /**
  24569. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24570. */
  24571. set velocityIterations(value: number);
  24572. /**
  24573. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24574. */
  24575. get positionIterations(): number;
  24576. /**
  24577. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24578. */
  24579. set positionIterations(value: number);
  24580. /**
  24581. * The unique id of the physics imposter
  24582. * set by the physics engine when adding this impostor to the array
  24583. */
  24584. uniqueId: number;
  24585. /**
  24586. * @hidden
  24587. */
  24588. soft: boolean;
  24589. /**
  24590. * @hidden
  24591. */
  24592. segments: number;
  24593. private _joints;
  24594. /**
  24595. * Initializes the physics imposter
  24596. * @param object The physics-enabled object used as the physics imposter
  24597. * @param type The type of the physics imposter
  24598. * @param _options The options for the physics imposter
  24599. * @param _scene The Babylon scene
  24600. */
  24601. constructor(
  24602. /**
  24603. * The physics-enabled object used as the physics imposter
  24604. */
  24605. object: IPhysicsEnabledObject,
  24606. /**
  24607. * The type of the physics imposter
  24608. */
  24609. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24610. /**
  24611. * This function will completly initialize this impostor.
  24612. * It will create a new body - but only if this mesh has no parent.
  24613. * If it has, this impostor will not be used other than to define the impostor
  24614. * of the child mesh.
  24615. * @hidden
  24616. */
  24617. _init(): void;
  24618. private _getPhysicsParent;
  24619. /**
  24620. * Should a new body be generated.
  24621. * @returns boolean specifying if body initialization is required
  24622. */
  24623. isBodyInitRequired(): boolean;
  24624. /**
  24625. * Sets the updated scaling
  24626. * @param updated Specifies if the scaling is updated
  24627. */
  24628. setScalingUpdated(): void;
  24629. /**
  24630. * Force a regeneration of this or the parent's impostor's body.
  24631. * Use under cautious - This will remove all joints already implemented.
  24632. */
  24633. forceUpdate(): void;
  24634. /**
  24635. * Gets the body that holds this impostor. Either its own, or its parent.
  24636. */
  24637. get physicsBody(): any;
  24638. /**
  24639. * Get the parent of the physics imposter
  24640. * @returns Physics imposter or null
  24641. */
  24642. get parent(): Nullable<PhysicsImpostor>;
  24643. /**
  24644. * Sets the parent of the physics imposter
  24645. */
  24646. set parent(value: Nullable<PhysicsImpostor>);
  24647. /**
  24648. * Set the physics body. Used mainly by the physics engine/plugin
  24649. */
  24650. set physicsBody(physicsBody: any);
  24651. /**
  24652. * Resets the update flags
  24653. */
  24654. resetUpdateFlags(): void;
  24655. /**
  24656. * Gets the object extend size
  24657. * @returns the object extend size
  24658. */
  24659. getObjectExtendSize(): Vector3;
  24660. /**
  24661. * Gets the object center
  24662. * @returns The object center
  24663. */
  24664. getObjectCenter(): Vector3;
  24665. /**
  24666. * Get a specific parameter from the options parameters
  24667. * @param paramName The object parameter name
  24668. * @returns The object parameter
  24669. */
  24670. getParam(paramName: string): any;
  24671. /**
  24672. * Sets a specific parameter in the options given to the physics plugin
  24673. * @param paramName The parameter name
  24674. * @param value The value of the parameter
  24675. */
  24676. setParam(paramName: string, value: number): void;
  24677. /**
  24678. * Specifically change the body's mass option. Won't recreate the physics body object
  24679. * @param mass The mass of the physics imposter
  24680. */
  24681. setMass(mass: number): void;
  24682. /**
  24683. * Gets the linear velocity
  24684. * @returns linear velocity or null
  24685. */
  24686. getLinearVelocity(): Nullable<Vector3>;
  24687. /**
  24688. * Sets the linear velocity
  24689. * @param velocity linear velocity or null
  24690. */
  24691. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24692. /**
  24693. * Gets the angular velocity
  24694. * @returns angular velocity or null
  24695. */
  24696. getAngularVelocity(): Nullable<Vector3>;
  24697. /**
  24698. * Sets the angular velocity
  24699. * @param velocity The velocity or null
  24700. */
  24701. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24702. /**
  24703. * Execute a function with the physics plugin native code
  24704. * Provide a function the will have two variables - the world object and the physics body object
  24705. * @param func The function to execute with the physics plugin native code
  24706. */
  24707. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24708. /**
  24709. * Register a function that will be executed before the physics world is stepping forward
  24710. * @param func The function to execute before the physics world is stepped forward
  24711. */
  24712. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24713. /**
  24714. * Unregister a function that will be executed before the physics world is stepping forward
  24715. * @param func The function to execute before the physics world is stepped forward
  24716. */
  24717. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24718. /**
  24719. * Register a function that will be executed after the physics step
  24720. * @param func The function to execute after physics step
  24721. */
  24722. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24723. /**
  24724. * Unregisters a function that will be executed after the physics step
  24725. * @param func The function to execute after physics step
  24726. */
  24727. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24728. /**
  24729. * register a function that will be executed when this impostor collides against a different body
  24730. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24731. * @param func Callback that is executed on collision
  24732. */
  24733. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24734. /**
  24735. * Unregisters the physics imposter on contact
  24736. * @param collideAgainst The physics object to collide against
  24737. * @param func Callback to execute on collision
  24738. */
  24739. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24740. private _tmpQuat;
  24741. private _tmpQuat2;
  24742. /**
  24743. * Get the parent rotation
  24744. * @returns The parent rotation
  24745. */
  24746. getParentsRotation(): Quaternion;
  24747. /**
  24748. * this function is executed by the physics engine.
  24749. */
  24750. beforeStep: () => void;
  24751. /**
  24752. * this function is executed by the physics engine
  24753. */
  24754. afterStep: () => void;
  24755. /**
  24756. * Legacy collision detection event support
  24757. */
  24758. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24759. /**
  24760. * event and body object due to cannon's event-based architecture.
  24761. */
  24762. onCollide: (e: {
  24763. body: any;
  24764. }) => void;
  24765. /**
  24766. * Apply a force
  24767. * @param force The force to apply
  24768. * @param contactPoint The contact point for the force
  24769. * @returns The physics imposter
  24770. */
  24771. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24772. /**
  24773. * Apply an impulse
  24774. * @param force The impulse force
  24775. * @param contactPoint The contact point for the impulse force
  24776. * @returns The physics imposter
  24777. */
  24778. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24779. /**
  24780. * A help function to create a joint
  24781. * @param otherImpostor A physics imposter used to create a joint
  24782. * @param jointType The type of joint
  24783. * @param jointData The data for the joint
  24784. * @returns The physics imposter
  24785. */
  24786. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24787. /**
  24788. * Add a joint to this impostor with a different impostor
  24789. * @param otherImpostor A physics imposter used to add a joint
  24790. * @param joint The joint to add
  24791. * @returns The physics imposter
  24792. */
  24793. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24794. /**
  24795. * Add an anchor to a cloth impostor
  24796. * @param otherImpostor rigid impostor to anchor to
  24797. * @param width ratio across width from 0 to 1
  24798. * @param height ratio up height from 0 to 1
  24799. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24800. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24801. * @returns impostor the soft imposter
  24802. */
  24803. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24804. /**
  24805. * Add a hook to a rope impostor
  24806. * @param otherImpostor rigid impostor to anchor to
  24807. * @param length ratio across rope from 0 to 1
  24808. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24809. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24810. * @returns impostor the rope imposter
  24811. */
  24812. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24813. /**
  24814. * Will keep this body still, in a sleep mode.
  24815. * @returns the physics imposter
  24816. */
  24817. sleep(): PhysicsImpostor;
  24818. /**
  24819. * Wake the body up.
  24820. * @returns The physics imposter
  24821. */
  24822. wakeUp(): PhysicsImpostor;
  24823. /**
  24824. * Clones the physics imposter
  24825. * @param newObject The physics imposter clones to this physics-enabled object
  24826. * @returns A nullable physics imposter
  24827. */
  24828. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24829. /**
  24830. * Disposes the physics imposter
  24831. */
  24832. dispose(): void;
  24833. /**
  24834. * Sets the delta position
  24835. * @param position The delta position amount
  24836. */
  24837. setDeltaPosition(position: Vector3): void;
  24838. /**
  24839. * Sets the delta rotation
  24840. * @param rotation The delta rotation amount
  24841. */
  24842. setDeltaRotation(rotation: Quaternion): void;
  24843. /**
  24844. * Gets the box size of the physics imposter and stores the result in the input parameter
  24845. * @param result Stores the box size
  24846. * @returns The physics imposter
  24847. */
  24848. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24849. /**
  24850. * Gets the radius of the physics imposter
  24851. * @returns Radius of the physics imposter
  24852. */
  24853. getRadius(): number;
  24854. /**
  24855. * Sync a bone with this impostor
  24856. * @param bone The bone to sync to the impostor.
  24857. * @param boneMesh The mesh that the bone is influencing.
  24858. * @param jointPivot The pivot of the joint / bone in local space.
  24859. * @param distToJoint Optional distance from the impostor to the joint.
  24860. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24861. */
  24862. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24863. /**
  24864. * Sync impostor to a bone
  24865. * @param bone The bone that the impostor will be synced to.
  24866. * @param boneMesh The mesh that the bone is influencing.
  24867. * @param jointPivot The pivot of the joint / bone in local space.
  24868. * @param distToJoint Optional distance from the impostor to the joint.
  24869. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24870. * @param boneAxis Optional vector3 axis the bone is aligned with
  24871. */
  24872. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24873. /**
  24874. * No-Imposter type
  24875. */
  24876. static NoImpostor: number;
  24877. /**
  24878. * Sphere-Imposter type
  24879. */
  24880. static SphereImpostor: number;
  24881. /**
  24882. * Box-Imposter type
  24883. */
  24884. static BoxImpostor: number;
  24885. /**
  24886. * Plane-Imposter type
  24887. */
  24888. static PlaneImpostor: number;
  24889. /**
  24890. * Mesh-imposter type
  24891. */
  24892. static MeshImpostor: number;
  24893. /**
  24894. * Capsule-Impostor type (Ammo.js plugin only)
  24895. */
  24896. static CapsuleImpostor: number;
  24897. /**
  24898. * Cylinder-Imposter type
  24899. */
  24900. static CylinderImpostor: number;
  24901. /**
  24902. * Particle-Imposter type
  24903. */
  24904. static ParticleImpostor: number;
  24905. /**
  24906. * Heightmap-Imposter type
  24907. */
  24908. static HeightmapImpostor: number;
  24909. /**
  24910. * ConvexHull-Impostor type (Ammo.js plugin only)
  24911. */
  24912. static ConvexHullImpostor: number;
  24913. /**
  24914. * Custom-Imposter type (Ammo.js plugin only)
  24915. */
  24916. static CustomImpostor: number;
  24917. /**
  24918. * Rope-Imposter type
  24919. */
  24920. static RopeImpostor: number;
  24921. /**
  24922. * Cloth-Imposter type
  24923. */
  24924. static ClothImpostor: number;
  24925. /**
  24926. * Softbody-Imposter type
  24927. */
  24928. static SoftbodyImpostor: number;
  24929. }
  24930. }
  24931. declare module "babylonjs/Meshes/mesh" {
  24932. import { Observable } from "babylonjs/Misc/observable";
  24933. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24934. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24935. import { Camera } from "babylonjs/Cameras/camera";
  24936. import { Scene } from "babylonjs/scene";
  24937. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24938. import { Color4 } from "babylonjs/Maths/math.color";
  24939. import { Engine } from "babylonjs/Engines/engine";
  24940. import { Node } from "babylonjs/node";
  24941. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24942. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24943. import { Buffer } from "babylonjs/Meshes/buffer";
  24944. import { Geometry } from "babylonjs/Meshes/geometry";
  24945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24946. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24947. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24948. import { Effect } from "babylonjs/Materials/effect";
  24949. import { Material } from "babylonjs/Materials/material";
  24950. import { Skeleton } from "babylonjs/Bones/skeleton";
  24951. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24952. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24953. import { Path3D } from "babylonjs/Maths/math.path";
  24954. import { Plane } from "babylonjs/Maths/math.plane";
  24955. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24956. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24957. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24958. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24959. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24960. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24961. /**
  24962. * @hidden
  24963. **/
  24964. export class _CreationDataStorage {
  24965. closePath?: boolean;
  24966. closeArray?: boolean;
  24967. idx: number[];
  24968. dashSize: number;
  24969. gapSize: number;
  24970. path3D: Path3D;
  24971. pathArray: Vector3[][];
  24972. arc: number;
  24973. radius: number;
  24974. cap: number;
  24975. tessellation: number;
  24976. }
  24977. /**
  24978. * @hidden
  24979. **/
  24980. class _InstanceDataStorage {
  24981. visibleInstances: any;
  24982. batchCache: _InstancesBatch;
  24983. instancesBufferSize: number;
  24984. instancesBuffer: Nullable<Buffer>;
  24985. instancesData: Float32Array;
  24986. overridenInstanceCount: number;
  24987. isFrozen: boolean;
  24988. previousBatch: Nullable<_InstancesBatch>;
  24989. hardwareInstancedRendering: boolean;
  24990. sideOrientation: number;
  24991. manualUpdate: boolean;
  24992. }
  24993. /**
  24994. * @hidden
  24995. **/
  24996. export class _InstancesBatch {
  24997. mustReturn: boolean;
  24998. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24999. renderSelf: boolean[];
  25000. hardwareInstancedRendering: boolean[];
  25001. }
  25002. /**
  25003. * Class used to represent renderable models
  25004. */
  25005. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25006. /**
  25007. * Mesh side orientation : usually the external or front surface
  25008. */
  25009. static readonly FRONTSIDE: number;
  25010. /**
  25011. * Mesh side orientation : usually the internal or back surface
  25012. */
  25013. static readonly BACKSIDE: number;
  25014. /**
  25015. * Mesh side orientation : both internal and external or front and back surfaces
  25016. */
  25017. static readonly DOUBLESIDE: number;
  25018. /**
  25019. * Mesh side orientation : by default, `FRONTSIDE`
  25020. */
  25021. static readonly DEFAULTSIDE: number;
  25022. /**
  25023. * Mesh cap setting : no cap
  25024. */
  25025. static readonly NO_CAP: number;
  25026. /**
  25027. * Mesh cap setting : one cap at the beginning of the mesh
  25028. */
  25029. static readonly CAP_START: number;
  25030. /**
  25031. * Mesh cap setting : one cap at the end of the mesh
  25032. */
  25033. static readonly CAP_END: number;
  25034. /**
  25035. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25036. */
  25037. static readonly CAP_ALL: number;
  25038. /**
  25039. * Mesh pattern setting : no flip or rotate
  25040. */
  25041. static readonly NO_FLIP: number;
  25042. /**
  25043. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25044. */
  25045. static readonly FLIP_TILE: number;
  25046. /**
  25047. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25048. */
  25049. static readonly ROTATE_TILE: number;
  25050. /**
  25051. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25052. */
  25053. static readonly FLIP_ROW: number;
  25054. /**
  25055. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25056. */
  25057. static readonly ROTATE_ROW: number;
  25058. /**
  25059. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25060. */
  25061. static readonly FLIP_N_ROTATE_TILE: number;
  25062. /**
  25063. * Mesh pattern setting : rotate pattern and rotate
  25064. */
  25065. static readonly FLIP_N_ROTATE_ROW: number;
  25066. /**
  25067. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25068. */
  25069. static readonly CENTER: number;
  25070. /**
  25071. * Mesh tile positioning : part tiles on left
  25072. */
  25073. static readonly LEFT: number;
  25074. /**
  25075. * Mesh tile positioning : part tiles on right
  25076. */
  25077. static readonly RIGHT: number;
  25078. /**
  25079. * Mesh tile positioning : part tiles on top
  25080. */
  25081. static readonly TOP: number;
  25082. /**
  25083. * Mesh tile positioning : part tiles on bottom
  25084. */
  25085. static readonly BOTTOM: number;
  25086. /**
  25087. * Gets the default side orientation.
  25088. * @param orientation the orientation to value to attempt to get
  25089. * @returns the default orientation
  25090. * @hidden
  25091. */
  25092. static _GetDefaultSideOrientation(orientation?: number): number;
  25093. private _internalMeshDataInfo;
  25094. /**
  25095. * An event triggered before rendering the mesh
  25096. */
  25097. get onBeforeRenderObservable(): Observable<Mesh>;
  25098. /**
  25099. * An event triggered before binding the mesh
  25100. */
  25101. get onBeforeBindObservable(): Observable<Mesh>;
  25102. /**
  25103. * An event triggered after rendering the mesh
  25104. */
  25105. get onAfterRenderObservable(): Observable<Mesh>;
  25106. /**
  25107. * An event triggered before drawing the mesh
  25108. */
  25109. get onBeforeDrawObservable(): Observable<Mesh>;
  25110. private _onBeforeDrawObserver;
  25111. /**
  25112. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25113. */
  25114. set onBeforeDraw(callback: () => void);
  25115. get hasInstances(): boolean;
  25116. /**
  25117. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25118. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25119. */
  25120. delayLoadState: number;
  25121. /**
  25122. * Gets the list of instances created from this mesh
  25123. * it is not supposed to be modified manually.
  25124. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25125. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25126. */
  25127. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25128. /**
  25129. * Gets the file containing delay loading data for this mesh
  25130. */
  25131. delayLoadingFile: string;
  25132. /** @hidden */
  25133. _binaryInfo: any;
  25134. /**
  25135. * User defined function used to change how LOD level selection is done
  25136. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25137. */
  25138. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25139. /**
  25140. * Gets or sets the morph target manager
  25141. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25142. */
  25143. get morphTargetManager(): Nullable<MorphTargetManager>;
  25144. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25145. /** @hidden */
  25146. _creationDataStorage: Nullable<_CreationDataStorage>;
  25147. /** @hidden */
  25148. _geometry: Nullable<Geometry>;
  25149. /** @hidden */
  25150. _delayInfo: Array<string>;
  25151. /** @hidden */
  25152. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25153. /** @hidden */
  25154. _instanceDataStorage: _InstanceDataStorage;
  25155. private _effectiveMaterial;
  25156. /** @hidden */
  25157. _shouldGenerateFlatShading: boolean;
  25158. /** @hidden */
  25159. _originalBuilderSideOrientation: number;
  25160. /**
  25161. * Use this property to change the original side orientation defined at construction time
  25162. */
  25163. overrideMaterialSideOrientation: Nullable<number>;
  25164. /**
  25165. * Gets the source mesh (the one used to clone this one from)
  25166. */
  25167. get source(): Nullable<Mesh>;
  25168. /**
  25169. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25170. */
  25171. get isUnIndexed(): boolean;
  25172. set isUnIndexed(value: boolean);
  25173. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25174. get worldMatrixInstancedBuffer(): Float32Array;
  25175. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25176. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25177. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25178. /**
  25179. * @constructor
  25180. * @param name The value used by scene.getMeshByName() to do a lookup.
  25181. * @param scene The scene to add this mesh to.
  25182. * @param parent The parent of this mesh, if it has one
  25183. * @param source An optional Mesh from which geometry is shared, cloned.
  25184. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25185. * When false, achieved by calling a clone(), also passing False.
  25186. * This will make creation of children, recursive.
  25187. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25188. */
  25189. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25190. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25191. doNotInstantiate: boolean;
  25192. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25193. /**
  25194. * Gets the class name
  25195. * @returns the string "Mesh".
  25196. */
  25197. getClassName(): string;
  25198. /** @hidden */
  25199. get _isMesh(): boolean;
  25200. /**
  25201. * Returns a description of this mesh
  25202. * @param fullDetails define if full details about this mesh must be used
  25203. * @returns a descriptive string representing this mesh
  25204. */
  25205. toString(fullDetails?: boolean): string;
  25206. /** @hidden */
  25207. _unBindEffect(): void;
  25208. /**
  25209. * Gets a boolean indicating if this mesh has LOD
  25210. */
  25211. get hasLODLevels(): boolean;
  25212. /**
  25213. * Gets the list of MeshLODLevel associated with the current mesh
  25214. * @returns an array of MeshLODLevel
  25215. */
  25216. getLODLevels(): MeshLODLevel[];
  25217. private _sortLODLevels;
  25218. /**
  25219. * Add a mesh as LOD level triggered at the given distance.
  25220. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25221. * @param distance The distance from the center of the object to show this level
  25222. * @param mesh The mesh to be added as LOD level (can be null)
  25223. * @return This mesh (for chaining)
  25224. */
  25225. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25226. /**
  25227. * Returns the LOD level mesh at the passed distance or null if not found.
  25228. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25229. * @param distance The distance from the center of the object to show this level
  25230. * @returns a Mesh or `null`
  25231. */
  25232. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25233. /**
  25234. * Remove a mesh from the LOD array
  25235. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25236. * @param mesh defines the mesh to be removed
  25237. * @return This mesh (for chaining)
  25238. */
  25239. removeLODLevel(mesh: Mesh): Mesh;
  25240. /**
  25241. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25242. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25243. * @param camera defines the camera to use to compute distance
  25244. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25245. * @return This mesh (for chaining)
  25246. */
  25247. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25248. /**
  25249. * Gets the mesh internal Geometry object
  25250. */
  25251. get geometry(): Nullable<Geometry>;
  25252. /**
  25253. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25254. * @returns the total number of vertices
  25255. */
  25256. getTotalVertices(): number;
  25257. /**
  25258. * Returns the content of an associated vertex buffer
  25259. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25260. * - VertexBuffer.PositionKind
  25261. * - VertexBuffer.UVKind
  25262. * - VertexBuffer.UV2Kind
  25263. * - VertexBuffer.UV3Kind
  25264. * - VertexBuffer.UV4Kind
  25265. * - VertexBuffer.UV5Kind
  25266. * - VertexBuffer.UV6Kind
  25267. * - VertexBuffer.ColorKind
  25268. * - VertexBuffer.MatricesIndicesKind
  25269. * - VertexBuffer.MatricesIndicesExtraKind
  25270. * - VertexBuffer.MatricesWeightsKind
  25271. * - VertexBuffer.MatricesWeightsExtraKind
  25272. * @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
  25273. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25274. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25275. */
  25276. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25277. /**
  25278. * Returns the mesh VertexBuffer object from the requested `kind`
  25279. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25280. * - VertexBuffer.PositionKind
  25281. * - VertexBuffer.NormalKind
  25282. * - VertexBuffer.UVKind
  25283. * - VertexBuffer.UV2Kind
  25284. * - VertexBuffer.UV3Kind
  25285. * - VertexBuffer.UV4Kind
  25286. * - VertexBuffer.UV5Kind
  25287. * - VertexBuffer.UV6Kind
  25288. * - VertexBuffer.ColorKind
  25289. * - VertexBuffer.MatricesIndicesKind
  25290. * - VertexBuffer.MatricesIndicesExtraKind
  25291. * - VertexBuffer.MatricesWeightsKind
  25292. * - VertexBuffer.MatricesWeightsExtraKind
  25293. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25294. */
  25295. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25296. /**
  25297. * Tests if a specific vertex buffer is associated with this mesh
  25298. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25299. * - VertexBuffer.PositionKind
  25300. * - VertexBuffer.NormalKind
  25301. * - VertexBuffer.UVKind
  25302. * - VertexBuffer.UV2Kind
  25303. * - VertexBuffer.UV3Kind
  25304. * - VertexBuffer.UV4Kind
  25305. * - VertexBuffer.UV5Kind
  25306. * - VertexBuffer.UV6Kind
  25307. * - VertexBuffer.ColorKind
  25308. * - VertexBuffer.MatricesIndicesKind
  25309. * - VertexBuffer.MatricesIndicesExtraKind
  25310. * - VertexBuffer.MatricesWeightsKind
  25311. * - VertexBuffer.MatricesWeightsExtraKind
  25312. * @returns a boolean
  25313. */
  25314. isVerticesDataPresent(kind: string): boolean;
  25315. /**
  25316. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25317. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25318. * - VertexBuffer.PositionKind
  25319. * - VertexBuffer.UVKind
  25320. * - VertexBuffer.UV2Kind
  25321. * - VertexBuffer.UV3Kind
  25322. * - VertexBuffer.UV4Kind
  25323. * - VertexBuffer.UV5Kind
  25324. * - VertexBuffer.UV6Kind
  25325. * - VertexBuffer.ColorKind
  25326. * - VertexBuffer.MatricesIndicesKind
  25327. * - VertexBuffer.MatricesIndicesExtraKind
  25328. * - VertexBuffer.MatricesWeightsKind
  25329. * - VertexBuffer.MatricesWeightsExtraKind
  25330. * @returns a boolean
  25331. */
  25332. isVertexBufferUpdatable(kind: string): boolean;
  25333. /**
  25334. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25335. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25336. * - VertexBuffer.PositionKind
  25337. * - VertexBuffer.NormalKind
  25338. * - VertexBuffer.UVKind
  25339. * - VertexBuffer.UV2Kind
  25340. * - VertexBuffer.UV3Kind
  25341. * - VertexBuffer.UV4Kind
  25342. * - VertexBuffer.UV5Kind
  25343. * - VertexBuffer.UV6Kind
  25344. * - VertexBuffer.ColorKind
  25345. * - VertexBuffer.MatricesIndicesKind
  25346. * - VertexBuffer.MatricesIndicesExtraKind
  25347. * - VertexBuffer.MatricesWeightsKind
  25348. * - VertexBuffer.MatricesWeightsExtraKind
  25349. * @returns an array of strings
  25350. */
  25351. getVerticesDataKinds(): string[];
  25352. /**
  25353. * Returns a positive integer : the total number of indices in this mesh geometry.
  25354. * @returns the numner of indices or zero if the mesh has no geometry.
  25355. */
  25356. getTotalIndices(): number;
  25357. /**
  25358. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25359. * @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.
  25360. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25361. * @returns the indices array or an empty array if the mesh has no geometry
  25362. */
  25363. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25364. get isBlocked(): boolean;
  25365. /**
  25366. * Determine if the current mesh is ready to be rendered
  25367. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25368. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25369. * @returns true if all associated assets are ready (material, textures, shaders)
  25370. */
  25371. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25372. /**
  25373. * 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.
  25374. */
  25375. get areNormalsFrozen(): boolean;
  25376. /**
  25377. * 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.
  25378. * @returns the current mesh
  25379. */
  25380. freezeNormals(): Mesh;
  25381. /**
  25382. * 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
  25383. * @returns the current mesh
  25384. */
  25385. unfreezeNormals(): Mesh;
  25386. /**
  25387. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25388. */
  25389. set overridenInstanceCount(count: number);
  25390. /** @hidden */
  25391. _preActivate(): Mesh;
  25392. /** @hidden */
  25393. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25394. /** @hidden */
  25395. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25396. /**
  25397. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25398. * This means the mesh underlying bounding box and sphere are recomputed.
  25399. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25400. * @returns the current mesh
  25401. */
  25402. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25403. /** @hidden */
  25404. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25405. /**
  25406. * This function will subdivide the mesh into multiple submeshes
  25407. * @param count defines the expected number of submeshes
  25408. */
  25409. subdivide(count: number): void;
  25410. /**
  25411. * Copy a FloatArray into a specific associated vertex buffer
  25412. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25413. * - VertexBuffer.PositionKind
  25414. * - VertexBuffer.UVKind
  25415. * - VertexBuffer.UV2Kind
  25416. * - VertexBuffer.UV3Kind
  25417. * - VertexBuffer.UV4Kind
  25418. * - VertexBuffer.UV5Kind
  25419. * - VertexBuffer.UV6Kind
  25420. * - VertexBuffer.ColorKind
  25421. * - VertexBuffer.MatricesIndicesKind
  25422. * - VertexBuffer.MatricesIndicesExtraKind
  25423. * - VertexBuffer.MatricesWeightsKind
  25424. * - VertexBuffer.MatricesWeightsExtraKind
  25425. * @param data defines the data source
  25426. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25427. * @param stride defines the data stride size (can be null)
  25428. * @returns the current mesh
  25429. */
  25430. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25431. /**
  25432. * Delete a vertex buffer associated with this mesh
  25433. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25434. * - VertexBuffer.PositionKind
  25435. * - VertexBuffer.UVKind
  25436. * - VertexBuffer.UV2Kind
  25437. * - VertexBuffer.UV3Kind
  25438. * - VertexBuffer.UV4Kind
  25439. * - VertexBuffer.UV5Kind
  25440. * - VertexBuffer.UV6Kind
  25441. * - VertexBuffer.ColorKind
  25442. * - VertexBuffer.MatricesIndicesKind
  25443. * - VertexBuffer.MatricesIndicesExtraKind
  25444. * - VertexBuffer.MatricesWeightsKind
  25445. * - VertexBuffer.MatricesWeightsExtraKind
  25446. */
  25447. removeVerticesData(kind: string): void;
  25448. /**
  25449. * Flags an associated vertex buffer as updatable
  25450. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25451. * - VertexBuffer.PositionKind
  25452. * - VertexBuffer.UVKind
  25453. * - VertexBuffer.UV2Kind
  25454. * - VertexBuffer.UV3Kind
  25455. * - VertexBuffer.UV4Kind
  25456. * - VertexBuffer.UV5Kind
  25457. * - VertexBuffer.UV6Kind
  25458. * - VertexBuffer.ColorKind
  25459. * - VertexBuffer.MatricesIndicesKind
  25460. * - VertexBuffer.MatricesIndicesExtraKind
  25461. * - VertexBuffer.MatricesWeightsKind
  25462. * - VertexBuffer.MatricesWeightsExtraKind
  25463. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25464. */
  25465. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25466. /**
  25467. * Sets the mesh global Vertex Buffer
  25468. * @param buffer defines the buffer to use
  25469. * @returns the current mesh
  25470. */
  25471. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25472. /**
  25473. * Update a specific associated vertex buffer
  25474. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25475. * - VertexBuffer.PositionKind
  25476. * - VertexBuffer.UVKind
  25477. * - VertexBuffer.UV2Kind
  25478. * - VertexBuffer.UV3Kind
  25479. * - VertexBuffer.UV4Kind
  25480. * - VertexBuffer.UV5Kind
  25481. * - VertexBuffer.UV6Kind
  25482. * - VertexBuffer.ColorKind
  25483. * - VertexBuffer.MatricesIndicesKind
  25484. * - VertexBuffer.MatricesIndicesExtraKind
  25485. * - VertexBuffer.MatricesWeightsKind
  25486. * - VertexBuffer.MatricesWeightsExtraKind
  25487. * @param data defines the data source
  25488. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25489. * @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)
  25490. * @returns the current mesh
  25491. */
  25492. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25493. /**
  25494. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25495. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25496. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25497. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25498. * @returns the current mesh
  25499. */
  25500. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25501. /**
  25502. * Creates a un-shared specific occurence of the geometry for the mesh.
  25503. * @returns the current mesh
  25504. */
  25505. makeGeometryUnique(): Mesh;
  25506. /**
  25507. * Set the index buffer of this mesh
  25508. * @param indices defines the source data
  25509. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25510. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25511. * @returns the current mesh
  25512. */
  25513. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25514. /**
  25515. * Update the current index buffer
  25516. * @param indices defines the source data
  25517. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25518. * @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)
  25519. * @returns the current mesh
  25520. */
  25521. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25522. /**
  25523. * Invert the geometry to move from a right handed system to a left handed one.
  25524. * @returns the current mesh
  25525. */
  25526. toLeftHanded(): Mesh;
  25527. /** @hidden */
  25528. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25529. /** @hidden */
  25530. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25531. /**
  25532. * Registers for this mesh a javascript function called just before the rendering process
  25533. * @param func defines the function to call before rendering this mesh
  25534. * @returns the current mesh
  25535. */
  25536. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25537. /**
  25538. * Disposes a previously registered javascript function called before the rendering
  25539. * @param func defines the function to remove
  25540. * @returns the current mesh
  25541. */
  25542. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25543. /**
  25544. * Registers for this mesh a javascript function called just after the rendering is complete
  25545. * @param func defines the function to call after rendering this mesh
  25546. * @returns the current mesh
  25547. */
  25548. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25549. /**
  25550. * Disposes a previously registered javascript function called after the rendering.
  25551. * @param func defines the function to remove
  25552. * @returns the current mesh
  25553. */
  25554. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25555. /** @hidden */
  25556. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25557. /** @hidden */
  25558. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25559. /** @hidden */
  25560. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25561. /** @hidden */
  25562. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25563. /** @hidden */
  25564. _rebuild(): void;
  25565. /** @hidden */
  25566. _freeze(): void;
  25567. /** @hidden */
  25568. _unFreeze(): void;
  25569. /**
  25570. * 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
  25571. * @param subMesh defines the subMesh to render
  25572. * @param enableAlphaMode defines if alpha mode can be changed
  25573. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25574. * @returns the current mesh
  25575. */
  25576. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25577. private _onBeforeDraw;
  25578. /**
  25579. * Renormalize the mesh and patch it up if there are no weights
  25580. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25581. * However in the case of zero weights then we set just a single influence to 1.
  25582. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25583. */
  25584. cleanMatrixWeights(): void;
  25585. private normalizeSkinFourWeights;
  25586. private normalizeSkinWeightsAndExtra;
  25587. /**
  25588. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25589. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25590. * the user know there was an issue with importing the mesh
  25591. * @returns a validation object with skinned, valid and report string
  25592. */
  25593. validateSkinning(): {
  25594. skinned: boolean;
  25595. valid: boolean;
  25596. report: string;
  25597. };
  25598. /** @hidden */
  25599. _checkDelayState(): Mesh;
  25600. private _queueLoad;
  25601. /**
  25602. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25603. * A mesh is in the frustum if its bounding box intersects the frustum
  25604. * @param frustumPlanes defines the frustum to test
  25605. * @returns true if the mesh is in the frustum planes
  25606. */
  25607. isInFrustum(frustumPlanes: Plane[]): boolean;
  25608. /**
  25609. * Sets the mesh material by the material or multiMaterial `id` property
  25610. * @param id is a string identifying the material or the multiMaterial
  25611. * @returns the current mesh
  25612. */
  25613. setMaterialByID(id: string): Mesh;
  25614. /**
  25615. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25616. * @returns an array of IAnimatable
  25617. */
  25618. getAnimatables(): IAnimatable[];
  25619. /**
  25620. * Modifies the mesh geometry according to the passed transformation matrix.
  25621. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25622. * The mesh normals are modified using the same transformation.
  25623. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25624. * @param transform defines the transform matrix to use
  25625. * @see http://doc.babylonjs.com/resources/baking_transformations
  25626. * @returns the current mesh
  25627. */
  25628. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25629. /**
  25630. * Modifies the mesh geometry according to its own current World Matrix.
  25631. * The mesh World Matrix is then reset.
  25632. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25633. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25634. * @see http://doc.babylonjs.com/resources/baking_transformations
  25635. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25636. * @returns the current mesh
  25637. */
  25638. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25639. /** @hidden */
  25640. get _positions(): Nullable<Vector3[]>;
  25641. /** @hidden */
  25642. _resetPointsArrayCache(): Mesh;
  25643. /** @hidden */
  25644. _generatePointsArray(): boolean;
  25645. /**
  25646. * Returns a new Mesh object generated from the current mesh properties.
  25647. * This method must not get confused with createInstance()
  25648. * @param name is a string, the name given to the new mesh
  25649. * @param newParent can be any Node object (default `null`)
  25650. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25651. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25652. * @returns a new mesh
  25653. */
  25654. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25655. /**
  25656. * Releases resources associated with this mesh.
  25657. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25658. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25659. */
  25660. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25661. /** @hidden */
  25662. _disposeInstanceSpecificData(): void;
  25663. /**
  25664. * Modifies the mesh geometry according to a displacement map.
  25665. * 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.
  25666. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25667. * @param url is a string, the URL from the image file is to be downloaded.
  25668. * @param minHeight is the lower limit of the displacement.
  25669. * @param maxHeight is the upper limit of the displacement.
  25670. * @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.
  25671. * @param uvOffset is an optional vector2 used to offset UV.
  25672. * @param uvScale is an optional vector2 used to scale UV.
  25673. * @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.
  25674. * @returns the Mesh.
  25675. */
  25676. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25677. /**
  25678. * Modifies the mesh geometry according to a displacementMap buffer.
  25679. * 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.
  25680. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25681. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25682. * @param heightMapWidth is the width of the buffer image.
  25683. * @param heightMapHeight is the height of the buffer image.
  25684. * @param minHeight is the lower limit of the displacement.
  25685. * @param maxHeight is the upper limit of the displacement.
  25686. * @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.
  25687. * @param uvOffset is an optional vector2 used to offset UV.
  25688. * @param uvScale is an optional vector2 used to scale UV.
  25689. * @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.
  25690. * @returns the Mesh.
  25691. */
  25692. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25693. /**
  25694. * Modify the mesh to get a flat shading rendering.
  25695. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25696. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25697. * @returns current mesh
  25698. */
  25699. convertToFlatShadedMesh(): Mesh;
  25700. /**
  25701. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25702. * In other words, more vertices, no more indices and a single bigger VBO.
  25703. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25704. * @returns current mesh
  25705. */
  25706. convertToUnIndexedMesh(): Mesh;
  25707. /**
  25708. * Inverses facet orientations.
  25709. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25710. * @param flipNormals will also inverts the normals
  25711. * @returns current mesh
  25712. */
  25713. flipFaces(flipNormals?: boolean): Mesh;
  25714. /**
  25715. * Increase the number of facets and hence vertices in a mesh
  25716. * Vertex normals are interpolated from existing vertex normals
  25717. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25718. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25719. */
  25720. increaseVertices(numberPerEdge: number): void;
  25721. /**
  25722. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25723. * This will undo any application of covertToFlatShadedMesh
  25724. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25725. */
  25726. forceSharedVertices(): void;
  25727. /** @hidden */
  25728. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25729. /** @hidden */
  25730. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25731. /**
  25732. * Creates a new InstancedMesh object from the mesh model.
  25733. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25734. * @param name defines the name of the new instance
  25735. * @returns a new InstancedMesh
  25736. */
  25737. createInstance(name: string): InstancedMesh;
  25738. /**
  25739. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25740. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25741. * @returns the current mesh
  25742. */
  25743. synchronizeInstances(): Mesh;
  25744. /**
  25745. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25746. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25747. * This should be used together with the simplification to avoid disappearing triangles.
  25748. * @param successCallback an optional success callback to be called after the optimization finished.
  25749. * @returns the current mesh
  25750. */
  25751. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25752. /**
  25753. * Serialize current mesh
  25754. * @param serializationObject defines the object which will receive the serialization data
  25755. */
  25756. serialize(serializationObject: any): void;
  25757. /** @hidden */
  25758. _syncGeometryWithMorphTargetManager(): void;
  25759. /** @hidden */
  25760. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25761. /**
  25762. * Returns a new Mesh object parsed from the source provided.
  25763. * @param parsedMesh is the source
  25764. * @param scene defines the hosting scene
  25765. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25766. * @returns a new Mesh
  25767. */
  25768. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25769. /**
  25770. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25771. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25772. * @param name defines the name of the mesh to create
  25773. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25774. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25775. * @param closePath creates a seam between the first and the last points of each path of the path array
  25776. * @param offset is taken in account only if the `pathArray` is containing a single path
  25777. * @param scene defines the hosting scene
  25778. * @param updatable defines if the mesh must be flagged as updatable
  25779. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25780. * @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)
  25781. * @returns a new Mesh
  25782. */
  25783. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25784. /**
  25785. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25786. * @param name defines the name of the mesh to create
  25787. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25788. * @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
  25789. * @param scene defines the hosting scene
  25790. * @param updatable defines if the mesh must be flagged as updatable
  25791. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25792. * @returns a new Mesh
  25793. */
  25794. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25795. /**
  25796. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25797. * @param name defines the name of the mesh to create
  25798. * @param size sets the size (float) of each box side (default 1)
  25799. * @param scene defines the hosting scene
  25800. * @param updatable defines if the mesh must be flagged as updatable
  25801. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25802. * @returns a new Mesh
  25803. */
  25804. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25805. /**
  25806. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25807. * @param name defines the name of the mesh to create
  25808. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25809. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25810. * @param scene defines the hosting scene
  25811. * @param updatable defines if the mesh must be flagged as updatable
  25812. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25813. * @returns a new Mesh
  25814. */
  25815. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25816. /**
  25817. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25818. * @param name defines the name of the mesh to create
  25819. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25820. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25821. * @param scene defines the hosting scene
  25822. * @returns a new Mesh
  25823. */
  25824. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25825. /**
  25826. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25827. * @param name defines the name of the mesh to create
  25828. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25829. * @param diameterTop set the top cap diameter (floats, default 1)
  25830. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25831. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25832. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25833. * @param scene defines the hosting scene
  25834. * @param updatable defines if the mesh must be flagged as updatable
  25835. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25836. * @returns a new Mesh
  25837. */
  25838. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25839. /**
  25840. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25841. * @param name defines the name of the mesh to create
  25842. * @param diameter sets the diameter size (float) of the torus (default 1)
  25843. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25844. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25845. * @param scene defines the hosting scene
  25846. * @param updatable defines if the mesh must be flagged as updatable
  25847. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25848. * @returns a new Mesh
  25849. */
  25850. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25851. /**
  25852. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25853. * @param name defines the name of the mesh to create
  25854. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25855. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25856. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25857. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25858. * @param p the number of windings on X axis (positive integers, default 2)
  25859. * @param q the number of windings on Y axis (positive integers, default 3)
  25860. * @param scene defines the hosting scene
  25861. * @param updatable defines if the mesh must be flagged as updatable
  25862. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25863. * @returns a new Mesh
  25864. */
  25865. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25866. /**
  25867. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25868. * @param name defines the name of the mesh to create
  25869. * @param points is an array successive Vector3
  25870. * @param scene defines the hosting scene
  25871. * @param updatable defines if the mesh must be flagged as updatable
  25872. * @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).
  25873. * @returns a new Mesh
  25874. */
  25875. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25876. /**
  25877. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25878. * @param name defines the name of the mesh to create
  25879. * @param points is an array successive Vector3
  25880. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25881. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25882. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25883. * @param scene defines the hosting scene
  25884. * @param updatable defines if the mesh must be flagged as updatable
  25885. * @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)
  25886. * @returns a new Mesh
  25887. */
  25888. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25889. /**
  25890. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25891. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25892. * 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.
  25893. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25894. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25895. * Remember you can only change the shape positions, not their number when updating a polygon.
  25896. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25897. * @param name defines the name of the mesh to create
  25898. * @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
  25899. * @param scene defines the hosting scene
  25900. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25901. * @param updatable defines if the mesh must be flagged as updatable
  25902. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25903. * @param earcutInjection can be used to inject your own earcut reference
  25904. * @returns a new Mesh
  25905. */
  25906. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25907. /**
  25908. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25909. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25910. * @param name defines the name of the mesh to create
  25911. * @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
  25912. * @param depth defines the height of extrusion
  25913. * @param scene defines the hosting scene
  25914. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25915. * @param updatable defines if the mesh must be flagged as updatable
  25916. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25917. * @param earcutInjection can be used to inject your own earcut reference
  25918. * @returns a new Mesh
  25919. */
  25920. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25921. /**
  25922. * Creates an extruded shape mesh.
  25923. * 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
  25924. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25925. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25926. * @param name defines the name of the mesh to create
  25927. * @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
  25928. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25929. * @param scale is the value to scale the shape
  25930. * @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
  25931. * @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
  25932. * @param scene defines the hosting scene
  25933. * @param updatable defines if the mesh must be flagged as updatable
  25934. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25935. * @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)
  25936. * @returns a new Mesh
  25937. */
  25938. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25939. /**
  25940. * Creates an custom extruded shape mesh.
  25941. * The custom extrusion is a parametric shape.
  25942. * It has no predefined shape. Its final shape will depend on the input parameters.
  25943. * Please consider using the same method from the MeshBuilder class instead
  25944. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25945. * @param name defines the name of the mesh to create
  25946. * @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
  25947. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25948. * @param scaleFunction is a custom Javascript function called on each path point
  25949. * @param rotationFunction is a custom Javascript function called on each path point
  25950. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25951. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25952. * @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
  25953. * @param scene defines the hosting scene
  25954. * @param updatable defines if the mesh must be flagged as updatable
  25955. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25956. * @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)
  25957. * @returns a new Mesh
  25958. */
  25959. 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;
  25960. /**
  25961. * Creates lathe mesh.
  25962. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25963. * Please consider using the same method from the MeshBuilder class instead
  25964. * @param name defines the name of the mesh to create
  25965. * @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
  25966. * @param radius is the radius value of the lathe
  25967. * @param tessellation is the side number of the lathe.
  25968. * @param scene defines the hosting scene
  25969. * @param updatable defines if the mesh must be flagged as updatable
  25970. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25971. * @returns a new Mesh
  25972. */
  25973. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25974. /**
  25975. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25976. * @param name defines the name of the mesh to create
  25977. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25978. * @param scene defines the hosting scene
  25979. * @param updatable defines if the mesh must be flagged as updatable
  25980. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25981. * @returns a new Mesh
  25982. */
  25983. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25984. /**
  25985. * Creates a ground mesh.
  25986. * Please consider using the same method from the MeshBuilder class instead
  25987. * @param name defines the name of the mesh to create
  25988. * @param width set the width of the ground
  25989. * @param height set the height of the ground
  25990. * @param subdivisions sets the number of subdivisions per side
  25991. * @param scene defines the hosting scene
  25992. * @param updatable defines if the mesh must be flagged as updatable
  25993. * @returns a new Mesh
  25994. */
  25995. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25996. /**
  25997. * Creates a tiled ground mesh.
  25998. * Please consider using the same method from the MeshBuilder class instead
  25999. * @param name defines the name of the mesh to create
  26000. * @param xmin set the ground minimum X coordinate
  26001. * @param zmin set the ground minimum Y coordinate
  26002. * @param xmax set the ground maximum X coordinate
  26003. * @param zmax set the ground maximum Z coordinate
  26004. * @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
  26005. * @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
  26006. * @param scene defines the hosting scene
  26007. * @param updatable defines if the mesh must be flagged as updatable
  26008. * @returns a new Mesh
  26009. */
  26010. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26011. w: number;
  26012. h: number;
  26013. }, precision: {
  26014. w: number;
  26015. h: number;
  26016. }, scene: Scene, updatable?: boolean): Mesh;
  26017. /**
  26018. * Creates a ground mesh from a height map.
  26019. * Please consider using the same method from the MeshBuilder class instead
  26020. * @see http://doc.babylonjs.com/babylon101/height_map
  26021. * @param name defines the name of the mesh to create
  26022. * @param url sets the URL of the height map image resource
  26023. * @param width set the ground width size
  26024. * @param height set the ground height size
  26025. * @param subdivisions sets the number of subdivision per side
  26026. * @param minHeight is the minimum altitude on the ground
  26027. * @param maxHeight is the maximum altitude on the ground
  26028. * @param scene defines the hosting scene
  26029. * @param updatable defines if the mesh must be flagged as updatable
  26030. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26031. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26032. * @returns a new Mesh
  26033. */
  26034. 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;
  26035. /**
  26036. * Creates a tube mesh.
  26037. * The tube is a parametric shape.
  26038. * It has no predefined shape. Its final shape will depend on the input parameters.
  26039. * Please consider using the same method from the MeshBuilder class instead
  26040. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26041. * @param name defines the name of the mesh to create
  26042. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26043. * @param radius sets the tube radius size
  26044. * @param tessellation is the number of sides on the tubular surface
  26045. * @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
  26046. * @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
  26047. * @param scene defines the hosting scene
  26048. * @param updatable defines if the mesh must be flagged as updatable
  26049. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26050. * @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)
  26051. * @returns a new Mesh
  26052. */
  26053. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26054. (i: number, distance: number): number;
  26055. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26056. /**
  26057. * Creates a polyhedron mesh.
  26058. * Please consider using the same method from the MeshBuilder class instead.
  26059. * * 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
  26060. * * The parameter `size` (positive float, default 1) sets the polygon size
  26061. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26062. * * 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`
  26063. * * 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
  26064. * * 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)`)
  26065. * * 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
  26066. * * 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
  26067. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26068. * * If you create a double-sided mesh, you can choose what parts of 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
  26069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26070. * @param name defines the name of the mesh to create
  26071. * @param options defines the options used to create the mesh
  26072. * @param scene defines the hosting scene
  26073. * @returns a new Mesh
  26074. */
  26075. static CreatePolyhedron(name: string, options: {
  26076. type?: number;
  26077. size?: number;
  26078. sizeX?: number;
  26079. sizeY?: number;
  26080. sizeZ?: number;
  26081. custom?: any;
  26082. faceUV?: Vector4[];
  26083. faceColors?: Color4[];
  26084. updatable?: boolean;
  26085. sideOrientation?: number;
  26086. }, scene: Scene): Mesh;
  26087. /**
  26088. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26089. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26090. * * 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`)
  26091. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26092. * * 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
  26093. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26094. * * If you create a double-sided mesh, you can choose what parts of 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
  26095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26096. * @param name defines the name of the mesh
  26097. * @param options defines the options used to create the mesh
  26098. * @param scene defines the hosting scene
  26099. * @returns a new Mesh
  26100. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26101. */
  26102. static CreateIcoSphere(name: string, options: {
  26103. radius?: number;
  26104. flat?: boolean;
  26105. subdivisions?: number;
  26106. sideOrientation?: number;
  26107. updatable?: boolean;
  26108. }, scene: Scene): Mesh;
  26109. /**
  26110. * Creates a decal mesh.
  26111. * Please consider using the same method from the MeshBuilder class instead.
  26112. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26113. * @param name defines the name of the mesh
  26114. * @param sourceMesh defines the mesh receiving the decal
  26115. * @param position sets the position of the decal in world coordinates
  26116. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26117. * @param size sets the decal scaling
  26118. * @param angle sets the angle to rotate the decal
  26119. * @returns a new Mesh
  26120. */
  26121. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26122. /**
  26123. * Prepare internal position array for software CPU skinning
  26124. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26125. */
  26126. setPositionsForCPUSkinning(): Float32Array;
  26127. /**
  26128. * Prepare internal normal array for software CPU skinning
  26129. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26130. */
  26131. setNormalsForCPUSkinning(): Float32Array;
  26132. /**
  26133. * Updates the vertex buffer by applying transformation from the bones
  26134. * @param skeleton defines the skeleton to apply to current mesh
  26135. * @returns the current mesh
  26136. */
  26137. applySkeleton(skeleton: Skeleton): Mesh;
  26138. /**
  26139. * 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
  26140. * @param meshes defines the list of meshes to scan
  26141. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26142. */
  26143. static MinMax(meshes: AbstractMesh[]): {
  26144. min: Vector3;
  26145. max: Vector3;
  26146. };
  26147. /**
  26148. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26149. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26150. * @returns a vector3
  26151. */
  26152. static Center(meshesOrMinMaxVector: {
  26153. min: Vector3;
  26154. max: Vector3;
  26155. } | AbstractMesh[]): Vector3;
  26156. /**
  26157. * Merge the array of meshes into a single mesh for performance reasons.
  26158. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26159. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26160. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26161. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26162. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26163. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26164. * @returns a new mesh
  26165. */
  26166. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26167. /** @hidden */
  26168. addInstance(instance: InstancedMesh): void;
  26169. /** @hidden */
  26170. removeInstance(instance: InstancedMesh): void;
  26171. }
  26172. }
  26173. declare module "babylonjs/Cameras/camera" {
  26174. import { SmartArray } from "babylonjs/Misc/smartArray";
  26175. import { Observable } from "babylonjs/Misc/observable";
  26176. import { Nullable } from "babylonjs/types";
  26177. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26178. import { Scene } from "babylonjs/scene";
  26179. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26180. import { Node } from "babylonjs/node";
  26181. import { Mesh } from "babylonjs/Meshes/mesh";
  26182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26183. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26184. import { Viewport } from "babylonjs/Maths/math.viewport";
  26185. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26186. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26187. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26188. import { Ray } from "babylonjs/Culling/ray";
  26189. /**
  26190. * This is the base class of all the camera used in the application.
  26191. * @see http://doc.babylonjs.com/features/cameras
  26192. */
  26193. export class Camera extends Node {
  26194. /** @hidden */
  26195. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26196. /**
  26197. * This is the default projection mode used by the cameras.
  26198. * It helps recreating a feeling of perspective and better appreciate depth.
  26199. * This is the best way to simulate real life cameras.
  26200. */
  26201. static readonly PERSPECTIVE_CAMERA: number;
  26202. /**
  26203. * This helps creating camera with an orthographic mode.
  26204. * 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.
  26205. */
  26206. static readonly ORTHOGRAPHIC_CAMERA: number;
  26207. /**
  26208. * This is the default FOV mode for perspective cameras.
  26209. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26210. */
  26211. static readonly FOVMODE_VERTICAL_FIXED: number;
  26212. /**
  26213. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26214. */
  26215. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26216. /**
  26217. * This specifies ther is no need for a camera rig.
  26218. * Basically only one eye is rendered corresponding to the camera.
  26219. */
  26220. static readonly RIG_MODE_NONE: number;
  26221. /**
  26222. * Simulates a camera Rig with one blue eye and one red eye.
  26223. * This can be use with 3d blue and red glasses.
  26224. */
  26225. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26226. /**
  26227. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26228. */
  26229. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26230. /**
  26231. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26232. */
  26233. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26234. /**
  26235. * Defines that both eyes of the camera will be rendered over under each other.
  26236. */
  26237. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26238. /**
  26239. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26240. */
  26241. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26242. /**
  26243. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26244. */
  26245. static readonly RIG_MODE_VR: number;
  26246. /**
  26247. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26248. */
  26249. static readonly RIG_MODE_WEBVR: number;
  26250. /**
  26251. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26252. */
  26253. static readonly RIG_MODE_CUSTOM: number;
  26254. /**
  26255. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26256. */
  26257. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26258. /**
  26259. * Define the input manager associated with the camera.
  26260. */
  26261. inputs: CameraInputsManager<Camera>;
  26262. /** @hidden */
  26263. _position: Vector3;
  26264. /**
  26265. * Define the current local position of the camera in the scene
  26266. */
  26267. get position(): Vector3;
  26268. set position(newPosition: Vector3);
  26269. /**
  26270. * The vector the camera should consider as up.
  26271. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26272. */
  26273. upVector: Vector3;
  26274. /**
  26275. * Define the current limit on the left side for an orthographic camera
  26276. * In scene unit
  26277. */
  26278. orthoLeft: Nullable<number>;
  26279. /**
  26280. * Define the current limit on the right side for an orthographic camera
  26281. * In scene unit
  26282. */
  26283. orthoRight: Nullable<number>;
  26284. /**
  26285. * Define the current limit on the bottom side for an orthographic camera
  26286. * In scene unit
  26287. */
  26288. orthoBottom: Nullable<number>;
  26289. /**
  26290. * Define the current limit on the top side for an orthographic camera
  26291. * In scene unit
  26292. */
  26293. orthoTop: Nullable<number>;
  26294. /**
  26295. * Field Of View is set in Radians. (default is 0.8)
  26296. */
  26297. fov: number;
  26298. /**
  26299. * Define the minimum distance the camera can see from.
  26300. * This is important to note that the depth buffer are not infinite and the closer it starts
  26301. * the more your scene might encounter depth fighting issue.
  26302. */
  26303. minZ: number;
  26304. /**
  26305. * Define the maximum distance the camera can see to.
  26306. * This is important to note that the depth buffer are not infinite and the further it end
  26307. * the more your scene might encounter depth fighting issue.
  26308. */
  26309. maxZ: number;
  26310. /**
  26311. * Define the default inertia of the camera.
  26312. * This helps giving a smooth feeling to the camera movement.
  26313. */
  26314. inertia: number;
  26315. /**
  26316. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26317. */
  26318. mode: number;
  26319. /**
  26320. * Define whether the camera is intermediate.
  26321. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26322. */
  26323. isIntermediate: boolean;
  26324. /**
  26325. * Define the viewport of the camera.
  26326. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26327. */
  26328. viewport: Viewport;
  26329. /**
  26330. * Restricts the camera to viewing objects with the same layerMask.
  26331. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26332. */
  26333. layerMask: number;
  26334. /**
  26335. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26336. */
  26337. fovMode: number;
  26338. /**
  26339. * Rig mode of the camera.
  26340. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26341. * This is normally controlled byt the camera themselves as internal use.
  26342. */
  26343. cameraRigMode: number;
  26344. /**
  26345. * Defines the distance between both "eyes" in case of a RIG
  26346. */
  26347. interaxialDistance: number;
  26348. /**
  26349. * Defines if stereoscopic rendering is done side by side or over under.
  26350. */
  26351. isStereoscopicSideBySide: boolean;
  26352. /**
  26353. * 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
  26354. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26355. * else in the scene. (Eg. security camera)
  26356. *
  26357. * 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)
  26358. */
  26359. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26360. /**
  26361. * When set, the camera will render to this render target instead of the default canvas
  26362. *
  26363. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26364. */
  26365. outputRenderTarget: Nullable<RenderTargetTexture>;
  26366. /**
  26367. * Observable triggered when the camera view matrix has changed.
  26368. */
  26369. onViewMatrixChangedObservable: Observable<Camera>;
  26370. /**
  26371. * Observable triggered when the camera Projection matrix has changed.
  26372. */
  26373. onProjectionMatrixChangedObservable: Observable<Camera>;
  26374. /**
  26375. * Observable triggered when the inputs have been processed.
  26376. */
  26377. onAfterCheckInputsObservable: Observable<Camera>;
  26378. /**
  26379. * Observable triggered when reset has been called and applied to the camera.
  26380. */
  26381. onRestoreStateObservable: Observable<Camera>;
  26382. /**
  26383. * Is this camera a part of a rig system?
  26384. */
  26385. isRigCamera: boolean;
  26386. /**
  26387. * If isRigCamera set to true this will be set with the parent camera.
  26388. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26389. */
  26390. rigParent?: Camera;
  26391. /** @hidden */
  26392. _cameraRigParams: any;
  26393. /** @hidden */
  26394. _rigCameras: Camera[];
  26395. /** @hidden */
  26396. _rigPostProcess: Nullable<PostProcess>;
  26397. protected _webvrViewMatrix: Matrix;
  26398. /** @hidden */
  26399. _skipRendering: boolean;
  26400. /** @hidden */
  26401. _projectionMatrix: Matrix;
  26402. /** @hidden */
  26403. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26404. /** @hidden */
  26405. _activeMeshes: SmartArray<AbstractMesh>;
  26406. protected _globalPosition: Vector3;
  26407. /** @hidden */
  26408. _computedViewMatrix: Matrix;
  26409. private _doNotComputeProjectionMatrix;
  26410. private _transformMatrix;
  26411. private _frustumPlanes;
  26412. private _refreshFrustumPlanes;
  26413. private _storedFov;
  26414. private _stateStored;
  26415. /**
  26416. * Instantiates a new camera object.
  26417. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26418. * @see http://doc.babylonjs.com/features/cameras
  26419. * @param name Defines the name of the camera in the scene
  26420. * @param position Defines the position of the camera
  26421. * @param scene Defines the scene the camera belongs too
  26422. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26423. */
  26424. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26425. /**
  26426. * Store current camera state (fov, position, etc..)
  26427. * @returns the camera
  26428. */
  26429. storeState(): Camera;
  26430. /**
  26431. * Restores the camera state values if it has been stored. You must call storeState() first
  26432. */
  26433. protected _restoreStateValues(): boolean;
  26434. /**
  26435. * Restored camera state. You must call storeState() first.
  26436. * @returns true if restored and false otherwise
  26437. */
  26438. restoreState(): boolean;
  26439. /**
  26440. * Gets the class name of the camera.
  26441. * @returns the class name
  26442. */
  26443. getClassName(): string;
  26444. /** @hidden */
  26445. readonly _isCamera: boolean;
  26446. /**
  26447. * Gets a string representation of the camera useful for debug purpose.
  26448. * @param fullDetails Defines that a more verboe level of logging is required
  26449. * @returns the string representation
  26450. */
  26451. toString(fullDetails?: boolean): string;
  26452. /**
  26453. * Gets the current world space position of the camera.
  26454. */
  26455. get globalPosition(): Vector3;
  26456. /**
  26457. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26458. * @returns the active meshe list
  26459. */
  26460. getActiveMeshes(): SmartArray<AbstractMesh>;
  26461. /**
  26462. * Check whether a mesh is part of the current active mesh list of the camera
  26463. * @param mesh Defines the mesh to check
  26464. * @returns true if active, false otherwise
  26465. */
  26466. isActiveMesh(mesh: Mesh): boolean;
  26467. /**
  26468. * Is this camera ready to be used/rendered
  26469. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26470. * @return true if the camera is ready
  26471. */
  26472. isReady(completeCheck?: boolean): boolean;
  26473. /** @hidden */
  26474. _initCache(): void;
  26475. /** @hidden */
  26476. _updateCache(ignoreParentClass?: boolean): void;
  26477. /** @hidden */
  26478. _isSynchronized(): boolean;
  26479. /** @hidden */
  26480. _isSynchronizedViewMatrix(): boolean;
  26481. /** @hidden */
  26482. _isSynchronizedProjectionMatrix(): boolean;
  26483. /**
  26484. * Attach the input controls to a specific dom element to get the input from.
  26485. * @param element Defines the element the controls should be listened from
  26486. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26487. */
  26488. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26489. /**
  26490. * Detach the current controls from the specified dom element.
  26491. * @param element Defines the element to stop listening the inputs from
  26492. */
  26493. detachControl(element: HTMLElement): void;
  26494. /**
  26495. * Update the camera state according to the different inputs gathered during the frame.
  26496. */
  26497. update(): void;
  26498. /** @hidden */
  26499. _checkInputs(): void;
  26500. /** @hidden */
  26501. get rigCameras(): Camera[];
  26502. /**
  26503. * Gets the post process used by the rig cameras
  26504. */
  26505. get rigPostProcess(): Nullable<PostProcess>;
  26506. /**
  26507. * Internal, gets the first post proces.
  26508. * @returns the first post process to be run on this camera.
  26509. */
  26510. _getFirstPostProcess(): Nullable<PostProcess>;
  26511. private _cascadePostProcessesToRigCams;
  26512. /**
  26513. * Attach a post process to the camera.
  26514. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26515. * @param postProcess The post process to attach to the camera
  26516. * @param insertAt The position of the post process in case several of them are in use in the scene
  26517. * @returns the position the post process has been inserted at
  26518. */
  26519. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26520. /**
  26521. * Detach a post process to the camera.
  26522. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26523. * @param postProcess The post process to detach from the camera
  26524. */
  26525. detachPostProcess(postProcess: PostProcess): void;
  26526. /**
  26527. * Gets the current world matrix of the camera
  26528. */
  26529. getWorldMatrix(): Matrix;
  26530. /** @hidden */
  26531. _getViewMatrix(): Matrix;
  26532. /**
  26533. * Gets the current view matrix of the camera.
  26534. * @param force forces the camera to recompute the matrix without looking at the cached state
  26535. * @returns the view matrix
  26536. */
  26537. getViewMatrix(force?: boolean): Matrix;
  26538. /**
  26539. * Freeze the projection matrix.
  26540. * It will prevent the cache check of the camera projection compute and can speed up perf
  26541. * if no parameter of the camera are meant to change
  26542. * @param projection Defines manually a projection if necessary
  26543. */
  26544. freezeProjectionMatrix(projection?: Matrix): void;
  26545. /**
  26546. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26547. */
  26548. unfreezeProjectionMatrix(): void;
  26549. /**
  26550. * Gets the current projection matrix of the camera.
  26551. * @param force forces the camera to recompute the matrix without looking at the cached state
  26552. * @returns the projection matrix
  26553. */
  26554. getProjectionMatrix(force?: boolean): Matrix;
  26555. /**
  26556. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26557. * @returns a Matrix
  26558. */
  26559. getTransformationMatrix(): Matrix;
  26560. private _updateFrustumPlanes;
  26561. /**
  26562. * Checks if a cullable object (mesh...) is in the camera frustum
  26563. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26564. * @param target The object to check
  26565. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26566. * @returns true if the object is in frustum otherwise false
  26567. */
  26568. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26569. /**
  26570. * Checks if a cullable object (mesh...) is in the camera frustum
  26571. * Unlike isInFrustum this cheks the full bounding box
  26572. * @param target The object to check
  26573. * @returns true if the object is in frustum otherwise false
  26574. */
  26575. isCompletelyInFrustum(target: ICullable): boolean;
  26576. /**
  26577. * Gets a ray in the forward direction from the camera.
  26578. * @param length Defines the length of the ray to create
  26579. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26580. * @param origin Defines the start point of the ray which defaults to the camera position
  26581. * @returns the forward ray
  26582. */
  26583. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26584. /**
  26585. * Releases resources associated with this node.
  26586. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26587. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26588. */
  26589. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26590. /** @hidden */
  26591. _isLeftCamera: boolean;
  26592. /**
  26593. * Gets the left camera of a rig setup in case of Rigged Camera
  26594. */
  26595. get isLeftCamera(): boolean;
  26596. /** @hidden */
  26597. _isRightCamera: boolean;
  26598. /**
  26599. * Gets the right camera of a rig setup in case of Rigged Camera
  26600. */
  26601. get isRightCamera(): boolean;
  26602. /**
  26603. * Gets the left camera of a rig setup in case of Rigged Camera
  26604. */
  26605. get leftCamera(): Nullable<FreeCamera>;
  26606. /**
  26607. * Gets the right camera of a rig setup in case of Rigged Camera
  26608. */
  26609. get rightCamera(): Nullable<FreeCamera>;
  26610. /**
  26611. * Gets the left camera target of a rig setup in case of Rigged Camera
  26612. * @returns the target position
  26613. */
  26614. getLeftTarget(): Nullable<Vector3>;
  26615. /**
  26616. * Gets the right camera target of a rig setup in case of Rigged Camera
  26617. * @returns the target position
  26618. */
  26619. getRightTarget(): Nullable<Vector3>;
  26620. /**
  26621. * @hidden
  26622. */
  26623. setCameraRigMode(mode: number, rigParams: any): void;
  26624. /** @hidden */
  26625. static _setStereoscopicRigMode(camera: Camera): void;
  26626. /** @hidden */
  26627. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26628. /** @hidden */
  26629. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26630. /** @hidden */
  26631. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26632. /** @hidden */
  26633. _getVRProjectionMatrix(): Matrix;
  26634. protected _updateCameraRotationMatrix(): void;
  26635. protected _updateWebVRCameraRotationMatrix(): void;
  26636. /**
  26637. * This function MUST be overwritten by the different WebVR cameras available.
  26638. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26639. * @hidden
  26640. */
  26641. _getWebVRProjectionMatrix(): Matrix;
  26642. /**
  26643. * This function MUST be overwritten by the different WebVR cameras available.
  26644. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26645. * @hidden
  26646. */
  26647. _getWebVRViewMatrix(): Matrix;
  26648. /** @hidden */
  26649. setCameraRigParameter(name: string, value: any): void;
  26650. /**
  26651. * needs to be overridden by children so sub has required properties to be copied
  26652. * @hidden
  26653. */
  26654. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26655. /**
  26656. * May need to be overridden by children
  26657. * @hidden
  26658. */
  26659. _updateRigCameras(): void;
  26660. /** @hidden */
  26661. _setupInputs(): void;
  26662. /**
  26663. * Serialiaze the camera setup to a json represention
  26664. * @returns the JSON representation
  26665. */
  26666. serialize(): any;
  26667. /**
  26668. * Clones the current camera.
  26669. * @param name The cloned camera name
  26670. * @returns the cloned camera
  26671. */
  26672. clone(name: string): Camera;
  26673. /**
  26674. * Gets the direction of the camera relative to a given local axis.
  26675. * @param localAxis Defines the reference axis to provide a relative direction.
  26676. * @return the direction
  26677. */
  26678. getDirection(localAxis: Vector3): Vector3;
  26679. /**
  26680. * Returns the current camera absolute rotation
  26681. */
  26682. get absoluteRotation(): Quaternion;
  26683. /**
  26684. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26685. * @param localAxis Defines the reference axis to provide a relative direction.
  26686. * @param result Defines the vector to store the result in
  26687. */
  26688. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26689. /**
  26690. * Gets a camera constructor for a given camera type
  26691. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26692. * @param name The name of the camera the result will be able to instantiate
  26693. * @param scene The scene the result will construct the camera in
  26694. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26695. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26696. * @returns a factory method to construc the camera
  26697. */
  26698. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26699. /**
  26700. * Compute the world matrix of the camera.
  26701. * @returns the camera world matrix
  26702. */
  26703. computeWorldMatrix(): Matrix;
  26704. /**
  26705. * Parse a JSON and creates the camera from the parsed information
  26706. * @param parsedCamera The JSON to parse
  26707. * @param scene The scene to instantiate the camera in
  26708. * @returns the newly constructed camera
  26709. */
  26710. static Parse(parsedCamera: any, scene: Scene): Camera;
  26711. }
  26712. }
  26713. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26714. import { Nullable } from "babylonjs/types";
  26715. import { Scene } from "babylonjs/scene";
  26716. import { Vector4 } from "babylonjs/Maths/math.vector";
  26717. import { Mesh } from "babylonjs/Meshes/mesh";
  26718. /**
  26719. * Class containing static functions to help procedurally build meshes
  26720. */
  26721. export class DiscBuilder {
  26722. /**
  26723. * Creates a plane polygonal mesh. By default, this is a disc
  26724. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26725. * * 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
  26726. * * 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
  26727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26730. * @param name defines the name of the mesh
  26731. * @param options defines the options used to create the mesh
  26732. * @param scene defines the hosting scene
  26733. * @returns the plane polygonal mesh
  26734. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26735. */
  26736. static CreateDisc(name: string, options: {
  26737. radius?: number;
  26738. tessellation?: number;
  26739. arc?: number;
  26740. updatable?: boolean;
  26741. sideOrientation?: number;
  26742. frontUVs?: Vector4;
  26743. backUVs?: Vector4;
  26744. }, scene?: Nullable<Scene>): Mesh;
  26745. }
  26746. }
  26747. declare module "babylonjs/Materials/fresnelParameters" {
  26748. import { Color3 } from "babylonjs/Maths/math.color";
  26749. /**
  26750. * This represents all the required information to add a fresnel effect on a material:
  26751. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26752. */
  26753. export class FresnelParameters {
  26754. private _isEnabled;
  26755. /**
  26756. * Define if the fresnel effect is enable or not.
  26757. */
  26758. get isEnabled(): boolean;
  26759. set isEnabled(value: boolean);
  26760. /**
  26761. * Define the color used on edges (grazing angle)
  26762. */
  26763. leftColor: Color3;
  26764. /**
  26765. * Define the color used on center
  26766. */
  26767. rightColor: Color3;
  26768. /**
  26769. * Define bias applied to computed fresnel term
  26770. */
  26771. bias: number;
  26772. /**
  26773. * Defined the power exponent applied to fresnel term
  26774. */
  26775. power: number;
  26776. /**
  26777. * Clones the current fresnel and its valuues
  26778. * @returns a clone fresnel configuration
  26779. */
  26780. clone(): FresnelParameters;
  26781. /**
  26782. * Serializes the current fresnel parameters to a JSON representation.
  26783. * @return the JSON serialization
  26784. */
  26785. serialize(): any;
  26786. /**
  26787. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26788. * @param parsedFresnelParameters Define the JSON representation
  26789. * @returns the parsed parameters
  26790. */
  26791. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26792. }
  26793. }
  26794. declare module "babylonjs/Materials/pushMaterial" {
  26795. import { Nullable } from "babylonjs/types";
  26796. import { Scene } from "babylonjs/scene";
  26797. import { Matrix } from "babylonjs/Maths/math.vector";
  26798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26799. import { Mesh } from "babylonjs/Meshes/mesh";
  26800. import { Material } from "babylonjs/Materials/material";
  26801. import { Effect } from "babylonjs/Materials/effect";
  26802. /**
  26803. * Base class of materials working in push mode in babylon JS
  26804. * @hidden
  26805. */
  26806. export class PushMaterial extends Material {
  26807. protected _activeEffect: Effect;
  26808. protected _normalMatrix: Matrix;
  26809. /**
  26810. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26811. * This means that the material can keep using a previous shader while a new one is being compiled.
  26812. * This is mostly used when shader parallel compilation is supported (true by default)
  26813. */
  26814. allowShaderHotSwapping: boolean;
  26815. constructor(name: string, scene: Scene);
  26816. getEffect(): Effect;
  26817. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26818. /**
  26819. * Binds the given world matrix to the active effect
  26820. *
  26821. * @param world the matrix to bind
  26822. */
  26823. bindOnlyWorldMatrix(world: Matrix): void;
  26824. /**
  26825. * Binds the given normal matrix to the active effect
  26826. *
  26827. * @param normalMatrix the matrix to bind
  26828. */
  26829. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26830. bind(world: Matrix, mesh?: Mesh): void;
  26831. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26832. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26833. }
  26834. }
  26835. declare module "babylonjs/Materials/materialFlags" {
  26836. /**
  26837. * This groups all the flags used to control the materials channel.
  26838. */
  26839. export class MaterialFlags {
  26840. private static _DiffuseTextureEnabled;
  26841. /**
  26842. * Are diffuse textures enabled in the application.
  26843. */
  26844. static get DiffuseTextureEnabled(): boolean;
  26845. static set DiffuseTextureEnabled(value: boolean);
  26846. private static _AmbientTextureEnabled;
  26847. /**
  26848. * Are ambient textures enabled in the application.
  26849. */
  26850. static get AmbientTextureEnabled(): boolean;
  26851. static set AmbientTextureEnabled(value: boolean);
  26852. private static _OpacityTextureEnabled;
  26853. /**
  26854. * Are opacity textures enabled in the application.
  26855. */
  26856. static get OpacityTextureEnabled(): boolean;
  26857. static set OpacityTextureEnabled(value: boolean);
  26858. private static _ReflectionTextureEnabled;
  26859. /**
  26860. * Are reflection textures enabled in the application.
  26861. */
  26862. static get ReflectionTextureEnabled(): boolean;
  26863. static set ReflectionTextureEnabled(value: boolean);
  26864. private static _EmissiveTextureEnabled;
  26865. /**
  26866. * Are emissive textures enabled in the application.
  26867. */
  26868. static get EmissiveTextureEnabled(): boolean;
  26869. static set EmissiveTextureEnabled(value: boolean);
  26870. private static _SpecularTextureEnabled;
  26871. /**
  26872. * Are specular textures enabled in the application.
  26873. */
  26874. static get SpecularTextureEnabled(): boolean;
  26875. static set SpecularTextureEnabled(value: boolean);
  26876. private static _BumpTextureEnabled;
  26877. /**
  26878. * Are bump textures enabled in the application.
  26879. */
  26880. static get BumpTextureEnabled(): boolean;
  26881. static set BumpTextureEnabled(value: boolean);
  26882. private static _LightmapTextureEnabled;
  26883. /**
  26884. * Are lightmap textures enabled in the application.
  26885. */
  26886. static get LightmapTextureEnabled(): boolean;
  26887. static set LightmapTextureEnabled(value: boolean);
  26888. private static _RefractionTextureEnabled;
  26889. /**
  26890. * Are refraction textures enabled in the application.
  26891. */
  26892. static get RefractionTextureEnabled(): boolean;
  26893. static set RefractionTextureEnabled(value: boolean);
  26894. private static _ColorGradingTextureEnabled;
  26895. /**
  26896. * Are color grading textures enabled in the application.
  26897. */
  26898. static get ColorGradingTextureEnabled(): boolean;
  26899. static set ColorGradingTextureEnabled(value: boolean);
  26900. private static _FresnelEnabled;
  26901. /**
  26902. * Are fresnels enabled in the application.
  26903. */
  26904. static get FresnelEnabled(): boolean;
  26905. static set FresnelEnabled(value: boolean);
  26906. private static _ClearCoatTextureEnabled;
  26907. /**
  26908. * Are clear coat textures enabled in the application.
  26909. */
  26910. static get ClearCoatTextureEnabled(): boolean;
  26911. static set ClearCoatTextureEnabled(value: boolean);
  26912. private static _ClearCoatBumpTextureEnabled;
  26913. /**
  26914. * Are clear coat bump textures enabled in the application.
  26915. */
  26916. static get ClearCoatBumpTextureEnabled(): boolean;
  26917. static set ClearCoatBumpTextureEnabled(value: boolean);
  26918. private static _ClearCoatTintTextureEnabled;
  26919. /**
  26920. * Are clear coat tint textures enabled in the application.
  26921. */
  26922. static get ClearCoatTintTextureEnabled(): boolean;
  26923. static set ClearCoatTintTextureEnabled(value: boolean);
  26924. private static _SheenTextureEnabled;
  26925. /**
  26926. * Are sheen textures enabled in the application.
  26927. */
  26928. static get SheenTextureEnabled(): boolean;
  26929. static set SheenTextureEnabled(value: boolean);
  26930. private static _AnisotropicTextureEnabled;
  26931. /**
  26932. * Are anisotropic textures enabled in the application.
  26933. */
  26934. static get AnisotropicTextureEnabled(): boolean;
  26935. static set AnisotropicTextureEnabled(value: boolean);
  26936. private static _ThicknessTextureEnabled;
  26937. /**
  26938. * Are thickness textures enabled in the application.
  26939. */
  26940. static get ThicknessTextureEnabled(): boolean;
  26941. static set ThicknessTextureEnabled(value: boolean);
  26942. }
  26943. }
  26944. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26945. /** @hidden */
  26946. export var defaultFragmentDeclaration: {
  26947. name: string;
  26948. shader: string;
  26949. };
  26950. }
  26951. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26952. /** @hidden */
  26953. export var defaultUboDeclaration: {
  26954. name: string;
  26955. shader: string;
  26956. };
  26957. }
  26958. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26959. /** @hidden */
  26960. export var lightFragmentDeclaration: {
  26961. name: string;
  26962. shader: string;
  26963. };
  26964. }
  26965. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26966. /** @hidden */
  26967. export var lightUboDeclaration: {
  26968. name: string;
  26969. shader: string;
  26970. };
  26971. }
  26972. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26973. /** @hidden */
  26974. export var lightsFragmentFunctions: {
  26975. name: string;
  26976. shader: string;
  26977. };
  26978. }
  26979. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26980. /** @hidden */
  26981. export var shadowsFragmentFunctions: {
  26982. name: string;
  26983. shader: string;
  26984. };
  26985. }
  26986. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26987. /** @hidden */
  26988. export var fresnelFunction: {
  26989. name: string;
  26990. shader: string;
  26991. };
  26992. }
  26993. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26994. /** @hidden */
  26995. export var reflectionFunction: {
  26996. name: string;
  26997. shader: string;
  26998. };
  26999. }
  27000. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27001. /** @hidden */
  27002. export var bumpFragmentFunctions: {
  27003. name: string;
  27004. shader: string;
  27005. };
  27006. }
  27007. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27008. /** @hidden */
  27009. export var logDepthDeclaration: {
  27010. name: string;
  27011. shader: string;
  27012. };
  27013. }
  27014. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27015. /** @hidden */
  27016. export var bumpFragment: {
  27017. name: string;
  27018. shader: string;
  27019. };
  27020. }
  27021. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27022. /** @hidden */
  27023. export var depthPrePass: {
  27024. name: string;
  27025. shader: string;
  27026. };
  27027. }
  27028. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27029. /** @hidden */
  27030. export var lightFragment: {
  27031. name: string;
  27032. shader: string;
  27033. };
  27034. }
  27035. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27036. /** @hidden */
  27037. export var logDepthFragment: {
  27038. name: string;
  27039. shader: string;
  27040. };
  27041. }
  27042. declare module "babylonjs/Shaders/default.fragment" {
  27043. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27044. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27045. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27046. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27047. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27048. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27049. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27050. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27051. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27052. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27053. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27054. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27055. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27056. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27057. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27058. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27059. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27060. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27061. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27062. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27063. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27064. /** @hidden */
  27065. export var defaultPixelShader: {
  27066. name: string;
  27067. shader: string;
  27068. };
  27069. }
  27070. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27071. /** @hidden */
  27072. export var defaultVertexDeclaration: {
  27073. name: string;
  27074. shader: string;
  27075. };
  27076. }
  27077. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27078. /** @hidden */
  27079. export var bumpVertexDeclaration: {
  27080. name: string;
  27081. shader: string;
  27082. };
  27083. }
  27084. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27085. /** @hidden */
  27086. export var bumpVertex: {
  27087. name: string;
  27088. shader: string;
  27089. };
  27090. }
  27091. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27092. /** @hidden */
  27093. export var fogVertex: {
  27094. name: string;
  27095. shader: string;
  27096. };
  27097. }
  27098. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27099. /** @hidden */
  27100. export var shadowsVertex: {
  27101. name: string;
  27102. shader: string;
  27103. };
  27104. }
  27105. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27106. /** @hidden */
  27107. export var pointCloudVertex: {
  27108. name: string;
  27109. shader: string;
  27110. };
  27111. }
  27112. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27113. /** @hidden */
  27114. export var logDepthVertex: {
  27115. name: string;
  27116. shader: string;
  27117. };
  27118. }
  27119. declare module "babylonjs/Shaders/default.vertex" {
  27120. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27121. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27122. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27123. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27124. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27125. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27126. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27127. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27128. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27129. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27130. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27131. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27132. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27133. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27134. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27135. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27136. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27137. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27138. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27139. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27140. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27141. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27142. /** @hidden */
  27143. export var defaultVertexShader: {
  27144. name: string;
  27145. shader: string;
  27146. };
  27147. }
  27148. declare module "babylonjs/Materials/standardMaterial" {
  27149. import { SmartArray } from "babylonjs/Misc/smartArray";
  27150. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27151. import { Nullable } from "babylonjs/types";
  27152. import { Scene } from "babylonjs/scene";
  27153. import { Matrix } from "babylonjs/Maths/math.vector";
  27154. import { Color3 } from "babylonjs/Maths/math.color";
  27155. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27157. import { Mesh } from "babylonjs/Meshes/mesh";
  27158. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27159. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27160. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27161. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27162. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27163. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27164. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27165. import "babylonjs/Shaders/default.fragment";
  27166. import "babylonjs/Shaders/default.vertex";
  27167. /** @hidden */
  27168. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27169. MAINUV1: boolean;
  27170. MAINUV2: boolean;
  27171. DIFFUSE: boolean;
  27172. DIFFUSEDIRECTUV: number;
  27173. AMBIENT: boolean;
  27174. AMBIENTDIRECTUV: number;
  27175. OPACITY: boolean;
  27176. OPACITYDIRECTUV: number;
  27177. OPACITYRGB: boolean;
  27178. REFLECTION: boolean;
  27179. EMISSIVE: boolean;
  27180. EMISSIVEDIRECTUV: number;
  27181. SPECULAR: boolean;
  27182. SPECULARDIRECTUV: number;
  27183. BUMP: boolean;
  27184. BUMPDIRECTUV: number;
  27185. PARALLAX: boolean;
  27186. PARALLAXOCCLUSION: boolean;
  27187. SPECULAROVERALPHA: boolean;
  27188. CLIPPLANE: boolean;
  27189. CLIPPLANE2: boolean;
  27190. CLIPPLANE3: boolean;
  27191. CLIPPLANE4: boolean;
  27192. CLIPPLANE5: boolean;
  27193. CLIPPLANE6: boolean;
  27194. ALPHATEST: boolean;
  27195. DEPTHPREPASS: boolean;
  27196. ALPHAFROMDIFFUSE: boolean;
  27197. POINTSIZE: boolean;
  27198. FOG: boolean;
  27199. SPECULARTERM: boolean;
  27200. DIFFUSEFRESNEL: boolean;
  27201. OPACITYFRESNEL: boolean;
  27202. REFLECTIONFRESNEL: boolean;
  27203. REFRACTIONFRESNEL: boolean;
  27204. EMISSIVEFRESNEL: boolean;
  27205. FRESNEL: boolean;
  27206. NORMAL: boolean;
  27207. UV1: boolean;
  27208. UV2: boolean;
  27209. VERTEXCOLOR: boolean;
  27210. VERTEXALPHA: boolean;
  27211. NUM_BONE_INFLUENCERS: number;
  27212. BonesPerMesh: number;
  27213. BONETEXTURE: boolean;
  27214. INSTANCES: boolean;
  27215. GLOSSINESS: boolean;
  27216. ROUGHNESS: boolean;
  27217. EMISSIVEASILLUMINATION: boolean;
  27218. LINKEMISSIVEWITHDIFFUSE: boolean;
  27219. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27220. LIGHTMAP: boolean;
  27221. LIGHTMAPDIRECTUV: number;
  27222. OBJECTSPACE_NORMALMAP: boolean;
  27223. USELIGHTMAPASSHADOWMAP: boolean;
  27224. REFLECTIONMAP_3D: boolean;
  27225. REFLECTIONMAP_SPHERICAL: boolean;
  27226. REFLECTIONMAP_PLANAR: boolean;
  27227. REFLECTIONMAP_CUBIC: boolean;
  27228. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27229. REFLECTIONMAP_PROJECTION: boolean;
  27230. REFLECTIONMAP_SKYBOX: boolean;
  27231. REFLECTIONMAP_EXPLICIT: boolean;
  27232. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27233. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27234. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27235. INVERTCUBICMAP: boolean;
  27236. LOGARITHMICDEPTH: boolean;
  27237. REFRACTION: boolean;
  27238. REFRACTIONMAP_3D: boolean;
  27239. REFLECTIONOVERALPHA: boolean;
  27240. TWOSIDEDLIGHTING: boolean;
  27241. SHADOWFLOAT: boolean;
  27242. MORPHTARGETS: boolean;
  27243. MORPHTARGETS_NORMAL: boolean;
  27244. MORPHTARGETS_TANGENT: boolean;
  27245. MORPHTARGETS_UV: boolean;
  27246. NUM_MORPH_INFLUENCERS: number;
  27247. NONUNIFORMSCALING: boolean;
  27248. PREMULTIPLYALPHA: boolean;
  27249. IMAGEPROCESSING: boolean;
  27250. VIGNETTE: boolean;
  27251. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27252. VIGNETTEBLENDMODEOPAQUE: boolean;
  27253. TONEMAPPING: boolean;
  27254. TONEMAPPING_ACES: boolean;
  27255. CONTRAST: boolean;
  27256. COLORCURVES: boolean;
  27257. COLORGRADING: boolean;
  27258. COLORGRADING3D: boolean;
  27259. SAMPLER3DGREENDEPTH: boolean;
  27260. SAMPLER3DBGRMAP: boolean;
  27261. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27262. MULTIVIEW: boolean;
  27263. /**
  27264. * If the reflection texture on this material is in linear color space
  27265. * @hidden
  27266. */
  27267. IS_REFLECTION_LINEAR: boolean;
  27268. /**
  27269. * If the refraction texture on this material is in linear color space
  27270. * @hidden
  27271. */
  27272. IS_REFRACTION_LINEAR: boolean;
  27273. EXPOSURE: boolean;
  27274. constructor();
  27275. setReflectionMode(modeToEnable: string): void;
  27276. }
  27277. /**
  27278. * This is the default material used in Babylon. It is the best trade off between quality
  27279. * and performances.
  27280. * @see http://doc.babylonjs.com/babylon101/materials
  27281. */
  27282. export class StandardMaterial extends PushMaterial {
  27283. private _diffuseTexture;
  27284. /**
  27285. * The basic texture of the material as viewed under a light.
  27286. */
  27287. diffuseTexture: Nullable<BaseTexture>;
  27288. private _ambientTexture;
  27289. /**
  27290. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27291. */
  27292. ambientTexture: Nullable<BaseTexture>;
  27293. private _opacityTexture;
  27294. /**
  27295. * Define the transparency of the material from a texture.
  27296. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27297. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27298. */
  27299. opacityTexture: Nullable<BaseTexture>;
  27300. private _reflectionTexture;
  27301. /**
  27302. * Define the texture used to display the reflection.
  27303. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27304. */
  27305. reflectionTexture: Nullable<BaseTexture>;
  27306. private _emissiveTexture;
  27307. /**
  27308. * Define texture of the material as if self lit.
  27309. * This will be mixed in the final result even in the absence of light.
  27310. */
  27311. emissiveTexture: Nullable<BaseTexture>;
  27312. private _specularTexture;
  27313. /**
  27314. * Define how the color and intensity of the highlight given by the light in the material.
  27315. */
  27316. specularTexture: Nullable<BaseTexture>;
  27317. private _bumpTexture;
  27318. /**
  27319. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27320. * 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.
  27321. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27322. */
  27323. bumpTexture: Nullable<BaseTexture>;
  27324. private _lightmapTexture;
  27325. /**
  27326. * Complex lighting can be computationally expensive to compute at runtime.
  27327. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27328. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27329. */
  27330. lightmapTexture: Nullable<BaseTexture>;
  27331. private _refractionTexture;
  27332. /**
  27333. * Define the texture used to display the refraction.
  27334. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27335. */
  27336. refractionTexture: Nullable<BaseTexture>;
  27337. /**
  27338. * The color of the material lit by the environmental background lighting.
  27339. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27340. */
  27341. ambientColor: Color3;
  27342. /**
  27343. * The basic color of the material as viewed under a light.
  27344. */
  27345. diffuseColor: Color3;
  27346. /**
  27347. * Define how the color and intensity of the highlight given by the light in the material.
  27348. */
  27349. specularColor: Color3;
  27350. /**
  27351. * Define the color of the material as if self lit.
  27352. * This will be mixed in the final result even in the absence of light.
  27353. */
  27354. emissiveColor: Color3;
  27355. /**
  27356. * Defines how sharp are the highlights in the material.
  27357. * The bigger the value the sharper giving a more glossy feeling to the result.
  27358. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27359. */
  27360. specularPower: number;
  27361. private _useAlphaFromDiffuseTexture;
  27362. /**
  27363. * Does the transparency come from the diffuse texture alpha channel.
  27364. */
  27365. useAlphaFromDiffuseTexture: boolean;
  27366. private _useEmissiveAsIllumination;
  27367. /**
  27368. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27369. */
  27370. useEmissiveAsIllumination: boolean;
  27371. private _linkEmissiveWithDiffuse;
  27372. /**
  27373. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27374. * the emissive level when the final color is close to one.
  27375. */
  27376. linkEmissiveWithDiffuse: boolean;
  27377. private _useSpecularOverAlpha;
  27378. /**
  27379. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27380. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27381. */
  27382. useSpecularOverAlpha: boolean;
  27383. private _useReflectionOverAlpha;
  27384. /**
  27385. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27386. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27387. */
  27388. useReflectionOverAlpha: boolean;
  27389. private _disableLighting;
  27390. /**
  27391. * Does lights from the scene impacts this material.
  27392. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27393. */
  27394. disableLighting: boolean;
  27395. private _useObjectSpaceNormalMap;
  27396. /**
  27397. * Allows using an object space normal map (instead of tangent space).
  27398. */
  27399. useObjectSpaceNormalMap: boolean;
  27400. private _useParallax;
  27401. /**
  27402. * Is parallax enabled or not.
  27403. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27404. */
  27405. useParallax: boolean;
  27406. private _useParallaxOcclusion;
  27407. /**
  27408. * Is parallax occlusion enabled or not.
  27409. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27410. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27411. */
  27412. useParallaxOcclusion: boolean;
  27413. /**
  27414. * 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.
  27415. */
  27416. parallaxScaleBias: number;
  27417. private _roughness;
  27418. /**
  27419. * Helps to define how blurry the reflections should appears in the material.
  27420. */
  27421. roughness: number;
  27422. /**
  27423. * In case of refraction, define the value of the index of refraction.
  27424. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27425. */
  27426. indexOfRefraction: number;
  27427. /**
  27428. * Invert the refraction texture alongside the y axis.
  27429. * It can be useful with procedural textures or probe for instance.
  27430. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27431. */
  27432. invertRefractionY: boolean;
  27433. /**
  27434. * Defines the alpha limits in alpha test mode.
  27435. */
  27436. alphaCutOff: number;
  27437. private _useLightmapAsShadowmap;
  27438. /**
  27439. * In case of light mapping, define whether the map contains light or shadow informations.
  27440. */
  27441. useLightmapAsShadowmap: boolean;
  27442. private _diffuseFresnelParameters;
  27443. /**
  27444. * Define the diffuse fresnel parameters of the material.
  27445. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27446. */
  27447. diffuseFresnelParameters: FresnelParameters;
  27448. private _opacityFresnelParameters;
  27449. /**
  27450. * Define the opacity fresnel parameters of the material.
  27451. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27452. */
  27453. opacityFresnelParameters: FresnelParameters;
  27454. private _reflectionFresnelParameters;
  27455. /**
  27456. * Define the reflection fresnel parameters of the material.
  27457. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27458. */
  27459. reflectionFresnelParameters: FresnelParameters;
  27460. private _refractionFresnelParameters;
  27461. /**
  27462. * Define the refraction fresnel parameters of the material.
  27463. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27464. */
  27465. refractionFresnelParameters: FresnelParameters;
  27466. private _emissiveFresnelParameters;
  27467. /**
  27468. * Define the emissive fresnel parameters of the material.
  27469. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27470. */
  27471. emissiveFresnelParameters: FresnelParameters;
  27472. private _useReflectionFresnelFromSpecular;
  27473. /**
  27474. * If true automatically deducts the fresnels values from the material specularity.
  27475. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27476. */
  27477. useReflectionFresnelFromSpecular: boolean;
  27478. private _useGlossinessFromSpecularMapAlpha;
  27479. /**
  27480. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27481. */
  27482. useGlossinessFromSpecularMapAlpha: boolean;
  27483. private _maxSimultaneousLights;
  27484. /**
  27485. * Defines the maximum number of lights that can be used in the material
  27486. */
  27487. maxSimultaneousLights: number;
  27488. private _invertNormalMapX;
  27489. /**
  27490. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27491. */
  27492. invertNormalMapX: boolean;
  27493. private _invertNormalMapY;
  27494. /**
  27495. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27496. */
  27497. invertNormalMapY: boolean;
  27498. private _twoSidedLighting;
  27499. /**
  27500. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27501. */
  27502. twoSidedLighting: boolean;
  27503. /**
  27504. * Default configuration related to image processing available in the standard Material.
  27505. */
  27506. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27507. /**
  27508. * Gets the image processing configuration used either in this material.
  27509. */
  27510. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27511. /**
  27512. * Sets the Default image processing configuration used either in the this material.
  27513. *
  27514. * If sets to null, the scene one is in use.
  27515. */
  27516. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27517. /**
  27518. * Keep track of the image processing observer to allow dispose and replace.
  27519. */
  27520. private _imageProcessingObserver;
  27521. /**
  27522. * Attaches a new image processing configuration to the Standard Material.
  27523. * @param configuration
  27524. */
  27525. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27526. /**
  27527. * Gets wether the color curves effect is enabled.
  27528. */
  27529. get cameraColorCurvesEnabled(): boolean;
  27530. /**
  27531. * Sets wether the color curves effect is enabled.
  27532. */
  27533. set cameraColorCurvesEnabled(value: boolean);
  27534. /**
  27535. * Gets wether the color grading effect is enabled.
  27536. */
  27537. get cameraColorGradingEnabled(): boolean;
  27538. /**
  27539. * Gets wether the color grading effect is enabled.
  27540. */
  27541. set cameraColorGradingEnabled(value: boolean);
  27542. /**
  27543. * Gets wether tonemapping is enabled or not.
  27544. */
  27545. get cameraToneMappingEnabled(): boolean;
  27546. /**
  27547. * Sets wether tonemapping is enabled or not
  27548. */
  27549. set cameraToneMappingEnabled(value: boolean);
  27550. /**
  27551. * The camera exposure used on this material.
  27552. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27553. * This corresponds to a photographic exposure.
  27554. */
  27555. get cameraExposure(): number;
  27556. /**
  27557. * The camera exposure used on this material.
  27558. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27559. * This corresponds to a photographic exposure.
  27560. */
  27561. set cameraExposure(value: number);
  27562. /**
  27563. * Gets The camera contrast used on this material.
  27564. */
  27565. get cameraContrast(): number;
  27566. /**
  27567. * Sets The camera contrast used on this material.
  27568. */
  27569. set cameraContrast(value: number);
  27570. /**
  27571. * Gets the Color Grading 2D Lookup Texture.
  27572. */
  27573. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27574. /**
  27575. * Sets the Color Grading 2D Lookup Texture.
  27576. */
  27577. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27578. /**
  27579. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27580. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27581. * 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;
  27582. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27583. */
  27584. get cameraColorCurves(): Nullable<ColorCurves>;
  27585. /**
  27586. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27587. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27588. * 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;
  27589. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27590. */
  27591. set cameraColorCurves(value: Nullable<ColorCurves>);
  27592. /**
  27593. * Custom callback helping to override the default shader used in the material.
  27594. */
  27595. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27596. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27597. protected _worldViewProjectionMatrix: Matrix;
  27598. protected _globalAmbientColor: Color3;
  27599. protected _useLogarithmicDepth: boolean;
  27600. protected _rebuildInParallel: boolean;
  27601. /**
  27602. * Instantiates a new standard material.
  27603. * This is the default material used in Babylon. It is the best trade off between quality
  27604. * and performances.
  27605. * @see http://doc.babylonjs.com/babylon101/materials
  27606. * @param name Define the name of the material in the scene
  27607. * @param scene Define the scene the material belong to
  27608. */
  27609. constructor(name: string, scene: Scene);
  27610. /**
  27611. * Gets a boolean indicating that current material needs to register RTT
  27612. */
  27613. get hasRenderTargetTextures(): boolean;
  27614. /**
  27615. * Gets the current class name of the material e.g. "StandardMaterial"
  27616. * Mainly use in serialization.
  27617. * @returns the class name
  27618. */
  27619. getClassName(): string;
  27620. /**
  27621. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27622. * You can try switching to logarithmic depth.
  27623. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27624. */
  27625. get useLogarithmicDepth(): boolean;
  27626. set useLogarithmicDepth(value: boolean);
  27627. /**
  27628. * Specifies if the material will require alpha blending
  27629. * @returns a boolean specifying if alpha blending is needed
  27630. */
  27631. needAlphaBlending(): boolean;
  27632. /**
  27633. * Specifies if this material should be rendered in alpha test mode
  27634. * @returns a boolean specifying if an alpha test is needed.
  27635. */
  27636. needAlphaTesting(): boolean;
  27637. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27638. /**
  27639. * Get the texture used for alpha test purpose.
  27640. * @returns the diffuse texture in case of the standard material.
  27641. */
  27642. getAlphaTestTexture(): Nullable<BaseTexture>;
  27643. /**
  27644. * Get if the submesh is ready to be used and all its information available.
  27645. * Child classes can use it to update shaders
  27646. * @param mesh defines the mesh to check
  27647. * @param subMesh defines which submesh to check
  27648. * @param useInstances specifies that instances should be used
  27649. * @returns a boolean indicating that the submesh is ready or not
  27650. */
  27651. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27652. /**
  27653. * Builds the material UBO layouts.
  27654. * Used internally during the effect preparation.
  27655. */
  27656. buildUniformLayout(): void;
  27657. /**
  27658. * Unbinds the material from the mesh
  27659. */
  27660. unbind(): void;
  27661. /**
  27662. * Binds the submesh to this material by preparing the effect and shader to draw
  27663. * @param world defines the world transformation matrix
  27664. * @param mesh defines the mesh containing the submesh
  27665. * @param subMesh defines the submesh to bind the material to
  27666. */
  27667. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27668. /**
  27669. * Get the list of animatables in the material.
  27670. * @returns the list of animatables object used in the material
  27671. */
  27672. getAnimatables(): IAnimatable[];
  27673. /**
  27674. * Gets the active textures from the material
  27675. * @returns an array of textures
  27676. */
  27677. getActiveTextures(): BaseTexture[];
  27678. /**
  27679. * Specifies if the material uses a texture
  27680. * @param texture defines the texture to check against the material
  27681. * @returns a boolean specifying if the material uses the texture
  27682. */
  27683. hasTexture(texture: BaseTexture): boolean;
  27684. /**
  27685. * Disposes the material
  27686. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27687. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27688. */
  27689. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27690. /**
  27691. * Makes a duplicate of the material, and gives it a new name
  27692. * @param name defines the new name for the duplicated material
  27693. * @returns the cloned material
  27694. */
  27695. clone(name: string): StandardMaterial;
  27696. /**
  27697. * Serializes this material in a JSON representation
  27698. * @returns the serialized material object
  27699. */
  27700. serialize(): any;
  27701. /**
  27702. * Creates a standard material from parsed material data
  27703. * @param source defines the JSON representation of the material
  27704. * @param scene defines the hosting scene
  27705. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27706. * @returns a new standard material
  27707. */
  27708. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27709. /**
  27710. * Are diffuse textures enabled in the application.
  27711. */
  27712. static get DiffuseTextureEnabled(): boolean;
  27713. static set DiffuseTextureEnabled(value: boolean);
  27714. /**
  27715. * Are ambient textures enabled in the application.
  27716. */
  27717. static get AmbientTextureEnabled(): boolean;
  27718. static set AmbientTextureEnabled(value: boolean);
  27719. /**
  27720. * Are opacity textures enabled in the application.
  27721. */
  27722. static get OpacityTextureEnabled(): boolean;
  27723. static set OpacityTextureEnabled(value: boolean);
  27724. /**
  27725. * Are reflection textures enabled in the application.
  27726. */
  27727. static get ReflectionTextureEnabled(): boolean;
  27728. static set ReflectionTextureEnabled(value: boolean);
  27729. /**
  27730. * Are emissive textures enabled in the application.
  27731. */
  27732. static get EmissiveTextureEnabled(): boolean;
  27733. static set EmissiveTextureEnabled(value: boolean);
  27734. /**
  27735. * Are specular textures enabled in the application.
  27736. */
  27737. static get SpecularTextureEnabled(): boolean;
  27738. static set SpecularTextureEnabled(value: boolean);
  27739. /**
  27740. * Are bump textures enabled in the application.
  27741. */
  27742. static get BumpTextureEnabled(): boolean;
  27743. static set BumpTextureEnabled(value: boolean);
  27744. /**
  27745. * Are lightmap textures enabled in the application.
  27746. */
  27747. static get LightmapTextureEnabled(): boolean;
  27748. static set LightmapTextureEnabled(value: boolean);
  27749. /**
  27750. * Are refraction textures enabled in the application.
  27751. */
  27752. static get RefractionTextureEnabled(): boolean;
  27753. static set RefractionTextureEnabled(value: boolean);
  27754. /**
  27755. * Are color grading textures enabled in the application.
  27756. */
  27757. static get ColorGradingTextureEnabled(): boolean;
  27758. static set ColorGradingTextureEnabled(value: boolean);
  27759. /**
  27760. * Are fresnels enabled in the application.
  27761. */
  27762. static get FresnelEnabled(): boolean;
  27763. static set FresnelEnabled(value: boolean);
  27764. }
  27765. }
  27766. declare module "babylonjs/Particles/solidParticleSystem" {
  27767. import { Nullable } from "babylonjs/types";
  27768. import { Vector3 } from "babylonjs/Maths/math.vector";
  27769. import { Mesh } from "babylonjs/Meshes/mesh";
  27770. import { Scene, IDisposable } from "babylonjs/scene";
  27771. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27772. import { Material } from "babylonjs/Materials/material";
  27773. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27774. /**
  27775. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27776. *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.
  27777. * The SPS is also a particle system. It provides some methods to manage the particles.
  27778. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27779. *
  27780. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27781. */
  27782. export class SolidParticleSystem implements IDisposable {
  27783. /**
  27784. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27785. * Example : var p = SPS.particles[i];
  27786. */
  27787. particles: SolidParticle[];
  27788. /**
  27789. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27790. */
  27791. nbParticles: number;
  27792. /**
  27793. * If the particles must ever face the camera (default false). Useful for planar particles.
  27794. */
  27795. billboard: boolean;
  27796. /**
  27797. * Recompute normals when adding a shape
  27798. */
  27799. recomputeNormals: boolean;
  27800. /**
  27801. * This a counter ofr your own usage. It's not set by any SPS functions.
  27802. */
  27803. counter: number;
  27804. /**
  27805. * The SPS name. This name is also given to the underlying mesh.
  27806. */
  27807. name: string;
  27808. /**
  27809. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27810. */
  27811. mesh: Mesh;
  27812. /**
  27813. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27814. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27815. */
  27816. vars: any;
  27817. /**
  27818. * This array is populated when the SPS is set as 'pickable'.
  27819. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27820. * Each element of this array is an object `{idx: int, faceId: int}`.
  27821. * `idx` is the picked particle index in the `SPS.particles` array
  27822. * `faceId` is the picked face index counted within this particle.
  27823. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27824. */
  27825. pickedParticles: {
  27826. idx: number;
  27827. faceId: number;
  27828. }[];
  27829. /**
  27830. * This array is populated when `enableDepthSort` is set to true.
  27831. * Each element of this array is an instance of the class DepthSortedParticle.
  27832. */
  27833. depthSortedParticles: DepthSortedParticle[];
  27834. /**
  27835. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27836. * @hidden
  27837. */
  27838. _bSphereOnly: boolean;
  27839. /**
  27840. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27841. * @hidden
  27842. */
  27843. _bSphereRadiusFactor: number;
  27844. private _scene;
  27845. private _positions;
  27846. private _indices;
  27847. private _normals;
  27848. private _colors;
  27849. private _uvs;
  27850. private _indices32;
  27851. private _positions32;
  27852. private _normals32;
  27853. private _fixedNormal32;
  27854. private _colors32;
  27855. private _uvs32;
  27856. private _index;
  27857. private _updatable;
  27858. private _pickable;
  27859. private _isVisibilityBoxLocked;
  27860. private _alwaysVisible;
  27861. private _depthSort;
  27862. private _expandable;
  27863. private _shapeCounter;
  27864. private _copy;
  27865. private _color;
  27866. private _computeParticleColor;
  27867. private _computeParticleTexture;
  27868. private _computeParticleRotation;
  27869. private _computeParticleVertex;
  27870. private _computeBoundingBox;
  27871. private _depthSortParticles;
  27872. private _camera;
  27873. private _mustUnrotateFixedNormals;
  27874. private _particlesIntersect;
  27875. private _needs32Bits;
  27876. private _isNotBuilt;
  27877. private _lastParticleId;
  27878. private _idxOfId;
  27879. private _multimaterialEnabled;
  27880. private _useModelMaterial;
  27881. private _indicesByMaterial;
  27882. private _materialIndexes;
  27883. private _depthSortFunction;
  27884. private _materialSortFunction;
  27885. private _materials;
  27886. private _multimaterial;
  27887. private _materialIndexesById;
  27888. private _defaultMaterial;
  27889. private _autoUpdateSubMeshes;
  27890. /**
  27891. * Creates a SPS (Solid Particle System) object.
  27892. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27893. * @param scene (Scene) is the scene in which the SPS is added.
  27894. * @param options defines the options of the sps e.g.
  27895. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27896. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27897. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27898. * * 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.
  27899. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27900. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27901. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27902. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27903. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27904. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27905. */
  27906. constructor(name: string, scene: Scene, options?: {
  27907. updatable?: boolean;
  27908. isPickable?: boolean;
  27909. enableDepthSort?: boolean;
  27910. particleIntersection?: boolean;
  27911. boundingSphereOnly?: boolean;
  27912. bSphereRadiusFactor?: number;
  27913. expandable?: boolean;
  27914. useModelMaterial?: boolean;
  27915. enableMultiMaterial?: boolean;
  27916. });
  27917. /**
  27918. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27919. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27920. * @returns the created mesh
  27921. */
  27922. buildMesh(): Mesh;
  27923. /**
  27924. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27925. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27926. * Thus the particles generated from `digest()` have their property `position` set yet.
  27927. * @param mesh ( Mesh ) is the mesh to be digested
  27928. * @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
  27929. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27930. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27931. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27932. * @returns the current SPS
  27933. */
  27934. digest(mesh: Mesh, options?: {
  27935. facetNb?: number;
  27936. number?: number;
  27937. delta?: number;
  27938. storage?: [];
  27939. }): SolidParticleSystem;
  27940. /**
  27941. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27942. * @hidden
  27943. */
  27944. private _unrotateFixedNormals;
  27945. /**
  27946. * Resets the temporary working copy particle
  27947. * @hidden
  27948. */
  27949. private _resetCopy;
  27950. /**
  27951. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27952. * @param p the current index in the positions array to be updated
  27953. * @param ind the current index in the indices array
  27954. * @param shape a Vector3 array, the shape geometry
  27955. * @param positions the positions array to be updated
  27956. * @param meshInd the shape indices array
  27957. * @param indices the indices array to be updated
  27958. * @param meshUV the shape uv array
  27959. * @param uvs the uv array to be updated
  27960. * @param meshCol the shape color array
  27961. * @param colors the color array to be updated
  27962. * @param meshNor the shape normals array
  27963. * @param normals the normals array to be updated
  27964. * @param idx the particle index
  27965. * @param idxInShape the particle index in its shape
  27966. * @param options the addShape() method passed options
  27967. * @model the particle model
  27968. * @hidden
  27969. */
  27970. private _meshBuilder;
  27971. /**
  27972. * Returns a shape Vector3 array from positions float array
  27973. * @param positions float array
  27974. * @returns a vector3 array
  27975. * @hidden
  27976. */
  27977. private _posToShape;
  27978. /**
  27979. * Returns a shapeUV array from a float uvs (array deep copy)
  27980. * @param uvs as a float array
  27981. * @returns a shapeUV array
  27982. * @hidden
  27983. */
  27984. private _uvsToShapeUV;
  27985. /**
  27986. * Adds a new particle object in the particles array
  27987. * @param idx particle index in particles array
  27988. * @param id particle id
  27989. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27990. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27991. * @param model particle ModelShape object
  27992. * @param shapeId model shape identifier
  27993. * @param idxInShape index of the particle in the current model
  27994. * @param bInfo model bounding info object
  27995. * @param storage target storage array, if any
  27996. * @hidden
  27997. */
  27998. private _addParticle;
  27999. /**
  28000. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28001. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28002. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28003. * @param nb (positive integer) the number of particles to be created from this model
  28004. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28005. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28006. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28007. * @returns the number of shapes in the system
  28008. */
  28009. addShape(mesh: Mesh, nb: number, options?: {
  28010. positionFunction?: any;
  28011. vertexFunction?: any;
  28012. storage?: [];
  28013. }): number;
  28014. /**
  28015. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28016. * @hidden
  28017. */
  28018. private _rebuildParticle;
  28019. /**
  28020. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28021. * @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.
  28022. * @returns the SPS.
  28023. */
  28024. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28025. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28026. * Returns an array with the removed particles.
  28027. * 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.
  28028. * The SPS can't be empty so at least one particle needs to remain in place.
  28029. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28030. * @param start index of the first particle to remove
  28031. * @param end index of the last particle to remove (included)
  28032. * @returns an array populated with the removed particles
  28033. */
  28034. removeParticles(start: number, end: number): SolidParticle[];
  28035. /**
  28036. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28037. * @param solidParticleArray an array populated with Solid Particles objects
  28038. * @returns the SPS
  28039. */
  28040. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28041. /**
  28042. * Creates a new particle and modifies the SPS mesh geometry :
  28043. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28044. * - calls _addParticle() to populate the particle array
  28045. * factorized code from addShape() and insertParticlesFromArray()
  28046. * @param idx particle index in the particles array
  28047. * @param i particle index in its shape
  28048. * @param modelShape particle ModelShape object
  28049. * @param shape shape vertex array
  28050. * @param meshInd shape indices array
  28051. * @param meshUV shape uv array
  28052. * @param meshCol shape color array
  28053. * @param meshNor shape normals array
  28054. * @param bbInfo shape bounding info
  28055. * @param storage target particle storage
  28056. * @options addShape() passed options
  28057. * @hidden
  28058. */
  28059. private _insertNewParticle;
  28060. /**
  28061. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28062. * This method calls `updateParticle()` for each particle of the SPS.
  28063. * For an animated SPS, it is usually called within the render loop.
  28064. * 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.
  28065. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28066. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28067. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28068. * @returns the SPS.
  28069. */
  28070. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28071. /**
  28072. * Disposes the SPS.
  28073. */
  28074. dispose(): void;
  28075. /**
  28076. * Returns a SolidParticle object from its identifier : particle.id
  28077. * @param id (integer) the particle Id
  28078. * @returns the searched particle or null if not found in the SPS.
  28079. */
  28080. getParticleById(id: number): Nullable<SolidParticle>;
  28081. /**
  28082. * Returns a new array populated with the particles having the passed shapeId.
  28083. * @param shapeId (integer) the shape identifier
  28084. * @returns a new solid particle array
  28085. */
  28086. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28087. /**
  28088. * Populates the passed array "ref" with the particles having the passed shapeId.
  28089. * @param shapeId the shape identifier
  28090. * @returns the SPS
  28091. * @param ref
  28092. */
  28093. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28094. /**
  28095. * Computes the required SubMeshes according the materials assigned to the particles.
  28096. * @returns the solid particle system.
  28097. * Does nothing if called before the SPS mesh is built.
  28098. */
  28099. computeSubMeshes(): SolidParticleSystem;
  28100. /**
  28101. * Sorts the solid particles by material when MultiMaterial is enabled.
  28102. * Updates the indices32 array.
  28103. * Updates the indicesByMaterial array.
  28104. * Updates the mesh indices array.
  28105. * @returns the SPS
  28106. * @hidden
  28107. */
  28108. private _sortParticlesByMaterial;
  28109. /**
  28110. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28111. * @hidden
  28112. */
  28113. private _setMaterialIndexesById;
  28114. /**
  28115. * Returns an array with unique values of Materials from the passed array
  28116. * @param array the material array to be checked and filtered
  28117. * @hidden
  28118. */
  28119. private _filterUniqueMaterialId;
  28120. /**
  28121. * Sets a new Standard Material as _defaultMaterial if not already set.
  28122. * @hidden
  28123. */
  28124. private _setDefaultMaterial;
  28125. /**
  28126. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28127. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28128. * @returns the SPS.
  28129. */
  28130. refreshVisibleSize(): SolidParticleSystem;
  28131. /**
  28132. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28133. * @param size the size (float) of the visibility box
  28134. * note : this doesn't lock the SPS mesh bounding box.
  28135. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28136. */
  28137. setVisibilityBox(size: number): void;
  28138. /**
  28139. * Gets whether the SPS as always visible or not
  28140. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28141. */
  28142. get isAlwaysVisible(): boolean;
  28143. /**
  28144. * Sets the SPS as always visible or not
  28145. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28146. */
  28147. set isAlwaysVisible(val: boolean);
  28148. /**
  28149. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28150. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28151. */
  28152. set isVisibilityBoxLocked(val: boolean);
  28153. /**
  28154. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28155. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28156. */
  28157. get isVisibilityBoxLocked(): boolean;
  28158. /**
  28159. * Tells to `setParticles()` to compute the particle rotations or not.
  28160. * Default value : true. The SPS is faster when it's set to false.
  28161. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28162. */
  28163. set computeParticleRotation(val: boolean);
  28164. /**
  28165. * Tells to `setParticles()` to compute the particle colors or not.
  28166. * Default value : true. The SPS is faster when it's set to false.
  28167. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28168. */
  28169. set computeParticleColor(val: boolean);
  28170. set computeParticleTexture(val: boolean);
  28171. /**
  28172. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28173. * Default value : false. The SPS is faster when it's set to false.
  28174. * Note : the particle custom vertex positions aren't stored values.
  28175. */
  28176. set computeParticleVertex(val: boolean);
  28177. /**
  28178. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28179. */
  28180. set computeBoundingBox(val: boolean);
  28181. /**
  28182. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28183. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28184. * Default : `true`
  28185. */
  28186. set depthSortParticles(val: boolean);
  28187. /**
  28188. * Gets if `setParticles()` computes the particle rotations or not.
  28189. * Default value : true. The SPS is faster when it's set to false.
  28190. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28191. */
  28192. get computeParticleRotation(): boolean;
  28193. /**
  28194. * Gets if `setParticles()` computes the particle colors or not.
  28195. * Default value : true. The SPS is faster when it's set to false.
  28196. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28197. */
  28198. get computeParticleColor(): boolean;
  28199. /**
  28200. * Gets if `setParticles()` computes the particle textures or not.
  28201. * Default value : true. The SPS is faster when it's set to false.
  28202. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28203. */
  28204. get computeParticleTexture(): boolean;
  28205. /**
  28206. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28207. * Default value : false. The SPS is faster when it's set to false.
  28208. * Note : the particle custom vertex positions aren't stored values.
  28209. */
  28210. get computeParticleVertex(): boolean;
  28211. /**
  28212. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28213. */
  28214. get computeBoundingBox(): boolean;
  28215. /**
  28216. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28217. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28218. * Default : `true`
  28219. */
  28220. get depthSortParticles(): boolean;
  28221. /**
  28222. * Gets if the SPS is created as expandable at construction time.
  28223. * Default : `false`
  28224. */
  28225. get expandable(): boolean;
  28226. /**
  28227. * Gets if the SPS supports the Multi Materials
  28228. */
  28229. get multimaterialEnabled(): boolean;
  28230. /**
  28231. * Gets if the SPS uses the model materials for its own multimaterial.
  28232. */
  28233. get useModelMaterial(): boolean;
  28234. /**
  28235. * The SPS used material array.
  28236. */
  28237. get materials(): Material[];
  28238. /**
  28239. * Sets the SPS MultiMaterial from the passed materials.
  28240. * Note : the passed array is internally copied and not used then by reference.
  28241. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28242. */
  28243. setMultiMaterial(materials: Material[]): void;
  28244. /**
  28245. * The SPS computed multimaterial object
  28246. */
  28247. get multimaterial(): MultiMaterial;
  28248. set multimaterial(mm: MultiMaterial);
  28249. /**
  28250. * If the subMeshes must be updated on the next call to setParticles()
  28251. */
  28252. get autoUpdateSubMeshes(): boolean;
  28253. set autoUpdateSubMeshes(val: boolean);
  28254. /**
  28255. * This function does nothing. It may be overwritten to set all the particle first values.
  28256. * The SPS doesn't call this function, you may have to call it by your own.
  28257. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28258. */
  28259. initParticles(): void;
  28260. /**
  28261. * This function does nothing. It may be overwritten to recycle a particle.
  28262. * The SPS doesn't call this function, you may have to call it by your own.
  28263. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28264. * @param particle The particle to recycle
  28265. * @returns the recycled particle
  28266. */
  28267. recycleParticle(particle: SolidParticle): SolidParticle;
  28268. /**
  28269. * Updates a particle : this function should be overwritten by the user.
  28270. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28271. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28272. * @example : just set a particle position or velocity and recycle conditions
  28273. * @param particle The particle to update
  28274. * @returns the updated particle
  28275. */
  28276. updateParticle(particle: SolidParticle): SolidParticle;
  28277. /**
  28278. * Updates a vertex of a particle : it can be overwritten by the user.
  28279. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28280. * @param particle the current particle
  28281. * @param vertex the current index of the current particle
  28282. * @param pt the index of the current vertex in the particle shape
  28283. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28284. * @example : just set a vertex particle position
  28285. * @returns the updated vertex
  28286. */
  28287. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28288. /**
  28289. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28290. * This does nothing and may be overwritten by the user.
  28291. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28292. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28293. * @param update the boolean update value actually passed to setParticles()
  28294. */
  28295. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28296. /**
  28297. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28298. * This will be passed three parameters.
  28299. * This does nothing and may be overwritten by the user.
  28300. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28301. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28302. * @param update the boolean update value actually passed to setParticles()
  28303. */
  28304. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28305. }
  28306. }
  28307. declare module "babylonjs/Particles/solidParticle" {
  28308. import { Nullable } from "babylonjs/types";
  28309. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28310. import { Color4 } from "babylonjs/Maths/math.color";
  28311. import { Mesh } from "babylonjs/Meshes/mesh";
  28312. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28313. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28314. import { Plane } from "babylonjs/Maths/math.plane";
  28315. import { Material } from "babylonjs/Materials/material";
  28316. /**
  28317. * Represents one particle of a solid particle system.
  28318. */
  28319. export class SolidParticle {
  28320. /**
  28321. * particle global index
  28322. */
  28323. idx: number;
  28324. /**
  28325. * particle identifier
  28326. */
  28327. id: number;
  28328. /**
  28329. * The color of the particle
  28330. */
  28331. color: Nullable<Color4>;
  28332. /**
  28333. * The world space position of the particle.
  28334. */
  28335. position: Vector3;
  28336. /**
  28337. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28338. */
  28339. rotation: Vector3;
  28340. /**
  28341. * The world space rotation quaternion of the particle.
  28342. */
  28343. rotationQuaternion: Nullable<Quaternion>;
  28344. /**
  28345. * The scaling of the particle.
  28346. */
  28347. scaling: Vector3;
  28348. /**
  28349. * The uvs of the particle.
  28350. */
  28351. uvs: Vector4;
  28352. /**
  28353. * The current speed of the particle.
  28354. */
  28355. velocity: Vector3;
  28356. /**
  28357. * The pivot point in the particle local space.
  28358. */
  28359. pivot: Vector3;
  28360. /**
  28361. * Must the particle be translated from its pivot point in its local space ?
  28362. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28363. * Default : false
  28364. */
  28365. translateFromPivot: boolean;
  28366. /**
  28367. * Is the particle active or not ?
  28368. */
  28369. alive: boolean;
  28370. /**
  28371. * Is the particle visible or not ?
  28372. */
  28373. isVisible: boolean;
  28374. /**
  28375. * Index of this particle in the global "positions" array (Internal use)
  28376. * @hidden
  28377. */
  28378. _pos: number;
  28379. /**
  28380. * @hidden Index of this particle in the global "indices" array (Internal use)
  28381. */
  28382. _ind: number;
  28383. /**
  28384. * @hidden ModelShape of this particle (Internal use)
  28385. */
  28386. _model: ModelShape;
  28387. /**
  28388. * ModelShape id of this particle
  28389. */
  28390. shapeId: number;
  28391. /**
  28392. * Index of the particle in its shape id
  28393. */
  28394. idxInShape: number;
  28395. /**
  28396. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28397. */
  28398. _modelBoundingInfo: BoundingInfo;
  28399. /**
  28400. * @hidden Particle BoundingInfo object (Internal use)
  28401. */
  28402. _boundingInfo: BoundingInfo;
  28403. /**
  28404. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28405. */
  28406. _sps: SolidParticleSystem;
  28407. /**
  28408. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28409. */
  28410. _stillInvisible: boolean;
  28411. /**
  28412. * @hidden Last computed particle rotation matrix
  28413. */
  28414. _rotationMatrix: number[];
  28415. /**
  28416. * Parent particle Id, if any.
  28417. * Default null.
  28418. */
  28419. parentId: Nullable<number>;
  28420. /**
  28421. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28422. */
  28423. materialIndex: Nullable<number>;
  28424. /**
  28425. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28426. * The possible values are :
  28427. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28428. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28429. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28430. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28431. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28432. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28433. * */
  28434. cullingStrategy: number;
  28435. /**
  28436. * @hidden Internal global position in the SPS.
  28437. */
  28438. _globalPosition: Vector3;
  28439. /**
  28440. * Creates a Solid Particle object.
  28441. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28442. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28443. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28444. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28445. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28446. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28447. * @param shapeId (integer) is the model shape identifier in the SPS.
  28448. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28449. * @param sps defines the sps it is associated to
  28450. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28451. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28452. */
  28453. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28454. /**
  28455. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28456. * @param target the particle target
  28457. * @returns the current particle
  28458. */
  28459. copyToRef(target: SolidParticle): SolidParticle;
  28460. /**
  28461. * Legacy support, changed scale to scaling
  28462. */
  28463. get scale(): Vector3;
  28464. /**
  28465. * Legacy support, changed scale to scaling
  28466. */
  28467. set scale(scale: Vector3);
  28468. /**
  28469. * Legacy support, changed quaternion to rotationQuaternion
  28470. */
  28471. get quaternion(): Nullable<Quaternion>;
  28472. /**
  28473. * Legacy support, changed quaternion to rotationQuaternion
  28474. */
  28475. set quaternion(q: Nullable<Quaternion>);
  28476. /**
  28477. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28478. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28479. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28480. * @returns true if it intersects
  28481. */
  28482. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28483. /**
  28484. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28485. * A particle is in the frustum if its bounding box intersects the frustum
  28486. * @param frustumPlanes defines the frustum to test
  28487. * @returns true if the particle is in the frustum planes
  28488. */
  28489. isInFrustum(frustumPlanes: Plane[]): boolean;
  28490. /**
  28491. * get the rotation matrix of the particle
  28492. * @hidden
  28493. */
  28494. getRotationMatrix(m: Matrix): void;
  28495. }
  28496. /**
  28497. * Represents the shape of the model used by one particle of a solid particle system.
  28498. * SPS internal tool, don't use it manually.
  28499. */
  28500. export class ModelShape {
  28501. /**
  28502. * The shape id
  28503. * @hidden
  28504. */
  28505. shapeID: number;
  28506. /**
  28507. * flat array of model positions (internal use)
  28508. * @hidden
  28509. */
  28510. _shape: Vector3[];
  28511. /**
  28512. * flat array of model UVs (internal use)
  28513. * @hidden
  28514. */
  28515. _shapeUV: number[];
  28516. /**
  28517. * color array of the model
  28518. * @hidden
  28519. */
  28520. _shapeColors: number[];
  28521. /**
  28522. * indices array of the model
  28523. * @hidden
  28524. */
  28525. _indices: number[];
  28526. /**
  28527. * normals array of the model
  28528. * @hidden
  28529. */
  28530. _normals: number[];
  28531. /**
  28532. * length of the shape in the model indices array (internal use)
  28533. * @hidden
  28534. */
  28535. _indicesLength: number;
  28536. /**
  28537. * Custom position function (internal use)
  28538. * @hidden
  28539. */
  28540. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28541. /**
  28542. * Custom vertex function (internal use)
  28543. * @hidden
  28544. */
  28545. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28546. /**
  28547. * Model material (internal use)
  28548. * @hidden
  28549. */
  28550. _material: Nullable<Material>;
  28551. /**
  28552. * 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.
  28553. * SPS internal tool, don't use it manually.
  28554. * @hidden
  28555. */
  28556. 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>);
  28557. }
  28558. /**
  28559. * Represents a Depth Sorted Particle in the solid particle system.
  28560. * @hidden
  28561. */
  28562. export class DepthSortedParticle {
  28563. /**
  28564. * Index of the particle in the "indices" array
  28565. */
  28566. ind: number;
  28567. /**
  28568. * Length of the particle shape in the "indices" array
  28569. */
  28570. indicesLength: number;
  28571. /**
  28572. * Squared distance from the particle to the camera
  28573. */
  28574. sqDistance: number;
  28575. /**
  28576. * Material index when used with MultiMaterials
  28577. */
  28578. materialIndex: number;
  28579. /**
  28580. * Creates a new sorted particle
  28581. * @param materialIndex
  28582. */
  28583. constructor(ind: number, indLength: number, materialIndex: number);
  28584. }
  28585. }
  28586. declare module "babylonjs/Collisions/meshCollisionData" {
  28587. import { Collider } from "babylonjs/Collisions/collider";
  28588. import { Vector3 } from "babylonjs/Maths/math.vector";
  28589. import { Nullable } from "babylonjs/types";
  28590. import { Observer } from "babylonjs/Misc/observable";
  28591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28592. /**
  28593. * @hidden
  28594. */
  28595. export class _MeshCollisionData {
  28596. _checkCollisions: boolean;
  28597. _collisionMask: number;
  28598. _collisionGroup: number;
  28599. _collider: Nullable<Collider>;
  28600. _oldPositionForCollisions: Vector3;
  28601. _diffPositionForCollisions: Vector3;
  28602. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28603. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28604. }
  28605. }
  28606. declare module "babylonjs/Meshes/abstractMesh" {
  28607. import { Observable } from "babylonjs/Misc/observable";
  28608. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28609. import { Camera } from "babylonjs/Cameras/camera";
  28610. import { Scene, IDisposable } from "babylonjs/scene";
  28611. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28612. import { Node } from "babylonjs/node";
  28613. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28614. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28615. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28616. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28617. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28618. import { Material } from "babylonjs/Materials/material";
  28619. import { Light } from "babylonjs/Lights/light";
  28620. import { Skeleton } from "babylonjs/Bones/skeleton";
  28621. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28622. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28623. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28624. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28625. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28626. import { Plane } from "babylonjs/Maths/math.plane";
  28627. import { Ray } from "babylonjs/Culling/ray";
  28628. import { Collider } from "babylonjs/Collisions/collider";
  28629. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28630. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28631. /** @hidden */
  28632. class _FacetDataStorage {
  28633. facetPositions: Vector3[];
  28634. facetNormals: Vector3[];
  28635. facetPartitioning: number[][];
  28636. facetNb: number;
  28637. partitioningSubdivisions: number;
  28638. partitioningBBoxRatio: number;
  28639. facetDataEnabled: boolean;
  28640. facetParameters: any;
  28641. bbSize: Vector3;
  28642. subDiv: {
  28643. max: number;
  28644. X: number;
  28645. Y: number;
  28646. Z: number;
  28647. };
  28648. facetDepthSort: boolean;
  28649. facetDepthSortEnabled: boolean;
  28650. depthSortedIndices: IndicesArray;
  28651. depthSortedFacets: {
  28652. ind: number;
  28653. sqDistance: number;
  28654. }[];
  28655. facetDepthSortFunction: (f1: {
  28656. ind: number;
  28657. sqDistance: number;
  28658. }, f2: {
  28659. ind: number;
  28660. sqDistance: number;
  28661. }) => number;
  28662. facetDepthSortFrom: Vector3;
  28663. facetDepthSortOrigin: Vector3;
  28664. invertedMatrix: Matrix;
  28665. }
  28666. /**
  28667. * @hidden
  28668. **/
  28669. class _InternalAbstractMeshDataInfo {
  28670. _hasVertexAlpha: boolean;
  28671. _useVertexColors: boolean;
  28672. _numBoneInfluencers: number;
  28673. _applyFog: boolean;
  28674. _receiveShadows: boolean;
  28675. _facetData: _FacetDataStorage;
  28676. _visibility: number;
  28677. _skeleton: Nullable<Skeleton>;
  28678. _layerMask: number;
  28679. _computeBonesUsingShaders: boolean;
  28680. _isActive: boolean;
  28681. _onlyForInstances: boolean;
  28682. _isActiveIntermediate: boolean;
  28683. _onlyForInstancesIntermediate: boolean;
  28684. _actAsRegularMesh: boolean;
  28685. }
  28686. /**
  28687. * Class used to store all common mesh properties
  28688. */
  28689. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28690. /** No occlusion */
  28691. static OCCLUSION_TYPE_NONE: number;
  28692. /** Occlusion set to optimisitic */
  28693. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28694. /** Occlusion set to strict */
  28695. static OCCLUSION_TYPE_STRICT: number;
  28696. /** Use an accurante occlusion algorithm */
  28697. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28698. /** Use a conservative occlusion algorithm */
  28699. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28700. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28701. * Test order :
  28702. * Is the bounding sphere outside the frustum ?
  28703. * If not, are the bounding box vertices outside the frustum ?
  28704. * It not, then the cullable object is in the frustum.
  28705. */
  28706. static readonly CULLINGSTRATEGY_STANDARD: number;
  28707. /** Culling strategy : Bounding Sphere Only.
  28708. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28709. * It's also less accurate than the standard because some not visible objects can still be selected.
  28710. * Test : is the bounding sphere outside the frustum ?
  28711. * If not, then the cullable object is in the frustum.
  28712. */
  28713. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28714. /** Culling strategy : Optimistic Inclusion.
  28715. * This in an inclusion test first, then the standard exclusion test.
  28716. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28717. * 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.
  28718. * Anyway, it's as accurate as the standard strategy.
  28719. * Test :
  28720. * Is the cullable object bounding sphere center in the frustum ?
  28721. * If not, apply the default culling strategy.
  28722. */
  28723. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28724. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28725. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28726. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28727. * 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.
  28728. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28729. * Test :
  28730. * Is the cullable object bounding sphere center in the frustum ?
  28731. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28732. */
  28733. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28734. /**
  28735. * No billboard
  28736. */
  28737. static get BILLBOARDMODE_NONE(): number;
  28738. /** Billboard on X axis */
  28739. static get BILLBOARDMODE_X(): number;
  28740. /** Billboard on Y axis */
  28741. static get BILLBOARDMODE_Y(): number;
  28742. /** Billboard on Z axis */
  28743. static get BILLBOARDMODE_Z(): number;
  28744. /** Billboard on all axes */
  28745. static get BILLBOARDMODE_ALL(): number;
  28746. /** Billboard on using position instead of orientation */
  28747. static get BILLBOARDMODE_USE_POSITION(): number;
  28748. /** @hidden */
  28749. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28750. /**
  28751. * The culling strategy to use to check whether the mesh must be rendered or not.
  28752. * This value can be changed at any time and will be used on the next render mesh selection.
  28753. * The possible values are :
  28754. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28755. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28756. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28757. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28758. * Please read each static variable documentation to get details about the culling process.
  28759. * */
  28760. cullingStrategy: number;
  28761. /**
  28762. * Gets the number of facets in the mesh
  28763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28764. */
  28765. get facetNb(): number;
  28766. /**
  28767. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28768. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28769. */
  28770. get partitioningSubdivisions(): number;
  28771. set partitioningSubdivisions(nb: number);
  28772. /**
  28773. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28774. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28775. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28776. */
  28777. get partitioningBBoxRatio(): number;
  28778. set partitioningBBoxRatio(ratio: number);
  28779. /**
  28780. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28781. * Works only for updatable meshes.
  28782. * Doesn't work with multi-materials
  28783. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28784. */
  28785. get mustDepthSortFacets(): boolean;
  28786. set mustDepthSortFacets(sort: boolean);
  28787. /**
  28788. * The location (Vector3) where the facet depth sort must be computed from.
  28789. * By default, the active camera position.
  28790. * Used only when facet depth sort is enabled
  28791. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28792. */
  28793. get facetDepthSortFrom(): Vector3;
  28794. set facetDepthSortFrom(location: Vector3);
  28795. /**
  28796. * gets a boolean indicating if facetData is enabled
  28797. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28798. */
  28799. get isFacetDataEnabled(): boolean;
  28800. /** @hidden */
  28801. _updateNonUniformScalingState(value: boolean): boolean;
  28802. /**
  28803. * An event triggered when this mesh collides with another one
  28804. */
  28805. onCollideObservable: Observable<AbstractMesh>;
  28806. /** Set a function to call when this mesh collides with another one */
  28807. set onCollide(callback: () => void);
  28808. /**
  28809. * An event triggered when the collision's position changes
  28810. */
  28811. onCollisionPositionChangeObservable: Observable<Vector3>;
  28812. /** Set a function to call when the collision's position changes */
  28813. set onCollisionPositionChange(callback: () => void);
  28814. /**
  28815. * An event triggered when material is changed
  28816. */
  28817. onMaterialChangedObservable: Observable<AbstractMesh>;
  28818. /**
  28819. * Gets or sets the orientation for POV movement & rotation
  28820. */
  28821. definedFacingForward: boolean;
  28822. /** @hidden */
  28823. _occlusionQuery: Nullable<WebGLQuery>;
  28824. /** @hidden */
  28825. _renderingGroup: Nullable<RenderingGroup>;
  28826. /**
  28827. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28828. */
  28829. get visibility(): number;
  28830. /**
  28831. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28832. */
  28833. set visibility(value: number);
  28834. /** Gets or sets the alpha index used to sort transparent meshes
  28835. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28836. */
  28837. alphaIndex: number;
  28838. /**
  28839. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28840. */
  28841. isVisible: boolean;
  28842. /**
  28843. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28844. */
  28845. isPickable: boolean;
  28846. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28847. showSubMeshesBoundingBox: boolean;
  28848. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28849. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28850. */
  28851. isBlocker: boolean;
  28852. /**
  28853. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28854. */
  28855. enablePointerMoveEvents: boolean;
  28856. /**
  28857. * Specifies the rendering group id for this mesh (0 by default)
  28858. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28859. */
  28860. renderingGroupId: number;
  28861. private _material;
  28862. /** Gets or sets current material */
  28863. get material(): Nullable<Material>;
  28864. set material(value: Nullable<Material>);
  28865. /**
  28866. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28867. * @see http://doc.babylonjs.com/babylon101/shadows
  28868. */
  28869. get receiveShadows(): boolean;
  28870. set receiveShadows(value: boolean);
  28871. /** Defines color to use when rendering outline */
  28872. outlineColor: Color3;
  28873. /** Define width to use when rendering outline */
  28874. outlineWidth: number;
  28875. /** Defines color to use when rendering overlay */
  28876. overlayColor: Color3;
  28877. /** Defines alpha to use when rendering overlay */
  28878. overlayAlpha: number;
  28879. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28880. get hasVertexAlpha(): boolean;
  28881. set hasVertexAlpha(value: boolean);
  28882. /** 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) */
  28883. get useVertexColors(): boolean;
  28884. set useVertexColors(value: boolean);
  28885. /**
  28886. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28887. */
  28888. get computeBonesUsingShaders(): boolean;
  28889. set computeBonesUsingShaders(value: boolean);
  28890. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28891. get numBoneInfluencers(): number;
  28892. set numBoneInfluencers(value: number);
  28893. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28894. get applyFog(): boolean;
  28895. set applyFog(value: boolean);
  28896. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28897. useOctreeForRenderingSelection: boolean;
  28898. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28899. useOctreeForPicking: boolean;
  28900. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28901. useOctreeForCollisions: boolean;
  28902. /**
  28903. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28904. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28905. */
  28906. get layerMask(): number;
  28907. set layerMask(value: number);
  28908. /**
  28909. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28910. */
  28911. alwaysSelectAsActiveMesh: boolean;
  28912. /**
  28913. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28914. */
  28915. doNotSyncBoundingInfo: boolean;
  28916. /**
  28917. * Gets or sets the current action manager
  28918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28919. */
  28920. actionManager: Nullable<AbstractActionManager>;
  28921. private _meshCollisionData;
  28922. /**
  28923. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28924. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28925. */
  28926. ellipsoid: Vector3;
  28927. /**
  28928. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28929. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28930. */
  28931. ellipsoidOffset: Vector3;
  28932. /**
  28933. * Gets or sets a collision mask used to mask collisions (default is -1).
  28934. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28935. */
  28936. get collisionMask(): number;
  28937. set collisionMask(mask: number);
  28938. /**
  28939. * Gets or sets the current collision group mask (-1 by default).
  28940. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28941. */
  28942. get collisionGroup(): number;
  28943. set collisionGroup(mask: number);
  28944. /**
  28945. * Defines edge width used when edgesRenderer is enabled
  28946. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28947. */
  28948. edgesWidth: number;
  28949. /**
  28950. * Defines edge color used when edgesRenderer is enabled
  28951. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28952. */
  28953. edgesColor: Color4;
  28954. /** @hidden */
  28955. _edgesRenderer: Nullable<IEdgesRenderer>;
  28956. /** @hidden */
  28957. _masterMesh: Nullable<AbstractMesh>;
  28958. /** @hidden */
  28959. _boundingInfo: Nullable<BoundingInfo>;
  28960. /** @hidden */
  28961. _renderId: number;
  28962. /**
  28963. * Gets or sets the list of subMeshes
  28964. * @see http://doc.babylonjs.com/how_to/multi_materials
  28965. */
  28966. subMeshes: SubMesh[];
  28967. /** @hidden */
  28968. _intersectionsInProgress: AbstractMesh[];
  28969. /** @hidden */
  28970. _unIndexed: boolean;
  28971. /** @hidden */
  28972. _lightSources: Light[];
  28973. /** Gets the list of lights affecting that mesh */
  28974. get lightSources(): Light[];
  28975. /** @hidden */
  28976. get _positions(): Nullable<Vector3[]>;
  28977. /** @hidden */
  28978. _waitingData: {
  28979. lods: Nullable<any>;
  28980. actions: Nullable<any>;
  28981. freezeWorldMatrix: Nullable<boolean>;
  28982. };
  28983. /** @hidden */
  28984. _bonesTransformMatrices: Nullable<Float32Array>;
  28985. /** @hidden */
  28986. _transformMatrixTexture: Nullable<RawTexture>;
  28987. /**
  28988. * Gets or sets a skeleton to apply skining transformations
  28989. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28990. */
  28991. set skeleton(value: Nullable<Skeleton>);
  28992. get skeleton(): Nullable<Skeleton>;
  28993. /**
  28994. * An event triggered when the mesh is rebuilt.
  28995. */
  28996. onRebuildObservable: Observable<AbstractMesh>;
  28997. /**
  28998. * Creates a new AbstractMesh
  28999. * @param name defines the name of the mesh
  29000. * @param scene defines the hosting scene
  29001. */
  29002. constructor(name: string, scene?: Nullable<Scene>);
  29003. /**
  29004. * Returns the string "AbstractMesh"
  29005. * @returns "AbstractMesh"
  29006. */
  29007. getClassName(): string;
  29008. /**
  29009. * Gets a string representation of the current mesh
  29010. * @param fullDetails defines a boolean indicating if full details must be included
  29011. * @returns a string representation of the current mesh
  29012. */
  29013. toString(fullDetails?: boolean): string;
  29014. /**
  29015. * @hidden
  29016. */
  29017. protected _getEffectiveParent(): Nullable<Node>;
  29018. /** @hidden */
  29019. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29020. /** @hidden */
  29021. _rebuild(): void;
  29022. /** @hidden */
  29023. _resyncLightSources(): void;
  29024. /** @hidden */
  29025. _resyncLightSource(light: Light): void;
  29026. /** @hidden */
  29027. _unBindEffect(): void;
  29028. /** @hidden */
  29029. _removeLightSource(light: Light, dispose: boolean): void;
  29030. private _markSubMeshesAsDirty;
  29031. /** @hidden */
  29032. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29033. /** @hidden */
  29034. _markSubMeshesAsAttributesDirty(): void;
  29035. /** @hidden */
  29036. _markSubMeshesAsMiscDirty(): void;
  29037. /**
  29038. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29039. */
  29040. get scaling(): Vector3;
  29041. set scaling(newScaling: Vector3);
  29042. /**
  29043. * Returns true if the mesh is blocked. Implemented by child classes
  29044. */
  29045. get isBlocked(): boolean;
  29046. /**
  29047. * Returns the mesh itself by default. Implemented by child classes
  29048. * @param camera defines the camera to use to pick the right LOD level
  29049. * @returns the currentAbstractMesh
  29050. */
  29051. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29052. /**
  29053. * Returns 0 by default. Implemented by child classes
  29054. * @returns an integer
  29055. */
  29056. getTotalVertices(): number;
  29057. /**
  29058. * Returns a positive integer : the total number of indices in this mesh geometry.
  29059. * @returns the numner of indices or zero if the mesh has no geometry.
  29060. */
  29061. getTotalIndices(): number;
  29062. /**
  29063. * Returns null by default. Implemented by child classes
  29064. * @returns null
  29065. */
  29066. getIndices(): Nullable<IndicesArray>;
  29067. /**
  29068. * Returns the array of the requested vertex data kind. Implemented by child classes
  29069. * @param kind defines the vertex data kind to use
  29070. * @returns null
  29071. */
  29072. getVerticesData(kind: string): Nullable<FloatArray>;
  29073. /**
  29074. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29075. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29076. * Note that a new underlying VertexBuffer object is created each call.
  29077. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29078. * @param kind defines vertex data kind:
  29079. * * VertexBuffer.PositionKind
  29080. * * VertexBuffer.UVKind
  29081. * * VertexBuffer.UV2Kind
  29082. * * VertexBuffer.UV3Kind
  29083. * * VertexBuffer.UV4Kind
  29084. * * VertexBuffer.UV5Kind
  29085. * * VertexBuffer.UV6Kind
  29086. * * VertexBuffer.ColorKind
  29087. * * VertexBuffer.MatricesIndicesKind
  29088. * * VertexBuffer.MatricesIndicesExtraKind
  29089. * * VertexBuffer.MatricesWeightsKind
  29090. * * VertexBuffer.MatricesWeightsExtraKind
  29091. * @param data defines the data source
  29092. * @param updatable defines if the data must be flagged as updatable (or static)
  29093. * @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
  29094. * @returns the current mesh
  29095. */
  29096. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29097. /**
  29098. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29099. * If the mesh has no geometry, it is simply returned as it is.
  29100. * @param kind defines vertex data kind:
  29101. * * VertexBuffer.PositionKind
  29102. * * VertexBuffer.UVKind
  29103. * * VertexBuffer.UV2Kind
  29104. * * VertexBuffer.UV3Kind
  29105. * * VertexBuffer.UV4Kind
  29106. * * VertexBuffer.UV5Kind
  29107. * * VertexBuffer.UV6Kind
  29108. * * VertexBuffer.ColorKind
  29109. * * VertexBuffer.MatricesIndicesKind
  29110. * * VertexBuffer.MatricesIndicesExtraKind
  29111. * * VertexBuffer.MatricesWeightsKind
  29112. * * VertexBuffer.MatricesWeightsExtraKind
  29113. * @param data defines the data source
  29114. * @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
  29115. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29116. * @returns the current mesh
  29117. */
  29118. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29119. /**
  29120. * Sets the mesh indices,
  29121. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29122. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29123. * @param totalVertices Defines the total number of vertices
  29124. * @returns the current mesh
  29125. */
  29126. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29127. /**
  29128. * Gets a boolean indicating if specific vertex data is present
  29129. * @param kind defines the vertex data kind to use
  29130. * @returns true is data kind is present
  29131. */
  29132. isVerticesDataPresent(kind: string): boolean;
  29133. /**
  29134. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29135. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29136. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29137. * @returns a BoundingInfo
  29138. */
  29139. getBoundingInfo(): BoundingInfo;
  29140. /**
  29141. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29142. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29143. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29144. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29145. * @returns the current mesh
  29146. */
  29147. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29148. /**
  29149. * Overwrite the current bounding info
  29150. * @param boundingInfo defines the new bounding info
  29151. * @returns the current mesh
  29152. */
  29153. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29154. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29155. get useBones(): boolean;
  29156. /** @hidden */
  29157. _preActivate(): void;
  29158. /** @hidden */
  29159. _preActivateForIntermediateRendering(renderId: number): void;
  29160. /** @hidden */
  29161. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29162. /** @hidden */
  29163. _postActivate(): void;
  29164. /** @hidden */
  29165. _freeze(): void;
  29166. /** @hidden */
  29167. _unFreeze(): void;
  29168. /**
  29169. * Gets the current world matrix
  29170. * @returns a Matrix
  29171. */
  29172. getWorldMatrix(): Matrix;
  29173. /** @hidden */
  29174. _getWorldMatrixDeterminant(): number;
  29175. /**
  29176. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29177. */
  29178. get isAnInstance(): boolean;
  29179. /**
  29180. * Gets a boolean indicating if this mesh has instances
  29181. */
  29182. get hasInstances(): boolean;
  29183. /**
  29184. * Perform relative position change from the point of view of behind the front of the mesh.
  29185. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29186. * Supports definition of mesh facing forward or backward
  29187. * @param amountRight defines the distance on the right axis
  29188. * @param amountUp defines the distance on the up axis
  29189. * @param amountForward defines the distance on the forward axis
  29190. * @returns the current mesh
  29191. */
  29192. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29193. /**
  29194. * Calculate relative position change from the point of view of behind the front of the mesh.
  29195. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29196. * Supports definition of mesh facing forward or backward
  29197. * @param amountRight defines the distance on the right axis
  29198. * @param amountUp defines the distance on the up axis
  29199. * @param amountForward defines the distance on the forward axis
  29200. * @returns the new displacement vector
  29201. */
  29202. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29203. /**
  29204. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29205. * Supports definition of mesh facing forward or backward
  29206. * @param flipBack defines the flip
  29207. * @param twirlClockwise defines the twirl
  29208. * @param tiltRight defines the tilt
  29209. * @returns the current mesh
  29210. */
  29211. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29212. /**
  29213. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29214. * Supports definition of mesh facing forward or backward.
  29215. * @param flipBack defines the flip
  29216. * @param twirlClockwise defines the twirl
  29217. * @param tiltRight defines the tilt
  29218. * @returns the new rotation vector
  29219. */
  29220. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29221. /**
  29222. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29223. * This means the mesh underlying bounding box and sphere are recomputed.
  29224. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29225. * @returns the current mesh
  29226. */
  29227. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29228. /** @hidden */
  29229. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29230. /** @hidden */
  29231. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29232. /** @hidden */
  29233. _updateBoundingInfo(): AbstractMesh;
  29234. /** @hidden */
  29235. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29236. /** @hidden */
  29237. protected _afterComputeWorldMatrix(): void;
  29238. /** @hidden */
  29239. get _effectiveMesh(): AbstractMesh;
  29240. /**
  29241. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29242. * A mesh is in the frustum if its bounding box intersects the frustum
  29243. * @param frustumPlanes defines the frustum to test
  29244. * @returns true if the mesh is in the frustum planes
  29245. */
  29246. isInFrustum(frustumPlanes: Plane[]): boolean;
  29247. /**
  29248. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29249. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29250. * @param frustumPlanes defines the frustum to test
  29251. * @returns true if the mesh is completely in the frustum planes
  29252. */
  29253. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29254. /**
  29255. * True if the mesh intersects another mesh or a SolidParticle object
  29256. * @param mesh defines a target mesh or SolidParticle to test
  29257. * @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)
  29258. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29259. * @returns true if there is an intersection
  29260. */
  29261. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29262. /**
  29263. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29264. * @param point defines the point to test
  29265. * @returns true if there is an intersection
  29266. */
  29267. intersectsPoint(point: Vector3): boolean;
  29268. /**
  29269. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29270. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29271. */
  29272. get checkCollisions(): boolean;
  29273. set checkCollisions(collisionEnabled: boolean);
  29274. /**
  29275. * Gets Collider object used to compute collisions (not physics)
  29276. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29277. */
  29278. get collider(): Nullable<Collider>;
  29279. /**
  29280. * Move the mesh using collision engine
  29281. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29282. * @param displacement defines the requested displacement vector
  29283. * @returns the current mesh
  29284. */
  29285. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29286. private _onCollisionPositionChange;
  29287. /** @hidden */
  29288. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29289. /** @hidden */
  29290. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29291. /** @hidden */
  29292. _checkCollision(collider: Collider): AbstractMesh;
  29293. /** @hidden */
  29294. _generatePointsArray(): boolean;
  29295. /**
  29296. * Checks if the passed Ray intersects with the mesh
  29297. * @param ray defines the ray to use
  29298. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29299. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29300. * @returns the picking info
  29301. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29302. */
  29303. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29304. /**
  29305. * Clones the current mesh
  29306. * @param name defines the mesh name
  29307. * @param newParent defines the new mesh parent
  29308. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29309. * @returns the new mesh
  29310. */
  29311. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29312. /**
  29313. * Disposes all the submeshes of the current meshnp
  29314. * @returns the current mesh
  29315. */
  29316. releaseSubMeshes(): AbstractMesh;
  29317. /**
  29318. * Releases resources associated with this abstract mesh.
  29319. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29320. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29321. */
  29322. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29323. /**
  29324. * Adds the passed mesh as a child to the current mesh
  29325. * @param mesh defines the child mesh
  29326. * @returns the current mesh
  29327. */
  29328. addChild(mesh: AbstractMesh): AbstractMesh;
  29329. /**
  29330. * Removes the passed mesh from the current mesh children list
  29331. * @param mesh defines the child mesh
  29332. * @returns the current mesh
  29333. */
  29334. removeChild(mesh: AbstractMesh): AbstractMesh;
  29335. /** @hidden */
  29336. private _initFacetData;
  29337. /**
  29338. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29339. * This method can be called within the render loop.
  29340. * 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
  29341. * @returns the current mesh
  29342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29343. */
  29344. updateFacetData(): AbstractMesh;
  29345. /**
  29346. * Returns the facetLocalNormals array.
  29347. * The normals are expressed in the mesh local spac
  29348. * @returns an array of Vector3
  29349. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29350. */
  29351. getFacetLocalNormals(): Vector3[];
  29352. /**
  29353. * Returns the facetLocalPositions array.
  29354. * The facet positions are expressed in the mesh local space
  29355. * @returns an array of Vector3
  29356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29357. */
  29358. getFacetLocalPositions(): Vector3[];
  29359. /**
  29360. * Returns the facetLocalPartioning array
  29361. * @returns an array of array of numbers
  29362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29363. */
  29364. getFacetLocalPartitioning(): number[][];
  29365. /**
  29366. * Returns the i-th facet position in the world system.
  29367. * This method allocates a new Vector3 per call
  29368. * @param i defines the facet index
  29369. * @returns a new Vector3
  29370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29371. */
  29372. getFacetPosition(i: number): Vector3;
  29373. /**
  29374. * Sets the reference Vector3 with the i-th facet position in the world system
  29375. * @param i defines the facet index
  29376. * @param ref defines the target vector
  29377. * @returns the current mesh
  29378. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29379. */
  29380. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29381. /**
  29382. * Returns the i-th facet normal in the world system.
  29383. * This method allocates a new Vector3 per call
  29384. * @param i defines the facet index
  29385. * @returns a new Vector3
  29386. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29387. */
  29388. getFacetNormal(i: number): Vector3;
  29389. /**
  29390. * Sets the reference Vector3 with the i-th facet normal in the world system
  29391. * @param i defines the facet index
  29392. * @param ref defines the target vector
  29393. * @returns the current mesh
  29394. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29395. */
  29396. getFacetNormalToRef(i: number, ref: Vector3): this;
  29397. /**
  29398. * 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)
  29399. * @param x defines x coordinate
  29400. * @param y defines y coordinate
  29401. * @param z defines z coordinate
  29402. * @returns the array of facet indexes
  29403. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29404. */
  29405. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29406. /**
  29407. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29408. * @param projected sets as the (x,y,z) world projection on the facet
  29409. * @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
  29410. * @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
  29411. * @param x defines x coordinate
  29412. * @param y defines y coordinate
  29413. * @param z defines z coordinate
  29414. * @returns the face index if found (or null instead)
  29415. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29416. */
  29417. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29418. /**
  29419. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29420. * @param projected sets as the (x,y,z) local projection on the facet
  29421. * @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
  29422. * @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
  29423. * @param x defines x coordinate
  29424. * @param y defines y coordinate
  29425. * @param z defines z coordinate
  29426. * @returns the face index if found (or null instead)
  29427. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29428. */
  29429. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29430. /**
  29431. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29432. * @returns the parameters
  29433. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29434. */
  29435. getFacetDataParameters(): any;
  29436. /**
  29437. * Disables the feature FacetData and frees the related memory
  29438. * @returns the current mesh
  29439. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29440. */
  29441. disableFacetData(): AbstractMesh;
  29442. /**
  29443. * Updates the AbstractMesh indices array
  29444. * @param indices defines the data source
  29445. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29446. * @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)
  29447. * @returns the current mesh
  29448. */
  29449. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29450. /**
  29451. * Creates new normals data for the mesh
  29452. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29453. * @returns the current mesh
  29454. */
  29455. createNormals(updatable: boolean): AbstractMesh;
  29456. /**
  29457. * Align the mesh with a normal
  29458. * @param normal defines the normal to use
  29459. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29460. * @returns the current mesh
  29461. */
  29462. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29463. /** @hidden */
  29464. _checkOcclusionQuery(): boolean;
  29465. /**
  29466. * Disables the mesh edge rendering mode
  29467. * @returns the currentAbstractMesh
  29468. */
  29469. disableEdgesRendering(): AbstractMesh;
  29470. /**
  29471. * Enables the edge rendering mode on the mesh.
  29472. * This mode makes the mesh edges visible
  29473. * @param epsilon defines the maximal distance between two angles to detect a face
  29474. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29475. * @returns the currentAbstractMesh
  29476. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29477. */
  29478. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29479. }
  29480. }
  29481. declare module "babylonjs/Actions/actionEvent" {
  29482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29483. import { Nullable } from "babylonjs/types";
  29484. import { Sprite } from "babylonjs/Sprites/sprite";
  29485. import { Scene } from "babylonjs/scene";
  29486. import { Vector2 } from "babylonjs/Maths/math.vector";
  29487. /**
  29488. * Interface used to define ActionEvent
  29489. */
  29490. export interface IActionEvent {
  29491. /** The mesh or sprite that triggered the action */
  29492. source: any;
  29493. /** The X mouse cursor position at the time of the event */
  29494. pointerX: number;
  29495. /** The Y mouse cursor position at the time of the event */
  29496. pointerY: number;
  29497. /** The mesh that is currently pointed at (can be null) */
  29498. meshUnderPointer: Nullable<AbstractMesh>;
  29499. /** the original (browser) event that triggered the ActionEvent */
  29500. sourceEvent?: any;
  29501. /** additional data for the event */
  29502. additionalData?: any;
  29503. }
  29504. /**
  29505. * ActionEvent is the event being sent when an action is triggered.
  29506. */
  29507. export class ActionEvent implements IActionEvent {
  29508. /** The mesh or sprite that triggered the action */
  29509. source: any;
  29510. /** The X mouse cursor position at the time of the event */
  29511. pointerX: number;
  29512. /** The Y mouse cursor position at the time of the event */
  29513. pointerY: number;
  29514. /** The mesh that is currently pointed at (can be null) */
  29515. meshUnderPointer: Nullable<AbstractMesh>;
  29516. /** the original (browser) event that triggered the ActionEvent */
  29517. sourceEvent?: any;
  29518. /** additional data for the event */
  29519. additionalData?: any;
  29520. /**
  29521. * Creates a new ActionEvent
  29522. * @param source The mesh or sprite that triggered the action
  29523. * @param pointerX The X mouse cursor position at the time of the event
  29524. * @param pointerY The Y mouse cursor position at the time of the event
  29525. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29526. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29527. * @param additionalData additional data for the event
  29528. */
  29529. constructor(
  29530. /** The mesh or sprite that triggered the action */
  29531. source: any,
  29532. /** The X mouse cursor position at the time of the event */
  29533. pointerX: number,
  29534. /** The Y mouse cursor position at the time of the event */
  29535. pointerY: number,
  29536. /** The mesh that is currently pointed at (can be null) */
  29537. meshUnderPointer: Nullable<AbstractMesh>,
  29538. /** the original (browser) event that triggered the ActionEvent */
  29539. sourceEvent?: any,
  29540. /** additional data for the event */
  29541. additionalData?: any);
  29542. /**
  29543. * Helper function to auto-create an ActionEvent from a source mesh.
  29544. * @param source The source mesh that triggered the event
  29545. * @param evt The original (browser) event
  29546. * @param additionalData additional data for the event
  29547. * @returns the new ActionEvent
  29548. */
  29549. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29550. /**
  29551. * Helper function to auto-create an ActionEvent from a source sprite
  29552. * @param source The source sprite that triggered the event
  29553. * @param scene Scene associated with the sprite
  29554. * @param evt The original (browser) event
  29555. * @param additionalData additional data for the event
  29556. * @returns the new ActionEvent
  29557. */
  29558. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29559. /**
  29560. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29561. * @param scene the scene where the event occurred
  29562. * @param evt The original (browser) event
  29563. * @returns the new ActionEvent
  29564. */
  29565. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29566. /**
  29567. * Helper function to auto-create an ActionEvent from a primitive
  29568. * @param prim defines the target primitive
  29569. * @param pointerPos defines the pointer position
  29570. * @param evt The original (browser) event
  29571. * @param additionalData additional data for the event
  29572. * @returns the new ActionEvent
  29573. */
  29574. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29575. }
  29576. }
  29577. declare module "babylonjs/Actions/abstractActionManager" {
  29578. import { IDisposable } from "babylonjs/scene";
  29579. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29580. import { IAction } from "babylonjs/Actions/action";
  29581. import { Nullable } from "babylonjs/types";
  29582. /**
  29583. * Abstract class used to decouple action Manager from scene and meshes.
  29584. * Do not instantiate.
  29585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29586. */
  29587. export abstract class AbstractActionManager implements IDisposable {
  29588. /** Gets the list of active triggers */
  29589. static Triggers: {
  29590. [key: string]: number;
  29591. };
  29592. /** Gets the cursor to use when hovering items */
  29593. hoverCursor: string;
  29594. /** Gets the list of actions */
  29595. actions: IAction[];
  29596. /**
  29597. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29598. */
  29599. isRecursive: boolean;
  29600. /**
  29601. * Releases all associated resources
  29602. */
  29603. abstract dispose(): void;
  29604. /**
  29605. * Does this action manager has pointer triggers
  29606. */
  29607. abstract get hasPointerTriggers(): boolean;
  29608. /**
  29609. * Does this action manager has pick triggers
  29610. */
  29611. abstract get hasPickTriggers(): boolean;
  29612. /**
  29613. * Process a specific trigger
  29614. * @param trigger defines the trigger to process
  29615. * @param evt defines the event details to be processed
  29616. */
  29617. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29618. /**
  29619. * Does this action manager handles actions of any of the given triggers
  29620. * @param triggers defines the triggers to be tested
  29621. * @return a boolean indicating whether one (or more) of the triggers is handled
  29622. */
  29623. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29624. /**
  29625. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29626. * speed.
  29627. * @param triggerA defines the trigger to be tested
  29628. * @param triggerB defines the trigger to be tested
  29629. * @return a boolean indicating whether one (or more) of the triggers is handled
  29630. */
  29631. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29632. /**
  29633. * Does this action manager handles actions of a given trigger
  29634. * @param trigger defines the trigger to be tested
  29635. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29636. * @return whether the trigger is handled
  29637. */
  29638. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29639. /**
  29640. * Serialize this manager to a JSON object
  29641. * @param name defines the property name to store this manager
  29642. * @returns a JSON representation of this manager
  29643. */
  29644. abstract serialize(name: string): any;
  29645. /**
  29646. * Registers an action to this action manager
  29647. * @param action defines the action to be registered
  29648. * @return the action amended (prepared) after registration
  29649. */
  29650. abstract registerAction(action: IAction): Nullable<IAction>;
  29651. /**
  29652. * Unregisters an action to this action manager
  29653. * @param action defines the action to be unregistered
  29654. * @return a boolean indicating whether the action has been unregistered
  29655. */
  29656. abstract unregisterAction(action: IAction): Boolean;
  29657. /**
  29658. * Does exist one action manager with at least one trigger
  29659. **/
  29660. static get HasTriggers(): boolean;
  29661. /**
  29662. * Does exist one action manager with at least one pick trigger
  29663. **/
  29664. static get HasPickTriggers(): boolean;
  29665. /**
  29666. * Does exist one action manager that handles actions of a given trigger
  29667. * @param trigger defines the trigger to be tested
  29668. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29669. **/
  29670. static HasSpecificTrigger(trigger: number): boolean;
  29671. }
  29672. }
  29673. declare module "babylonjs/node" {
  29674. import { Scene } from "babylonjs/scene";
  29675. import { Nullable } from "babylonjs/types";
  29676. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29677. import { Engine } from "babylonjs/Engines/engine";
  29678. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29679. import { Observable } from "babylonjs/Misc/observable";
  29680. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29681. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29682. import { Animatable } from "babylonjs/Animations/animatable";
  29683. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29684. import { Animation } from "babylonjs/Animations/animation";
  29685. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29687. /**
  29688. * Defines how a node can be built from a string name.
  29689. */
  29690. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29691. /**
  29692. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29693. */
  29694. export class Node implements IBehaviorAware<Node> {
  29695. /** @hidden */
  29696. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29697. private static _NodeConstructors;
  29698. /**
  29699. * Add a new node constructor
  29700. * @param type defines the type name of the node to construct
  29701. * @param constructorFunc defines the constructor function
  29702. */
  29703. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29704. /**
  29705. * Returns a node constructor based on type name
  29706. * @param type defines the type name
  29707. * @param name defines the new node name
  29708. * @param scene defines the hosting scene
  29709. * @param options defines optional options to transmit to constructors
  29710. * @returns the new constructor or null
  29711. */
  29712. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29713. /**
  29714. * Gets or sets the name of the node
  29715. */
  29716. name: string;
  29717. /**
  29718. * Gets or sets the id of the node
  29719. */
  29720. id: string;
  29721. /**
  29722. * Gets or sets the unique id of the node
  29723. */
  29724. uniqueId: number;
  29725. /**
  29726. * Gets or sets a string used to store user defined state for the node
  29727. */
  29728. state: string;
  29729. /**
  29730. * Gets or sets an object used to store user defined information for the node
  29731. */
  29732. metadata: any;
  29733. /**
  29734. * For internal use only. Please do not use.
  29735. */
  29736. reservedDataStore: any;
  29737. /**
  29738. * List of inspectable custom properties (used by the Inspector)
  29739. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29740. */
  29741. inspectableCustomProperties: IInspectable[];
  29742. private _doNotSerialize;
  29743. /**
  29744. * Gets or sets a boolean used to define if the node must be serialized
  29745. */
  29746. get doNotSerialize(): boolean;
  29747. set doNotSerialize(value: boolean);
  29748. /** @hidden */
  29749. _isDisposed: boolean;
  29750. /**
  29751. * Gets a list of Animations associated with the node
  29752. */
  29753. animations: import("babylonjs/Animations/animation").Animation[];
  29754. protected _ranges: {
  29755. [name: string]: Nullable<AnimationRange>;
  29756. };
  29757. /**
  29758. * Callback raised when the node is ready to be used
  29759. */
  29760. onReady: Nullable<(node: Node) => void>;
  29761. private _isEnabled;
  29762. private _isParentEnabled;
  29763. private _isReady;
  29764. /** @hidden */
  29765. _currentRenderId: number;
  29766. private _parentUpdateId;
  29767. /** @hidden */
  29768. _childUpdateId: number;
  29769. /** @hidden */
  29770. _waitingParentId: Nullable<string>;
  29771. /** @hidden */
  29772. _scene: Scene;
  29773. /** @hidden */
  29774. _cache: any;
  29775. private _parentNode;
  29776. private _children;
  29777. /** @hidden */
  29778. _worldMatrix: Matrix;
  29779. /** @hidden */
  29780. _worldMatrixDeterminant: number;
  29781. /** @hidden */
  29782. _worldMatrixDeterminantIsDirty: boolean;
  29783. /** @hidden */
  29784. private _sceneRootNodesIndex;
  29785. /**
  29786. * Gets a boolean indicating if the node has been disposed
  29787. * @returns true if the node was disposed
  29788. */
  29789. isDisposed(): boolean;
  29790. /**
  29791. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29792. * @see https://doc.babylonjs.com/how_to/parenting
  29793. */
  29794. set parent(parent: Nullable<Node>);
  29795. get parent(): Nullable<Node>;
  29796. /** @hidden */
  29797. _addToSceneRootNodes(): void;
  29798. /** @hidden */
  29799. _removeFromSceneRootNodes(): void;
  29800. private _animationPropertiesOverride;
  29801. /**
  29802. * Gets or sets the animation properties override
  29803. */
  29804. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29805. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29806. /**
  29807. * Gets a string idenfifying the name of the class
  29808. * @returns "Node" string
  29809. */
  29810. getClassName(): string;
  29811. /** @hidden */
  29812. readonly _isNode: boolean;
  29813. /**
  29814. * An event triggered when the mesh is disposed
  29815. */
  29816. onDisposeObservable: Observable<Node>;
  29817. private _onDisposeObserver;
  29818. /**
  29819. * Sets a callback that will be raised when the node will be disposed
  29820. */
  29821. set onDispose(callback: () => void);
  29822. /**
  29823. * Creates a new Node
  29824. * @param name the name and id to be given to this node
  29825. * @param scene the scene this node will be added to
  29826. */
  29827. constructor(name: string, scene?: Nullable<Scene>);
  29828. /**
  29829. * Gets the scene of the node
  29830. * @returns a scene
  29831. */
  29832. getScene(): Scene;
  29833. /**
  29834. * Gets the engine of the node
  29835. * @returns a Engine
  29836. */
  29837. getEngine(): Engine;
  29838. private _behaviors;
  29839. /**
  29840. * Attach a behavior to the node
  29841. * @see http://doc.babylonjs.com/features/behaviour
  29842. * @param behavior defines the behavior to attach
  29843. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29844. * @returns the current Node
  29845. */
  29846. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29847. /**
  29848. * Remove an attached behavior
  29849. * @see http://doc.babylonjs.com/features/behaviour
  29850. * @param behavior defines the behavior to attach
  29851. * @returns the current Node
  29852. */
  29853. removeBehavior(behavior: Behavior<Node>): Node;
  29854. /**
  29855. * Gets the list of attached behaviors
  29856. * @see http://doc.babylonjs.com/features/behaviour
  29857. */
  29858. get behaviors(): Behavior<Node>[];
  29859. /**
  29860. * Gets an attached behavior by name
  29861. * @param name defines the name of the behavior to look for
  29862. * @see http://doc.babylonjs.com/features/behaviour
  29863. * @returns null if behavior was not found else the requested behavior
  29864. */
  29865. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29866. /**
  29867. * Returns the latest update of the World matrix
  29868. * @returns a Matrix
  29869. */
  29870. getWorldMatrix(): Matrix;
  29871. /** @hidden */
  29872. _getWorldMatrixDeterminant(): number;
  29873. /**
  29874. * Returns directly the latest state of the mesh World matrix.
  29875. * A Matrix is returned.
  29876. */
  29877. get worldMatrixFromCache(): Matrix;
  29878. /** @hidden */
  29879. _initCache(): void;
  29880. /** @hidden */
  29881. updateCache(force?: boolean): void;
  29882. /** @hidden */
  29883. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29884. /** @hidden */
  29885. _updateCache(ignoreParentClass?: boolean): void;
  29886. /** @hidden */
  29887. _isSynchronized(): boolean;
  29888. /** @hidden */
  29889. _markSyncedWithParent(): void;
  29890. /** @hidden */
  29891. isSynchronizedWithParent(): boolean;
  29892. /** @hidden */
  29893. isSynchronized(): boolean;
  29894. /**
  29895. * Is this node ready to be used/rendered
  29896. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29897. * @return true if the node is ready
  29898. */
  29899. isReady(completeCheck?: boolean): boolean;
  29900. /**
  29901. * Is this node enabled?
  29902. * 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
  29903. * @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
  29904. * @return whether this node (and its parent) is enabled
  29905. */
  29906. isEnabled(checkAncestors?: boolean): boolean;
  29907. /** @hidden */
  29908. protected _syncParentEnabledState(): void;
  29909. /**
  29910. * Set the enabled state of this node
  29911. * @param value defines the new enabled state
  29912. */
  29913. setEnabled(value: boolean): void;
  29914. /**
  29915. * Is this node a descendant of the given node?
  29916. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29917. * @param ancestor defines the parent node to inspect
  29918. * @returns a boolean indicating if this node is a descendant of the given node
  29919. */
  29920. isDescendantOf(ancestor: Node): boolean;
  29921. /** @hidden */
  29922. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29923. /**
  29924. * Will return all nodes that have this node as ascendant
  29925. * @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
  29926. * @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
  29927. * @return all children nodes of all types
  29928. */
  29929. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29930. /**
  29931. * Get all child-meshes of this node
  29932. * @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)
  29933. * @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
  29934. * @returns an array of AbstractMesh
  29935. */
  29936. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29937. /**
  29938. * Get all direct children of this node
  29939. * @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
  29940. * @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)
  29941. * @returns an array of Node
  29942. */
  29943. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29944. /** @hidden */
  29945. _setReady(state: boolean): void;
  29946. /**
  29947. * Get an animation by name
  29948. * @param name defines the name of the animation to look for
  29949. * @returns null if not found else the requested animation
  29950. */
  29951. getAnimationByName(name: string): Nullable<Animation>;
  29952. /**
  29953. * Creates an animation range for this node
  29954. * @param name defines the name of the range
  29955. * @param from defines the starting key
  29956. * @param to defines the end key
  29957. */
  29958. createAnimationRange(name: string, from: number, to: number): void;
  29959. /**
  29960. * Delete a specific animation range
  29961. * @param name defines the name of the range to delete
  29962. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29963. */
  29964. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29965. /**
  29966. * Get an animation range by name
  29967. * @param name defines the name of the animation range to look for
  29968. * @returns null if not found else the requested animation range
  29969. */
  29970. getAnimationRange(name: string): Nullable<AnimationRange>;
  29971. /**
  29972. * Gets the list of all animation ranges defined on this node
  29973. * @returns an array
  29974. */
  29975. getAnimationRanges(): Nullable<AnimationRange>[];
  29976. /**
  29977. * Will start the animation sequence
  29978. * @param name defines the range frames for animation sequence
  29979. * @param loop defines if the animation should loop (false by default)
  29980. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29981. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29982. * @returns the object created for this animation. If range does not exist, it will return null
  29983. */
  29984. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29985. /**
  29986. * Serialize animation ranges into a JSON compatible object
  29987. * @returns serialization object
  29988. */
  29989. serializeAnimationRanges(): any;
  29990. /**
  29991. * Computes the world matrix of the node
  29992. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29993. * @returns the world matrix
  29994. */
  29995. computeWorldMatrix(force?: boolean): Matrix;
  29996. /**
  29997. * Releases resources associated with this node.
  29998. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29999. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30000. */
  30001. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30002. /**
  30003. * Parse animation range data from a serialization object and store them into a given node
  30004. * @param node defines where to store the animation ranges
  30005. * @param parsedNode defines the serialization object to read data from
  30006. * @param scene defines the hosting scene
  30007. */
  30008. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30009. /**
  30010. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30011. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30012. * @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
  30013. * @returns the new bounding vectors
  30014. */
  30015. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30016. min: Vector3;
  30017. max: Vector3;
  30018. };
  30019. }
  30020. }
  30021. declare module "babylonjs/Animations/animation" {
  30022. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30023. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30024. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30025. import { Nullable } from "babylonjs/types";
  30026. import { Scene } from "babylonjs/scene";
  30027. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30028. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30029. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30030. import { Node } from "babylonjs/node";
  30031. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30032. import { Size } from "babylonjs/Maths/math.size";
  30033. import { Animatable } from "babylonjs/Animations/animatable";
  30034. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30035. /**
  30036. * @hidden
  30037. */
  30038. export class _IAnimationState {
  30039. key: number;
  30040. repeatCount: number;
  30041. workValue?: any;
  30042. loopMode?: number;
  30043. offsetValue?: any;
  30044. highLimitValue?: any;
  30045. }
  30046. /**
  30047. * Class used to store any kind of animation
  30048. */
  30049. export class Animation {
  30050. /**Name of the animation */
  30051. name: string;
  30052. /**Property to animate */
  30053. targetProperty: string;
  30054. /**The frames per second of the animation */
  30055. framePerSecond: number;
  30056. /**The data type of the animation */
  30057. dataType: number;
  30058. /**The loop mode of the animation */
  30059. loopMode?: number | undefined;
  30060. /**Specifies if blending should be enabled */
  30061. enableBlending?: boolean | undefined;
  30062. /**
  30063. * Use matrix interpolation instead of using direct key value when animating matrices
  30064. */
  30065. static AllowMatricesInterpolation: boolean;
  30066. /**
  30067. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30068. */
  30069. static AllowMatrixDecomposeForInterpolation: boolean;
  30070. /**
  30071. * Stores the key frames of the animation
  30072. */
  30073. private _keys;
  30074. /**
  30075. * Stores the easing function of the animation
  30076. */
  30077. private _easingFunction;
  30078. /**
  30079. * @hidden Internal use only
  30080. */
  30081. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30082. /**
  30083. * The set of event that will be linked to this animation
  30084. */
  30085. private _events;
  30086. /**
  30087. * Stores an array of target property paths
  30088. */
  30089. targetPropertyPath: string[];
  30090. /**
  30091. * Stores the blending speed of the animation
  30092. */
  30093. blendingSpeed: number;
  30094. /**
  30095. * Stores the animation ranges for the animation
  30096. */
  30097. private _ranges;
  30098. /**
  30099. * @hidden Internal use
  30100. */
  30101. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30102. /**
  30103. * Sets up an animation
  30104. * @param property The property to animate
  30105. * @param animationType The animation type to apply
  30106. * @param framePerSecond The frames per second of the animation
  30107. * @param easingFunction The easing function used in the animation
  30108. * @returns The created animation
  30109. */
  30110. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30111. /**
  30112. * Create and start an animation on a node
  30113. * @param name defines the name of the global animation that will be run on all nodes
  30114. * @param node defines the root node where the animation will take place
  30115. * @param targetProperty defines property to animate
  30116. * @param framePerSecond defines the number of frame per second yo use
  30117. * @param totalFrame defines the number of frames in total
  30118. * @param from defines the initial value
  30119. * @param to defines the final value
  30120. * @param loopMode defines which loop mode you want to use (off by default)
  30121. * @param easingFunction defines the easing function to use (linear by default)
  30122. * @param onAnimationEnd defines the callback to call when animation end
  30123. * @returns the animatable created for this animation
  30124. */
  30125. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30126. /**
  30127. * Create and start an animation on a node and its descendants
  30128. * @param name defines the name of the global animation that will be run on all nodes
  30129. * @param node defines the root node where the animation will take place
  30130. * @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
  30131. * @param targetProperty defines property to animate
  30132. * @param framePerSecond defines the number of frame per second to use
  30133. * @param totalFrame defines the number of frames in total
  30134. * @param from defines the initial value
  30135. * @param to defines the final value
  30136. * @param loopMode defines which loop mode you want to use (off by default)
  30137. * @param easingFunction defines the easing function to use (linear by default)
  30138. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30139. * @returns the list of animatables created for all nodes
  30140. * @example https://www.babylonjs-playground.com/#MH0VLI
  30141. */
  30142. 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[]>;
  30143. /**
  30144. * Creates a new animation, merges it with the existing animations and starts it
  30145. * @param name Name of the animation
  30146. * @param node Node which contains the scene that begins the animations
  30147. * @param targetProperty Specifies which property to animate
  30148. * @param framePerSecond The frames per second of the animation
  30149. * @param totalFrame The total number of frames
  30150. * @param from The frame at the beginning of the animation
  30151. * @param to The frame at the end of the animation
  30152. * @param loopMode Specifies the loop mode of the animation
  30153. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30154. * @param onAnimationEnd Callback to run once the animation is complete
  30155. * @returns Nullable animation
  30156. */
  30157. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30158. /**
  30159. * Transition property of an host to the target Value
  30160. * @param property The property to transition
  30161. * @param targetValue The target Value of the property
  30162. * @param host The object where the property to animate belongs
  30163. * @param scene Scene used to run the animation
  30164. * @param frameRate Framerate (in frame/s) to use
  30165. * @param transition The transition type we want to use
  30166. * @param duration The duration of the animation, in milliseconds
  30167. * @param onAnimationEnd Callback trigger at the end of the animation
  30168. * @returns Nullable animation
  30169. */
  30170. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30171. /**
  30172. * Return the array of runtime animations currently using this animation
  30173. */
  30174. get runtimeAnimations(): RuntimeAnimation[];
  30175. /**
  30176. * Specifies if any of the runtime animations are currently running
  30177. */
  30178. get hasRunningRuntimeAnimations(): boolean;
  30179. /**
  30180. * Initializes the animation
  30181. * @param name Name of the animation
  30182. * @param targetProperty Property to animate
  30183. * @param framePerSecond The frames per second of the animation
  30184. * @param dataType The data type of the animation
  30185. * @param loopMode The loop mode of the animation
  30186. * @param enableBlending Specifies if blending should be enabled
  30187. */
  30188. constructor(
  30189. /**Name of the animation */
  30190. name: string,
  30191. /**Property to animate */
  30192. targetProperty: string,
  30193. /**The frames per second of the animation */
  30194. framePerSecond: number,
  30195. /**The data type of the animation */
  30196. dataType: number,
  30197. /**The loop mode of the animation */
  30198. loopMode?: number | undefined,
  30199. /**Specifies if blending should be enabled */
  30200. enableBlending?: boolean | undefined);
  30201. /**
  30202. * Converts the animation to a string
  30203. * @param fullDetails support for multiple levels of logging within scene loading
  30204. * @returns String form of the animation
  30205. */
  30206. toString(fullDetails?: boolean): string;
  30207. /**
  30208. * Add an event to this animation
  30209. * @param event Event to add
  30210. */
  30211. addEvent(event: AnimationEvent): void;
  30212. /**
  30213. * Remove all events found at the given frame
  30214. * @param frame The frame to remove events from
  30215. */
  30216. removeEvents(frame: number): void;
  30217. /**
  30218. * Retrieves all the events from the animation
  30219. * @returns Events from the animation
  30220. */
  30221. getEvents(): AnimationEvent[];
  30222. /**
  30223. * Creates an animation range
  30224. * @param name Name of the animation range
  30225. * @param from Starting frame of the animation range
  30226. * @param to Ending frame of the animation
  30227. */
  30228. createRange(name: string, from: number, to: number): void;
  30229. /**
  30230. * Deletes an animation range by name
  30231. * @param name Name of the animation range to delete
  30232. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30233. */
  30234. deleteRange(name: string, deleteFrames?: boolean): void;
  30235. /**
  30236. * Gets the animation range by name, or null if not defined
  30237. * @param name Name of the animation range
  30238. * @returns Nullable animation range
  30239. */
  30240. getRange(name: string): Nullable<AnimationRange>;
  30241. /**
  30242. * Gets the key frames from the animation
  30243. * @returns The key frames of the animation
  30244. */
  30245. getKeys(): Array<IAnimationKey>;
  30246. /**
  30247. * Gets the highest frame rate of the animation
  30248. * @returns Highest frame rate of the animation
  30249. */
  30250. getHighestFrame(): number;
  30251. /**
  30252. * Gets the easing function of the animation
  30253. * @returns Easing function of the animation
  30254. */
  30255. getEasingFunction(): IEasingFunction;
  30256. /**
  30257. * Sets the easing function of the animation
  30258. * @param easingFunction A custom mathematical formula for animation
  30259. */
  30260. setEasingFunction(easingFunction: EasingFunction): void;
  30261. /**
  30262. * Interpolates a scalar linearly
  30263. * @param startValue Start value of the animation curve
  30264. * @param endValue End value of the animation curve
  30265. * @param gradient Scalar amount to interpolate
  30266. * @returns Interpolated scalar value
  30267. */
  30268. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30269. /**
  30270. * Interpolates a scalar cubically
  30271. * @param startValue Start value of the animation curve
  30272. * @param outTangent End tangent of the animation
  30273. * @param endValue End value of the animation curve
  30274. * @param inTangent Start tangent of the animation curve
  30275. * @param gradient Scalar amount to interpolate
  30276. * @returns Interpolated scalar value
  30277. */
  30278. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30279. /**
  30280. * Interpolates a quaternion using a spherical linear interpolation
  30281. * @param startValue Start value of the animation curve
  30282. * @param endValue End value of the animation curve
  30283. * @param gradient Scalar amount to interpolate
  30284. * @returns Interpolated quaternion value
  30285. */
  30286. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30287. /**
  30288. * Interpolates a quaternion cubically
  30289. * @param startValue Start value of the animation curve
  30290. * @param outTangent End tangent of the animation curve
  30291. * @param endValue End value of the animation curve
  30292. * @param inTangent Start tangent of the animation curve
  30293. * @param gradient Scalar amount to interpolate
  30294. * @returns Interpolated quaternion value
  30295. */
  30296. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30297. /**
  30298. * Interpolates a Vector3 linearl
  30299. * @param startValue Start value of the animation curve
  30300. * @param endValue End value of the animation curve
  30301. * @param gradient Scalar amount to interpolate
  30302. * @returns Interpolated scalar value
  30303. */
  30304. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30305. /**
  30306. * Interpolates a Vector3 cubically
  30307. * @param startValue Start value of the animation curve
  30308. * @param outTangent End tangent of the animation
  30309. * @param endValue End value of the animation curve
  30310. * @param inTangent Start tangent of the animation curve
  30311. * @param gradient Scalar amount to interpolate
  30312. * @returns InterpolatedVector3 value
  30313. */
  30314. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30315. /**
  30316. * Interpolates a Vector2 linearly
  30317. * @param startValue Start value of the animation curve
  30318. * @param endValue End value of the animation curve
  30319. * @param gradient Scalar amount to interpolate
  30320. * @returns Interpolated Vector2 value
  30321. */
  30322. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30323. /**
  30324. * Interpolates a Vector2 cubically
  30325. * @param startValue Start value of the animation curve
  30326. * @param outTangent End tangent of the animation
  30327. * @param endValue End value of the animation curve
  30328. * @param inTangent Start tangent of the animation curve
  30329. * @param gradient Scalar amount to interpolate
  30330. * @returns Interpolated Vector2 value
  30331. */
  30332. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30333. /**
  30334. * Interpolates a size linearly
  30335. * @param startValue Start value of the animation curve
  30336. * @param endValue End value of the animation curve
  30337. * @param gradient Scalar amount to interpolate
  30338. * @returns Interpolated Size value
  30339. */
  30340. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30341. /**
  30342. * Interpolates a Color3 linearly
  30343. * @param startValue Start value of the animation curve
  30344. * @param endValue End value of the animation curve
  30345. * @param gradient Scalar amount to interpolate
  30346. * @returns Interpolated Color3 value
  30347. */
  30348. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30349. /**
  30350. * Interpolates a Color4 linearly
  30351. * @param startValue Start value of the animation curve
  30352. * @param endValue End value of the animation curve
  30353. * @param gradient Scalar amount to interpolate
  30354. * @returns Interpolated Color3 value
  30355. */
  30356. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30357. /**
  30358. * @hidden Internal use only
  30359. */
  30360. _getKeyValue(value: any): any;
  30361. /**
  30362. * @hidden Internal use only
  30363. */
  30364. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30365. /**
  30366. * Defines the function to use to interpolate matrices
  30367. * @param startValue defines the start matrix
  30368. * @param endValue defines the end matrix
  30369. * @param gradient defines the gradient between both matrices
  30370. * @param result defines an optional target matrix where to store the interpolation
  30371. * @returns the interpolated matrix
  30372. */
  30373. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30374. /**
  30375. * Makes a copy of the animation
  30376. * @returns Cloned animation
  30377. */
  30378. clone(): Animation;
  30379. /**
  30380. * Sets the key frames of the animation
  30381. * @param values The animation key frames to set
  30382. */
  30383. setKeys(values: Array<IAnimationKey>): void;
  30384. /**
  30385. * Serializes the animation to an object
  30386. * @returns Serialized object
  30387. */
  30388. serialize(): any;
  30389. /**
  30390. * Float animation type
  30391. */
  30392. static readonly ANIMATIONTYPE_FLOAT: number;
  30393. /**
  30394. * Vector3 animation type
  30395. */
  30396. static readonly ANIMATIONTYPE_VECTOR3: number;
  30397. /**
  30398. * Quaternion animation type
  30399. */
  30400. static readonly ANIMATIONTYPE_QUATERNION: number;
  30401. /**
  30402. * Matrix animation type
  30403. */
  30404. static readonly ANIMATIONTYPE_MATRIX: number;
  30405. /**
  30406. * Color3 animation type
  30407. */
  30408. static readonly ANIMATIONTYPE_COLOR3: number;
  30409. /**
  30410. * Color3 animation type
  30411. */
  30412. static readonly ANIMATIONTYPE_COLOR4: number;
  30413. /**
  30414. * Vector2 animation type
  30415. */
  30416. static readonly ANIMATIONTYPE_VECTOR2: number;
  30417. /**
  30418. * Size animation type
  30419. */
  30420. static readonly ANIMATIONTYPE_SIZE: number;
  30421. /**
  30422. * Relative Loop Mode
  30423. */
  30424. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30425. /**
  30426. * Cycle Loop Mode
  30427. */
  30428. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30429. /**
  30430. * Constant Loop Mode
  30431. */
  30432. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30433. /** @hidden */
  30434. static _UniversalLerp(left: any, right: any, amount: number): any;
  30435. /**
  30436. * Parses an animation object and creates an animation
  30437. * @param parsedAnimation Parsed animation object
  30438. * @returns Animation object
  30439. */
  30440. static Parse(parsedAnimation: any): Animation;
  30441. /**
  30442. * Appends the serialized animations from the source animations
  30443. * @param source Source containing the animations
  30444. * @param destination Target to store the animations
  30445. */
  30446. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30447. }
  30448. }
  30449. declare module "babylonjs/Animations/animatable.interface" {
  30450. import { Nullable } from "babylonjs/types";
  30451. import { Animation } from "babylonjs/Animations/animation";
  30452. /**
  30453. * Interface containing an array of animations
  30454. */
  30455. export interface IAnimatable {
  30456. /**
  30457. * Array of animations
  30458. */
  30459. animations: Nullable<Array<Animation>>;
  30460. }
  30461. }
  30462. declare module "babylonjs/Misc/decorators" {
  30463. import { Nullable } from "babylonjs/types";
  30464. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30465. import { Scene } from "babylonjs/scene";
  30466. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30467. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30468. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30469. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30470. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30471. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30472. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30473. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30474. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30475. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30476. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30477. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30478. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30479. /**
  30480. * Decorator used to define property that can be serialized as reference to a camera
  30481. * @param sourceName defines the name of the property to decorate
  30482. */
  30483. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30484. /**
  30485. * Class used to help serialization objects
  30486. */
  30487. export class SerializationHelper {
  30488. /** @hidden */
  30489. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30490. /** @hidden */
  30491. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30492. /** @hidden */
  30493. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30494. /** @hidden */
  30495. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30496. /**
  30497. * Appends the serialized animations from the source animations
  30498. * @param source Source containing the animations
  30499. * @param destination Target to store the animations
  30500. */
  30501. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30502. /**
  30503. * Static function used to serialized a specific entity
  30504. * @param entity defines the entity to serialize
  30505. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30506. * @returns a JSON compatible object representing the serialization of the entity
  30507. */
  30508. static Serialize<T>(entity: T, serializationObject?: any): any;
  30509. /**
  30510. * Creates a new entity from a serialization data object
  30511. * @param creationFunction defines a function used to instanciated the new entity
  30512. * @param source defines the source serialization data
  30513. * @param scene defines the hosting scene
  30514. * @param rootUrl defines the root url for resources
  30515. * @returns a new entity
  30516. */
  30517. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30518. /**
  30519. * Clones an object
  30520. * @param creationFunction defines the function used to instanciate the new object
  30521. * @param source defines the source object
  30522. * @returns the cloned object
  30523. */
  30524. static Clone<T>(creationFunction: () => T, source: T): T;
  30525. /**
  30526. * Instanciates a new object based on a source one (some data will be shared between both object)
  30527. * @param creationFunction defines the function used to instanciate the new object
  30528. * @param source defines the source object
  30529. * @returns the new object
  30530. */
  30531. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30532. }
  30533. }
  30534. declare module "babylonjs/Misc/guid" {
  30535. /**
  30536. * Class used to manipulate GUIDs
  30537. */
  30538. export class GUID {
  30539. /**
  30540. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30541. * Be aware Math.random() could cause collisions, but:
  30542. * "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"
  30543. * @returns a pseudo random id
  30544. */
  30545. static RandomId(): string;
  30546. }
  30547. }
  30548. declare module "babylonjs/Materials/Textures/baseTexture" {
  30549. import { Observable } from "babylonjs/Misc/observable";
  30550. import { Nullable } from "babylonjs/types";
  30551. import { Scene } from "babylonjs/scene";
  30552. import { Matrix } from "babylonjs/Maths/math.vector";
  30553. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30554. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30555. import { ISize } from "babylonjs/Maths/math.size";
  30556. import "babylonjs/Misc/fileTools";
  30557. /**
  30558. * Base class of all the textures in babylon.
  30559. * It groups all the common properties the materials, post process, lights... might need
  30560. * in order to make a correct use of the texture.
  30561. */
  30562. export class BaseTexture implements IAnimatable {
  30563. /**
  30564. * Default anisotropic filtering level for the application.
  30565. * It is set to 4 as a good tradeoff between perf and quality.
  30566. */
  30567. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30568. /**
  30569. * Gets or sets the unique id of the texture
  30570. */
  30571. uniqueId: number;
  30572. /**
  30573. * Define the name of the texture.
  30574. */
  30575. name: string;
  30576. /**
  30577. * Gets or sets an object used to store user defined information.
  30578. */
  30579. metadata: any;
  30580. /**
  30581. * For internal use only. Please do not use.
  30582. */
  30583. reservedDataStore: any;
  30584. private _hasAlpha;
  30585. /**
  30586. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30587. */
  30588. set hasAlpha(value: boolean);
  30589. get hasAlpha(): boolean;
  30590. /**
  30591. * Defines if the alpha value should be determined via the rgb values.
  30592. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30593. */
  30594. getAlphaFromRGB: boolean;
  30595. /**
  30596. * Intensity or strength of the texture.
  30597. * It is commonly used by materials to fine tune the intensity of the texture
  30598. */
  30599. level: number;
  30600. /**
  30601. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30602. * This is part of the texture as textures usually maps to one uv set.
  30603. */
  30604. coordinatesIndex: number;
  30605. private _coordinatesMode;
  30606. /**
  30607. * How a texture is mapped.
  30608. *
  30609. * | Value | Type | Description |
  30610. * | ----- | ----------------------------------- | ----------- |
  30611. * | 0 | EXPLICIT_MODE | |
  30612. * | 1 | SPHERICAL_MODE | |
  30613. * | 2 | PLANAR_MODE | |
  30614. * | 3 | CUBIC_MODE | |
  30615. * | 4 | PROJECTION_MODE | |
  30616. * | 5 | SKYBOX_MODE | |
  30617. * | 6 | INVCUBIC_MODE | |
  30618. * | 7 | EQUIRECTANGULAR_MODE | |
  30619. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30620. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30621. */
  30622. set coordinatesMode(value: number);
  30623. get coordinatesMode(): number;
  30624. /**
  30625. * | Value | Type | Description |
  30626. * | ----- | ------------------ | ----------- |
  30627. * | 0 | CLAMP_ADDRESSMODE | |
  30628. * | 1 | WRAP_ADDRESSMODE | |
  30629. * | 2 | MIRROR_ADDRESSMODE | |
  30630. */
  30631. wrapU: number;
  30632. /**
  30633. * | Value | Type | Description |
  30634. * | ----- | ------------------ | ----------- |
  30635. * | 0 | CLAMP_ADDRESSMODE | |
  30636. * | 1 | WRAP_ADDRESSMODE | |
  30637. * | 2 | MIRROR_ADDRESSMODE | |
  30638. */
  30639. wrapV: number;
  30640. /**
  30641. * | Value | Type | Description |
  30642. * | ----- | ------------------ | ----------- |
  30643. * | 0 | CLAMP_ADDRESSMODE | |
  30644. * | 1 | WRAP_ADDRESSMODE | |
  30645. * | 2 | MIRROR_ADDRESSMODE | |
  30646. */
  30647. wrapR: number;
  30648. /**
  30649. * With compliant hardware and browser (supporting anisotropic filtering)
  30650. * this defines the level of anisotropic filtering in the texture.
  30651. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30652. */
  30653. anisotropicFilteringLevel: number;
  30654. /**
  30655. * Define if the texture is a cube texture or if false a 2d texture.
  30656. */
  30657. get isCube(): boolean;
  30658. set isCube(value: boolean);
  30659. /**
  30660. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30661. */
  30662. get is3D(): boolean;
  30663. set is3D(value: boolean);
  30664. /**
  30665. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30666. */
  30667. get is2DArray(): boolean;
  30668. set is2DArray(value: boolean);
  30669. /**
  30670. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30671. * HDR texture are usually stored in linear space.
  30672. * This only impacts the PBR and Background materials
  30673. */
  30674. gammaSpace: boolean;
  30675. /**
  30676. * Gets or sets whether or not the texture contains RGBD data.
  30677. */
  30678. get isRGBD(): boolean;
  30679. set isRGBD(value: boolean);
  30680. /**
  30681. * Is Z inverted in the texture (useful in a cube texture).
  30682. */
  30683. invertZ: boolean;
  30684. /**
  30685. * Are mip maps generated for this texture or not.
  30686. */
  30687. get noMipmap(): boolean;
  30688. /**
  30689. * @hidden
  30690. */
  30691. lodLevelInAlpha: boolean;
  30692. /**
  30693. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30694. */
  30695. get lodGenerationOffset(): number;
  30696. set lodGenerationOffset(value: number);
  30697. /**
  30698. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30699. */
  30700. get lodGenerationScale(): number;
  30701. set lodGenerationScale(value: number);
  30702. /**
  30703. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30704. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30705. * average roughness values.
  30706. */
  30707. get linearSpecularLOD(): boolean;
  30708. set linearSpecularLOD(value: boolean);
  30709. /**
  30710. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30711. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30712. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30713. */
  30714. get irradianceTexture(): Nullable<BaseTexture>;
  30715. set irradianceTexture(value: Nullable<BaseTexture>);
  30716. /**
  30717. * Define if the texture is a render target.
  30718. */
  30719. isRenderTarget: boolean;
  30720. /**
  30721. * Define the unique id of the texture in the scene.
  30722. */
  30723. get uid(): string;
  30724. /**
  30725. * Return a string representation of the texture.
  30726. * @returns the texture as a string
  30727. */
  30728. toString(): string;
  30729. /**
  30730. * Get the class name of the texture.
  30731. * @returns "BaseTexture"
  30732. */
  30733. getClassName(): string;
  30734. /**
  30735. * Define the list of animation attached to the texture.
  30736. */
  30737. animations: import("babylonjs/Animations/animation").Animation[];
  30738. /**
  30739. * An event triggered when the texture is disposed.
  30740. */
  30741. onDisposeObservable: Observable<BaseTexture>;
  30742. private _onDisposeObserver;
  30743. /**
  30744. * Callback triggered when the texture has been disposed.
  30745. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30746. */
  30747. set onDispose(callback: () => void);
  30748. /**
  30749. * Define the current state of the loading sequence when in delayed load mode.
  30750. */
  30751. delayLoadState: number;
  30752. private _scene;
  30753. /** @hidden */
  30754. _texture: Nullable<InternalTexture>;
  30755. private _uid;
  30756. /**
  30757. * Define if the texture is preventinga material to render or not.
  30758. * If not and the texture is not ready, the engine will use a default black texture instead.
  30759. */
  30760. get isBlocking(): boolean;
  30761. /**
  30762. * Instantiates a new BaseTexture.
  30763. * Base class of all the textures in babylon.
  30764. * It groups all the common properties the materials, post process, lights... might need
  30765. * in order to make a correct use of the texture.
  30766. * @param scene Define the scene the texture blongs to
  30767. */
  30768. constructor(scene: Nullable<Scene>);
  30769. /**
  30770. * Get the scene the texture belongs to.
  30771. * @returns the scene or null if undefined
  30772. */
  30773. getScene(): Nullable<Scene>;
  30774. /**
  30775. * Get the texture transform matrix used to offset tile the texture for istance.
  30776. * @returns the transformation matrix
  30777. */
  30778. getTextureMatrix(): Matrix;
  30779. /**
  30780. * Get the texture reflection matrix used to rotate/transform the reflection.
  30781. * @returns the reflection matrix
  30782. */
  30783. getReflectionTextureMatrix(): Matrix;
  30784. /**
  30785. * Get the underlying lower level texture from Babylon.
  30786. * @returns the insternal texture
  30787. */
  30788. getInternalTexture(): Nullable<InternalTexture>;
  30789. /**
  30790. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30791. * @returns true if ready or not blocking
  30792. */
  30793. isReadyOrNotBlocking(): boolean;
  30794. /**
  30795. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30796. * @returns true if fully ready
  30797. */
  30798. isReady(): boolean;
  30799. private _cachedSize;
  30800. /**
  30801. * Get the size of the texture.
  30802. * @returns the texture size.
  30803. */
  30804. getSize(): ISize;
  30805. /**
  30806. * Get the base size of the texture.
  30807. * It can be different from the size if the texture has been resized for POT for instance
  30808. * @returns the base size
  30809. */
  30810. getBaseSize(): ISize;
  30811. /**
  30812. * Update the sampling mode of the texture.
  30813. * Default is Trilinear mode.
  30814. *
  30815. * | Value | Type | Description |
  30816. * | ----- | ------------------ | ----------- |
  30817. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30818. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30819. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30820. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30821. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30822. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30823. * | 7 | NEAREST_LINEAR | |
  30824. * | 8 | NEAREST_NEAREST | |
  30825. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30826. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30827. * | 11 | LINEAR_LINEAR | |
  30828. * | 12 | LINEAR_NEAREST | |
  30829. *
  30830. * > _mag_: magnification filter (close to the viewer)
  30831. * > _min_: minification filter (far from the viewer)
  30832. * > _mip_: filter used between mip map levels
  30833. *@param samplingMode Define the new sampling mode of the texture
  30834. */
  30835. updateSamplingMode(samplingMode: number): void;
  30836. /**
  30837. * Scales the texture if is `canRescale()`
  30838. * @param ratio the resize factor we want to use to rescale
  30839. */
  30840. scale(ratio: number): void;
  30841. /**
  30842. * Get if the texture can rescale.
  30843. */
  30844. get canRescale(): boolean;
  30845. /** @hidden */
  30846. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30847. /** @hidden */
  30848. _rebuild(): void;
  30849. /**
  30850. * Triggers the load sequence in delayed load mode.
  30851. */
  30852. delayLoad(): void;
  30853. /**
  30854. * Clones the texture.
  30855. * @returns the cloned texture
  30856. */
  30857. clone(): Nullable<BaseTexture>;
  30858. /**
  30859. * Get the texture underlying type (INT, FLOAT...)
  30860. */
  30861. get textureType(): number;
  30862. /**
  30863. * Get the texture underlying format (RGB, RGBA...)
  30864. */
  30865. get textureFormat(): number;
  30866. /**
  30867. * Indicates that textures need to be re-calculated for all materials
  30868. */
  30869. protected _markAllSubMeshesAsTexturesDirty(): void;
  30870. /**
  30871. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30872. * This will returns an RGBA array buffer containing either in values (0-255) or
  30873. * float values (0-1) depending of the underlying buffer type.
  30874. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30875. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30876. * @param buffer defines a user defined buffer to fill with data (can be null)
  30877. * @returns The Array buffer containing the pixels data.
  30878. */
  30879. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30880. /**
  30881. * Release and destroy the underlying lower level texture aka internalTexture.
  30882. */
  30883. releaseInternalTexture(): void;
  30884. /** @hidden */
  30885. get _lodTextureHigh(): Nullable<BaseTexture>;
  30886. /** @hidden */
  30887. get _lodTextureMid(): Nullable<BaseTexture>;
  30888. /** @hidden */
  30889. get _lodTextureLow(): Nullable<BaseTexture>;
  30890. /**
  30891. * Dispose the texture and release its associated resources.
  30892. */
  30893. dispose(): void;
  30894. /**
  30895. * Serialize the texture into a JSON representation that can be parsed later on.
  30896. * @returns the JSON representation of the texture
  30897. */
  30898. serialize(): any;
  30899. /**
  30900. * Helper function to be called back once a list of texture contains only ready textures.
  30901. * @param textures Define the list of textures to wait for
  30902. * @param callback Define the callback triggered once the entire list will be ready
  30903. */
  30904. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30905. }
  30906. }
  30907. declare module "babylonjs/Materials/effect" {
  30908. import { Observable } from "babylonjs/Misc/observable";
  30909. import { Nullable } from "babylonjs/types";
  30910. import { IDisposable } from "babylonjs/scene";
  30911. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30912. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30913. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30914. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30915. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30916. import { Engine } from "babylonjs/Engines/engine";
  30917. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30918. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30919. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30920. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30921. /**
  30922. * Options to be used when creating an effect.
  30923. */
  30924. export interface IEffectCreationOptions {
  30925. /**
  30926. * Atrributes that will be used in the shader.
  30927. */
  30928. attributes: string[];
  30929. /**
  30930. * Uniform varible names that will be set in the shader.
  30931. */
  30932. uniformsNames: string[];
  30933. /**
  30934. * Uniform buffer variable names that will be set in the shader.
  30935. */
  30936. uniformBuffersNames: string[];
  30937. /**
  30938. * Sampler texture variable names that will be set in the shader.
  30939. */
  30940. samplers: string[];
  30941. /**
  30942. * Define statements that will be set in the shader.
  30943. */
  30944. defines: any;
  30945. /**
  30946. * Possible fallbacks for this effect to improve performance when needed.
  30947. */
  30948. fallbacks: Nullable<IEffectFallbacks>;
  30949. /**
  30950. * Callback that will be called when the shader is compiled.
  30951. */
  30952. onCompiled: Nullable<(effect: Effect) => void>;
  30953. /**
  30954. * Callback that will be called if an error occurs during shader compilation.
  30955. */
  30956. onError: Nullable<(effect: Effect, errors: string) => void>;
  30957. /**
  30958. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30959. */
  30960. indexParameters?: any;
  30961. /**
  30962. * Max number of lights that can be used in the shader.
  30963. */
  30964. maxSimultaneousLights?: number;
  30965. /**
  30966. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30967. */
  30968. transformFeedbackVaryings?: Nullable<string[]>;
  30969. }
  30970. /**
  30971. * Effect containing vertex and fragment shader that can be executed on an object.
  30972. */
  30973. export class Effect implements IDisposable {
  30974. /**
  30975. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30976. */
  30977. static ShadersRepository: string;
  30978. /**
  30979. * Enable logging of the shader code when a compilation error occurs
  30980. */
  30981. static LogShaderCodeOnCompilationError: boolean;
  30982. /**
  30983. * Name of the effect.
  30984. */
  30985. name: any;
  30986. /**
  30987. * String container all the define statements that should be set on the shader.
  30988. */
  30989. defines: string;
  30990. /**
  30991. * Callback that will be called when the shader is compiled.
  30992. */
  30993. onCompiled: Nullable<(effect: Effect) => void>;
  30994. /**
  30995. * Callback that will be called if an error occurs during shader compilation.
  30996. */
  30997. onError: Nullable<(effect: Effect, errors: string) => void>;
  30998. /**
  30999. * Callback that will be called when effect is bound.
  31000. */
  31001. onBind: Nullable<(effect: Effect) => void>;
  31002. /**
  31003. * Unique ID of the effect.
  31004. */
  31005. uniqueId: number;
  31006. /**
  31007. * Observable that will be called when the shader is compiled.
  31008. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31009. */
  31010. onCompileObservable: Observable<Effect>;
  31011. /**
  31012. * Observable that will be called if an error occurs during shader compilation.
  31013. */
  31014. onErrorObservable: Observable<Effect>;
  31015. /** @hidden */
  31016. _onBindObservable: Nullable<Observable<Effect>>;
  31017. /**
  31018. * @hidden
  31019. * Specifies if the effect was previously ready
  31020. */
  31021. _wasPreviouslyReady: boolean;
  31022. /**
  31023. * Observable that will be called when effect is bound.
  31024. */
  31025. get onBindObservable(): Observable<Effect>;
  31026. /** @hidden */
  31027. _bonesComputationForcedToCPU: boolean;
  31028. private static _uniqueIdSeed;
  31029. private _engine;
  31030. private _uniformBuffersNames;
  31031. private _uniformsNames;
  31032. private _samplerList;
  31033. private _samplers;
  31034. private _isReady;
  31035. private _compilationError;
  31036. private _allFallbacksProcessed;
  31037. private _attributesNames;
  31038. private _attributes;
  31039. private _attributeLocationByName;
  31040. private _uniforms;
  31041. /**
  31042. * Key for the effect.
  31043. * @hidden
  31044. */
  31045. _key: string;
  31046. private _indexParameters;
  31047. private _fallbacks;
  31048. private _vertexSourceCode;
  31049. private _fragmentSourceCode;
  31050. private _vertexSourceCodeOverride;
  31051. private _fragmentSourceCodeOverride;
  31052. private _transformFeedbackVaryings;
  31053. /**
  31054. * Compiled shader to webGL program.
  31055. * @hidden
  31056. */
  31057. _pipelineContext: Nullable<IPipelineContext>;
  31058. private _valueCache;
  31059. private static _baseCache;
  31060. /**
  31061. * Instantiates an effect.
  31062. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31063. * @param baseName Name of the effect.
  31064. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31065. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31066. * @param samplers List of sampler variables that will be passed to the shader.
  31067. * @param engine Engine to be used to render the effect
  31068. * @param defines Define statements to be added to the shader.
  31069. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31070. * @param onCompiled Callback that will be called when the shader is compiled.
  31071. * @param onError Callback that will be called if an error occurs during shader compilation.
  31072. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31073. */
  31074. 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);
  31075. private _useFinalCode;
  31076. /**
  31077. * Unique key for this effect
  31078. */
  31079. get key(): string;
  31080. /**
  31081. * If the effect has been compiled and prepared.
  31082. * @returns if the effect is compiled and prepared.
  31083. */
  31084. isReady(): boolean;
  31085. private _isReadyInternal;
  31086. /**
  31087. * The engine the effect was initialized with.
  31088. * @returns the engine.
  31089. */
  31090. getEngine(): Engine;
  31091. /**
  31092. * The pipeline context for this effect
  31093. * @returns the associated pipeline context
  31094. */
  31095. getPipelineContext(): Nullable<IPipelineContext>;
  31096. /**
  31097. * The set of names of attribute variables for the shader.
  31098. * @returns An array of attribute names.
  31099. */
  31100. getAttributesNames(): string[];
  31101. /**
  31102. * Returns the attribute at the given index.
  31103. * @param index The index of the attribute.
  31104. * @returns The location of the attribute.
  31105. */
  31106. getAttributeLocation(index: number): number;
  31107. /**
  31108. * Returns the attribute based on the name of the variable.
  31109. * @param name of the attribute to look up.
  31110. * @returns the attribute location.
  31111. */
  31112. getAttributeLocationByName(name: string): number;
  31113. /**
  31114. * The number of attributes.
  31115. * @returns the numnber of attributes.
  31116. */
  31117. getAttributesCount(): number;
  31118. /**
  31119. * Gets the index of a uniform variable.
  31120. * @param uniformName of the uniform to look up.
  31121. * @returns the index.
  31122. */
  31123. getUniformIndex(uniformName: string): number;
  31124. /**
  31125. * Returns the attribute based on the name of the variable.
  31126. * @param uniformName of the uniform to look up.
  31127. * @returns the location of the uniform.
  31128. */
  31129. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31130. /**
  31131. * Returns an array of sampler variable names
  31132. * @returns The array of sampler variable neames.
  31133. */
  31134. getSamplers(): string[];
  31135. /**
  31136. * The error from the last compilation.
  31137. * @returns the error string.
  31138. */
  31139. getCompilationError(): string;
  31140. /**
  31141. * Gets a boolean indicating that all fallbacks were used during compilation
  31142. * @returns true if all fallbacks were used
  31143. */
  31144. allFallbacksProcessed(): boolean;
  31145. /**
  31146. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31147. * @param func The callback to be used.
  31148. */
  31149. executeWhenCompiled(func: (effect: Effect) => void): void;
  31150. private _checkIsReady;
  31151. private _loadShader;
  31152. /**
  31153. * Recompiles the webGL program
  31154. * @param vertexSourceCode The source code for the vertex shader.
  31155. * @param fragmentSourceCode The source code for the fragment shader.
  31156. * @param onCompiled Callback called when completed.
  31157. * @param onError Callback called on error.
  31158. * @hidden
  31159. */
  31160. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31161. /**
  31162. * Prepares the effect
  31163. * @hidden
  31164. */
  31165. _prepareEffect(): void;
  31166. private _getShaderCodeAndErrorLine;
  31167. private _processCompilationErrors;
  31168. /**
  31169. * Checks if the effect is supported. (Must be called after compilation)
  31170. */
  31171. get isSupported(): boolean;
  31172. /**
  31173. * Binds a texture to the engine to be used as output of the shader.
  31174. * @param channel Name of the output variable.
  31175. * @param texture Texture to bind.
  31176. * @hidden
  31177. */
  31178. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31179. /**
  31180. * Sets a texture on the engine to be used in the shader.
  31181. * @param channel Name of the sampler variable.
  31182. * @param texture Texture to set.
  31183. */
  31184. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31185. /**
  31186. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31187. * @param channel Name of the sampler variable.
  31188. * @param texture Texture to set.
  31189. */
  31190. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31191. /**
  31192. * Sets an array of textures on the engine to be used in the shader.
  31193. * @param channel Name of the variable.
  31194. * @param textures Textures to set.
  31195. */
  31196. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31197. /**
  31198. * 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)
  31199. * @param channel Name of the sampler variable.
  31200. * @param postProcess Post process to get the input texture from.
  31201. */
  31202. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31203. /**
  31204. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31205. * 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)
  31206. * @param channel Name of the sampler variable.
  31207. * @param postProcess Post process to get the output texture from.
  31208. */
  31209. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31210. /** @hidden */
  31211. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31212. /** @hidden */
  31213. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31214. /** @hidden */
  31215. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31216. /** @hidden */
  31217. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31218. /**
  31219. * Binds a buffer to a uniform.
  31220. * @param buffer Buffer to bind.
  31221. * @param name Name of the uniform variable to bind to.
  31222. */
  31223. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31224. /**
  31225. * Binds block to a uniform.
  31226. * @param blockName Name of the block to bind.
  31227. * @param index Index to bind.
  31228. */
  31229. bindUniformBlock(blockName: string, index: number): void;
  31230. /**
  31231. * Sets an interger value on a uniform variable.
  31232. * @param uniformName Name of the variable.
  31233. * @param value Value to be set.
  31234. * @returns this effect.
  31235. */
  31236. setInt(uniformName: string, value: number): Effect;
  31237. /**
  31238. * Sets an int array on a uniform variable.
  31239. * @param uniformName Name of the variable.
  31240. * @param array array to be set.
  31241. * @returns this effect.
  31242. */
  31243. setIntArray(uniformName: string, array: Int32Array): Effect;
  31244. /**
  31245. * 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)
  31246. * @param uniformName Name of the variable.
  31247. * @param array array to be set.
  31248. * @returns this effect.
  31249. */
  31250. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31251. /**
  31252. * 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)
  31253. * @param uniformName Name of the variable.
  31254. * @param array array to be set.
  31255. * @returns this effect.
  31256. */
  31257. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31258. /**
  31259. * 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)
  31260. * @param uniformName Name of the variable.
  31261. * @param array array to be set.
  31262. * @returns this effect.
  31263. */
  31264. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31265. /**
  31266. * Sets an float array on a uniform variable.
  31267. * @param uniformName Name of the variable.
  31268. * @param array array to be set.
  31269. * @returns this effect.
  31270. */
  31271. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31272. /**
  31273. * 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)
  31274. * @param uniformName Name of the variable.
  31275. * @param array array to be set.
  31276. * @returns this effect.
  31277. */
  31278. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31279. /**
  31280. * 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)
  31281. * @param uniformName Name of the variable.
  31282. * @param array array to be set.
  31283. * @returns this effect.
  31284. */
  31285. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31286. /**
  31287. * 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)
  31288. * @param uniformName Name of the variable.
  31289. * @param array array to be set.
  31290. * @returns this effect.
  31291. */
  31292. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31293. /**
  31294. * Sets an array on a uniform variable.
  31295. * @param uniformName Name of the variable.
  31296. * @param array array to be set.
  31297. * @returns this effect.
  31298. */
  31299. setArray(uniformName: string, array: number[]): Effect;
  31300. /**
  31301. * 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)
  31302. * @param uniformName Name of the variable.
  31303. * @param array array to be set.
  31304. * @returns this effect.
  31305. */
  31306. setArray2(uniformName: string, array: number[]): Effect;
  31307. /**
  31308. * 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)
  31309. * @param uniformName Name of the variable.
  31310. * @param array array to be set.
  31311. * @returns this effect.
  31312. */
  31313. setArray3(uniformName: string, array: number[]): Effect;
  31314. /**
  31315. * 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)
  31316. * @param uniformName Name of the variable.
  31317. * @param array array to be set.
  31318. * @returns this effect.
  31319. */
  31320. setArray4(uniformName: string, array: number[]): Effect;
  31321. /**
  31322. * Sets matrices on a uniform variable.
  31323. * @param uniformName Name of the variable.
  31324. * @param matrices matrices to be set.
  31325. * @returns this effect.
  31326. */
  31327. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31328. /**
  31329. * Sets matrix on a uniform variable.
  31330. * @param uniformName Name of the variable.
  31331. * @param matrix matrix to be set.
  31332. * @returns this effect.
  31333. */
  31334. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31335. /**
  31336. * 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)
  31337. * @param uniformName Name of the variable.
  31338. * @param matrix matrix to be set.
  31339. * @returns this effect.
  31340. */
  31341. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31342. /**
  31343. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31344. * @param uniformName Name of the variable.
  31345. * @param matrix matrix to be set.
  31346. * @returns this effect.
  31347. */
  31348. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31349. /**
  31350. * Sets a float on a uniform variable.
  31351. * @param uniformName Name of the variable.
  31352. * @param value value to be set.
  31353. * @returns this effect.
  31354. */
  31355. setFloat(uniformName: string, value: number): Effect;
  31356. /**
  31357. * Sets a boolean on a uniform variable.
  31358. * @param uniformName Name of the variable.
  31359. * @param bool value to be set.
  31360. * @returns this effect.
  31361. */
  31362. setBool(uniformName: string, bool: boolean): Effect;
  31363. /**
  31364. * Sets a Vector2 on a uniform variable.
  31365. * @param uniformName Name of the variable.
  31366. * @param vector2 vector2 to be set.
  31367. * @returns this effect.
  31368. */
  31369. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31370. /**
  31371. * Sets a float2 on a uniform variable.
  31372. * @param uniformName Name of the variable.
  31373. * @param x First float in float2.
  31374. * @param y Second float in float2.
  31375. * @returns this effect.
  31376. */
  31377. setFloat2(uniformName: string, x: number, y: number): Effect;
  31378. /**
  31379. * Sets a Vector3 on a uniform variable.
  31380. * @param uniformName Name of the variable.
  31381. * @param vector3 Value to be set.
  31382. * @returns this effect.
  31383. */
  31384. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31385. /**
  31386. * Sets a float3 on a uniform variable.
  31387. * @param uniformName Name of the variable.
  31388. * @param x First float in float3.
  31389. * @param y Second float in float3.
  31390. * @param z Third float in float3.
  31391. * @returns this effect.
  31392. */
  31393. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31394. /**
  31395. * Sets a Vector4 on a uniform variable.
  31396. * @param uniformName Name of the variable.
  31397. * @param vector4 Value to be set.
  31398. * @returns this effect.
  31399. */
  31400. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31401. /**
  31402. * Sets a float4 on a uniform variable.
  31403. * @param uniformName Name of the variable.
  31404. * @param x First float in float4.
  31405. * @param y Second float in float4.
  31406. * @param z Third float in float4.
  31407. * @param w Fourth float in float4.
  31408. * @returns this effect.
  31409. */
  31410. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31411. /**
  31412. * Sets a Color3 on a uniform variable.
  31413. * @param uniformName Name of the variable.
  31414. * @param color3 Value to be set.
  31415. * @returns this effect.
  31416. */
  31417. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31418. /**
  31419. * Sets a Color4 on a uniform variable.
  31420. * @param uniformName Name of the variable.
  31421. * @param color3 Value to be set.
  31422. * @param alpha Alpha value to be set.
  31423. * @returns this effect.
  31424. */
  31425. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31426. /**
  31427. * Sets a Color4 on a uniform variable
  31428. * @param uniformName defines the name of the variable
  31429. * @param color4 defines the value to be set
  31430. * @returns this effect.
  31431. */
  31432. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31433. /** Release all associated resources */
  31434. dispose(): void;
  31435. /**
  31436. * This function will add a new shader to the shader store
  31437. * @param name the name of the shader
  31438. * @param pixelShader optional pixel shader content
  31439. * @param vertexShader optional vertex shader content
  31440. */
  31441. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31442. /**
  31443. * Store of each shader (The can be looked up using effect.key)
  31444. */
  31445. static ShadersStore: {
  31446. [key: string]: string;
  31447. };
  31448. /**
  31449. * Store of each included file for a shader (The can be looked up using effect.key)
  31450. */
  31451. static IncludesShadersStore: {
  31452. [key: string]: string;
  31453. };
  31454. /**
  31455. * Resets the cache of effects.
  31456. */
  31457. static ResetCache(): void;
  31458. }
  31459. }
  31460. declare module "babylonjs/Engines/engineCapabilities" {
  31461. /**
  31462. * Interface used to describe the capabilities of the engine relatively to the current browser
  31463. */
  31464. export interface EngineCapabilities {
  31465. /** Maximum textures units per fragment shader */
  31466. maxTexturesImageUnits: number;
  31467. /** Maximum texture units per vertex shader */
  31468. maxVertexTextureImageUnits: number;
  31469. /** Maximum textures units in the entire pipeline */
  31470. maxCombinedTexturesImageUnits: number;
  31471. /** Maximum texture size */
  31472. maxTextureSize: number;
  31473. /** Maximum texture samples */
  31474. maxSamples?: number;
  31475. /** Maximum cube texture size */
  31476. maxCubemapTextureSize: number;
  31477. /** Maximum render texture size */
  31478. maxRenderTextureSize: number;
  31479. /** Maximum number of vertex attributes */
  31480. maxVertexAttribs: number;
  31481. /** Maximum number of varyings */
  31482. maxVaryingVectors: number;
  31483. /** Maximum number of uniforms per vertex shader */
  31484. maxVertexUniformVectors: number;
  31485. /** Maximum number of uniforms per fragment shader */
  31486. maxFragmentUniformVectors: number;
  31487. /** Defines if standard derivates (dx/dy) are supported */
  31488. standardDerivatives: boolean;
  31489. /** Defines if s3tc texture compression is supported */
  31490. s3tc?: WEBGL_compressed_texture_s3tc;
  31491. /** Defines if pvrtc texture compression is supported */
  31492. pvrtc: any;
  31493. /** Defines if etc1 texture compression is supported */
  31494. etc1: any;
  31495. /** Defines if etc2 texture compression is supported */
  31496. etc2: any;
  31497. /** Defines if astc texture compression is supported */
  31498. astc: any;
  31499. /** Defines if float textures are supported */
  31500. textureFloat: boolean;
  31501. /** Defines if vertex array objects are supported */
  31502. vertexArrayObject: boolean;
  31503. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31504. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31505. /** Gets the maximum level of anisotropy supported */
  31506. maxAnisotropy: number;
  31507. /** Defines if instancing is supported */
  31508. instancedArrays: boolean;
  31509. /** Defines if 32 bits indices are supported */
  31510. uintIndices: boolean;
  31511. /** Defines if high precision shaders are supported */
  31512. highPrecisionShaderSupported: boolean;
  31513. /** Defines if depth reading in the fragment shader is supported */
  31514. fragmentDepthSupported: boolean;
  31515. /** Defines if float texture linear filtering is supported*/
  31516. textureFloatLinearFiltering: boolean;
  31517. /** Defines if rendering to float textures is supported */
  31518. textureFloatRender: boolean;
  31519. /** Defines if half float textures are supported*/
  31520. textureHalfFloat: boolean;
  31521. /** Defines if half float texture linear filtering is supported*/
  31522. textureHalfFloatLinearFiltering: boolean;
  31523. /** Defines if rendering to half float textures is supported */
  31524. textureHalfFloatRender: boolean;
  31525. /** Defines if textureLOD shader command is supported */
  31526. textureLOD: boolean;
  31527. /** Defines if draw buffers extension is supported */
  31528. drawBuffersExtension: boolean;
  31529. /** Defines if depth textures are supported */
  31530. depthTextureExtension: boolean;
  31531. /** Defines if float color buffer are supported */
  31532. colorBufferFloat: boolean;
  31533. /** Gets disjoint timer query extension (null if not supported) */
  31534. timerQuery?: EXT_disjoint_timer_query;
  31535. /** Defines if timestamp can be used with timer query */
  31536. canUseTimestampForTimerQuery: boolean;
  31537. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31538. multiview?: any;
  31539. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31540. oculusMultiview?: any;
  31541. /** Function used to let the system compiles shaders in background */
  31542. parallelShaderCompile?: {
  31543. COMPLETION_STATUS_KHR: number;
  31544. };
  31545. /** Max number of texture samples for MSAA */
  31546. maxMSAASamples: number;
  31547. /** Defines if the blend min max extension is supported */
  31548. blendMinMax: boolean;
  31549. }
  31550. }
  31551. declare module "babylonjs/States/depthCullingState" {
  31552. import { Nullable } from "babylonjs/types";
  31553. /**
  31554. * @hidden
  31555. **/
  31556. export class DepthCullingState {
  31557. private _isDepthTestDirty;
  31558. private _isDepthMaskDirty;
  31559. private _isDepthFuncDirty;
  31560. private _isCullFaceDirty;
  31561. private _isCullDirty;
  31562. private _isZOffsetDirty;
  31563. private _isFrontFaceDirty;
  31564. private _depthTest;
  31565. private _depthMask;
  31566. private _depthFunc;
  31567. private _cull;
  31568. private _cullFace;
  31569. private _zOffset;
  31570. private _frontFace;
  31571. /**
  31572. * Initializes the state.
  31573. */
  31574. constructor();
  31575. get isDirty(): boolean;
  31576. get zOffset(): number;
  31577. set zOffset(value: number);
  31578. get cullFace(): Nullable<number>;
  31579. set cullFace(value: Nullable<number>);
  31580. get cull(): Nullable<boolean>;
  31581. set cull(value: Nullable<boolean>);
  31582. get depthFunc(): Nullable<number>;
  31583. set depthFunc(value: Nullable<number>);
  31584. get depthMask(): boolean;
  31585. set depthMask(value: boolean);
  31586. get depthTest(): boolean;
  31587. set depthTest(value: boolean);
  31588. get frontFace(): Nullable<number>;
  31589. set frontFace(value: Nullable<number>);
  31590. reset(): void;
  31591. apply(gl: WebGLRenderingContext): void;
  31592. }
  31593. }
  31594. declare module "babylonjs/States/stencilState" {
  31595. /**
  31596. * @hidden
  31597. **/
  31598. export class StencilState {
  31599. /** 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 */
  31600. static readonly ALWAYS: number;
  31601. /** Passed to stencilOperation to specify that stencil value must be kept */
  31602. static readonly KEEP: number;
  31603. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31604. static readonly REPLACE: number;
  31605. private _isStencilTestDirty;
  31606. private _isStencilMaskDirty;
  31607. private _isStencilFuncDirty;
  31608. private _isStencilOpDirty;
  31609. private _stencilTest;
  31610. private _stencilMask;
  31611. private _stencilFunc;
  31612. private _stencilFuncRef;
  31613. private _stencilFuncMask;
  31614. private _stencilOpStencilFail;
  31615. private _stencilOpDepthFail;
  31616. private _stencilOpStencilDepthPass;
  31617. get isDirty(): boolean;
  31618. get stencilFunc(): number;
  31619. set stencilFunc(value: number);
  31620. get stencilFuncRef(): number;
  31621. set stencilFuncRef(value: number);
  31622. get stencilFuncMask(): number;
  31623. set stencilFuncMask(value: number);
  31624. get stencilOpStencilFail(): number;
  31625. set stencilOpStencilFail(value: number);
  31626. get stencilOpDepthFail(): number;
  31627. set stencilOpDepthFail(value: number);
  31628. get stencilOpStencilDepthPass(): number;
  31629. set stencilOpStencilDepthPass(value: number);
  31630. get stencilMask(): number;
  31631. set stencilMask(value: number);
  31632. get stencilTest(): boolean;
  31633. set stencilTest(value: boolean);
  31634. constructor();
  31635. reset(): void;
  31636. apply(gl: WebGLRenderingContext): void;
  31637. }
  31638. }
  31639. declare module "babylonjs/States/alphaCullingState" {
  31640. /**
  31641. * @hidden
  31642. **/
  31643. export class AlphaState {
  31644. private _isAlphaBlendDirty;
  31645. private _isBlendFunctionParametersDirty;
  31646. private _isBlendEquationParametersDirty;
  31647. private _isBlendConstantsDirty;
  31648. private _alphaBlend;
  31649. private _blendFunctionParameters;
  31650. private _blendEquationParameters;
  31651. private _blendConstants;
  31652. /**
  31653. * Initializes the state.
  31654. */
  31655. constructor();
  31656. get isDirty(): boolean;
  31657. get alphaBlend(): boolean;
  31658. set alphaBlend(value: boolean);
  31659. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31660. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31661. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31662. reset(): void;
  31663. apply(gl: WebGLRenderingContext): void;
  31664. }
  31665. }
  31666. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31667. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31668. /** @hidden */
  31669. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31670. attributeProcessor(attribute: string): string;
  31671. varyingProcessor(varying: string, isFragment: boolean): string;
  31672. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31673. }
  31674. }
  31675. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31676. /**
  31677. * Interface for attribute information associated with buffer instanciation
  31678. */
  31679. export interface InstancingAttributeInfo {
  31680. /**
  31681. * Name of the GLSL attribute
  31682. * if attribute index is not specified, this is used to retrieve the index from the effect
  31683. */
  31684. attributeName: string;
  31685. /**
  31686. * Index/offset of the attribute in the vertex shader
  31687. * if not specified, this will be computes from the name.
  31688. */
  31689. index?: number;
  31690. /**
  31691. * size of the attribute, 1, 2, 3 or 4
  31692. */
  31693. attributeSize: number;
  31694. /**
  31695. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31696. */
  31697. offset: number;
  31698. /**
  31699. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31700. * default to 1
  31701. */
  31702. divisor?: number;
  31703. /**
  31704. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31705. * default is FLOAT
  31706. */
  31707. attributeType?: number;
  31708. /**
  31709. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31710. */
  31711. normalized?: boolean;
  31712. }
  31713. }
  31714. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31715. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31716. import { Nullable } from "babylonjs/types";
  31717. module "babylonjs/Engines/thinEngine" {
  31718. interface ThinEngine {
  31719. /**
  31720. * Update a video texture
  31721. * @param texture defines the texture to update
  31722. * @param video defines the video element to use
  31723. * @param invertY defines if data must be stored with Y axis inverted
  31724. */
  31725. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31726. }
  31727. }
  31728. }
  31729. declare module "babylonjs/Materials/Textures/videoTexture" {
  31730. import { Observable } from "babylonjs/Misc/observable";
  31731. import { Nullable } from "babylonjs/types";
  31732. import { Scene } from "babylonjs/scene";
  31733. import { Texture } from "babylonjs/Materials/Textures/texture";
  31734. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31735. /**
  31736. * Settings for finer control over video usage
  31737. */
  31738. export interface VideoTextureSettings {
  31739. /**
  31740. * Applies `autoplay` to video, if specified
  31741. */
  31742. autoPlay?: boolean;
  31743. /**
  31744. * Applies `loop` to video, if specified
  31745. */
  31746. loop?: boolean;
  31747. /**
  31748. * Automatically updates internal texture from video at every frame in the render loop
  31749. */
  31750. autoUpdateTexture: boolean;
  31751. /**
  31752. * Image src displayed during the video loading or until the user interacts with the video.
  31753. */
  31754. poster?: string;
  31755. }
  31756. /**
  31757. * If you want to display a video in your scene, this is the special texture for that.
  31758. * This special texture works similar to other textures, with the exception of a few parameters.
  31759. * @see https://doc.babylonjs.com/how_to/video_texture
  31760. */
  31761. export class VideoTexture extends Texture {
  31762. /**
  31763. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31764. */
  31765. readonly autoUpdateTexture: boolean;
  31766. /**
  31767. * The video instance used by the texture internally
  31768. */
  31769. readonly video: HTMLVideoElement;
  31770. private _onUserActionRequestedObservable;
  31771. /**
  31772. * Event triggerd when a dom action is required by the user to play the video.
  31773. * This happens due to recent changes in browser policies preventing video to auto start.
  31774. */
  31775. get onUserActionRequestedObservable(): Observable<Texture>;
  31776. private _generateMipMaps;
  31777. private _engine;
  31778. private _stillImageCaptured;
  31779. private _displayingPosterTexture;
  31780. private _settings;
  31781. private _createInternalTextureOnEvent;
  31782. private _frameId;
  31783. private _currentSrc;
  31784. /**
  31785. * Creates a video texture.
  31786. * If you want to display a video in your scene, this is the special texture for that.
  31787. * This special texture works similar to other textures, with the exception of a few parameters.
  31788. * @see https://doc.babylonjs.com/how_to/video_texture
  31789. * @param name optional name, will detect from video source, if not defined
  31790. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31791. * @param scene is obviously the current scene.
  31792. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31793. * @param invertY is false by default but can be used to invert video on Y axis
  31794. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31795. * @param settings allows finer control over video usage
  31796. */
  31797. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31798. private _getName;
  31799. private _getVideo;
  31800. private _createInternalTexture;
  31801. private reset;
  31802. /**
  31803. * @hidden Internal method to initiate `update`.
  31804. */
  31805. _rebuild(): void;
  31806. /**
  31807. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31808. */
  31809. update(): void;
  31810. /**
  31811. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31812. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31813. */
  31814. updateTexture(isVisible: boolean): void;
  31815. protected _updateInternalTexture: () => void;
  31816. /**
  31817. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31818. * @param url New url.
  31819. */
  31820. updateURL(url: string): void;
  31821. /**
  31822. * Clones the texture.
  31823. * @returns the cloned texture
  31824. */
  31825. clone(): VideoTexture;
  31826. /**
  31827. * Dispose the texture and release its associated resources.
  31828. */
  31829. dispose(): void;
  31830. /**
  31831. * Creates a video texture straight from a stream.
  31832. * @param scene Define the scene the texture should be created in
  31833. * @param stream Define the stream the texture should be created from
  31834. * @returns The created video texture as a promise
  31835. */
  31836. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31837. /**
  31838. * Creates a video texture straight from your WebCam video feed.
  31839. * @param scene Define the scene the texture should be created in
  31840. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31841. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31842. * @returns The created video texture as a promise
  31843. */
  31844. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31845. minWidth: number;
  31846. maxWidth: number;
  31847. minHeight: number;
  31848. maxHeight: number;
  31849. deviceId: string;
  31850. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31851. /**
  31852. * Creates a video texture straight from your WebCam video feed.
  31853. * @param scene Define the scene the texture should be created in
  31854. * @param onReady Define a callback to triggered once the texture will be ready
  31855. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31856. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31857. */
  31858. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31859. minWidth: number;
  31860. maxWidth: number;
  31861. minHeight: number;
  31862. maxHeight: number;
  31863. deviceId: string;
  31864. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31865. }
  31866. }
  31867. declare module "babylonjs/Engines/thinEngine" {
  31868. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31869. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31870. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31871. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31872. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31873. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31874. import { Observable } from "babylonjs/Misc/observable";
  31875. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31876. import { StencilState } from "babylonjs/States/stencilState";
  31877. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31878. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31879. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31880. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31881. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31882. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31883. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31884. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31885. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31886. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31887. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31888. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31889. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31890. import { WebRequest } from "babylonjs/Misc/webRequest";
  31891. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31892. /**
  31893. * Defines the interface used by objects working like Scene
  31894. * @hidden
  31895. */
  31896. export interface ISceneLike {
  31897. _addPendingData(data: any): void;
  31898. _removePendingData(data: any): void;
  31899. offlineProvider: IOfflineProvider;
  31900. }
  31901. /** Interface defining initialization parameters for Engine class */
  31902. export interface EngineOptions extends WebGLContextAttributes {
  31903. /**
  31904. * Defines if the engine should no exceed a specified device ratio
  31905. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31906. */
  31907. limitDeviceRatio?: number;
  31908. /**
  31909. * Defines if webvr should be enabled automatically
  31910. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31911. */
  31912. autoEnableWebVR?: boolean;
  31913. /**
  31914. * Defines if webgl2 should be turned off even if supported
  31915. * @see http://doc.babylonjs.com/features/webgl2
  31916. */
  31917. disableWebGL2Support?: boolean;
  31918. /**
  31919. * Defines if webaudio should be initialized as well
  31920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31921. */
  31922. audioEngine?: boolean;
  31923. /**
  31924. * Defines if animations should run using a deterministic lock step
  31925. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31926. */
  31927. deterministicLockstep?: boolean;
  31928. /** Defines the maximum steps to use with deterministic lock step mode */
  31929. lockstepMaxSteps?: number;
  31930. /** Defines the seconds between each deterministic lock step */
  31931. timeStep?: number;
  31932. /**
  31933. * Defines that engine should ignore context lost events
  31934. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31935. */
  31936. doNotHandleContextLost?: boolean;
  31937. /**
  31938. * Defines that engine should ignore modifying touch action attribute and style
  31939. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31940. */
  31941. doNotHandleTouchAction?: boolean;
  31942. /**
  31943. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31944. */
  31945. useHighPrecisionFloats?: boolean;
  31946. }
  31947. /**
  31948. * The base engine class (root of all engines)
  31949. */
  31950. export class ThinEngine {
  31951. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31952. static ExceptionList: ({
  31953. key: string;
  31954. capture: string;
  31955. captureConstraint: number;
  31956. targets: string[];
  31957. } | {
  31958. key: string;
  31959. capture: null;
  31960. captureConstraint: null;
  31961. targets: string[];
  31962. })[];
  31963. /** @hidden */
  31964. static _TextureLoaders: IInternalTextureLoader[];
  31965. /**
  31966. * Returns the current npm package of the sdk
  31967. */
  31968. static get NpmPackage(): string;
  31969. /**
  31970. * Returns the current version of the framework
  31971. */
  31972. static get Version(): string;
  31973. /**
  31974. * Returns a string describing the current engine
  31975. */
  31976. get description(): string;
  31977. /**
  31978. * Gets or sets the epsilon value used by collision engine
  31979. */
  31980. static CollisionsEpsilon: number;
  31981. /**
  31982. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31983. */
  31984. static get ShadersRepository(): string;
  31985. static set ShadersRepository(value: string);
  31986. /** @hidden */
  31987. _shaderProcessor: IShaderProcessor;
  31988. /**
  31989. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31990. */
  31991. forcePOTTextures: boolean;
  31992. /**
  31993. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31994. */
  31995. isFullscreen: boolean;
  31996. /**
  31997. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31998. */
  31999. cullBackFaces: boolean;
  32000. /**
  32001. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32002. */
  32003. renderEvenInBackground: boolean;
  32004. /**
  32005. * Gets or sets a boolean indicating that cache can be kept between frames
  32006. */
  32007. preventCacheWipeBetweenFrames: boolean;
  32008. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32009. validateShaderPrograms: boolean;
  32010. /**
  32011. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32012. * This can provide greater z depth for distant objects.
  32013. */
  32014. useReverseDepthBuffer: boolean;
  32015. /**
  32016. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32017. */
  32018. disableUniformBuffers: boolean;
  32019. /** @hidden */
  32020. _uniformBuffers: UniformBuffer[];
  32021. /**
  32022. * Gets a boolean indicating that the engine supports uniform buffers
  32023. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32024. */
  32025. get supportsUniformBuffers(): boolean;
  32026. /** @hidden */
  32027. _gl: WebGLRenderingContext;
  32028. /** @hidden */
  32029. _webGLVersion: number;
  32030. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32031. protected _windowIsBackground: boolean;
  32032. protected _creationOptions: EngineOptions;
  32033. protected _highPrecisionShadersAllowed: boolean;
  32034. /** @hidden */
  32035. get _shouldUseHighPrecisionShader(): boolean;
  32036. /**
  32037. * Gets a boolean indicating that only power of 2 textures are supported
  32038. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32039. */
  32040. get needPOTTextures(): boolean;
  32041. /** @hidden */
  32042. _badOS: boolean;
  32043. /** @hidden */
  32044. _badDesktopOS: boolean;
  32045. private _hardwareScalingLevel;
  32046. /** @hidden */
  32047. _caps: EngineCapabilities;
  32048. private _isStencilEnable;
  32049. private _glVersion;
  32050. private _glRenderer;
  32051. private _glVendor;
  32052. /** @hidden */
  32053. _videoTextureSupported: boolean;
  32054. protected _renderingQueueLaunched: boolean;
  32055. protected _activeRenderLoops: (() => void)[];
  32056. /**
  32057. * Observable signaled when a context lost event is raised
  32058. */
  32059. onContextLostObservable: Observable<ThinEngine>;
  32060. /**
  32061. * Observable signaled when a context restored event is raised
  32062. */
  32063. onContextRestoredObservable: Observable<ThinEngine>;
  32064. private _onContextLost;
  32065. private _onContextRestored;
  32066. protected _contextWasLost: boolean;
  32067. /** @hidden */
  32068. _doNotHandleContextLost: boolean;
  32069. /**
  32070. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32071. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32072. */
  32073. get doNotHandleContextLost(): boolean;
  32074. set doNotHandleContextLost(value: boolean);
  32075. /**
  32076. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32077. */
  32078. disableVertexArrayObjects: boolean;
  32079. /** @hidden */
  32080. protected _colorWrite: boolean;
  32081. /** @hidden */
  32082. protected _colorWriteChanged: boolean;
  32083. /** @hidden */
  32084. protected _depthCullingState: DepthCullingState;
  32085. /** @hidden */
  32086. protected _stencilState: StencilState;
  32087. /** @hidden */
  32088. _alphaState: AlphaState;
  32089. /** @hidden */
  32090. _alphaMode: number;
  32091. /** @hidden */
  32092. _alphaEquation: number;
  32093. /** @hidden */
  32094. _internalTexturesCache: InternalTexture[];
  32095. /** @hidden */
  32096. protected _activeChannel: number;
  32097. private _currentTextureChannel;
  32098. /** @hidden */
  32099. protected _boundTexturesCache: {
  32100. [key: string]: Nullable<InternalTexture>;
  32101. };
  32102. /** @hidden */
  32103. protected _currentEffect: Nullable<Effect>;
  32104. /** @hidden */
  32105. protected _currentProgram: Nullable<WebGLProgram>;
  32106. private _compiledEffects;
  32107. private _vertexAttribArraysEnabled;
  32108. /** @hidden */
  32109. protected _cachedViewport: Nullable<IViewportLike>;
  32110. private _cachedVertexArrayObject;
  32111. /** @hidden */
  32112. protected _cachedVertexBuffers: any;
  32113. /** @hidden */
  32114. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32115. /** @hidden */
  32116. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32117. /** @hidden */
  32118. _currentRenderTarget: Nullable<InternalTexture>;
  32119. private _uintIndicesCurrentlySet;
  32120. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32121. /** @hidden */
  32122. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32123. private _currentBufferPointers;
  32124. private _currentInstanceLocations;
  32125. private _currentInstanceBuffers;
  32126. private _textureUnits;
  32127. /** @hidden */
  32128. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32129. /** @hidden */
  32130. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32131. /** @hidden */
  32132. _boundRenderFunction: any;
  32133. private _vaoRecordInProgress;
  32134. private _mustWipeVertexAttributes;
  32135. private _emptyTexture;
  32136. private _emptyCubeTexture;
  32137. private _emptyTexture3D;
  32138. private _emptyTexture2DArray;
  32139. /** @hidden */
  32140. _frameHandler: number;
  32141. private _nextFreeTextureSlots;
  32142. private _maxSimultaneousTextures;
  32143. private _activeRequests;
  32144. protected _texturesSupported: string[];
  32145. /** @hidden */
  32146. _textureFormatInUse: Nullable<string>;
  32147. protected get _supportsHardwareTextureRescaling(): boolean;
  32148. private _framebufferDimensionsObject;
  32149. /**
  32150. * sets the object from which width and height will be taken from when getting render width and height
  32151. * Will fallback to the gl object
  32152. * @param dimensions the framebuffer width and height that will be used.
  32153. */
  32154. set framebufferDimensionsObject(dimensions: Nullable<{
  32155. framebufferWidth: number;
  32156. framebufferHeight: number;
  32157. }>);
  32158. /**
  32159. * Gets the list of texture formats supported
  32160. */
  32161. get texturesSupported(): Array<string>;
  32162. /**
  32163. * Gets the list of texture formats in use
  32164. */
  32165. get textureFormatInUse(): Nullable<string>;
  32166. /**
  32167. * Gets the current viewport
  32168. */
  32169. get currentViewport(): Nullable<IViewportLike>;
  32170. /**
  32171. * Gets the default empty texture
  32172. */
  32173. get emptyTexture(): InternalTexture;
  32174. /**
  32175. * Gets the default empty 3D texture
  32176. */
  32177. get emptyTexture3D(): InternalTexture;
  32178. /**
  32179. * Gets the default empty 2D array texture
  32180. */
  32181. get emptyTexture2DArray(): InternalTexture;
  32182. /**
  32183. * Gets the default empty cube texture
  32184. */
  32185. get emptyCubeTexture(): InternalTexture;
  32186. /**
  32187. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32188. */
  32189. readonly premultipliedAlpha: boolean;
  32190. /**
  32191. * Observable event triggered before each texture is initialized
  32192. */
  32193. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32194. /**
  32195. * Creates a new engine
  32196. * @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
  32197. * @param antialias defines enable antialiasing (default: false)
  32198. * @param options defines further options to be sent to the getContext() function
  32199. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32200. */
  32201. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32202. private _rebuildInternalTextures;
  32203. private _rebuildEffects;
  32204. /**
  32205. * Gets a boolean indicating if all created effects are ready
  32206. * @returns true if all effects are ready
  32207. */
  32208. areAllEffectsReady(): boolean;
  32209. protected _rebuildBuffers(): void;
  32210. private _initGLContext;
  32211. /**
  32212. * Gets version of the current webGL context
  32213. */
  32214. get webGLVersion(): number;
  32215. /**
  32216. * Gets a string idenfifying the name of the class
  32217. * @returns "Engine" string
  32218. */
  32219. getClassName(): string;
  32220. /**
  32221. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32222. */
  32223. get isStencilEnable(): boolean;
  32224. /** @hidden */
  32225. _prepareWorkingCanvas(): void;
  32226. /**
  32227. * Reset the texture cache to empty state
  32228. */
  32229. resetTextureCache(): void;
  32230. /**
  32231. * Gets an object containing information about the current webGL context
  32232. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32233. */
  32234. getGlInfo(): {
  32235. vendor: string;
  32236. renderer: string;
  32237. version: string;
  32238. };
  32239. /**
  32240. * Defines the hardware scaling level.
  32241. * By default the hardware scaling level is computed from the window device ratio.
  32242. * 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.
  32243. * @param level defines the level to use
  32244. */
  32245. setHardwareScalingLevel(level: number): void;
  32246. /**
  32247. * Gets the current hardware scaling level.
  32248. * By default the hardware scaling level is computed from the window device ratio.
  32249. * 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.
  32250. * @returns a number indicating the current hardware scaling level
  32251. */
  32252. getHardwareScalingLevel(): number;
  32253. /**
  32254. * Gets the list of loaded textures
  32255. * @returns an array containing all loaded textures
  32256. */
  32257. getLoadedTexturesCache(): InternalTexture[];
  32258. /**
  32259. * Gets the object containing all engine capabilities
  32260. * @returns the EngineCapabilities object
  32261. */
  32262. getCaps(): EngineCapabilities;
  32263. /**
  32264. * stop executing a render loop function and remove it from the execution array
  32265. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32266. */
  32267. stopRenderLoop(renderFunction?: () => void): void;
  32268. /** @hidden */
  32269. _renderLoop(): void;
  32270. /**
  32271. * Gets the HTML canvas attached with the current webGL context
  32272. * @returns a HTML canvas
  32273. */
  32274. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32275. /**
  32276. * Gets host window
  32277. * @returns the host window object
  32278. */
  32279. getHostWindow(): Nullable<Window>;
  32280. /**
  32281. * Gets the current render width
  32282. * @param useScreen defines if screen size must be used (or the current render target if any)
  32283. * @returns a number defining the current render width
  32284. */
  32285. getRenderWidth(useScreen?: boolean): number;
  32286. /**
  32287. * Gets the current render height
  32288. * @param useScreen defines if screen size must be used (or the current render target if any)
  32289. * @returns a number defining the current render height
  32290. */
  32291. getRenderHeight(useScreen?: boolean): number;
  32292. /**
  32293. * Can be used to override the current requestAnimationFrame requester.
  32294. * @hidden
  32295. */
  32296. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32297. /**
  32298. * Register and execute a render loop. The engine can have more than one render function
  32299. * @param renderFunction defines the function to continuously execute
  32300. */
  32301. runRenderLoop(renderFunction: () => void): void;
  32302. /**
  32303. * Clear the current render buffer or the current render target (if any is set up)
  32304. * @param color defines the color to use
  32305. * @param backBuffer defines if the back buffer must be cleared
  32306. * @param depth defines if the depth buffer must be cleared
  32307. * @param stencil defines if the stencil buffer must be cleared
  32308. */
  32309. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32310. private _viewportCached;
  32311. /** @hidden */
  32312. _viewport(x: number, y: number, width: number, height: number): void;
  32313. /**
  32314. * Set the WebGL's viewport
  32315. * @param viewport defines the viewport element to be used
  32316. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32317. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32318. */
  32319. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32320. /**
  32321. * Begin a new frame
  32322. */
  32323. beginFrame(): void;
  32324. /**
  32325. * Enf the current frame
  32326. */
  32327. endFrame(): void;
  32328. /**
  32329. * Resize the view according to the canvas' size
  32330. */
  32331. resize(): void;
  32332. /**
  32333. * Force a specific size of the canvas
  32334. * @param width defines the new canvas' width
  32335. * @param height defines the new canvas' height
  32336. */
  32337. setSize(width: number, height: number): void;
  32338. /**
  32339. * Binds the frame buffer to the specified texture.
  32340. * @param texture The texture to render to or null for the default canvas
  32341. * @param faceIndex The face of the texture to render to in case of cube texture
  32342. * @param requiredWidth The width of the target to render to
  32343. * @param requiredHeight The height of the target to render to
  32344. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32345. * @param lodLevel defines the lod level to bind to the frame buffer
  32346. * @param layer defines the 2d array index to bind to frame buffer to
  32347. */
  32348. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32349. /** @hidden */
  32350. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32351. /**
  32352. * Unbind the current render target texture from the webGL context
  32353. * @param texture defines the render target texture to unbind
  32354. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32355. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32356. */
  32357. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32358. /**
  32359. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32360. */
  32361. flushFramebuffer(): void;
  32362. /**
  32363. * Unbind the current render target and bind the default framebuffer
  32364. */
  32365. restoreDefaultFramebuffer(): void;
  32366. /** @hidden */
  32367. protected _resetVertexBufferBinding(): void;
  32368. /**
  32369. * Creates a vertex buffer
  32370. * @param data the data for the vertex buffer
  32371. * @returns the new WebGL static buffer
  32372. */
  32373. createVertexBuffer(data: DataArray): DataBuffer;
  32374. private _createVertexBuffer;
  32375. /**
  32376. * Creates a dynamic vertex buffer
  32377. * @param data the data for the dynamic vertex buffer
  32378. * @returns the new WebGL dynamic buffer
  32379. */
  32380. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32381. protected _resetIndexBufferBinding(): void;
  32382. /**
  32383. * Creates a new index buffer
  32384. * @param indices defines the content of the index buffer
  32385. * @param updatable defines if the index buffer must be updatable
  32386. * @returns a new webGL buffer
  32387. */
  32388. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32389. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32390. /**
  32391. * Bind a webGL buffer to the webGL context
  32392. * @param buffer defines the buffer to bind
  32393. */
  32394. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32395. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32396. private bindBuffer;
  32397. /**
  32398. * update the bound buffer with the given data
  32399. * @param data defines the data to update
  32400. */
  32401. updateArrayBuffer(data: Float32Array): void;
  32402. private _vertexAttribPointer;
  32403. /** @hidden */
  32404. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32405. private _bindVertexBuffersAttributes;
  32406. /**
  32407. * Records a vertex array object
  32408. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32409. * @param vertexBuffers defines the list of vertex buffers to store
  32410. * @param indexBuffer defines the index buffer to store
  32411. * @param effect defines the effect to store
  32412. * @returns the new vertex array object
  32413. */
  32414. recordVertexArrayObject(vertexBuffers: {
  32415. [key: string]: VertexBuffer;
  32416. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32417. /**
  32418. * Bind a specific vertex array object
  32419. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32420. * @param vertexArrayObject defines the vertex array object to bind
  32421. * @param indexBuffer defines the index buffer to bind
  32422. */
  32423. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32424. /**
  32425. * Bind webGl buffers directly to the webGL context
  32426. * @param vertexBuffer defines the vertex buffer to bind
  32427. * @param indexBuffer defines the index buffer to bind
  32428. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32429. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32430. * @param effect defines the effect associated with the vertex buffer
  32431. */
  32432. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32433. private _unbindVertexArrayObject;
  32434. /**
  32435. * Bind a list of vertex buffers to the webGL context
  32436. * @param vertexBuffers defines the list of vertex buffers to bind
  32437. * @param indexBuffer defines the index buffer to bind
  32438. * @param effect defines the effect associated with the vertex buffers
  32439. */
  32440. bindBuffers(vertexBuffers: {
  32441. [key: string]: Nullable<VertexBuffer>;
  32442. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32443. /**
  32444. * Unbind all instance attributes
  32445. */
  32446. unbindInstanceAttributes(): void;
  32447. /**
  32448. * Release and free the memory of a vertex array object
  32449. * @param vao defines the vertex array object to delete
  32450. */
  32451. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32452. /** @hidden */
  32453. _releaseBuffer(buffer: DataBuffer): boolean;
  32454. protected _deleteBuffer(buffer: DataBuffer): void;
  32455. /**
  32456. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32457. * @param instancesBuffer defines the webGL buffer to update and bind
  32458. * @param data defines the data to store in the buffer
  32459. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32460. */
  32461. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32462. /**
  32463. * Bind the content of a webGL buffer used with instantiation
  32464. * @param instancesBuffer defines the webGL buffer to bind
  32465. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32466. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32467. */
  32468. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32469. /**
  32470. * Disable the instance attribute corresponding to the name in parameter
  32471. * @param name defines the name of the attribute to disable
  32472. */
  32473. disableInstanceAttributeByName(name: string): void;
  32474. /**
  32475. * Disable the instance attribute corresponding to the location in parameter
  32476. * @param attributeLocation defines the attribute location of the attribute to disable
  32477. */
  32478. disableInstanceAttribute(attributeLocation: number): void;
  32479. /**
  32480. * Disable the attribute corresponding to the location in parameter
  32481. * @param attributeLocation defines the attribute location of the attribute to disable
  32482. */
  32483. disableAttributeByIndex(attributeLocation: number): void;
  32484. /**
  32485. * Send a draw order
  32486. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32487. * @param indexStart defines the starting index
  32488. * @param indexCount defines the number of index to draw
  32489. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32490. */
  32491. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32492. /**
  32493. * Draw a list of points
  32494. * @param verticesStart defines the index of first vertex to draw
  32495. * @param verticesCount defines the count of vertices to draw
  32496. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32497. */
  32498. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32499. /**
  32500. * Draw a list of unindexed primitives
  32501. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32502. * @param verticesStart defines the index of first vertex to draw
  32503. * @param verticesCount defines the count of vertices to draw
  32504. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32505. */
  32506. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32507. /**
  32508. * Draw a list of indexed primitives
  32509. * @param fillMode defines the primitive to use
  32510. * @param indexStart defines the starting index
  32511. * @param indexCount defines the number of index to draw
  32512. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32513. */
  32514. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32515. /**
  32516. * Draw a list of unindexed primitives
  32517. * @param fillMode defines the primitive to use
  32518. * @param verticesStart defines the index of first vertex to draw
  32519. * @param verticesCount defines the count of vertices to draw
  32520. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32521. */
  32522. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32523. private _drawMode;
  32524. /** @hidden */
  32525. protected _reportDrawCall(): void;
  32526. /** @hidden */
  32527. _releaseEffect(effect: Effect): void;
  32528. /** @hidden */
  32529. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32530. /**
  32531. * Create a new effect (used to store vertex/fragment shaders)
  32532. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32533. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32534. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32535. * @param samplers defines an array of string used to represent textures
  32536. * @param defines defines the string containing the defines to use to compile the shaders
  32537. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32538. * @param onCompiled defines a function to call when the effect creation is successful
  32539. * @param onError defines a function to call when the effect creation has failed
  32540. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32541. * @returns the new Effect
  32542. */
  32543. 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;
  32544. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32545. private _compileShader;
  32546. private _compileRawShader;
  32547. /** @hidden */
  32548. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32549. /**
  32550. * Directly creates a webGL program
  32551. * @param pipelineContext defines the pipeline context to attach to
  32552. * @param vertexCode defines the vertex shader code to use
  32553. * @param fragmentCode defines the fragment shader code to use
  32554. * @param context defines the webGL context to use (if not set, the current one will be used)
  32555. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32556. * @returns the new webGL program
  32557. */
  32558. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32559. /**
  32560. * Creates a webGL program
  32561. * @param pipelineContext defines the pipeline context to attach to
  32562. * @param vertexCode defines the vertex shader code to use
  32563. * @param fragmentCode defines the fragment shader code to use
  32564. * @param defines defines the string containing the defines to use to compile the shaders
  32565. * @param context defines the webGL context to use (if not set, the current one will be used)
  32566. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32567. * @returns the new webGL program
  32568. */
  32569. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32570. /**
  32571. * Creates a new pipeline context
  32572. * @returns the new pipeline
  32573. */
  32574. createPipelineContext(): IPipelineContext;
  32575. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32576. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32577. /** @hidden */
  32578. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32579. /** @hidden */
  32580. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32581. /** @hidden */
  32582. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32583. /**
  32584. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32585. * @param pipelineContext defines the pipeline context to use
  32586. * @param uniformsNames defines the list of uniform names
  32587. * @returns an array of webGL uniform locations
  32588. */
  32589. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32590. /**
  32591. * Gets the lsit of active attributes for a given webGL program
  32592. * @param pipelineContext defines the pipeline context to use
  32593. * @param attributesNames defines the list of attribute names to get
  32594. * @returns an array of indices indicating the offset of each attribute
  32595. */
  32596. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32597. /**
  32598. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32599. * @param effect defines the effect to activate
  32600. */
  32601. enableEffect(effect: Nullable<Effect>): void;
  32602. /**
  32603. * Set the value of an uniform to a number (int)
  32604. * @param uniform defines the webGL uniform location where to store the value
  32605. * @param value defines the int number to store
  32606. */
  32607. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32608. /**
  32609. * Set the value of an uniform to an array of int32
  32610. * @param uniform defines the webGL uniform location where to store the value
  32611. * @param array defines the array of int32 to store
  32612. */
  32613. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32614. /**
  32615. * Set the value of an uniform to an array of int32 (stored as vec2)
  32616. * @param uniform defines the webGL uniform location where to store the value
  32617. * @param array defines the array of int32 to store
  32618. */
  32619. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32620. /**
  32621. * Set the value of an uniform to an array of int32 (stored as vec3)
  32622. * @param uniform defines the webGL uniform location where to store the value
  32623. * @param array defines the array of int32 to store
  32624. */
  32625. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32626. /**
  32627. * Set the value of an uniform to an array of int32 (stored as vec4)
  32628. * @param uniform defines the webGL uniform location where to store the value
  32629. * @param array defines the array of int32 to store
  32630. */
  32631. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32632. /**
  32633. * Set the value of an uniform to an array of number
  32634. * @param uniform defines the webGL uniform location where to store the value
  32635. * @param array defines the array of number to store
  32636. */
  32637. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32638. /**
  32639. * Set the value of an uniform to an array of number (stored as vec2)
  32640. * @param uniform defines the webGL uniform location where to store the value
  32641. * @param array defines the array of number to store
  32642. */
  32643. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32644. /**
  32645. * Set the value of an uniform to an array of number (stored as vec3)
  32646. * @param uniform defines the webGL uniform location where to store the value
  32647. * @param array defines the array of number to store
  32648. */
  32649. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32650. /**
  32651. * Set the value of an uniform to an array of number (stored as vec4)
  32652. * @param uniform defines the webGL uniform location where to store the value
  32653. * @param array defines the array of number to store
  32654. */
  32655. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32656. /**
  32657. * Set the value of an uniform to an array of float32 (stored as matrices)
  32658. * @param uniform defines the webGL uniform location where to store the value
  32659. * @param matrices defines the array of float32 to store
  32660. */
  32661. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32662. /**
  32663. * Set the value of an uniform to a matrix (3x3)
  32664. * @param uniform defines the webGL uniform location where to store the value
  32665. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32666. */
  32667. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32668. /**
  32669. * Set the value of an uniform to a matrix (2x2)
  32670. * @param uniform defines the webGL uniform location where to store the value
  32671. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32672. */
  32673. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32674. /**
  32675. * Set the value of an uniform to a number (float)
  32676. * @param uniform defines the webGL uniform location where to store the value
  32677. * @param value defines the float number to store
  32678. */
  32679. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32680. /**
  32681. * Set the value of an uniform to a vec2
  32682. * @param uniform defines the webGL uniform location where to store the value
  32683. * @param x defines the 1st component of the value
  32684. * @param y defines the 2nd component of the value
  32685. */
  32686. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32687. /**
  32688. * Set the value of an uniform to a vec3
  32689. * @param uniform defines the webGL uniform location where to store the value
  32690. * @param x defines the 1st component of the value
  32691. * @param y defines the 2nd component of the value
  32692. * @param z defines the 3rd component of the value
  32693. */
  32694. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32695. /**
  32696. * Set the value of an uniform to a vec4
  32697. * @param uniform defines the webGL uniform location where to store the value
  32698. * @param x defines the 1st component of the value
  32699. * @param y defines the 2nd component of the value
  32700. * @param z defines the 3rd component of the value
  32701. * @param w defines the 4th component of the value
  32702. */
  32703. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32704. /**
  32705. * Apply all cached states (depth, culling, stencil and alpha)
  32706. */
  32707. applyStates(): void;
  32708. /**
  32709. * Enable or disable color writing
  32710. * @param enable defines the state to set
  32711. */
  32712. setColorWrite(enable: boolean): void;
  32713. /**
  32714. * Gets a boolean indicating if color writing is enabled
  32715. * @returns the current color writing state
  32716. */
  32717. getColorWrite(): boolean;
  32718. /**
  32719. * Gets the depth culling state manager
  32720. */
  32721. get depthCullingState(): DepthCullingState;
  32722. /**
  32723. * Gets the alpha state manager
  32724. */
  32725. get alphaState(): AlphaState;
  32726. /**
  32727. * Gets the stencil state manager
  32728. */
  32729. get stencilState(): StencilState;
  32730. /**
  32731. * Clears the list of texture accessible through engine.
  32732. * This can help preventing texture load conflict due to name collision.
  32733. */
  32734. clearInternalTexturesCache(): void;
  32735. /**
  32736. * Force the entire cache to be cleared
  32737. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32738. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32739. */
  32740. wipeCaches(bruteForce?: boolean): void;
  32741. /** @hidden */
  32742. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32743. min: number;
  32744. mag: number;
  32745. };
  32746. /** @hidden */
  32747. _createTexture(): WebGLTexture;
  32748. /**
  32749. * Usually called from Texture.ts.
  32750. * Passed information to create a WebGLTexture
  32751. * @param urlArg defines a value which contains one of the following:
  32752. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32753. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32754. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32755. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32756. * @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)
  32757. * @param scene needed for loading to the correct scene
  32758. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32759. * @param onLoad optional callback to be called upon successful completion
  32760. * @param onError optional callback to be called upon failure
  32761. * @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
  32762. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32763. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32764. * @param forcedExtension defines the extension to use to pick the right loader
  32765. * @param mimeType defines an optional mime type
  32766. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32767. */
  32768. 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>, mimeType?: string): InternalTexture;
  32769. /**
  32770. * Loads an image as an HTMLImageElement.
  32771. * @param input url string, ArrayBuffer, or Blob to load
  32772. * @param onLoad callback called when the image successfully loads
  32773. * @param onError callback called when the image fails to load
  32774. * @param offlineProvider offline provider for caching
  32775. * @param mimeType optional mime type
  32776. * @returns the HTMLImageElement of the loaded image
  32777. * @hidden
  32778. */
  32779. 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>;
  32780. /**
  32781. * @hidden
  32782. */
  32783. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32784. /**
  32785. * Creates a raw texture
  32786. * @param data defines the data to store in the texture
  32787. * @param width defines the width of the texture
  32788. * @param height defines the height of the texture
  32789. * @param format defines the format of the data
  32790. * @param generateMipMaps defines if the engine should generate the mip levels
  32791. * @param invertY defines if data must be stored with Y axis inverted
  32792. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32793. * @param compression defines the compression used (null by default)
  32794. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32795. * @returns the raw texture inside an InternalTexture
  32796. */
  32797. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32798. /**
  32799. * Creates a new raw cube texture
  32800. * @param data defines the array of data to use to create each face
  32801. * @param size defines the size of the textures
  32802. * @param format defines the format of the data
  32803. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32804. * @param generateMipMaps defines if the engine should generate the mip levels
  32805. * @param invertY defines if data must be stored with Y axis inverted
  32806. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32807. * @param compression defines the compression used (null by default)
  32808. * @returns the cube texture as an InternalTexture
  32809. */
  32810. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32811. /**
  32812. * Creates a new raw 3D texture
  32813. * @param data defines the data used to create the texture
  32814. * @param width defines the width of the texture
  32815. * @param height defines the height of the texture
  32816. * @param depth defines the depth of the texture
  32817. * @param format defines the format of the texture
  32818. * @param generateMipMaps defines if the engine must generate mip levels
  32819. * @param invertY defines if data must be stored with Y axis inverted
  32820. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32821. * @param compression defines the compressed used (can be null)
  32822. * @param textureType defines the compressed used (can be null)
  32823. * @returns a new raw 3D texture (stored in an InternalTexture)
  32824. */
  32825. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32826. /**
  32827. * Creates a new raw 2D array texture
  32828. * @param data defines the data used to create the texture
  32829. * @param width defines the width of the texture
  32830. * @param height defines the height of the texture
  32831. * @param depth defines the number of layers of the texture
  32832. * @param format defines the format of the texture
  32833. * @param generateMipMaps defines if the engine must generate mip levels
  32834. * @param invertY defines if data must be stored with Y axis inverted
  32835. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32836. * @param compression defines the compressed used (can be null)
  32837. * @param textureType defines the compressed used (can be null)
  32838. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32839. */
  32840. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32841. private _unpackFlipYCached;
  32842. /**
  32843. * In case you are sharing the context with other applications, it might
  32844. * be interested to not cache the unpack flip y state to ensure a consistent
  32845. * value would be set.
  32846. */
  32847. enableUnpackFlipYCached: boolean;
  32848. /** @hidden */
  32849. _unpackFlipY(value: boolean): void;
  32850. /** @hidden */
  32851. _getUnpackAlignement(): number;
  32852. private _getTextureTarget;
  32853. /**
  32854. * Update the sampling mode of a given texture
  32855. * @param samplingMode defines the required sampling mode
  32856. * @param texture defines the texture to update
  32857. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32858. */
  32859. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32860. /**
  32861. * Update the sampling mode of a given texture
  32862. * @param texture defines the texture to update
  32863. * @param wrapU defines the texture wrap mode of the u coordinates
  32864. * @param wrapV defines the texture wrap mode of the v coordinates
  32865. * @param wrapR defines the texture wrap mode of the r coordinates
  32866. */
  32867. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32868. /** @hidden */
  32869. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32870. width: number;
  32871. height: number;
  32872. layers?: number;
  32873. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32874. /** @hidden */
  32875. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32876. /** @hidden */
  32877. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32878. /**
  32879. * Update a portion of an internal texture
  32880. * @param texture defines the texture to update
  32881. * @param imageData defines the data to store into the texture
  32882. * @param xOffset defines the x coordinates of the update rectangle
  32883. * @param yOffset defines the y coordinates of the update rectangle
  32884. * @param width defines the width of the update rectangle
  32885. * @param height defines the height of the update rectangle
  32886. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32887. * @param lod defines the lod level to update (0 by default)
  32888. */
  32889. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32890. /** @hidden */
  32891. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32892. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32893. private _prepareWebGLTexture;
  32894. /** @hidden */
  32895. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32896. private _getDepthStencilBuffer;
  32897. /** @hidden */
  32898. _releaseFramebufferObjects(texture: InternalTexture): void;
  32899. /** @hidden */
  32900. _releaseTexture(texture: InternalTexture): void;
  32901. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32902. protected _setProgram(program: WebGLProgram): void;
  32903. protected _boundUniforms: {
  32904. [key: number]: WebGLUniformLocation;
  32905. };
  32906. /**
  32907. * Binds an effect to the webGL context
  32908. * @param effect defines the effect to bind
  32909. */
  32910. bindSamplers(effect: Effect): void;
  32911. private _activateCurrentTexture;
  32912. /** @hidden */
  32913. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32914. /** @hidden */
  32915. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32916. /**
  32917. * Unbind all textures from the webGL context
  32918. */
  32919. unbindAllTextures(): void;
  32920. /**
  32921. * Sets a texture to the according uniform.
  32922. * @param channel The texture channel
  32923. * @param uniform The uniform to set
  32924. * @param texture The texture to apply
  32925. */
  32926. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32927. private _bindSamplerUniformToChannel;
  32928. private _getTextureWrapMode;
  32929. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32930. /**
  32931. * Sets an array of texture to the webGL context
  32932. * @param channel defines the channel where the texture array must be set
  32933. * @param uniform defines the associated uniform location
  32934. * @param textures defines the array of textures to bind
  32935. */
  32936. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32937. /** @hidden */
  32938. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32939. private _setTextureParameterFloat;
  32940. private _setTextureParameterInteger;
  32941. /**
  32942. * Unbind all vertex attributes from the webGL context
  32943. */
  32944. unbindAllAttributes(): void;
  32945. /**
  32946. * 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
  32947. */
  32948. releaseEffects(): void;
  32949. /**
  32950. * Dispose and release all associated resources
  32951. */
  32952. dispose(): void;
  32953. /**
  32954. * Attach a new callback raised when context lost event is fired
  32955. * @param callback defines the callback to call
  32956. */
  32957. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32958. /**
  32959. * Attach a new callback raised when context restored event is fired
  32960. * @param callback defines the callback to call
  32961. */
  32962. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32963. /**
  32964. * Get the current error code of the webGL context
  32965. * @returns the error code
  32966. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32967. */
  32968. getError(): number;
  32969. private _canRenderToFloatFramebuffer;
  32970. private _canRenderToHalfFloatFramebuffer;
  32971. private _canRenderToFramebuffer;
  32972. /** @hidden */
  32973. _getWebGLTextureType(type: number): number;
  32974. /** @hidden */
  32975. _getInternalFormat(format: number): number;
  32976. /** @hidden */
  32977. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32978. /** @hidden */
  32979. _getRGBAMultiSampleBufferFormat(type: number): number;
  32980. /** @hidden */
  32981. _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;
  32982. /**
  32983. * Loads a file from a url
  32984. * @param url url to load
  32985. * @param onSuccess callback called when the file successfully loads
  32986. * @param onProgress callback called while file is loading (if the server supports this mode)
  32987. * @param offlineProvider defines the offline provider for caching
  32988. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32989. * @param onError callback called when the file fails to load
  32990. * @returns a file request object
  32991. * @hidden
  32992. */
  32993. 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;
  32994. /**
  32995. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32996. * @param x defines the x coordinate of the rectangle where pixels must be read
  32997. * @param y defines the y coordinate of the rectangle where pixels must be read
  32998. * @param width defines the width of the rectangle where pixels must be read
  32999. * @param height defines the height of the rectangle where pixels must be read
  33000. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33001. * @returns a Uint8Array containing RGBA colors
  33002. */
  33003. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33004. private static _isSupported;
  33005. /**
  33006. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33007. * @returns true if the engine can be created
  33008. * @ignorenaming
  33009. */
  33010. static isSupported(): boolean;
  33011. /**
  33012. * Find the next highest power of two.
  33013. * @param x Number to start search from.
  33014. * @return Next highest power of two.
  33015. */
  33016. static CeilingPOT(x: number): number;
  33017. /**
  33018. * Find the next lowest power of two.
  33019. * @param x Number to start search from.
  33020. * @return Next lowest power of two.
  33021. */
  33022. static FloorPOT(x: number): number;
  33023. /**
  33024. * Find the nearest power of two.
  33025. * @param x Number to start search from.
  33026. * @return Next nearest power of two.
  33027. */
  33028. static NearestPOT(x: number): number;
  33029. /**
  33030. * Get the closest exponent of two
  33031. * @param value defines the value to approximate
  33032. * @param max defines the maximum value to return
  33033. * @param mode defines how to define the closest value
  33034. * @returns closest exponent of two of the given value
  33035. */
  33036. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33037. /**
  33038. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33039. * @param func - the function to be called
  33040. * @param requester - the object that will request the next frame. Falls back to window.
  33041. * @returns frame number
  33042. */
  33043. static QueueNewFrame(func: () => void, requester?: any): number;
  33044. /**
  33045. * Gets host document
  33046. * @returns the host document object
  33047. */
  33048. getHostDocument(): Nullable<Document>;
  33049. }
  33050. }
  33051. declare module "babylonjs/Maths/sphericalPolynomial" {
  33052. import { Vector3 } from "babylonjs/Maths/math.vector";
  33053. import { Color3 } from "babylonjs/Maths/math.color";
  33054. /**
  33055. * Class representing spherical harmonics coefficients to the 3rd degree
  33056. */
  33057. export class SphericalHarmonics {
  33058. /**
  33059. * Defines whether or not the harmonics have been prescaled for rendering.
  33060. */
  33061. preScaled: boolean;
  33062. /**
  33063. * The l0,0 coefficients of the spherical harmonics
  33064. */
  33065. l00: Vector3;
  33066. /**
  33067. * The l1,-1 coefficients of the spherical harmonics
  33068. */
  33069. l1_1: Vector3;
  33070. /**
  33071. * The l1,0 coefficients of the spherical harmonics
  33072. */
  33073. l10: Vector3;
  33074. /**
  33075. * The l1,1 coefficients of the spherical harmonics
  33076. */
  33077. l11: Vector3;
  33078. /**
  33079. * The l2,-2 coefficients of the spherical harmonics
  33080. */
  33081. l2_2: Vector3;
  33082. /**
  33083. * The l2,-1 coefficients of the spherical harmonics
  33084. */
  33085. l2_1: Vector3;
  33086. /**
  33087. * The l2,0 coefficients of the spherical harmonics
  33088. */
  33089. l20: Vector3;
  33090. /**
  33091. * The l2,1 coefficients of the spherical harmonics
  33092. */
  33093. l21: Vector3;
  33094. /**
  33095. * The l2,2 coefficients of the spherical harmonics
  33096. */
  33097. l22: Vector3;
  33098. /**
  33099. * Adds a light to the spherical harmonics
  33100. * @param direction the direction of the light
  33101. * @param color the color of the light
  33102. * @param deltaSolidAngle the delta solid angle of the light
  33103. */
  33104. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33105. /**
  33106. * Scales the spherical harmonics by the given amount
  33107. * @param scale the amount to scale
  33108. */
  33109. scaleInPlace(scale: number): void;
  33110. /**
  33111. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33112. *
  33113. * ```
  33114. * E_lm = A_l * L_lm
  33115. * ```
  33116. *
  33117. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33118. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33119. * the scaling factors are given in equation 9.
  33120. */
  33121. convertIncidentRadianceToIrradiance(): void;
  33122. /**
  33123. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33124. *
  33125. * ```
  33126. * L = (1/pi) * E * rho
  33127. * ```
  33128. *
  33129. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33130. */
  33131. convertIrradianceToLambertianRadiance(): void;
  33132. /**
  33133. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33134. * required operations at run time.
  33135. *
  33136. * This is simply done by scaling back the SH with Ylm constants parameter.
  33137. * The trigonometric part being applied by the shader at run time.
  33138. */
  33139. preScaleForRendering(): void;
  33140. /**
  33141. * Constructs a spherical harmonics from an array.
  33142. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33143. * @returns the spherical harmonics
  33144. */
  33145. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33146. /**
  33147. * Gets the spherical harmonics from polynomial
  33148. * @param polynomial the spherical polynomial
  33149. * @returns the spherical harmonics
  33150. */
  33151. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33152. }
  33153. /**
  33154. * Class representing spherical polynomial coefficients to the 3rd degree
  33155. */
  33156. export class SphericalPolynomial {
  33157. private _harmonics;
  33158. /**
  33159. * The spherical harmonics used to create the polynomials.
  33160. */
  33161. get preScaledHarmonics(): SphericalHarmonics;
  33162. /**
  33163. * The x coefficients of the spherical polynomial
  33164. */
  33165. x: Vector3;
  33166. /**
  33167. * The y coefficients of the spherical polynomial
  33168. */
  33169. y: Vector3;
  33170. /**
  33171. * The z coefficients of the spherical polynomial
  33172. */
  33173. z: Vector3;
  33174. /**
  33175. * The xx coefficients of the spherical polynomial
  33176. */
  33177. xx: Vector3;
  33178. /**
  33179. * The yy coefficients of the spherical polynomial
  33180. */
  33181. yy: Vector3;
  33182. /**
  33183. * The zz coefficients of the spherical polynomial
  33184. */
  33185. zz: Vector3;
  33186. /**
  33187. * The xy coefficients of the spherical polynomial
  33188. */
  33189. xy: Vector3;
  33190. /**
  33191. * The yz coefficients of the spherical polynomial
  33192. */
  33193. yz: Vector3;
  33194. /**
  33195. * The zx coefficients of the spherical polynomial
  33196. */
  33197. zx: Vector3;
  33198. /**
  33199. * Adds an ambient color to the spherical polynomial
  33200. * @param color the color to add
  33201. */
  33202. addAmbient(color: Color3): void;
  33203. /**
  33204. * Scales the spherical polynomial by the given amount
  33205. * @param scale the amount to scale
  33206. */
  33207. scaleInPlace(scale: number): void;
  33208. /**
  33209. * Gets the spherical polynomial from harmonics
  33210. * @param harmonics the spherical harmonics
  33211. * @returns the spherical polynomial
  33212. */
  33213. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33214. /**
  33215. * Constructs a spherical polynomial from an array.
  33216. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33217. * @returns the spherical polynomial
  33218. */
  33219. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33220. }
  33221. }
  33222. declare module "babylonjs/Materials/Textures/internalTexture" {
  33223. import { Observable } from "babylonjs/Misc/observable";
  33224. import { Nullable, int } from "babylonjs/types";
  33225. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33226. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33227. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33228. /**
  33229. * Defines the source of the internal texture
  33230. */
  33231. export enum InternalTextureSource {
  33232. /**
  33233. * The source of the texture data is unknown
  33234. */
  33235. Unknown = 0,
  33236. /**
  33237. * Texture data comes from an URL
  33238. */
  33239. Url = 1,
  33240. /**
  33241. * Texture data is only used for temporary storage
  33242. */
  33243. Temp = 2,
  33244. /**
  33245. * Texture data comes from raw data (ArrayBuffer)
  33246. */
  33247. Raw = 3,
  33248. /**
  33249. * Texture content is dynamic (video or dynamic texture)
  33250. */
  33251. Dynamic = 4,
  33252. /**
  33253. * Texture content is generated by rendering to it
  33254. */
  33255. RenderTarget = 5,
  33256. /**
  33257. * Texture content is part of a multi render target process
  33258. */
  33259. MultiRenderTarget = 6,
  33260. /**
  33261. * Texture data comes from a cube data file
  33262. */
  33263. Cube = 7,
  33264. /**
  33265. * Texture data comes from a raw cube data
  33266. */
  33267. CubeRaw = 8,
  33268. /**
  33269. * Texture data come from a prefiltered cube data file
  33270. */
  33271. CubePrefiltered = 9,
  33272. /**
  33273. * Texture content is raw 3D data
  33274. */
  33275. Raw3D = 10,
  33276. /**
  33277. * Texture content is raw 2D array data
  33278. */
  33279. Raw2DArray = 11,
  33280. /**
  33281. * Texture content is a depth texture
  33282. */
  33283. Depth = 12,
  33284. /**
  33285. * Texture data comes from a raw cube data encoded with RGBD
  33286. */
  33287. CubeRawRGBD = 13
  33288. }
  33289. /**
  33290. * Class used to store data associated with WebGL texture data for the engine
  33291. * This class should not be used directly
  33292. */
  33293. export class InternalTexture {
  33294. /** @hidden */
  33295. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33296. /**
  33297. * Defines if the texture is ready
  33298. */
  33299. isReady: boolean;
  33300. /**
  33301. * Defines if the texture is a cube texture
  33302. */
  33303. isCube: boolean;
  33304. /**
  33305. * Defines if the texture contains 3D data
  33306. */
  33307. is3D: boolean;
  33308. /**
  33309. * Defines if the texture contains 2D array data
  33310. */
  33311. is2DArray: boolean;
  33312. /**
  33313. * Defines if the texture contains multiview data
  33314. */
  33315. isMultiview: boolean;
  33316. /**
  33317. * Gets the URL used to load this texture
  33318. */
  33319. url: string;
  33320. /**
  33321. * Gets the sampling mode of the texture
  33322. */
  33323. samplingMode: number;
  33324. /**
  33325. * Gets a boolean indicating if the texture needs mipmaps generation
  33326. */
  33327. generateMipMaps: boolean;
  33328. /**
  33329. * Gets the number of samples used by the texture (WebGL2+ only)
  33330. */
  33331. samples: number;
  33332. /**
  33333. * Gets the type of the texture (int, float...)
  33334. */
  33335. type: number;
  33336. /**
  33337. * Gets the format of the texture (RGB, RGBA...)
  33338. */
  33339. format: number;
  33340. /**
  33341. * Observable called when the texture is loaded
  33342. */
  33343. onLoadedObservable: Observable<InternalTexture>;
  33344. /**
  33345. * Gets the width of the texture
  33346. */
  33347. width: number;
  33348. /**
  33349. * Gets the height of the texture
  33350. */
  33351. height: number;
  33352. /**
  33353. * Gets the depth of the texture
  33354. */
  33355. depth: number;
  33356. /**
  33357. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33358. */
  33359. baseWidth: number;
  33360. /**
  33361. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33362. */
  33363. baseHeight: number;
  33364. /**
  33365. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33366. */
  33367. baseDepth: number;
  33368. /**
  33369. * Gets a boolean indicating if the texture is inverted on Y axis
  33370. */
  33371. invertY: boolean;
  33372. /** @hidden */
  33373. _invertVScale: boolean;
  33374. /** @hidden */
  33375. _associatedChannel: number;
  33376. /** @hidden */
  33377. _source: InternalTextureSource;
  33378. /** @hidden */
  33379. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33380. /** @hidden */
  33381. _bufferView: Nullable<ArrayBufferView>;
  33382. /** @hidden */
  33383. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33384. /** @hidden */
  33385. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33386. /** @hidden */
  33387. _size: number;
  33388. /** @hidden */
  33389. _extension: string;
  33390. /** @hidden */
  33391. _files: Nullable<string[]>;
  33392. /** @hidden */
  33393. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33394. /** @hidden */
  33395. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33396. /** @hidden */
  33397. _framebuffer: Nullable<WebGLFramebuffer>;
  33398. /** @hidden */
  33399. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33400. /** @hidden */
  33401. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33402. /** @hidden */
  33403. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33404. /** @hidden */
  33405. _attachments: Nullable<number[]>;
  33406. /** @hidden */
  33407. _cachedCoordinatesMode: Nullable<number>;
  33408. /** @hidden */
  33409. _cachedWrapU: Nullable<number>;
  33410. /** @hidden */
  33411. _cachedWrapV: Nullable<number>;
  33412. /** @hidden */
  33413. _cachedWrapR: Nullable<number>;
  33414. /** @hidden */
  33415. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33416. /** @hidden */
  33417. _isDisabled: boolean;
  33418. /** @hidden */
  33419. _compression: Nullable<string>;
  33420. /** @hidden */
  33421. _generateStencilBuffer: boolean;
  33422. /** @hidden */
  33423. _generateDepthBuffer: boolean;
  33424. /** @hidden */
  33425. _comparisonFunction: number;
  33426. /** @hidden */
  33427. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33428. /** @hidden */
  33429. _lodGenerationScale: number;
  33430. /** @hidden */
  33431. _lodGenerationOffset: number;
  33432. /** @hidden */
  33433. _depthStencilTexture: Nullable<InternalTexture>;
  33434. /** @hidden */
  33435. _colorTextureArray: Nullable<WebGLTexture>;
  33436. /** @hidden */
  33437. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33438. /** @hidden */
  33439. _lodTextureHigh: Nullable<BaseTexture>;
  33440. /** @hidden */
  33441. _lodTextureMid: Nullable<BaseTexture>;
  33442. /** @hidden */
  33443. _lodTextureLow: Nullable<BaseTexture>;
  33444. /** @hidden */
  33445. _isRGBD: boolean;
  33446. /** @hidden */
  33447. _linearSpecularLOD: boolean;
  33448. /** @hidden */
  33449. _irradianceTexture: Nullable<BaseTexture>;
  33450. /** @hidden */
  33451. _webGLTexture: Nullable<WebGLTexture>;
  33452. /** @hidden */
  33453. _references: number;
  33454. private _engine;
  33455. /**
  33456. * Gets the Engine the texture belongs to.
  33457. * @returns The babylon engine
  33458. */
  33459. getEngine(): ThinEngine;
  33460. /**
  33461. * Gets the data source type of the texture
  33462. */
  33463. get source(): InternalTextureSource;
  33464. /**
  33465. * Creates a new InternalTexture
  33466. * @param engine defines the engine to use
  33467. * @param source defines the type of data that will be used
  33468. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33469. */
  33470. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33471. /**
  33472. * Increments the number of references (ie. the number of Texture that point to it)
  33473. */
  33474. incrementReferences(): void;
  33475. /**
  33476. * Change the size of the texture (not the size of the content)
  33477. * @param width defines the new width
  33478. * @param height defines the new height
  33479. * @param depth defines the new depth (1 by default)
  33480. */
  33481. updateSize(width: int, height: int, depth?: int): void;
  33482. /** @hidden */
  33483. _rebuild(): void;
  33484. /** @hidden */
  33485. _swapAndDie(target: InternalTexture): void;
  33486. /**
  33487. * Dispose the current allocated resources
  33488. */
  33489. dispose(): void;
  33490. }
  33491. }
  33492. declare module "babylonjs/Audio/analyser" {
  33493. import { Scene } from "babylonjs/scene";
  33494. /**
  33495. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33496. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33497. */
  33498. export class Analyser {
  33499. /**
  33500. * Gets or sets the smoothing
  33501. * @ignorenaming
  33502. */
  33503. SMOOTHING: number;
  33504. /**
  33505. * Gets or sets the FFT table size
  33506. * @ignorenaming
  33507. */
  33508. FFT_SIZE: number;
  33509. /**
  33510. * Gets or sets the bar graph amplitude
  33511. * @ignorenaming
  33512. */
  33513. BARGRAPHAMPLITUDE: number;
  33514. /**
  33515. * Gets or sets the position of the debug canvas
  33516. * @ignorenaming
  33517. */
  33518. DEBUGCANVASPOS: {
  33519. x: number;
  33520. y: number;
  33521. };
  33522. /**
  33523. * Gets or sets the debug canvas size
  33524. * @ignorenaming
  33525. */
  33526. DEBUGCANVASSIZE: {
  33527. width: number;
  33528. height: number;
  33529. };
  33530. private _byteFreqs;
  33531. private _byteTime;
  33532. private _floatFreqs;
  33533. private _webAudioAnalyser;
  33534. private _debugCanvas;
  33535. private _debugCanvasContext;
  33536. private _scene;
  33537. private _registerFunc;
  33538. private _audioEngine;
  33539. /**
  33540. * Creates a new analyser
  33541. * @param scene defines hosting scene
  33542. */
  33543. constructor(scene: Scene);
  33544. /**
  33545. * Get the number of data values you will have to play with for the visualization
  33546. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33547. * @returns a number
  33548. */
  33549. getFrequencyBinCount(): number;
  33550. /**
  33551. * Gets the current frequency data as a byte array
  33552. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33553. * @returns a Uint8Array
  33554. */
  33555. getByteFrequencyData(): Uint8Array;
  33556. /**
  33557. * Gets the current waveform as a byte array
  33558. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33559. * @returns a Uint8Array
  33560. */
  33561. getByteTimeDomainData(): Uint8Array;
  33562. /**
  33563. * Gets the current frequency data as a float array
  33564. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33565. * @returns a Float32Array
  33566. */
  33567. getFloatFrequencyData(): Float32Array;
  33568. /**
  33569. * Renders the debug canvas
  33570. */
  33571. drawDebugCanvas(): void;
  33572. /**
  33573. * Stops rendering the debug canvas and removes it
  33574. */
  33575. stopDebugCanvas(): void;
  33576. /**
  33577. * Connects two audio nodes
  33578. * @param inputAudioNode defines first node to connect
  33579. * @param outputAudioNode defines second node to connect
  33580. */
  33581. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33582. /**
  33583. * Releases all associated resources
  33584. */
  33585. dispose(): void;
  33586. }
  33587. }
  33588. declare module "babylonjs/Audio/audioEngine" {
  33589. import { IDisposable } from "babylonjs/scene";
  33590. import { Analyser } from "babylonjs/Audio/analyser";
  33591. import { Nullable } from "babylonjs/types";
  33592. import { Observable } from "babylonjs/Misc/observable";
  33593. /**
  33594. * This represents an audio engine and it is responsible
  33595. * to play, synchronize and analyse sounds throughout the application.
  33596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33597. */
  33598. export interface IAudioEngine extends IDisposable {
  33599. /**
  33600. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33601. */
  33602. readonly canUseWebAudio: boolean;
  33603. /**
  33604. * Gets the current AudioContext if available.
  33605. */
  33606. readonly audioContext: Nullable<AudioContext>;
  33607. /**
  33608. * The master gain node defines the global audio volume of your audio engine.
  33609. */
  33610. readonly masterGain: GainNode;
  33611. /**
  33612. * Gets whether or not mp3 are supported by your browser.
  33613. */
  33614. readonly isMP3supported: boolean;
  33615. /**
  33616. * Gets whether or not ogg are supported by your browser.
  33617. */
  33618. readonly isOGGsupported: boolean;
  33619. /**
  33620. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33621. * @ignoreNaming
  33622. */
  33623. WarnedWebAudioUnsupported: boolean;
  33624. /**
  33625. * Defines if the audio engine relies on a custom unlocked button.
  33626. * In this case, the embedded button will not be displayed.
  33627. */
  33628. useCustomUnlockedButton: boolean;
  33629. /**
  33630. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33631. */
  33632. readonly unlocked: boolean;
  33633. /**
  33634. * Event raised when audio has been unlocked on the browser.
  33635. */
  33636. onAudioUnlockedObservable: Observable<AudioEngine>;
  33637. /**
  33638. * Event raised when audio has been locked on the browser.
  33639. */
  33640. onAudioLockedObservable: Observable<AudioEngine>;
  33641. /**
  33642. * Flags the audio engine in Locked state.
  33643. * This happens due to new browser policies preventing audio to autoplay.
  33644. */
  33645. lock(): void;
  33646. /**
  33647. * Unlocks the audio engine once a user action has been done on the dom.
  33648. * This is helpful to resume play once browser policies have been satisfied.
  33649. */
  33650. unlock(): void;
  33651. /**
  33652. * Gets the global volume sets on the master gain.
  33653. * @returns the global volume if set or -1 otherwise
  33654. */
  33655. getGlobalVolume(): number;
  33656. /**
  33657. * Sets the global volume of your experience (sets on the master gain).
  33658. * @param newVolume Defines the new global volume of the application
  33659. */
  33660. setGlobalVolume(newVolume: number): void;
  33661. /**
  33662. * Connect the audio engine to an audio analyser allowing some amazing
  33663. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33665. * @param analyser The analyser to connect to the engine
  33666. */
  33667. connectToAnalyser(analyser: Analyser): void;
  33668. }
  33669. /**
  33670. * This represents the default audio engine used in babylon.
  33671. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33673. */
  33674. export class AudioEngine implements IAudioEngine {
  33675. private _audioContext;
  33676. private _audioContextInitialized;
  33677. private _muteButton;
  33678. private _hostElement;
  33679. /**
  33680. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33681. */
  33682. canUseWebAudio: boolean;
  33683. /**
  33684. * The master gain node defines the global audio volume of your audio engine.
  33685. */
  33686. masterGain: GainNode;
  33687. /**
  33688. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33689. * @ignoreNaming
  33690. */
  33691. WarnedWebAudioUnsupported: boolean;
  33692. /**
  33693. * Gets whether or not mp3 are supported by your browser.
  33694. */
  33695. isMP3supported: boolean;
  33696. /**
  33697. * Gets whether or not ogg are supported by your browser.
  33698. */
  33699. isOGGsupported: boolean;
  33700. /**
  33701. * Gets whether audio has been unlocked on the device.
  33702. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33703. * a user interaction has happened.
  33704. */
  33705. unlocked: boolean;
  33706. /**
  33707. * Defines if the audio engine relies on a custom unlocked button.
  33708. * In this case, the embedded button will not be displayed.
  33709. */
  33710. useCustomUnlockedButton: boolean;
  33711. /**
  33712. * Event raised when audio has been unlocked on the browser.
  33713. */
  33714. onAudioUnlockedObservable: Observable<AudioEngine>;
  33715. /**
  33716. * Event raised when audio has been locked on the browser.
  33717. */
  33718. onAudioLockedObservable: Observable<AudioEngine>;
  33719. /**
  33720. * Gets the current AudioContext if available.
  33721. */
  33722. get audioContext(): Nullable<AudioContext>;
  33723. private _connectedAnalyser;
  33724. /**
  33725. * Instantiates a new audio engine.
  33726. *
  33727. * There should be only one per page as some browsers restrict the number
  33728. * of audio contexts you can create.
  33729. * @param hostElement defines the host element where to display the mute icon if necessary
  33730. */
  33731. constructor(hostElement?: Nullable<HTMLElement>);
  33732. /**
  33733. * Flags the audio engine in Locked state.
  33734. * This happens due to new browser policies preventing audio to autoplay.
  33735. */
  33736. lock(): void;
  33737. /**
  33738. * Unlocks the audio engine once a user action has been done on the dom.
  33739. * This is helpful to resume play once browser policies have been satisfied.
  33740. */
  33741. unlock(): void;
  33742. private _resumeAudioContext;
  33743. private _initializeAudioContext;
  33744. private _tryToRun;
  33745. private _triggerRunningState;
  33746. private _triggerSuspendedState;
  33747. private _displayMuteButton;
  33748. private _moveButtonToTopLeft;
  33749. private _onResize;
  33750. private _hideMuteButton;
  33751. /**
  33752. * Destroy and release the resources associated with the audio ccontext.
  33753. */
  33754. dispose(): void;
  33755. /**
  33756. * Gets the global volume sets on the master gain.
  33757. * @returns the global volume if set or -1 otherwise
  33758. */
  33759. getGlobalVolume(): number;
  33760. /**
  33761. * Sets the global volume of your experience (sets on the master gain).
  33762. * @param newVolume Defines the new global volume of the application
  33763. */
  33764. setGlobalVolume(newVolume: number): void;
  33765. /**
  33766. * Connect the audio engine to an audio analyser allowing some amazing
  33767. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33769. * @param analyser The analyser to connect to the engine
  33770. */
  33771. connectToAnalyser(analyser: Analyser): void;
  33772. }
  33773. }
  33774. declare module "babylonjs/Loading/loadingScreen" {
  33775. /**
  33776. * Interface used to present a loading screen while loading a scene
  33777. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33778. */
  33779. export interface ILoadingScreen {
  33780. /**
  33781. * Function called to display the loading screen
  33782. */
  33783. displayLoadingUI: () => void;
  33784. /**
  33785. * Function called to hide the loading screen
  33786. */
  33787. hideLoadingUI: () => void;
  33788. /**
  33789. * Gets or sets the color to use for the background
  33790. */
  33791. loadingUIBackgroundColor: string;
  33792. /**
  33793. * Gets or sets the text to display while loading
  33794. */
  33795. loadingUIText: string;
  33796. }
  33797. /**
  33798. * Class used for the default loading screen
  33799. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33800. */
  33801. export class DefaultLoadingScreen implements ILoadingScreen {
  33802. private _renderingCanvas;
  33803. private _loadingText;
  33804. private _loadingDivBackgroundColor;
  33805. private _loadingDiv;
  33806. private _loadingTextDiv;
  33807. /** Gets or sets the logo url to use for the default loading screen */
  33808. static DefaultLogoUrl: string;
  33809. /** Gets or sets the spinner url to use for the default loading screen */
  33810. static DefaultSpinnerUrl: string;
  33811. /**
  33812. * Creates a new default loading screen
  33813. * @param _renderingCanvas defines the canvas used to render the scene
  33814. * @param _loadingText defines the default text to display
  33815. * @param _loadingDivBackgroundColor defines the default background color
  33816. */
  33817. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33818. /**
  33819. * Function called to display the loading screen
  33820. */
  33821. displayLoadingUI(): void;
  33822. /**
  33823. * Function called to hide the loading screen
  33824. */
  33825. hideLoadingUI(): void;
  33826. /**
  33827. * Gets or sets the text to display while loading
  33828. */
  33829. set loadingUIText(text: string);
  33830. get loadingUIText(): string;
  33831. /**
  33832. * Gets or sets the color to use for the background
  33833. */
  33834. get loadingUIBackgroundColor(): string;
  33835. set loadingUIBackgroundColor(color: string);
  33836. private _resizeLoadingUI;
  33837. }
  33838. }
  33839. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33840. /**
  33841. * Interface for any object that can request an animation frame
  33842. */
  33843. export interface ICustomAnimationFrameRequester {
  33844. /**
  33845. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33846. */
  33847. renderFunction?: Function;
  33848. /**
  33849. * Called to request the next frame to render to
  33850. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33851. */
  33852. requestAnimationFrame: Function;
  33853. /**
  33854. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33855. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33856. */
  33857. requestID?: number;
  33858. }
  33859. }
  33860. declare module "babylonjs/Misc/performanceMonitor" {
  33861. /**
  33862. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33863. */
  33864. export class PerformanceMonitor {
  33865. private _enabled;
  33866. private _rollingFrameTime;
  33867. private _lastFrameTimeMs;
  33868. /**
  33869. * constructor
  33870. * @param frameSampleSize The number of samples required to saturate the sliding window
  33871. */
  33872. constructor(frameSampleSize?: number);
  33873. /**
  33874. * Samples current frame
  33875. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33876. */
  33877. sampleFrame(timeMs?: number): void;
  33878. /**
  33879. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33880. */
  33881. get averageFrameTime(): number;
  33882. /**
  33883. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33884. */
  33885. get averageFrameTimeVariance(): number;
  33886. /**
  33887. * Returns the frame time of the most recent frame
  33888. */
  33889. get instantaneousFrameTime(): number;
  33890. /**
  33891. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33892. */
  33893. get averageFPS(): number;
  33894. /**
  33895. * Returns the average framerate in frames per second using the most recent frame time
  33896. */
  33897. get instantaneousFPS(): number;
  33898. /**
  33899. * Returns true if enough samples have been taken to completely fill the sliding window
  33900. */
  33901. get isSaturated(): boolean;
  33902. /**
  33903. * Enables contributions to the sliding window sample set
  33904. */
  33905. enable(): void;
  33906. /**
  33907. * Disables contributions to the sliding window sample set
  33908. * Samples will not be interpolated over the disabled period
  33909. */
  33910. disable(): void;
  33911. /**
  33912. * Returns true if sampling is enabled
  33913. */
  33914. get isEnabled(): boolean;
  33915. /**
  33916. * Resets performance monitor
  33917. */
  33918. reset(): void;
  33919. }
  33920. /**
  33921. * RollingAverage
  33922. *
  33923. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33924. */
  33925. export class RollingAverage {
  33926. /**
  33927. * Current average
  33928. */
  33929. average: number;
  33930. /**
  33931. * Current variance
  33932. */
  33933. variance: number;
  33934. protected _samples: Array<number>;
  33935. protected _sampleCount: number;
  33936. protected _pos: number;
  33937. protected _m2: number;
  33938. /**
  33939. * constructor
  33940. * @param length The number of samples required to saturate the sliding window
  33941. */
  33942. constructor(length: number);
  33943. /**
  33944. * Adds a sample to the sample set
  33945. * @param v The sample value
  33946. */
  33947. add(v: number): void;
  33948. /**
  33949. * Returns previously added values or null if outside of history or outside the sliding window domain
  33950. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33951. * @return Value previously recorded with add() or null if outside of range
  33952. */
  33953. history(i: number): number;
  33954. /**
  33955. * Returns true if enough samples have been taken to completely fill the sliding window
  33956. * @return true if sample-set saturated
  33957. */
  33958. isSaturated(): boolean;
  33959. /**
  33960. * Resets the rolling average (equivalent to 0 samples taken so far)
  33961. */
  33962. reset(): void;
  33963. /**
  33964. * Wraps a value around the sample range boundaries
  33965. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33966. * @return Wrapped position in sample range
  33967. */
  33968. protected _wrapPosition(i: number): number;
  33969. }
  33970. }
  33971. declare module "babylonjs/Misc/perfCounter" {
  33972. /**
  33973. * This class is used to track a performance counter which is number based.
  33974. * The user has access to many properties which give statistics of different nature.
  33975. *
  33976. * The implementer can track two kinds of Performance Counter: time and count.
  33977. * 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.
  33978. * 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.
  33979. */
  33980. export class PerfCounter {
  33981. /**
  33982. * Gets or sets a global boolean to turn on and off all the counters
  33983. */
  33984. static Enabled: boolean;
  33985. /**
  33986. * Returns the smallest value ever
  33987. */
  33988. get min(): number;
  33989. /**
  33990. * Returns the biggest value ever
  33991. */
  33992. get max(): number;
  33993. /**
  33994. * Returns the average value since the performance counter is running
  33995. */
  33996. get average(): number;
  33997. /**
  33998. * Returns the average value of the last second the counter was monitored
  33999. */
  34000. get lastSecAverage(): number;
  34001. /**
  34002. * Returns the current value
  34003. */
  34004. get current(): number;
  34005. /**
  34006. * Gets the accumulated total
  34007. */
  34008. get total(): number;
  34009. /**
  34010. * Gets the total value count
  34011. */
  34012. get count(): number;
  34013. /**
  34014. * Creates a new counter
  34015. */
  34016. constructor();
  34017. /**
  34018. * Call this method to start monitoring a new frame.
  34019. * 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.
  34020. */
  34021. fetchNewFrame(): void;
  34022. /**
  34023. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34024. * @param newCount the count value to add to the monitored count
  34025. * @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.
  34026. */
  34027. addCount(newCount: number, fetchResult: boolean): void;
  34028. /**
  34029. * Start monitoring this performance counter
  34030. */
  34031. beginMonitoring(): void;
  34032. /**
  34033. * Compute the time lapsed since the previous beginMonitoring() call.
  34034. * @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
  34035. */
  34036. endMonitoring(newFrame?: boolean): void;
  34037. private _fetchResult;
  34038. private _startMonitoringTime;
  34039. private _min;
  34040. private _max;
  34041. private _average;
  34042. private _current;
  34043. private _totalValueCount;
  34044. private _totalAccumulated;
  34045. private _lastSecAverage;
  34046. private _lastSecAccumulated;
  34047. private _lastSecTime;
  34048. private _lastSecValueCount;
  34049. }
  34050. }
  34051. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34052. module "babylonjs/Engines/thinEngine" {
  34053. interface ThinEngine {
  34054. /**
  34055. * Sets alpha constants used by some alpha blending modes
  34056. * @param r defines the red component
  34057. * @param g defines the green component
  34058. * @param b defines the blue component
  34059. * @param a defines the alpha component
  34060. */
  34061. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34062. /**
  34063. * Sets the current alpha mode
  34064. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34065. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34066. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34067. */
  34068. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34069. /**
  34070. * Gets the current alpha mode
  34071. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34072. * @returns the current alpha mode
  34073. */
  34074. getAlphaMode(): number;
  34075. /**
  34076. * Sets the current alpha equation
  34077. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34078. */
  34079. setAlphaEquation(equation: number): void;
  34080. /**
  34081. * Gets the current alpha equation.
  34082. * @returns the current alpha equation
  34083. */
  34084. getAlphaEquation(): number;
  34085. }
  34086. }
  34087. }
  34088. declare module "babylonjs/Engines/engine" {
  34089. import { Observable } from "babylonjs/Misc/observable";
  34090. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34091. import { Scene } from "babylonjs/scene";
  34092. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34093. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34094. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34095. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34096. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34097. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34098. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34099. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34100. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34101. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34102. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34103. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34104. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34105. import "babylonjs/Engines/Extensions/engine.alpha";
  34106. import { Material } from "babylonjs/Materials/material";
  34107. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34108. /**
  34109. * Defines the interface used by display changed events
  34110. */
  34111. export interface IDisplayChangedEventArgs {
  34112. /** Gets the vrDisplay object (if any) */
  34113. vrDisplay: Nullable<any>;
  34114. /** Gets a boolean indicating if webVR is supported */
  34115. vrSupported: boolean;
  34116. }
  34117. /**
  34118. * Defines the interface used by objects containing a viewport (like a camera)
  34119. */
  34120. interface IViewportOwnerLike {
  34121. /**
  34122. * Gets or sets the viewport
  34123. */
  34124. viewport: IViewportLike;
  34125. }
  34126. /**
  34127. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34128. */
  34129. export class Engine extends ThinEngine {
  34130. /** Defines that alpha blending is disabled */
  34131. static readonly ALPHA_DISABLE: number;
  34132. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34133. static readonly ALPHA_ADD: number;
  34134. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34135. static readonly ALPHA_COMBINE: number;
  34136. /** Defines that alpha blending to DEST - SRC * DEST */
  34137. static readonly ALPHA_SUBTRACT: number;
  34138. /** Defines that alpha blending to SRC * DEST */
  34139. static readonly ALPHA_MULTIPLY: number;
  34140. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34141. static readonly ALPHA_MAXIMIZED: number;
  34142. /** Defines that alpha blending to SRC + DEST */
  34143. static readonly ALPHA_ONEONE: number;
  34144. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34145. static readonly ALPHA_PREMULTIPLIED: number;
  34146. /**
  34147. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34148. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34149. */
  34150. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34151. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34152. static readonly ALPHA_INTERPOLATE: number;
  34153. /**
  34154. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34155. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34156. */
  34157. static readonly ALPHA_SCREENMODE: number;
  34158. /** Defines that the ressource is not delayed*/
  34159. static readonly DELAYLOADSTATE_NONE: number;
  34160. /** Defines that the ressource was successfully delay loaded */
  34161. static readonly DELAYLOADSTATE_LOADED: number;
  34162. /** Defines that the ressource is currently delay loading */
  34163. static readonly DELAYLOADSTATE_LOADING: number;
  34164. /** Defines that the ressource is delayed and has not started loading */
  34165. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34166. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34167. static readonly NEVER: number;
  34168. /** 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 */
  34169. static readonly ALWAYS: number;
  34170. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34171. static readonly LESS: number;
  34172. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34173. static readonly EQUAL: number;
  34174. /** 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 */
  34175. static readonly LEQUAL: number;
  34176. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34177. static readonly GREATER: number;
  34178. /** 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 */
  34179. static readonly GEQUAL: number;
  34180. /** 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 */
  34181. static readonly NOTEQUAL: number;
  34182. /** Passed to stencilOperation to specify that stencil value must be kept */
  34183. static readonly KEEP: number;
  34184. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34185. static readonly REPLACE: number;
  34186. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34187. static readonly INCR: number;
  34188. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34189. static readonly DECR: number;
  34190. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34191. static readonly INVERT: number;
  34192. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34193. static readonly INCR_WRAP: number;
  34194. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34195. static readonly DECR_WRAP: number;
  34196. /** Texture is not repeating outside of 0..1 UVs */
  34197. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34198. /** Texture is repeating outside of 0..1 UVs */
  34199. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34200. /** Texture is repeating and mirrored */
  34201. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34202. /** ALPHA */
  34203. static readonly TEXTUREFORMAT_ALPHA: number;
  34204. /** LUMINANCE */
  34205. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34206. /** LUMINANCE_ALPHA */
  34207. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34208. /** RGB */
  34209. static readonly TEXTUREFORMAT_RGB: number;
  34210. /** RGBA */
  34211. static readonly TEXTUREFORMAT_RGBA: number;
  34212. /** RED */
  34213. static readonly TEXTUREFORMAT_RED: number;
  34214. /** RED (2nd reference) */
  34215. static readonly TEXTUREFORMAT_R: number;
  34216. /** RG */
  34217. static readonly TEXTUREFORMAT_RG: number;
  34218. /** RED_INTEGER */
  34219. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34220. /** RED_INTEGER (2nd reference) */
  34221. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34222. /** RG_INTEGER */
  34223. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34224. /** RGB_INTEGER */
  34225. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34226. /** RGBA_INTEGER */
  34227. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34228. /** UNSIGNED_BYTE */
  34229. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34230. /** UNSIGNED_BYTE (2nd reference) */
  34231. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34232. /** FLOAT */
  34233. static readonly TEXTURETYPE_FLOAT: number;
  34234. /** HALF_FLOAT */
  34235. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34236. /** BYTE */
  34237. static readonly TEXTURETYPE_BYTE: number;
  34238. /** SHORT */
  34239. static readonly TEXTURETYPE_SHORT: number;
  34240. /** UNSIGNED_SHORT */
  34241. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34242. /** INT */
  34243. static readonly TEXTURETYPE_INT: number;
  34244. /** UNSIGNED_INT */
  34245. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34246. /** UNSIGNED_SHORT_4_4_4_4 */
  34247. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34248. /** UNSIGNED_SHORT_5_5_5_1 */
  34249. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34250. /** UNSIGNED_SHORT_5_6_5 */
  34251. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34252. /** UNSIGNED_INT_2_10_10_10_REV */
  34253. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34254. /** UNSIGNED_INT_24_8 */
  34255. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34256. /** UNSIGNED_INT_10F_11F_11F_REV */
  34257. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34258. /** UNSIGNED_INT_5_9_9_9_REV */
  34259. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34260. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34261. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34262. /** nearest is mag = nearest and min = nearest and mip = linear */
  34263. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34264. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34265. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34266. /** Trilinear is mag = linear and min = linear and mip = linear */
  34267. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34268. /** nearest is mag = nearest and min = nearest and mip = linear */
  34269. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34270. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34271. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34272. /** Trilinear is mag = linear and min = linear and mip = linear */
  34273. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34274. /** mag = nearest and min = nearest and mip = nearest */
  34275. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34276. /** mag = nearest and min = linear and mip = nearest */
  34277. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34278. /** mag = nearest and min = linear and mip = linear */
  34279. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34280. /** mag = nearest and min = linear and mip = none */
  34281. static readonly TEXTURE_NEAREST_LINEAR: number;
  34282. /** mag = nearest and min = nearest and mip = none */
  34283. static readonly TEXTURE_NEAREST_NEAREST: number;
  34284. /** mag = linear and min = nearest and mip = nearest */
  34285. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34286. /** mag = linear and min = nearest and mip = linear */
  34287. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34288. /** mag = linear and min = linear and mip = none */
  34289. static readonly TEXTURE_LINEAR_LINEAR: number;
  34290. /** mag = linear and min = nearest and mip = none */
  34291. static readonly TEXTURE_LINEAR_NEAREST: number;
  34292. /** Explicit coordinates mode */
  34293. static readonly TEXTURE_EXPLICIT_MODE: number;
  34294. /** Spherical coordinates mode */
  34295. static readonly TEXTURE_SPHERICAL_MODE: number;
  34296. /** Planar coordinates mode */
  34297. static readonly TEXTURE_PLANAR_MODE: number;
  34298. /** Cubic coordinates mode */
  34299. static readonly TEXTURE_CUBIC_MODE: number;
  34300. /** Projection coordinates mode */
  34301. static readonly TEXTURE_PROJECTION_MODE: number;
  34302. /** Skybox coordinates mode */
  34303. static readonly TEXTURE_SKYBOX_MODE: number;
  34304. /** Inverse Cubic coordinates mode */
  34305. static readonly TEXTURE_INVCUBIC_MODE: number;
  34306. /** Equirectangular coordinates mode */
  34307. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34308. /** Equirectangular Fixed coordinates mode */
  34309. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34310. /** Equirectangular Fixed Mirrored coordinates mode */
  34311. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34312. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34313. static readonly SCALEMODE_FLOOR: number;
  34314. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34315. static readonly SCALEMODE_NEAREST: number;
  34316. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34317. static readonly SCALEMODE_CEILING: number;
  34318. /**
  34319. * Returns the current npm package of the sdk
  34320. */
  34321. static get NpmPackage(): string;
  34322. /**
  34323. * Returns the current version of the framework
  34324. */
  34325. static get Version(): string;
  34326. /** Gets the list of created engines */
  34327. static get Instances(): Engine[];
  34328. /**
  34329. * Gets the latest created engine
  34330. */
  34331. static get LastCreatedEngine(): Nullable<Engine>;
  34332. /**
  34333. * Gets the latest created scene
  34334. */
  34335. static get LastCreatedScene(): Nullable<Scene>;
  34336. /**
  34337. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34338. * @param flag defines which part of the materials must be marked as dirty
  34339. * @param predicate defines a predicate used to filter which materials should be affected
  34340. */
  34341. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34342. /**
  34343. * Method called to create the default loading screen.
  34344. * This can be overriden in your own app.
  34345. * @param canvas The rendering canvas element
  34346. * @returns The loading screen
  34347. */
  34348. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34349. /**
  34350. * Method called to create the default rescale post process on each engine.
  34351. */
  34352. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34353. /**
  34354. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34355. **/
  34356. enableOfflineSupport: boolean;
  34357. /**
  34358. * 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)
  34359. **/
  34360. disableManifestCheck: boolean;
  34361. /**
  34362. * Gets the list of created scenes
  34363. */
  34364. scenes: Scene[];
  34365. /**
  34366. * Event raised when a new scene is created
  34367. */
  34368. onNewSceneAddedObservable: Observable<Scene>;
  34369. /**
  34370. * Gets the list of created postprocesses
  34371. */
  34372. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34373. /**
  34374. * Gets a boolean indicating if the pointer is currently locked
  34375. */
  34376. isPointerLock: boolean;
  34377. /**
  34378. * Observable event triggered each time the rendering canvas is resized
  34379. */
  34380. onResizeObservable: Observable<Engine>;
  34381. /**
  34382. * Observable event triggered each time the canvas loses focus
  34383. */
  34384. onCanvasBlurObservable: Observable<Engine>;
  34385. /**
  34386. * Observable event triggered each time the canvas gains focus
  34387. */
  34388. onCanvasFocusObservable: Observable<Engine>;
  34389. /**
  34390. * Observable event triggered each time the canvas receives pointerout event
  34391. */
  34392. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34393. /**
  34394. * Observable raised when the engine begins a new frame
  34395. */
  34396. onBeginFrameObservable: Observable<Engine>;
  34397. /**
  34398. * If set, will be used to request the next animation frame for the render loop
  34399. */
  34400. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34401. /**
  34402. * Observable raised when the engine ends the current frame
  34403. */
  34404. onEndFrameObservable: Observable<Engine>;
  34405. /**
  34406. * Observable raised when the engine is about to compile a shader
  34407. */
  34408. onBeforeShaderCompilationObservable: Observable<Engine>;
  34409. /**
  34410. * Observable raised when the engine has jsut compiled a shader
  34411. */
  34412. onAfterShaderCompilationObservable: Observable<Engine>;
  34413. /**
  34414. * Gets the audio engine
  34415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34416. * @ignorenaming
  34417. */
  34418. static audioEngine: IAudioEngine;
  34419. /**
  34420. * Default AudioEngine factory responsible of creating the Audio Engine.
  34421. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34422. */
  34423. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34424. /**
  34425. * Default offline support factory responsible of creating a tool used to store data locally.
  34426. * By default, this will create a Database object if the workload has been embedded.
  34427. */
  34428. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34429. private _loadingScreen;
  34430. private _pointerLockRequested;
  34431. private _dummyFramebuffer;
  34432. private _rescalePostProcess;
  34433. private _deterministicLockstep;
  34434. private _lockstepMaxSteps;
  34435. private _timeStep;
  34436. protected get _supportsHardwareTextureRescaling(): boolean;
  34437. private _fps;
  34438. private _deltaTime;
  34439. /** @hidden */
  34440. _drawCalls: PerfCounter;
  34441. /** 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 */
  34442. canvasTabIndex: number;
  34443. /**
  34444. * Turn this value on if you want to pause FPS computation when in background
  34445. */
  34446. disablePerformanceMonitorInBackground: boolean;
  34447. private _performanceMonitor;
  34448. /**
  34449. * Gets the performance monitor attached to this engine
  34450. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34451. */
  34452. get performanceMonitor(): PerformanceMonitor;
  34453. private _onFocus;
  34454. private _onBlur;
  34455. private _onCanvasPointerOut;
  34456. private _onCanvasBlur;
  34457. private _onCanvasFocus;
  34458. private _onFullscreenChange;
  34459. private _onPointerLockChange;
  34460. /**
  34461. * Gets the HTML element used to attach event listeners
  34462. * @returns a HTML element
  34463. */
  34464. getInputElement(): Nullable<HTMLElement>;
  34465. /**
  34466. * Creates a new engine
  34467. * @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
  34468. * @param antialias defines enable antialiasing (default: false)
  34469. * @param options defines further options to be sent to the getContext() function
  34470. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34471. */
  34472. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34473. /**
  34474. * Gets current aspect ratio
  34475. * @param viewportOwner defines the camera to use to get the aspect ratio
  34476. * @param useScreen defines if screen size must be used (or the current render target if any)
  34477. * @returns a number defining the aspect ratio
  34478. */
  34479. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34480. /**
  34481. * Gets current screen aspect ratio
  34482. * @returns a number defining the aspect ratio
  34483. */
  34484. getScreenAspectRatio(): number;
  34485. /**
  34486. * Gets the client rect of the HTML canvas attached with the current webGL context
  34487. * @returns a client rectanglee
  34488. */
  34489. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34490. /**
  34491. * Gets the client rect of the HTML element used for events
  34492. * @returns a client rectanglee
  34493. */
  34494. getInputElementClientRect(): Nullable<ClientRect>;
  34495. /**
  34496. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34497. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34498. * @returns true if engine is in deterministic lock step mode
  34499. */
  34500. isDeterministicLockStep(): boolean;
  34501. /**
  34502. * Gets the max steps when engine is running in deterministic lock step
  34503. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34504. * @returns the max steps
  34505. */
  34506. getLockstepMaxSteps(): number;
  34507. /**
  34508. * Returns the time in ms between steps when using deterministic lock step.
  34509. * @returns time step in (ms)
  34510. */
  34511. getTimeStep(): number;
  34512. /**
  34513. * Force the mipmap generation for the given render target texture
  34514. * @param texture defines the render target texture to use
  34515. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34516. */
  34517. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34518. /** States */
  34519. /**
  34520. * Set various states to the webGL context
  34521. * @param culling defines backface culling state
  34522. * @param zOffset defines the value to apply to zOffset (0 by default)
  34523. * @param force defines if states must be applied even if cache is up to date
  34524. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34525. */
  34526. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34527. /**
  34528. * Set the z offset to apply to current rendering
  34529. * @param value defines the offset to apply
  34530. */
  34531. setZOffset(value: number): void;
  34532. /**
  34533. * Gets the current value of the zOffset
  34534. * @returns the current zOffset state
  34535. */
  34536. getZOffset(): number;
  34537. /**
  34538. * Enable or disable depth buffering
  34539. * @param enable defines the state to set
  34540. */
  34541. setDepthBuffer(enable: boolean): void;
  34542. /**
  34543. * Gets a boolean indicating if depth writing is enabled
  34544. * @returns the current depth writing state
  34545. */
  34546. getDepthWrite(): boolean;
  34547. /**
  34548. * Enable or disable depth writing
  34549. * @param enable defines the state to set
  34550. */
  34551. setDepthWrite(enable: boolean): void;
  34552. /**
  34553. * Gets a boolean indicating if stencil buffer is enabled
  34554. * @returns the current stencil buffer state
  34555. */
  34556. getStencilBuffer(): boolean;
  34557. /**
  34558. * Enable or disable the stencil buffer
  34559. * @param enable defines if the stencil buffer must be enabled or disabled
  34560. */
  34561. setStencilBuffer(enable: boolean): void;
  34562. /**
  34563. * Gets the current stencil mask
  34564. * @returns a number defining the new stencil mask to use
  34565. */
  34566. getStencilMask(): number;
  34567. /**
  34568. * Sets the current stencil mask
  34569. * @param mask defines the new stencil mask to use
  34570. */
  34571. setStencilMask(mask: number): void;
  34572. /**
  34573. * Gets the current stencil function
  34574. * @returns a number defining the stencil function to use
  34575. */
  34576. getStencilFunction(): number;
  34577. /**
  34578. * Gets the current stencil reference value
  34579. * @returns a number defining the stencil reference value to use
  34580. */
  34581. getStencilFunctionReference(): number;
  34582. /**
  34583. * Gets the current stencil mask
  34584. * @returns a number defining the stencil mask to use
  34585. */
  34586. getStencilFunctionMask(): number;
  34587. /**
  34588. * Sets the current stencil function
  34589. * @param stencilFunc defines the new stencil function to use
  34590. */
  34591. setStencilFunction(stencilFunc: number): void;
  34592. /**
  34593. * Sets the current stencil reference
  34594. * @param reference defines the new stencil reference to use
  34595. */
  34596. setStencilFunctionReference(reference: number): void;
  34597. /**
  34598. * Sets the current stencil mask
  34599. * @param mask defines the new stencil mask to use
  34600. */
  34601. setStencilFunctionMask(mask: number): void;
  34602. /**
  34603. * Gets the current stencil operation when stencil fails
  34604. * @returns a number defining stencil operation to use when stencil fails
  34605. */
  34606. getStencilOperationFail(): number;
  34607. /**
  34608. * Gets the current stencil operation when depth fails
  34609. * @returns a number defining stencil operation to use when depth fails
  34610. */
  34611. getStencilOperationDepthFail(): number;
  34612. /**
  34613. * Gets the current stencil operation when stencil passes
  34614. * @returns a number defining stencil operation to use when stencil passes
  34615. */
  34616. getStencilOperationPass(): number;
  34617. /**
  34618. * Sets the stencil operation to use when stencil fails
  34619. * @param operation defines the stencil operation to use when stencil fails
  34620. */
  34621. setStencilOperationFail(operation: number): void;
  34622. /**
  34623. * Sets the stencil operation to use when depth fails
  34624. * @param operation defines the stencil operation to use when depth fails
  34625. */
  34626. setStencilOperationDepthFail(operation: number): void;
  34627. /**
  34628. * Sets the stencil operation to use when stencil passes
  34629. * @param operation defines the stencil operation to use when stencil passes
  34630. */
  34631. setStencilOperationPass(operation: number): void;
  34632. /**
  34633. * Sets a boolean indicating if the dithering state is enabled or disabled
  34634. * @param value defines the dithering state
  34635. */
  34636. setDitheringState(value: boolean): void;
  34637. /**
  34638. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34639. * @param value defines the rasterizer state
  34640. */
  34641. setRasterizerState(value: boolean): void;
  34642. /**
  34643. * Gets the current depth function
  34644. * @returns a number defining the depth function
  34645. */
  34646. getDepthFunction(): Nullable<number>;
  34647. /**
  34648. * Sets the current depth function
  34649. * @param depthFunc defines the function to use
  34650. */
  34651. setDepthFunction(depthFunc: number): void;
  34652. /**
  34653. * Sets the current depth function to GREATER
  34654. */
  34655. setDepthFunctionToGreater(): void;
  34656. /**
  34657. * Sets the current depth function to GEQUAL
  34658. */
  34659. setDepthFunctionToGreaterOrEqual(): void;
  34660. /**
  34661. * Sets the current depth function to LESS
  34662. */
  34663. setDepthFunctionToLess(): void;
  34664. /**
  34665. * Sets the current depth function to LEQUAL
  34666. */
  34667. setDepthFunctionToLessOrEqual(): void;
  34668. private _cachedStencilBuffer;
  34669. private _cachedStencilFunction;
  34670. private _cachedStencilMask;
  34671. private _cachedStencilOperationPass;
  34672. private _cachedStencilOperationFail;
  34673. private _cachedStencilOperationDepthFail;
  34674. private _cachedStencilReference;
  34675. /**
  34676. * Caches the the state of the stencil buffer
  34677. */
  34678. cacheStencilState(): void;
  34679. /**
  34680. * Restores the state of the stencil buffer
  34681. */
  34682. restoreStencilState(): void;
  34683. /**
  34684. * Directly set the WebGL Viewport
  34685. * @param x defines the x coordinate of the viewport (in screen space)
  34686. * @param y defines the y coordinate of the viewport (in screen space)
  34687. * @param width defines the width of the viewport (in screen space)
  34688. * @param height defines the height of the viewport (in screen space)
  34689. * @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
  34690. */
  34691. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34692. /**
  34693. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34694. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34695. * @param y defines the y-coordinate of the corner of the clear rectangle
  34696. * @param width defines the width of the clear rectangle
  34697. * @param height defines the height of the clear rectangle
  34698. * @param clearColor defines the clear color
  34699. */
  34700. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34701. /**
  34702. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34703. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34704. * @param y defines the y-coordinate of the corner of the clear rectangle
  34705. * @param width defines the width of the clear rectangle
  34706. * @param height defines the height of the clear rectangle
  34707. */
  34708. enableScissor(x: number, y: number, width: number, height: number): void;
  34709. /**
  34710. * Disable previously set scissor test rectangle
  34711. */
  34712. disableScissor(): void;
  34713. protected _reportDrawCall(): void;
  34714. /**
  34715. * Initializes a webVR display and starts listening to display change events
  34716. * The onVRDisplayChangedObservable will be notified upon these changes
  34717. * @returns The onVRDisplayChangedObservable
  34718. */
  34719. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34720. /** @hidden */
  34721. _prepareVRComponent(): void;
  34722. /** @hidden */
  34723. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34724. /** @hidden */
  34725. _submitVRFrame(): void;
  34726. /**
  34727. * Call this function to leave webVR mode
  34728. * Will do nothing if webVR is not supported or if there is no webVR device
  34729. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34730. */
  34731. disableVR(): void;
  34732. /**
  34733. * Gets a boolean indicating that the system is in VR mode and is presenting
  34734. * @returns true if VR mode is engaged
  34735. */
  34736. isVRPresenting(): boolean;
  34737. /** @hidden */
  34738. _requestVRFrame(): void;
  34739. /** @hidden */
  34740. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34741. /**
  34742. * Gets the source code of the vertex shader associated with a specific webGL program
  34743. * @param program defines the program to use
  34744. * @returns a string containing the source code of the vertex shader associated with the program
  34745. */
  34746. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34747. /**
  34748. * Gets the source code of the fragment shader associated with a specific webGL program
  34749. * @param program defines the program to use
  34750. * @returns a string containing the source code of the fragment shader associated with the program
  34751. */
  34752. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34753. /**
  34754. * Sets a depth stencil texture from a render target to the according uniform.
  34755. * @param channel The texture channel
  34756. * @param uniform The uniform to set
  34757. * @param texture The render target texture containing the depth stencil texture to apply
  34758. */
  34759. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34760. /**
  34761. * Sets a texture to the webGL context from a postprocess
  34762. * @param channel defines the channel to use
  34763. * @param postProcess defines the source postprocess
  34764. */
  34765. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34766. /**
  34767. * Binds the output of the passed in post process to the texture channel specified
  34768. * @param channel The channel the texture should be bound to
  34769. * @param postProcess The post process which's output should be bound
  34770. */
  34771. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34772. /** @hidden */
  34773. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34774. protected _rebuildBuffers(): void;
  34775. /** @hidden */
  34776. _renderFrame(): void;
  34777. _renderLoop(): void;
  34778. /** @hidden */
  34779. _renderViews(): boolean;
  34780. /**
  34781. * Toggle full screen mode
  34782. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34783. */
  34784. switchFullscreen(requestPointerLock: boolean): void;
  34785. /**
  34786. * Enters full screen mode
  34787. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34788. */
  34789. enterFullscreen(requestPointerLock: boolean): void;
  34790. /**
  34791. * Exits full screen mode
  34792. */
  34793. exitFullscreen(): void;
  34794. /**
  34795. * Enters Pointerlock mode
  34796. */
  34797. enterPointerlock(): void;
  34798. /**
  34799. * Exits Pointerlock mode
  34800. */
  34801. exitPointerlock(): void;
  34802. /**
  34803. * Begin a new frame
  34804. */
  34805. beginFrame(): void;
  34806. /**
  34807. * Enf the current frame
  34808. */
  34809. endFrame(): void;
  34810. resize(): void;
  34811. /**
  34812. * Force a specific size of the canvas
  34813. * @param width defines the new canvas' width
  34814. * @param height defines the new canvas' height
  34815. */
  34816. setSize(width: number, height: number): void;
  34817. /**
  34818. * Updates a dynamic vertex buffer.
  34819. * @param vertexBuffer the vertex buffer to update
  34820. * @param data the data used to update the vertex buffer
  34821. * @param byteOffset the byte offset of the data
  34822. * @param byteLength the byte length of the data
  34823. */
  34824. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34825. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34826. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34827. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34828. _releaseTexture(texture: InternalTexture): void;
  34829. /**
  34830. * @hidden
  34831. * Rescales a texture
  34832. * @param source input texutre
  34833. * @param destination destination texture
  34834. * @param scene scene to use to render the resize
  34835. * @param internalFormat format to use when resizing
  34836. * @param onComplete callback to be called when resize has completed
  34837. */
  34838. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34839. /**
  34840. * Gets the current framerate
  34841. * @returns a number representing the framerate
  34842. */
  34843. getFps(): number;
  34844. /**
  34845. * Gets the time spent between current and previous frame
  34846. * @returns a number representing the delta time in ms
  34847. */
  34848. getDeltaTime(): number;
  34849. private _measureFps;
  34850. /** @hidden */
  34851. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34852. /**
  34853. * Update a dynamic index buffer
  34854. * @param indexBuffer defines the target index buffer
  34855. * @param indices defines the data to update
  34856. * @param offset defines the offset in the target index buffer where update should start
  34857. */
  34858. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34859. /**
  34860. * Updates the sample count of a render target texture
  34861. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34862. * @param texture defines the texture to update
  34863. * @param samples defines the sample count to set
  34864. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34865. */
  34866. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34867. /**
  34868. * Updates a depth texture Comparison Mode and Function.
  34869. * If the comparison Function is equal to 0, the mode will be set to none.
  34870. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34871. * @param texture The texture to set the comparison function for
  34872. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34873. */
  34874. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34875. /**
  34876. * Creates a webGL buffer to use with instanciation
  34877. * @param capacity defines the size of the buffer
  34878. * @returns the webGL buffer
  34879. */
  34880. createInstancesBuffer(capacity: number): DataBuffer;
  34881. /**
  34882. * Delete a webGL buffer used with instanciation
  34883. * @param buffer defines the webGL buffer to delete
  34884. */
  34885. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34886. private _clientWaitAsync;
  34887. /** @hidden */
  34888. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34889. /** @hidden */
  34890. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34891. dispose(): void;
  34892. private _disableTouchAction;
  34893. /**
  34894. * Display the loading screen
  34895. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34896. */
  34897. displayLoadingUI(): void;
  34898. /**
  34899. * Hide the loading screen
  34900. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34901. */
  34902. hideLoadingUI(): void;
  34903. /**
  34904. * Gets the current loading screen object
  34905. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34906. */
  34907. get loadingScreen(): ILoadingScreen;
  34908. /**
  34909. * Sets the current loading screen object
  34910. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34911. */
  34912. set loadingScreen(loadingScreen: ILoadingScreen);
  34913. /**
  34914. * Sets the current loading screen text
  34915. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34916. */
  34917. set loadingUIText(text: string);
  34918. /**
  34919. * Sets the current loading screen background color
  34920. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34921. */
  34922. set loadingUIBackgroundColor(color: string);
  34923. /** Pointerlock and fullscreen */
  34924. /**
  34925. * Ask the browser to promote the current element to pointerlock mode
  34926. * @param element defines the DOM element to promote
  34927. */
  34928. static _RequestPointerlock(element: HTMLElement): void;
  34929. /**
  34930. * Asks the browser to exit pointerlock mode
  34931. */
  34932. static _ExitPointerlock(): void;
  34933. /**
  34934. * Ask the browser to promote the current element to fullscreen rendering mode
  34935. * @param element defines the DOM element to promote
  34936. */
  34937. static _RequestFullscreen(element: HTMLElement): void;
  34938. /**
  34939. * Asks the browser to exit fullscreen mode
  34940. */
  34941. static _ExitFullscreen(): void;
  34942. }
  34943. }
  34944. declare module "babylonjs/Engines/engineStore" {
  34945. import { Nullable } from "babylonjs/types";
  34946. import { Engine } from "babylonjs/Engines/engine";
  34947. import { Scene } from "babylonjs/scene";
  34948. /**
  34949. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34950. * during the life time of the application.
  34951. */
  34952. export class EngineStore {
  34953. /** Gets the list of created engines */
  34954. static Instances: import("babylonjs/Engines/engine").Engine[];
  34955. /** @hidden */
  34956. static _LastCreatedScene: Nullable<Scene>;
  34957. /**
  34958. * Gets the latest created engine
  34959. */
  34960. static get LastCreatedEngine(): Nullable<Engine>;
  34961. /**
  34962. * Gets the latest created scene
  34963. */
  34964. static get LastCreatedScene(): Nullable<Scene>;
  34965. /**
  34966. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34967. * @ignorenaming
  34968. */
  34969. static UseFallbackTexture: boolean;
  34970. /**
  34971. * Texture content used if a texture cannot loaded
  34972. * @ignorenaming
  34973. */
  34974. static FallbackTexture: string;
  34975. }
  34976. }
  34977. declare module "babylonjs/Misc/promise" {
  34978. /**
  34979. * Helper class that provides a small promise polyfill
  34980. */
  34981. export class PromisePolyfill {
  34982. /**
  34983. * Static function used to check if the polyfill is required
  34984. * If this is the case then the function will inject the polyfill to window.Promise
  34985. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34986. */
  34987. static Apply(force?: boolean): void;
  34988. }
  34989. }
  34990. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34991. /**
  34992. * Interface for screenshot methods with describe argument called `size` as object with options
  34993. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34994. */
  34995. export interface IScreenshotSize {
  34996. /**
  34997. * number in pixels for canvas height
  34998. */
  34999. height?: number;
  35000. /**
  35001. * multiplier allowing render at a higher or lower resolution
  35002. * If value is defined then height and width will be ignored and taken from camera
  35003. */
  35004. precision?: number;
  35005. /**
  35006. * number in pixels for canvas width
  35007. */
  35008. width?: number;
  35009. }
  35010. }
  35011. declare module "babylonjs/Misc/tools" {
  35012. import { Nullable, float } from "babylonjs/types";
  35013. import { DomManagement } from "babylonjs/Misc/domManagement";
  35014. import { WebRequest } from "babylonjs/Misc/webRequest";
  35015. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35016. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35017. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35018. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35019. import { Camera } from "babylonjs/Cameras/camera";
  35020. import { Engine } from "babylonjs/Engines/engine";
  35021. interface IColor4Like {
  35022. r: float;
  35023. g: float;
  35024. b: float;
  35025. a: float;
  35026. }
  35027. /**
  35028. * Class containing a set of static utilities functions
  35029. */
  35030. export class Tools {
  35031. /**
  35032. * Gets or sets the base URL to use to load assets
  35033. */
  35034. static get BaseUrl(): string;
  35035. static set BaseUrl(value: string);
  35036. /**
  35037. * Enable/Disable Custom HTTP Request Headers globally.
  35038. * default = false
  35039. * @see CustomRequestHeaders
  35040. */
  35041. static UseCustomRequestHeaders: boolean;
  35042. /**
  35043. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35044. * i.e. when loading files, where the server/service expects an Authorization header
  35045. */
  35046. static CustomRequestHeaders: {
  35047. [key: string]: string;
  35048. };
  35049. /**
  35050. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35051. */
  35052. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35053. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35054. /**
  35055. * Default behaviour for cors in the application.
  35056. * It can be a string if the expected behavior is identical in the entire app.
  35057. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35058. */
  35059. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35060. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35061. /**
  35062. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35063. * @ignorenaming
  35064. */
  35065. static get UseFallbackTexture(): boolean;
  35066. static set UseFallbackTexture(value: boolean);
  35067. /**
  35068. * Use this object to register external classes like custom textures or material
  35069. * to allow the laoders to instantiate them
  35070. */
  35071. static get RegisteredExternalClasses(): {
  35072. [key: string]: Object;
  35073. };
  35074. static set RegisteredExternalClasses(classes: {
  35075. [key: string]: Object;
  35076. });
  35077. /**
  35078. * Texture content used if a texture cannot loaded
  35079. * @ignorenaming
  35080. */
  35081. static get fallbackTexture(): string;
  35082. static set fallbackTexture(value: string);
  35083. /**
  35084. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35085. * @param u defines the coordinate on X axis
  35086. * @param v defines the coordinate on Y axis
  35087. * @param width defines the width of the source data
  35088. * @param height defines the height of the source data
  35089. * @param pixels defines the source byte array
  35090. * @param color defines the output color
  35091. */
  35092. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35093. /**
  35094. * Interpolates between a and b via alpha
  35095. * @param a The lower value (returned when alpha = 0)
  35096. * @param b The upper value (returned when alpha = 1)
  35097. * @param alpha The interpolation-factor
  35098. * @return The mixed value
  35099. */
  35100. static Mix(a: number, b: number, alpha: number): number;
  35101. /**
  35102. * Tries to instantiate a new object from a given class name
  35103. * @param className defines the class name to instantiate
  35104. * @returns the new object or null if the system was not able to do the instantiation
  35105. */
  35106. static Instantiate(className: string): any;
  35107. /**
  35108. * Provides a slice function that will work even on IE
  35109. * @param data defines the array to slice
  35110. * @param start defines the start of the data (optional)
  35111. * @param end defines the end of the data (optional)
  35112. * @returns the new sliced array
  35113. */
  35114. static Slice<T>(data: T, start?: number, end?: number): T;
  35115. /**
  35116. * Polyfill for setImmediate
  35117. * @param action defines the action to execute after the current execution block
  35118. */
  35119. static SetImmediate(action: () => void): void;
  35120. /**
  35121. * Function indicating if a number is an exponent of 2
  35122. * @param value defines the value to test
  35123. * @returns true if the value is an exponent of 2
  35124. */
  35125. static IsExponentOfTwo(value: number): boolean;
  35126. private static _tmpFloatArray;
  35127. /**
  35128. * Returns the nearest 32-bit single precision float representation of a Number
  35129. * @param value A Number. If the parameter is of a different type, it will get converted
  35130. * to a number or to NaN if it cannot be converted
  35131. * @returns number
  35132. */
  35133. static FloatRound(value: number): number;
  35134. /**
  35135. * Extracts the filename from a path
  35136. * @param path defines the path to use
  35137. * @returns the filename
  35138. */
  35139. static GetFilename(path: string): string;
  35140. /**
  35141. * Extracts the "folder" part of a path (everything before the filename).
  35142. * @param uri The URI to extract the info from
  35143. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35144. * @returns The "folder" part of the path
  35145. */
  35146. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35147. /**
  35148. * Extracts text content from a DOM element hierarchy
  35149. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35150. */
  35151. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35152. /**
  35153. * Convert an angle in radians to degrees
  35154. * @param angle defines the angle to convert
  35155. * @returns the angle in degrees
  35156. */
  35157. static ToDegrees(angle: number): number;
  35158. /**
  35159. * Convert an angle in degrees to radians
  35160. * @param angle defines the angle to convert
  35161. * @returns the angle in radians
  35162. */
  35163. static ToRadians(angle: number): number;
  35164. /**
  35165. * Returns an array if obj is not an array
  35166. * @param obj defines the object to evaluate as an array
  35167. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35168. * @returns either obj directly if obj is an array or a new array containing obj
  35169. */
  35170. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35171. /**
  35172. * Gets the pointer prefix to use
  35173. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35174. */
  35175. static GetPointerPrefix(): string;
  35176. /**
  35177. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35178. * @param url define the url we are trying
  35179. * @param element define the dom element where to configure the cors policy
  35180. */
  35181. static SetCorsBehavior(url: string | string[], element: {
  35182. crossOrigin: string | null;
  35183. }): void;
  35184. /**
  35185. * Removes unwanted characters from an url
  35186. * @param url defines the url to clean
  35187. * @returns the cleaned url
  35188. */
  35189. static CleanUrl(url: string): string;
  35190. /**
  35191. * Gets or sets a function used to pre-process url before using them to load assets
  35192. */
  35193. static get PreprocessUrl(): (url: string) => string;
  35194. static set PreprocessUrl(processor: (url: string) => string);
  35195. /**
  35196. * Loads an image as an HTMLImageElement.
  35197. * @param input url string, ArrayBuffer, or Blob to load
  35198. * @param onLoad callback called when the image successfully loads
  35199. * @param onError callback called when the image fails to load
  35200. * @param offlineProvider offline provider for caching
  35201. * @param mimeType optional mime type
  35202. * @returns the HTMLImageElement of the loaded image
  35203. */
  35204. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35205. /**
  35206. * Loads a file from a url
  35207. * @param url url string, ArrayBuffer, or Blob to load
  35208. * @param onSuccess callback called when the file successfully loads
  35209. * @param onProgress callback called while file is loading (if the server supports this mode)
  35210. * @param offlineProvider defines the offline provider for caching
  35211. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35212. * @param onError callback called when the file fails to load
  35213. * @returns a file request object
  35214. */
  35215. 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;
  35216. /**
  35217. * Loads a file from a url
  35218. * @param url the file url to load
  35219. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35220. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35221. */
  35222. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35223. /**
  35224. * Load a script (identified by an url). When the url returns, the
  35225. * content of this file is added into a new script element, attached to the DOM (body element)
  35226. * @param scriptUrl defines the url of the script to laod
  35227. * @param onSuccess defines the callback called when the script is loaded
  35228. * @param onError defines the callback to call if an error occurs
  35229. * @param scriptId defines the id of the script element
  35230. */
  35231. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35232. /**
  35233. * Load an asynchronous script (identified by an url). When the url returns, the
  35234. * content of this file is added into a new script element, attached to the DOM (body element)
  35235. * @param scriptUrl defines the url of the script to laod
  35236. * @param scriptId defines the id of the script element
  35237. * @returns a promise request object
  35238. */
  35239. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35240. /**
  35241. * Loads a file from a blob
  35242. * @param fileToLoad defines the blob to use
  35243. * @param callback defines the callback to call when data is loaded
  35244. * @param progressCallback defines the callback to call during loading process
  35245. * @returns a file request object
  35246. */
  35247. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35248. /**
  35249. * Reads a file from a File object
  35250. * @param file defines the file to load
  35251. * @param onSuccess defines the callback to call when data is loaded
  35252. * @param onProgress defines the callback to call during loading process
  35253. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35254. * @param onError defines the callback to call when an error occurs
  35255. * @returns a file request object
  35256. */
  35257. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35258. /**
  35259. * Creates a data url from a given string content
  35260. * @param content defines the content to convert
  35261. * @returns the new data url link
  35262. */
  35263. static FileAsURL(content: string): string;
  35264. /**
  35265. * Format the given number to a specific decimal format
  35266. * @param value defines the number to format
  35267. * @param decimals defines the number of decimals to use
  35268. * @returns the formatted string
  35269. */
  35270. static Format(value: number, decimals?: number): string;
  35271. /**
  35272. * Tries to copy an object by duplicating every property
  35273. * @param source defines the source object
  35274. * @param destination defines the target object
  35275. * @param doNotCopyList defines a list of properties to avoid
  35276. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35277. */
  35278. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35279. /**
  35280. * Gets a boolean indicating if the given object has no own property
  35281. * @param obj defines the object to test
  35282. * @returns true if object has no own property
  35283. */
  35284. static IsEmpty(obj: any): boolean;
  35285. /**
  35286. * Function used to register events at window level
  35287. * @param windowElement defines the Window object to use
  35288. * @param events defines the events to register
  35289. */
  35290. static RegisterTopRootEvents(windowElement: Window, events: {
  35291. name: string;
  35292. handler: Nullable<(e: FocusEvent) => any>;
  35293. }[]): void;
  35294. /**
  35295. * Function used to unregister events from window level
  35296. * @param windowElement defines the Window object to use
  35297. * @param events defines the events to unregister
  35298. */
  35299. static UnregisterTopRootEvents(windowElement: Window, events: {
  35300. name: string;
  35301. handler: Nullable<(e: FocusEvent) => any>;
  35302. }[]): void;
  35303. /**
  35304. * @ignore
  35305. */
  35306. static _ScreenshotCanvas: HTMLCanvasElement;
  35307. /**
  35308. * Dumps the current bound framebuffer
  35309. * @param width defines the rendering width
  35310. * @param height defines the rendering height
  35311. * @param engine defines the hosting engine
  35312. * @param successCallback defines the callback triggered once the data are available
  35313. * @param mimeType defines the mime type of the result
  35314. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35315. */
  35316. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35317. /**
  35318. * Converts the canvas data to blob.
  35319. * This acts as a polyfill for browsers not supporting the to blob function.
  35320. * @param canvas Defines the canvas to extract the data from
  35321. * @param successCallback Defines the callback triggered once the data are available
  35322. * @param mimeType Defines the mime type of the result
  35323. */
  35324. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35325. /**
  35326. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35327. * @param successCallback defines the callback triggered once the data are available
  35328. * @param mimeType defines the mime type of the result
  35329. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35330. */
  35331. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35332. /**
  35333. * Downloads a blob in the browser
  35334. * @param blob defines the blob to download
  35335. * @param fileName defines the name of the downloaded file
  35336. */
  35337. static Download(blob: Blob, fileName: string): void;
  35338. /**
  35339. * Captures a screenshot of the current rendering
  35340. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35341. * @param engine defines the rendering engine
  35342. * @param camera defines the source camera
  35343. * @param size This parameter can be set to a single number or to an object with the
  35344. * following (optional) properties: precision, width, height. If a single number is passed,
  35345. * it will be used for both width and height. If an object is passed, the screenshot size
  35346. * will be derived from the parameters. The precision property is a multiplier allowing
  35347. * rendering at a higher or lower resolution
  35348. * @param successCallback defines the callback receives a single parameter which contains the
  35349. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35350. * src parameter of an <img> to display it
  35351. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35352. * Check your browser for supported MIME types
  35353. */
  35354. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35355. /**
  35356. * Captures a screenshot of the current rendering
  35357. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35358. * @param engine defines the rendering engine
  35359. * @param camera defines the source camera
  35360. * @param size This parameter can be set to a single number or to an object with the
  35361. * following (optional) properties: precision, width, height. If a single number is passed,
  35362. * it will be used for both width and height. If an object is passed, the screenshot size
  35363. * will be derived from the parameters. The precision property is a multiplier allowing
  35364. * rendering at a higher or lower resolution
  35365. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35366. * Check your browser for supported MIME types
  35367. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35368. * to the src parameter of an <img> to display it
  35369. */
  35370. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35371. /**
  35372. * Generates an image screenshot from the specified camera.
  35373. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35374. * @param engine The engine to use for rendering
  35375. * @param camera The camera to use for rendering
  35376. * @param size This parameter can be set to a single number or to an object with the
  35377. * following (optional) properties: precision, width, height. If a single number is passed,
  35378. * it will be used for both width and height. If an object is passed, the screenshot size
  35379. * will be derived from the parameters. The precision property is a multiplier allowing
  35380. * rendering at a higher or lower resolution
  35381. * @param successCallback The callback receives a single parameter which contains the
  35382. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35383. * src parameter of an <img> to display it
  35384. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35385. * Check your browser for supported MIME types
  35386. * @param samples Texture samples (default: 1)
  35387. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35388. * @param fileName A name for for the downloaded file.
  35389. */
  35390. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35391. /**
  35392. * Generates an image screenshot from the specified camera.
  35393. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35394. * @param engine The engine to use for rendering
  35395. * @param camera The camera to use for rendering
  35396. * @param size This parameter can be set to a single number or to an object with the
  35397. * following (optional) properties: precision, width, height. If a single number is passed,
  35398. * it will be used for both width and height. If an object is passed, the screenshot size
  35399. * will be derived from the parameters. The precision property is a multiplier allowing
  35400. * rendering at a higher or lower resolution
  35401. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35402. * Check your browser for supported MIME types
  35403. * @param samples Texture samples (default: 1)
  35404. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35405. * @param fileName A name for for the downloaded file.
  35406. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35407. * to the src parameter of an <img> to display it
  35408. */
  35409. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35410. /**
  35411. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35412. * Be aware Math.random() could cause collisions, but:
  35413. * "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"
  35414. * @returns a pseudo random id
  35415. */
  35416. static RandomId(): string;
  35417. /**
  35418. * Test if the given uri is a base64 string
  35419. * @param uri The uri to test
  35420. * @return True if the uri is a base64 string or false otherwise
  35421. */
  35422. static IsBase64(uri: string): boolean;
  35423. /**
  35424. * Decode the given base64 uri.
  35425. * @param uri The uri to decode
  35426. * @return The decoded base64 data.
  35427. */
  35428. static DecodeBase64(uri: string): ArrayBuffer;
  35429. /**
  35430. * Gets the absolute url.
  35431. * @param url the input url
  35432. * @return the absolute url
  35433. */
  35434. static GetAbsoluteUrl(url: string): string;
  35435. /**
  35436. * No log
  35437. */
  35438. static readonly NoneLogLevel: number;
  35439. /**
  35440. * Only message logs
  35441. */
  35442. static readonly MessageLogLevel: number;
  35443. /**
  35444. * Only warning logs
  35445. */
  35446. static readonly WarningLogLevel: number;
  35447. /**
  35448. * Only error logs
  35449. */
  35450. static readonly ErrorLogLevel: number;
  35451. /**
  35452. * All logs
  35453. */
  35454. static readonly AllLogLevel: number;
  35455. /**
  35456. * Gets a value indicating the number of loading errors
  35457. * @ignorenaming
  35458. */
  35459. static get errorsCount(): number;
  35460. /**
  35461. * Callback called when a new log is added
  35462. */
  35463. static OnNewCacheEntry: (entry: string) => void;
  35464. /**
  35465. * Log a message to the console
  35466. * @param message defines the message to log
  35467. */
  35468. static Log(message: string): void;
  35469. /**
  35470. * Write a warning message to the console
  35471. * @param message defines the message to log
  35472. */
  35473. static Warn(message: string): void;
  35474. /**
  35475. * Write an error message to the console
  35476. * @param message defines the message to log
  35477. */
  35478. static Error(message: string): void;
  35479. /**
  35480. * Gets current log cache (list of logs)
  35481. */
  35482. static get LogCache(): string;
  35483. /**
  35484. * Clears the log cache
  35485. */
  35486. static ClearLogCache(): void;
  35487. /**
  35488. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35489. */
  35490. static set LogLevels(level: number);
  35491. /**
  35492. * Checks if the window object exists
  35493. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35494. */
  35495. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35496. /**
  35497. * No performance log
  35498. */
  35499. static readonly PerformanceNoneLogLevel: number;
  35500. /**
  35501. * Use user marks to log performance
  35502. */
  35503. static readonly PerformanceUserMarkLogLevel: number;
  35504. /**
  35505. * Log performance to the console
  35506. */
  35507. static readonly PerformanceConsoleLogLevel: number;
  35508. private static _performance;
  35509. /**
  35510. * Sets the current performance log level
  35511. */
  35512. static set PerformanceLogLevel(level: number);
  35513. private static _StartPerformanceCounterDisabled;
  35514. private static _EndPerformanceCounterDisabled;
  35515. private static _StartUserMark;
  35516. private static _EndUserMark;
  35517. private static _StartPerformanceConsole;
  35518. private static _EndPerformanceConsole;
  35519. /**
  35520. * Starts a performance counter
  35521. */
  35522. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35523. /**
  35524. * Ends a specific performance coutner
  35525. */
  35526. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35527. /**
  35528. * Gets either window.performance.now() if supported or Date.now() else
  35529. */
  35530. static get Now(): number;
  35531. /**
  35532. * This method will return the name of the class used to create the instance of the given object.
  35533. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35534. * @param object the object to get the class name from
  35535. * @param isType defines if the object is actually a type
  35536. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35537. */
  35538. static GetClassName(object: any, isType?: boolean): string;
  35539. /**
  35540. * Gets the first element of an array satisfying a given predicate
  35541. * @param array defines the array to browse
  35542. * @param predicate defines the predicate to use
  35543. * @returns null if not found or the element
  35544. */
  35545. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35546. /**
  35547. * This method will return the name of the full name of the class, including its owning module (if any).
  35548. * 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).
  35549. * @param object the object to get the class name from
  35550. * @param isType defines if the object is actually a type
  35551. * @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.
  35552. * @ignorenaming
  35553. */
  35554. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35555. /**
  35556. * Returns a promise that resolves after the given amount of time.
  35557. * @param delay Number of milliseconds to delay
  35558. * @returns Promise that resolves after the given amount of time
  35559. */
  35560. static DelayAsync(delay: number): Promise<void>;
  35561. /**
  35562. * Utility function to detect if the current user agent is Safari
  35563. * @returns whether or not the current user agent is safari
  35564. */
  35565. static IsSafari(): boolean;
  35566. }
  35567. /**
  35568. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35569. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35570. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35571. * @param name The name of the class, case should be preserved
  35572. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35573. */
  35574. export function className(name: string, module?: string): (target: Object) => void;
  35575. /**
  35576. * An implementation of a loop for asynchronous functions.
  35577. */
  35578. export class AsyncLoop {
  35579. /**
  35580. * Defines the number of iterations for the loop
  35581. */
  35582. iterations: number;
  35583. /**
  35584. * Defines the current index of the loop.
  35585. */
  35586. index: number;
  35587. private _done;
  35588. private _fn;
  35589. private _successCallback;
  35590. /**
  35591. * Constructor.
  35592. * @param iterations the number of iterations.
  35593. * @param func the function to run each iteration
  35594. * @param successCallback the callback that will be called upon succesful execution
  35595. * @param offset starting offset.
  35596. */
  35597. constructor(
  35598. /**
  35599. * Defines the number of iterations for the loop
  35600. */
  35601. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35602. /**
  35603. * Execute the next iteration. Must be called after the last iteration was finished.
  35604. */
  35605. executeNext(): void;
  35606. /**
  35607. * Break the loop and run the success callback.
  35608. */
  35609. breakLoop(): void;
  35610. /**
  35611. * Create and run an async loop.
  35612. * @param iterations the number of iterations.
  35613. * @param fn the function to run each iteration
  35614. * @param successCallback the callback that will be called upon succesful execution
  35615. * @param offset starting offset.
  35616. * @returns the created async loop object
  35617. */
  35618. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35619. /**
  35620. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35621. * @param iterations total number of iterations
  35622. * @param syncedIterations number of synchronous iterations in each async iteration.
  35623. * @param fn the function to call each iteration.
  35624. * @param callback a success call back that will be called when iterating stops.
  35625. * @param breakFunction a break condition (optional)
  35626. * @param timeout timeout settings for the setTimeout function. default - 0.
  35627. * @returns the created async loop object
  35628. */
  35629. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35630. }
  35631. }
  35632. declare module "babylonjs/Misc/stringDictionary" {
  35633. import { Nullable } from "babylonjs/types";
  35634. /**
  35635. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35636. * The underlying implementation relies on an associative array to ensure the best performances.
  35637. * The value can be anything including 'null' but except 'undefined'
  35638. */
  35639. export class StringDictionary<T> {
  35640. /**
  35641. * This will clear this dictionary and copy the content from the 'source' one.
  35642. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35643. * @param source the dictionary to take the content from and copy to this dictionary
  35644. */
  35645. copyFrom(source: StringDictionary<T>): void;
  35646. /**
  35647. * Get a value based from its key
  35648. * @param key the given key to get the matching value from
  35649. * @return the value if found, otherwise undefined is returned
  35650. */
  35651. get(key: string): T | undefined;
  35652. /**
  35653. * Get a value from its key or add it if it doesn't exist.
  35654. * This method will ensure you that a given key/data will be present in the dictionary.
  35655. * @param key the given key to get the matching value from
  35656. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35657. * The factory will only be invoked if there's no data for the given key.
  35658. * @return the value corresponding to the key.
  35659. */
  35660. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35661. /**
  35662. * Get a value from its key if present in the dictionary otherwise add it
  35663. * @param key the key to get the value from
  35664. * @param val if there's no such key/value pair in the dictionary add it with this value
  35665. * @return the value corresponding to the key
  35666. */
  35667. getOrAdd(key: string, val: T): T;
  35668. /**
  35669. * Check if there's a given key in the dictionary
  35670. * @param key the key to check for
  35671. * @return true if the key is present, false otherwise
  35672. */
  35673. contains(key: string): boolean;
  35674. /**
  35675. * Add a new key and its corresponding value
  35676. * @param key the key to add
  35677. * @param value the value corresponding to the key
  35678. * @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
  35679. */
  35680. add(key: string, value: T): boolean;
  35681. /**
  35682. * Update a specific value associated to a key
  35683. * @param key defines the key to use
  35684. * @param value defines the value to store
  35685. * @returns true if the value was updated (or false if the key was not found)
  35686. */
  35687. set(key: string, value: T): boolean;
  35688. /**
  35689. * Get the element of the given key and remove it from the dictionary
  35690. * @param key defines the key to search
  35691. * @returns the value associated with the key or null if not found
  35692. */
  35693. getAndRemove(key: string): Nullable<T>;
  35694. /**
  35695. * Remove a key/value from the dictionary.
  35696. * @param key the key to remove
  35697. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35698. */
  35699. remove(key: string): boolean;
  35700. /**
  35701. * Clear the whole content of the dictionary
  35702. */
  35703. clear(): void;
  35704. /**
  35705. * Gets the current count
  35706. */
  35707. get count(): number;
  35708. /**
  35709. * Execute a callback on each key/val of the dictionary.
  35710. * Note that you can remove any element in this dictionary in the callback implementation
  35711. * @param callback the callback to execute on a given key/value pair
  35712. */
  35713. forEach(callback: (key: string, val: T) => void): void;
  35714. /**
  35715. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35716. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35717. * Note that you can remove any element in this dictionary in the callback implementation
  35718. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35719. * @returns the first item
  35720. */
  35721. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35722. private _count;
  35723. private _data;
  35724. }
  35725. }
  35726. declare module "babylonjs/Collisions/collisionCoordinator" {
  35727. import { Nullable } from "babylonjs/types";
  35728. import { Scene } from "babylonjs/scene";
  35729. import { Vector3 } from "babylonjs/Maths/math.vector";
  35730. import { Collider } from "babylonjs/Collisions/collider";
  35731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35732. /** @hidden */
  35733. export interface ICollisionCoordinator {
  35734. createCollider(): Collider;
  35735. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35736. init(scene: Scene): void;
  35737. }
  35738. /** @hidden */
  35739. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35740. private _scene;
  35741. private _scaledPosition;
  35742. private _scaledVelocity;
  35743. private _finalPosition;
  35744. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35745. createCollider(): Collider;
  35746. init(scene: Scene): void;
  35747. private _collideWithWorld;
  35748. }
  35749. }
  35750. declare module "babylonjs/Inputs/scene.inputManager" {
  35751. import { Nullable } from "babylonjs/types";
  35752. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35753. import { Vector2 } from "babylonjs/Maths/math.vector";
  35754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35755. import { Scene } from "babylonjs/scene";
  35756. /**
  35757. * Class used to manage all inputs for the scene.
  35758. */
  35759. export class InputManager {
  35760. /** The distance in pixel that you have to move to prevent some events */
  35761. static DragMovementThreshold: number;
  35762. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35763. static LongPressDelay: number;
  35764. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35765. static DoubleClickDelay: number;
  35766. /** If you need to check double click without raising a single click at first click, enable this flag */
  35767. static ExclusiveDoubleClickMode: boolean;
  35768. private _wheelEventName;
  35769. private _onPointerMove;
  35770. private _onPointerDown;
  35771. private _onPointerUp;
  35772. private _initClickEvent;
  35773. private _initActionManager;
  35774. private _delayedSimpleClick;
  35775. private _delayedSimpleClickTimeout;
  35776. private _previousDelayedSimpleClickTimeout;
  35777. private _meshPickProceed;
  35778. private _previousButtonPressed;
  35779. private _currentPickResult;
  35780. private _previousPickResult;
  35781. private _totalPointersPressed;
  35782. private _doubleClickOccured;
  35783. private _pointerOverMesh;
  35784. private _pickedDownMesh;
  35785. private _pickedUpMesh;
  35786. private _pointerX;
  35787. private _pointerY;
  35788. private _unTranslatedPointerX;
  35789. private _unTranslatedPointerY;
  35790. private _startingPointerPosition;
  35791. private _previousStartingPointerPosition;
  35792. private _startingPointerTime;
  35793. private _previousStartingPointerTime;
  35794. private _pointerCaptures;
  35795. private _onKeyDown;
  35796. private _onKeyUp;
  35797. private _onCanvasFocusObserver;
  35798. private _onCanvasBlurObserver;
  35799. private _scene;
  35800. /**
  35801. * Creates a new InputManager
  35802. * @param scene defines the hosting scene
  35803. */
  35804. constructor(scene: Scene);
  35805. /**
  35806. * Gets the mesh that is currently under the pointer
  35807. */
  35808. get meshUnderPointer(): Nullable<AbstractMesh>;
  35809. /**
  35810. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35811. */
  35812. get unTranslatedPointer(): Vector2;
  35813. /**
  35814. * Gets or sets the current on-screen X position of the pointer
  35815. */
  35816. get pointerX(): number;
  35817. set pointerX(value: number);
  35818. /**
  35819. * Gets or sets the current on-screen Y position of the pointer
  35820. */
  35821. get pointerY(): number;
  35822. set pointerY(value: number);
  35823. private _updatePointerPosition;
  35824. private _processPointerMove;
  35825. private _setRayOnPointerInfo;
  35826. private _checkPrePointerObservable;
  35827. /**
  35828. * Use this method to simulate a pointer move on a mesh
  35829. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35830. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35831. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35832. */
  35833. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35834. /**
  35835. * Use this method to simulate a pointer down on a mesh
  35836. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35837. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35838. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35839. */
  35840. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35841. private _processPointerDown;
  35842. /** @hidden */
  35843. _isPointerSwiping(): boolean;
  35844. /**
  35845. * Use this method to simulate a pointer up on a mesh
  35846. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35847. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35848. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35849. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35850. */
  35851. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35852. private _processPointerUp;
  35853. /**
  35854. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35855. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35856. * @returns true if the pointer was captured
  35857. */
  35858. isPointerCaptured(pointerId?: number): boolean;
  35859. /**
  35860. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35861. * @param attachUp defines if you want to attach events to pointerup
  35862. * @param attachDown defines if you want to attach events to pointerdown
  35863. * @param attachMove defines if you want to attach events to pointermove
  35864. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35865. */
  35866. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35867. /**
  35868. * Detaches all event handlers
  35869. */
  35870. detachControl(): void;
  35871. /**
  35872. * Force the value of meshUnderPointer
  35873. * @param mesh defines the mesh to use
  35874. */
  35875. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35876. /**
  35877. * Gets the mesh under the pointer
  35878. * @returns a Mesh or null if no mesh is under the pointer
  35879. */
  35880. getPointerOverMesh(): Nullable<AbstractMesh>;
  35881. }
  35882. }
  35883. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35884. /**
  35885. * Helper class used to generate session unique ID
  35886. */
  35887. export class UniqueIdGenerator {
  35888. private static _UniqueIdCounter;
  35889. /**
  35890. * Gets an unique (relatively to the current scene) Id
  35891. */
  35892. static get UniqueId(): number;
  35893. }
  35894. }
  35895. declare module "babylonjs/Animations/animationGroup" {
  35896. import { Animatable } from "babylonjs/Animations/animatable";
  35897. import { Animation } from "babylonjs/Animations/animation";
  35898. import { Scene, IDisposable } from "babylonjs/scene";
  35899. import { Observable } from "babylonjs/Misc/observable";
  35900. import { Nullable } from "babylonjs/types";
  35901. import "babylonjs/Animations/animatable";
  35902. /**
  35903. * This class defines the direct association between an animation and a target
  35904. */
  35905. export class TargetedAnimation {
  35906. /**
  35907. * Animation to perform
  35908. */
  35909. animation: Animation;
  35910. /**
  35911. * Target to animate
  35912. */
  35913. target: any;
  35914. /**
  35915. * Serialize the object
  35916. * @returns the JSON object representing the current entity
  35917. */
  35918. serialize(): any;
  35919. }
  35920. /**
  35921. * Use this class to create coordinated animations on multiple targets
  35922. */
  35923. export class AnimationGroup implements IDisposable {
  35924. /** The name of the animation group */
  35925. name: string;
  35926. private _scene;
  35927. private _targetedAnimations;
  35928. private _animatables;
  35929. private _from;
  35930. private _to;
  35931. private _isStarted;
  35932. private _isPaused;
  35933. private _speedRatio;
  35934. private _loopAnimation;
  35935. /**
  35936. * Gets or sets the unique id of the node
  35937. */
  35938. uniqueId: number;
  35939. /**
  35940. * This observable will notify when one animation have ended
  35941. */
  35942. onAnimationEndObservable: Observable<TargetedAnimation>;
  35943. /**
  35944. * Observer raised when one animation loops
  35945. */
  35946. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35947. /**
  35948. * Observer raised when all animations have looped
  35949. */
  35950. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35951. /**
  35952. * This observable will notify when all animations have ended.
  35953. */
  35954. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35955. /**
  35956. * This observable will notify when all animations have paused.
  35957. */
  35958. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35959. /**
  35960. * This observable will notify when all animations are playing.
  35961. */
  35962. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35963. /**
  35964. * Gets the first frame
  35965. */
  35966. get from(): number;
  35967. /**
  35968. * Gets the last frame
  35969. */
  35970. get to(): number;
  35971. /**
  35972. * Define if the animations are started
  35973. */
  35974. get isStarted(): boolean;
  35975. /**
  35976. * Gets a value indicating that the current group is playing
  35977. */
  35978. get isPlaying(): boolean;
  35979. /**
  35980. * Gets or sets the speed ratio to use for all animations
  35981. */
  35982. get speedRatio(): number;
  35983. /**
  35984. * Gets or sets the speed ratio to use for all animations
  35985. */
  35986. set speedRatio(value: number);
  35987. /**
  35988. * Gets or sets if all animations should loop or not
  35989. */
  35990. get loopAnimation(): boolean;
  35991. set loopAnimation(value: boolean);
  35992. /**
  35993. * Gets the targeted animations for this animation group
  35994. */
  35995. get targetedAnimations(): Array<TargetedAnimation>;
  35996. /**
  35997. * returning the list of animatables controlled by this animation group.
  35998. */
  35999. get animatables(): Array<Animatable>;
  36000. /**
  36001. * Instantiates a new Animation Group.
  36002. * This helps managing several animations at once.
  36003. * @see http://doc.babylonjs.com/how_to/group
  36004. * @param name Defines the name of the group
  36005. * @param scene Defines the scene the group belongs to
  36006. */
  36007. constructor(
  36008. /** The name of the animation group */
  36009. name: string, scene?: Nullable<Scene>);
  36010. /**
  36011. * Add an animation (with its target) in the group
  36012. * @param animation defines the animation we want to add
  36013. * @param target defines the target of the animation
  36014. * @returns the TargetedAnimation object
  36015. */
  36016. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36017. /**
  36018. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36019. * It can add constant keys at begin or end
  36020. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36021. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36022. * @returns the animation group
  36023. */
  36024. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36025. private _animationLoopCount;
  36026. private _animationLoopFlags;
  36027. private _processLoop;
  36028. /**
  36029. * Start all animations on given targets
  36030. * @param loop defines if animations must loop
  36031. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36032. * @param from defines the from key (optional)
  36033. * @param to defines the to key (optional)
  36034. * @returns the current animation group
  36035. */
  36036. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  36037. /**
  36038. * Pause all animations
  36039. * @returns the animation group
  36040. */
  36041. pause(): AnimationGroup;
  36042. /**
  36043. * Play all animations to initial state
  36044. * This function will start() the animations if they were not started or will restart() them if they were paused
  36045. * @param loop defines if animations must loop
  36046. * @returns the animation group
  36047. */
  36048. play(loop?: boolean): AnimationGroup;
  36049. /**
  36050. * Reset all animations to initial state
  36051. * @returns the animation group
  36052. */
  36053. reset(): AnimationGroup;
  36054. /**
  36055. * Restart animations from key 0
  36056. * @returns the animation group
  36057. */
  36058. restart(): AnimationGroup;
  36059. /**
  36060. * Stop all animations
  36061. * @returns the animation group
  36062. */
  36063. stop(): AnimationGroup;
  36064. /**
  36065. * Set animation weight for all animatables
  36066. * @param weight defines the weight to use
  36067. * @return the animationGroup
  36068. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36069. */
  36070. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36071. /**
  36072. * Synchronize and normalize all animatables with a source animatable
  36073. * @param root defines the root animatable to synchronize with
  36074. * @return the animationGroup
  36075. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36076. */
  36077. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36078. /**
  36079. * Goes to a specific frame in this animation group
  36080. * @param frame the frame number to go to
  36081. * @return the animationGroup
  36082. */
  36083. goToFrame(frame: number): AnimationGroup;
  36084. /**
  36085. * Dispose all associated resources
  36086. */
  36087. dispose(): void;
  36088. private _checkAnimationGroupEnded;
  36089. /**
  36090. * Clone the current animation group and returns a copy
  36091. * @param newName defines the name of the new group
  36092. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36093. * @returns the new aniamtion group
  36094. */
  36095. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36096. /**
  36097. * Serializes the animationGroup to an object
  36098. * @returns Serialized object
  36099. */
  36100. serialize(): any;
  36101. /**
  36102. * Returns a new AnimationGroup object parsed from the source provided.
  36103. * @param parsedAnimationGroup defines the source
  36104. * @param scene defines the scene that will receive the animationGroup
  36105. * @returns a new AnimationGroup
  36106. */
  36107. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36108. /**
  36109. * Returns the string "AnimationGroup"
  36110. * @returns "AnimationGroup"
  36111. */
  36112. getClassName(): string;
  36113. /**
  36114. * Creates a detailled string about the object
  36115. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36116. * @returns a string representing the object
  36117. */
  36118. toString(fullDetails?: boolean): string;
  36119. }
  36120. }
  36121. declare module "babylonjs/scene" {
  36122. import { Nullable } from "babylonjs/types";
  36123. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36124. import { Observable } from "babylonjs/Misc/observable";
  36125. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36126. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36127. import { Geometry } from "babylonjs/Meshes/geometry";
  36128. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36129. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36131. import { Mesh } from "babylonjs/Meshes/mesh";
  36132. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36133. import { Bone } from "babylonjs/Bones/bone";
  36134. import { Skeleton } from "babylonjs/Bones/skeleton";
  36135. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36136. import { Camera } from "babylonjs/Cameras/camera";
  36137. import { AbstractScene } from "babylonjs/abstractScene";
  36138. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36139. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36140. import { Material } from "babylonjs/Materials/material";
  36141. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36142. import { Effect } from "babylonjs/Materials/effect";
  36143. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36144. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36145. import { Light } from "babylonjs/Lights/light";
  36146. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36147. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36148. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36149. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36150. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36151. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36152. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36153. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36154. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36155. import { Engine } from "babylonjs/Engines/engine";
  36156. import { Node } from "babylonjs/node";
  36157. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36158. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36159. import { WebRequest } from "babylonjs/Misc/webRequest";
  36160. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36161. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36162. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36163. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36164. import { Plane } from "babylonjs/Maths/math.plane";
  36165. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36166. import { Ray } from "babylonjs/Culling/ray";
  36167. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36168. import { Animation } from "babylonjs/Animations/animation";
  36169. import { Animatable } from "babylonjs/Animations/animatable";
  36170. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36171. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36172. import { Collider } from "babylonjs/Collisions/collider";
  36173. /**
  36174. * Define an interface for all classes that will hold resources
  36175. */
  36176. export interface IDisposable {
  36177. /**
  36178. * Releases all held resources
  36179. */
  36180. dispose(): void;
  36181. }
  36182. /** Interface defining initialization parameters for Scene class */
  36183. export interface SceneOptions {
  36184. /**
  36185. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36186. * It will improve performance when the number of geometries becomes important.
  36187. */
  36188. useGeometryUniqueIdsMap?: boolean;
  36189. /**
  36190. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36191. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36192. */
  36193. useMaterialMeshMap?: boolean;
  36194. /**
  36195. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36196. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36197. */
  36198. useClonedMeshMap?: boolean;
  36199. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36200. virtual?: boolean;
  36201. }
  36202. /**
  36203. * Represents a scene to be rendered by the engine.
  36204. * @see http://doc.babylonjs.com/features/scene
  36205. */
  36206. export class Scene extends AbstractScene implements IAnimatable {
  36207. /** The fog is deactivated */
  36208. static readonly FOGMODE_NONE: number;
  36209. /** The fog density is following an exponential function */
  36210. static readonly FOGMODE_EXP: number;
  36211. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36212. static readonly FOGMODE_EXP2: number;
  36213. /** The fog density is following a linear function. */
  36214. static readonly FOGMODE_LINEAR: number;
  36215. /**
  36216. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36217. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36218. */
  36219. static MinDeltaTime: number;
  36220. /**
  36221. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36222. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36223. */
  36224. static MaxDeltaTime: number;
  36225. /**
  36226. * Factory used to create the default material.
  36227. * @param name The name of the material to create
  36228. * @param scene The scene to create the material for
  36229. * @returns The default material
  36230. */
  36231. static DefaultMaterialFactory(scene: Scene): Material;
  36232. /**
  36233. * Factory used to create the a collision coordinator.
  36234. * @returns The collision coordinator
  36235. */
  36236. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36237. /** @hidden */
  36238. _inputManager: InputManager;
  36239. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36240. cameraToUseForPointers: Nullable<Camera>;
  36241. /** @hidden */
  36242. readonly _isScene: boolean;
  36243. /** @hidden */
  36244. _blockEntityCollection: boolean;
  36245. /**
  36246. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36247. */
  36248. autoClear: boolean;
  36249. /**
  36250. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36251. */
  36252. autoClearDepthAndStencil: boolean;
  36253. /**
  36254. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36255. */
  36256. clearColor: Color4;
  36257. /**
  36258. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36259. */
  36260. ambientColor: Color3;
  36261. /**
  36262. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36263. * It should only be one of the following (if not the default embedded one):
  36264. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36265. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36266. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36267. * The material properties need to be setup according to the type of texture in use.
  36268. */
  36269. environmentBRDFTexture: BaseTexture;
  36270. /** @hidden */
  36271. protected _environmentTexture: Nullable<BaseTexture>;
  36272. /**
  36273. * Texture used in all pbr material as the reflection texture.
  36274. * As in the majority of the scene they are the same (exception for multi room and so on),
  36275. * this is easier to reference from here than from all the materials.
  36276. */
  36277. get environmentTexture(): Nullable<BaseTexture>;
  36278. /**
  36279. * Texture used in all pbr material as the reflection texture.
  36280. * As in the majority of the scene they are the same (exception for multi room and so on),
  36281. * this is easier to set here than in all the materials.
  36282. */
  36283. set environmentTexture(value: Nullable<BaseTexture>);
  36284. /** @hidden */
  36285. protected _environmentIntensity: number;
  36286. /**
  36287. * Intensity of the environment in all pbr material.
  36288. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36289. * As in the majority of the scene they are the same (exception for multi room and so on),
  36290. * this is easier to reference from here than from all the materials.
  36291. */
  36292. get environmentIntensity(): number;
  36293. /**
  36294. * Intensity of the environment in all pbr material.
  36295. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36296. * As in the majority of the scene they are the same (exception for multi room and so on),
  36297. * this is easier to set here than in all the materials.
  36298. */
  36299. set environmentIntensity(value: number);
  36300. /** @hidden */
  36301. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36302. /**
  36303. * Default image processing configuration used either in the rendering
  36304. * Forward main pass or through the imageProcessingPostProcess if present.
  36305. * As in the majority of the scene they are the same (exception for multi camera),
  36306. * this is easier to reference from here than from all the materials and post process.
  36307. *
  36308. * No setter as we it is a shared configuration, you can set the values instead.
  36309. */
  36310. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36311. private _forceWireframe;
  36312. /**
  36313. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36314. */
  36315. set forceWireframe(value: boolean);
  36316. get forceWireframe(): boolean;
  36317. private _skipFrustumClipping;
  36318. /**
  36319. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36320. */
  36321. set skipFrustumClipping(value: boolean);
  36322. get skipFrustumClipping(): boolean;
  36323. private _forcePointsCloud;
  36324. /**
  36325. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36326. */
  36327. set forcePointsCloud(value: boolean);
  36328. get forcePointsCloud(): boolean;
  36329. /**
  36330. * Gets or sets the active clipplane 1
  36331. */
  36332. clipPlane: Nullable<Plane>;
  36333. /**
  36334. * Gets or sets the active clipplane 2
  36335. */
  36336. clipPlane2: Nullable<Plane>;
  36337. /**
  36338. * Gets or sets the active clipplane 3
  36339. */
  36340. clipPlane3: Nullable<Plane>;
  36341. /**
  36342. * Gets or sets the active clipplane 4
  36343. */
  36344. clipPlane4: Nullable<Plane>;
  36345. /**
  36346. * Gets or sets the active clipplane 5
  36347. */
  36348. clipPlane5: Nullable<Plane>;
  36349. /**
  36350. * Gets or sets the active clipplane 6
  36351. */
  36352. clipPlane6: Nullable<Plane>;
  36353. /**
  36354. * Gets or sets a boolean indicating if animations are enabled
  36355. */
  36356. animationsEnabled: boolean;
  36357. private _animationPropertiesOverride;
  36358. /**
  36359. * Gets or sets the animation properties override
  36360. */
  36361. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36362. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36363. /**
  36364. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36365. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36366. */
  36367. useConstantAnimationDeltaTime: boolean;
  36368. /**
  36369. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36370. * Please note that it requires to run a ray cast through the scene on every frame
  36371. */
  36372. constantlyUpdateMeshUnderPointer: boolean;
  36373. /**
  36374. * Defines the HTML cursor to use when hovering over interactive elements
  36375. */
  36376. hoverCursor: string;
  36377. /**
  36378. * Defines the HTML default cursor to use (empty by default)
  36379. */
  36380. defaultCursor: string;
  36381. /**
  36382. * Defines whether cursors are handled by the scene.
  36383. */
  36384. doNotHandleCursors: boolean;
  36385. /**
  36386. * This is used to call preventDefault() on pointer down
  36387. * in order to block unwanted artifacts like system double clicks
  36388. */
  36389. preventDefaultOnPointerDown: boolean;
  36390. /**
  36391. * This is used to call preventDefault() on pointer up
  36392. * in order to block unwanted artifacts like system double clicks
  36393. */
  36394. preventDefaultOnPointerUp: boolean;
  36395. /**
  36396. * Gets or sets user defined metadata
  36397. */
  36398. metadata: any;
  36399. /**
  36400. * For internal use only. Please do not use.
  36401. */
  36402. reservedDataStore: any;
  36403. /**
  36404. * Gets the name of the plugin used to load this scene (null by default)
  36405. */
  36406. loadingPluginName: string;
  36407. /**
  36408. * Use this array to add regular expressions used to disable offline support for specific urls
  36409. */
  36410. disableOfflineSupportExceptionRules: RegExp[];
  36411. /**
  36412. * An event triggered when the scene is disposed.
  36413. */
  36414. onDisposeObservable: Observable<Scene>;
  36415. private _onDisposeObserver;
  36416. /** Sets a function to be executed when this scene is disposed. */
  36417. set onDispose(callback: () => void);
  36418. /**
  36419. * An event triggered before rendering the scene (right after animations and physics)
  36420. */
  36421. onBeforeRenderObservable: Observable<Scene>;
  36422. private _onBeforeRenderObserver;
  36423. /** Sets a function to be executed before rendering this scene */
  36424. set beforeRender(callback: Nullable<() => void>);
  36425. /**
  36426. * An event triggered after rendering the scene
  36427. */
  36428. onAfterRenderObservable: Observable<Scene>;
  36429. /**
  36430. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36431. */
  36432. onAfterRenderCameraObservable: Observable<Camera>;
  36433. private _onAfterRenderObserver;
  36434. /** Sets a function to be executed after rendering this scene */
  36435. set afterRender(callback: Nullable<() => void>);
  36436. /**
  36437. * An event triggered before animating the scene
  36438. */
  36439. onBeforeAnimationsObservable: Observable<Scene>;
  36440. /**
  36441. * An event triggered after animations processing
  36442. */
  36443. onAfterAnimationsObservable: Observable<Scene>;
  36444. /**
  36445. * An event triggered before draw calls are ready to be sent
  36446. */
  36447. onBeforeDrawPhaseObservable: Observable<Scene>;
  36448. /**
  36449. * An event triggered after draw calls have been sent
  36450. */
  36451. onAfterDrawPhaseObservable: Observable<Scene>;
  36452. /**
  36453. * An event triggered when the scene is ready
  36454. */
  36455. onReadyObservable: Observable<Scene>;
  36456. /**
  36457. * An event triggered before rendering a camera
  36458. */
  36459. onBeforeCameraRenderObservable: Observable<Camera>;
  36460. private _onBeforeCameraRenderObserver;
  36461. /** Sets a function to be executed before rendering a camera*/
  36462. set beforeCameraRender(callback: () => void);
  36463. /**
  36464. * An event triggered after rendering a camera
  36465. */
  36466. onAfterCameraRenderObservable: Observable<Camera>;
  36467. private _onAfterCameraRenderObserver;
  36468. /** Sets a function to be executed after rendering a camera*/
  36469. set afterCameraRender(callback: () => void);
  36470. /**
  36471. * An event triggered when active meshes evaluation is about to start
  36472. */
  36473. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36474. /**
  36475. * An event triggered when active meshes evaluation is done
  36476. */
  36477. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36478. /**
  36479. * An event triggered when particles rendering is about to start
  36480. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36481. */
  36482. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36483. /**
  36484. * An event triggered when particles rendering is done
  36485. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36486. */
  36487. onAfterParticlesRenderingObservable: Observable<Scene>;
  36488. /**
  36489. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36490. */
  36491. onDataLoadedObservable: Observable<Scene>;
  36492. /**
  36493. * An event triggered when a camera is created
  36494. */
  36495. onNewCameraAddedObservable: Observable<Camera>;
  36496. /**
  36497. * An event triggered when a camera is removed
  36498. */
  36499. onCameraRemovedObservable: Observable<Camera>;
  36500. /**
  36501. * An event triggered when a light is created
  36502. */
  36503. onNewLightAddedObservable: Observable<Light>;
  36504. /**
  36505. * An event triggered when a light is removed
  36506. */
  36507. onLightRemovedObservable: Observable<Light>;
  36508. /**
  36509. * An event triggered when a geometry is created
  36510. */
  36511. onNewGeometryAddedObservable: Observable<Geometry>;
  36512. /**
  36513. * An event triggered when a geometry is removed
  36514. */
  36515. onGeometryRemovedObservable: Observable<Geometry>;
  36516. /**
  36517. * An event triggered when a transform node is created
  36518. */
  36519. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36520. /**
  36521. * An event triggered when a transform node is removed
  36522. */
  36523. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36524. /**
  36525. * An event triggered when a mesh is created
  36526. */
  36527. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36528. /**
  36529. * An event triggered when a mesh is removed
  36530. */
  36531. onMeshRemovedObservable: Observable<AbstractMesh>;
  36532. /**
  36533. * An event triggered when a skeleton is created
  36534. */
  36535. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36536. /**
  36537. * An event triggered when a skeleton is removed
  36538. */
  36539. onSkeletonRemovedObservable: Observable<Skeleton>;
  36540. /**
  36541. * An event triggered when a material is created
  36542. */
  36543. onNewMaterialAddedObservable: Observable<Material>;
  36544. /**
  36545. * An event triggered when a material is removed
  36546. */
  36547. onMaterialRemovedObservable: Observable<Material>;
  36548. /**
  36549. * An event triggered when a texture is created
  36550. */
  36551. onNewTextureAddedObservable: Observable<BaseTexture>;
  36552. /**
  36553. * An event triggered when a texture is removed
  36554. */
  36555. onTextureRemovedObservable: Observable<BaseTexture>;
  36556. /**
  36557. * An event triggered when render targets are about to be rendered
  36558. * Can happen multiple times per frame.
  36559. */
  36560. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36561. /**
  36562. * An event triggered when render targets were rendered.
  36563. * Can happen multiple times per frame.
  36564. */
  36565. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36566. /**
  36567. * An event triggered before calculating deterministic simulation step
  36568. */
  36569. onBeforeStepObservable: Observable<Scene>;
  36570. /**
  36571. * An event triggered after calculating deterministic simulation step
  36572. */
  36573. onAfterStepObservable: Observable<Scene>;
  36574. /**
  36575. * An event triggered when the activeCamera property is updated
  36576. */
  36577. onActiveCameraChanged: Observable<Scene>;
  36578. /**
  36579. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36580. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36581. * 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)
  36582. */
  36583. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36584. /**
  36585. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36586. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36587. * 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)
  36588. */
  36589. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36590. /**
  36591. * This Observable will when a mesh has been imported into the scene.
  36592. */
  36593. onMeshImportedObservable: Observable<AbstractMesh>;
  36594. /**
  36595. * This Observable will when an animation file has been imported into the scene.
  36596. */
  36597. onAnimationFileImportedObservable: Observable<Scene>;
  36598. /**
  36599. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36600. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36601. */
  36602. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36603. /** @hidden */
  36604. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36605. /**
  36606. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36607. */
  36608. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36609. /**
  36610. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36611. */
  36612. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36613. /**
  36614. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36615. */
  36616. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36617. /** Callback called when a pointer move is detected */
  36618. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36619. /** Callback called when a pointer down is detected */
  36620. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36621. /** Callback called when a pointer up is detected */
  36622. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36623. /** Callback called when a pointer pick is detected */
  36624. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36625. /**
  36626. * 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).
  36627. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36628. */
  36629. onPrePointerObservable: Observable<PointerInfoPre>;
  36630. /**
  36631. * Observable event triggered each time an input event is received from the rendering canvas
  36632. */
  36633. onPointerObservable: Observable<PointerInfo>;
  36634. /**
  36635. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36636. */
  36637. get unTranslatedPointer(): Vector2;
  36638. /**
  36639. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36640. */
  36641. static get DragMovementThreshold(): number;
  36642. static set DragMovementThreshold(value: number);
  36643. /**
  36644. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36645. */
  36646. static get LongPressDelay(): number;
  36647. static set LongPressDelay(value: number);
  36648. /**
  36649. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36650. */
  36651. static get DoubleClickDelay(): number;
  36652. static set DoubleClickDelay(value: number);
  36653. /** If you need to check double click without raising a single click at first click, enable this flag */
  36654. static get ExclusiveDoubleClickMode(): boolean;
  36655. static set ExclusiveDoubleClickMode(value: boolean);
  36656. /** @hidden */
  36657. _mirroredCameraPosition: Nullable<Vector3>;
  36658. /**
  36659. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36660. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36661. */
  36662. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36663. /**
  36664. * Observable event triggered each time an keyboard event is received from the hosting window
  36665. */
  36666. onKeyboardObservable: Observable<KeyboardInfo>;
  36667. private _useRightHandedSystem;
  36668. /**
  36669. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36670. */
  36671. set useRightHandedSystem(value: boolean);
  36672. get useRightHandedSystem(): boolean;
  36673. private _timeAccumulator;
  36674. private _currentStepId;
  36675. private _currentInternalStep;
  36676. /**
  36677. * Sets the step Id used by deterministic lock step
  36678. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36679. * @param newStepId defines the step Id
  36680. */
  36681. setStepId(newStepId: number): void;
  36682. /**
  36683. * Gets the step Id used by deterministic lock step
  36684. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36685. * @returns the step Id
  36686. */
  36687. getStepId(): number;
  36688. /**
  36689. * Gets the internal step used by deterministic lock step
  36690. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36691. * @returns the internal step
  36692. */
  36693. getInternalStep(): number;
  36694. private _fogEnabled;
  36695. /**
  36696. * Gets or sets a boolean indicating if fog is enabled on this scene
  36697. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36698. * (Default is true)
  36699. */
  36700. set fogEnabled(value: boolean);
  36701. get fogEnabled(): boolean;
  36702. private _fogMode;
  36703. /**
  36704. * Gets or sets the fog mode to use
  36705. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36706. * | mode | value |
  36707. * | --- | --- |
  36708. * | FOGMODE_NONE | 0 |
  36709. * | FOGMODE_EXP | 1 |
  36710. * | FOGMODE_EXP2 | 2 |
  36711. * | FOGMODE_LINEAR | 3 |
  36712. */
  36713. set fogMode(value: number);
  36714. get fogMode(): number;
  36715. /**
  36716. * Gets or sets the fog color to use
  36717. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36718. * (Default is Color3(0.2, 0.2, 0.3))
  36719. */
  36720. fogColor: Color3;
  36721. /**
  36722. * Gets or sets the fog density to use
  36723. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36724. * (Default is 0.1)
  36725. */
  36726. fogDensity: number;
  36727. /**
  36728. * Gets or sets the fog start distance to use
  36729. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36730. * (Default is 0)
  36731. */
  36732. fogStart: number;
  36733. /**
  36734. * Gets or sets the fog end distance to use
  36735. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36736. * (Default is 1000)
  36737. */
  36738. fogEnd: number;
  36739. private _shadowsEnabled;
  36740. /**
  36741. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36742. */
  36743. set shadowsEnabled(value: boolean);
  36744. get shadowsEnabled(): boolean;
  36745. private _lightsEnabled;
  36746. /**
  36747. * Gets or sets a boolean indicating if lights are enabled on this scene
  36748. */
  36749. set lightsEnabled(value: boolean);
  36750. get lightsEnabled(): boolean;
  36751. /** All of the active cameras added to this scene. */
  36752. activeCameras: Camera[];
  36753. /** @hidden */
  36754. _activeCamera: Nullable<Camera>;
  36755. /** Gets or sets the current active camera */
  36756. get activeCamera(): Nullable<Camera>;
  36757. set activeCamera(value: Nullable<Camera>);
  36758. private _defaultMaterial;
  36759. /** The default material used on meshes when no material is affected */
  36760. get defaultMaterial(): Material;
  36761. /** The default material used on meshes when no material is affected */
  36762. set defaultMaterial(value: Material);
  36763. private _texturesEnabled;
  36764. /**
  36765. * Gets or sets a boolean indicating if textures are enabled on this scene
  36766. */
  36767. set texturesEnabled(value: boolean);
  36768. get texturesEnabled(): boolean;
  36769. /**
  36770. * Gets or sets a boolean indicating if particles are enabled on this scene
  36771. */
  36772. particlesEnabled: boolean;
  36773. /**
  36774. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36775. */
  36776. spritesEnabled: boolean;
  36777. private _skeletonsEnabled;
  36778. /**
  36779. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36780. */
  36781. set skeletonsEnabled(value: boolean);
  36782. get skeletonsEnabled(): boolean;
  36783. /**
  36784. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36785. */
  36786. lensFlaresEnabled: boolean;
  36787. /**
  36788. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36789. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36790. */
  36791. collisionsEnabled: boolean;
  36792. private _collisionCoordinator;
  36793. /** @hidden */
  36794. get collisionCoordinator(): ICollisionCoordinator;
  36795. /**
  36796. * Defines the gravity applied to this scene (used only for collisions)
  36797. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36798. */
  36799. gravity: Vector3;
  36800. /**
  36801. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36802. */
  36803. postProcessesEnabled: boolean;
  36804. /**
  36805. * The list of postprocesses added to the scene
  36806. */
  36807. postProcesses: PostProcess[];
  36808. /**
  36809. * Gets the current postprocess manager
  36810. */
  36811. postProcessManager: PostProcessManager;
  36812. /**
  36813. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36814. */
  36815. renderTargetsEnabled: boolean;
  36816. /**
  36817. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36818. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36819. */
  36820. dumpNextRenderTargets: boolean;
  36821. /**
  36822. * The list of user defined render targets added to the scene
  36823. */
  36824. customRenderTargets: RenderTargetTexture[];
  36825. /**
  36826. * Defines if texture loading must be delayed
  36827. * If true, textures will only be loaded when they need to be rendered
  36828. */
  36829. useDelayedTextureLoading: boolean;
  36830. /**
  36831. * Gets the list of meshes imported to the scene through SceneLoader
  36832. */
  36833. importedMeshesFiles: String[];
  36834. /**
  36835. * Gets or sets a boolean indicating if probes are enabled on this scene
  36836. */
  36837. probesEnabled: boolean;
  36838. /**
  36839. * Gets or sets the current offline provider to use to store scene data
  36840. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36841. */
  36842. offlineProvider: IOfflineProvider;
  36843. /**
  36844. * Gets or sets the action manager associated with the scene
  36845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36846. */
  36847. actionManager: AbstractActionManager;
  36848. private _meshesForIntersections;
  36849. /**
  36850. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36851. */
  36852. proceduralTexturesEnabled: boolean;
  36853. private _engine;
  36854. private _totalVertices;
  36855. /** @hidden */
  36856. _activeIndices: PerfCounter;
  36857. /** @hidden */
  36858. _activeParticles: PerfCounter;
  36859. /** @hidden */
  36860. _activeBones: PerfCounter;
  36861. private _animationRatio;
  36862. /** @hidden */
  36863. _animationTimeLast: number;
  36864. /** @hidden */
  36865. _animationTime: number;
  36866. /**
  36867. * Gets or sets a general scale for animation speed
  36868. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36869. */
  36870. animationTimeScale: number;
  36871. /** @hidden */
  36872. _cachedMaterial: Nullable<Material>;
  36873. /** @hidden */
  36874. _cachedEffect: Nullable<Effect>;
  36875. /** @hidden */
  36876. _cachedVisibility: Nullable<number>;
  36877. private _renderId;
  36878. private _frameId;
  36879. private _executeWhenReadyTimeoutId;
  36880. private _intermediateRendering;
  36881. private _viewUpdateFlag;
  36882. private _projectionUpdateFlag;
  36883. /** @hidden */
  36884. _toBeDisposed: Nullable<IDisposable>[];
  36885. private _activeRequests;
  36886. /** @hidden */
  36887. _pendingData: any[];
  36888. private _isDisposed;
  36889. /**
  36890. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36891. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36892. */
  36893. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36894. private _activeMeshes;
  36895. private _processedMaterials;
  36896. private _renderTargets;
  36897. /** @hidden */
  36898. _activeParticleSystems: SmartArray<IParticleSystem>;
  36899. private _activeSkeletons;
  36900. private _softwareSkinnedMeshes;
  36901. private _renderingManager;
  36902. /** @hidden */
  36903. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36904. private _transformMatrix;
  36905. private _sceneUbo;
  36906. /** @hidden */
  36907. _viewMatrix: Matrix;
  36908. private _projectionMatrix;
  36909. /** @hidden */
  36910. _forcedViewPosition: Nullable<Vector3>;
  36911. /** @hidden */
  36912. _frustumPlanes: Plane[];
  36913. /**
  36914. * Gets the list of frustum planes (built from the active camera)
  36915. */
  36916. get frustumPlanes(): Plane[];
  36917. /**
  36918. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36919. * This is useful if there are more lights that the maximum simulteanous authorized
  36920. */
  36921. requireLightSorting: boolean;
  36922. /** @hidden */
  36923. readonly useMaterialMeshMap: boolean;
  36924. /** @hidden */
  36925. readonly useClonedMeshMap: boolean;
  36926. private _externalData;
  36927. private _uid;
  36928. /**
  36929. * @hidden
  36930. * Backing store of defined scene components.
  36931. */
  36932. _components: ISceneComponent[];
  36933. /**
  36934. * @hidden
  36935. * Backing store of defined scene components.
  36936. */
  36937. _serializableComponents: ISceneSerializableComponent[];
  36938. /**
  36939. * List of components to register on the next registration step.
  36940. */
  36941. private _transientComponents;
  36942. /**
  36943. * Registers the transient components if needed.
  36944. */
  36945. private _registerTransientComponents;
  36946. /**
  36947. * @hidden
  36948. * Add a component to the scene.
  36949. * Note that the ccomponent could be registered on th next frame if this is called after
  36950. * the register component stage.
  36951. * @param component Defines the component to add to the scene
  36952. */
  36953. _addComponent(component: ISceneComponent): void;
  36954. /**
  36955. * @hidden
  36956. * Gets a component from the scene.
  36957. * @param name defines the name of the component to retrieve
  36958. * @returns the component or null if not present
  36959. */
  36960. _getComponent(name: string): Nullable<ISceneComponent>;
  36961. /**
  36962. * @hidden
  36963. * Defines the actions happening before camera updates.
  36964. */
  36965. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36966. /**
  36967. * @hidden
  36968. * Defines the actions happening before clear the canvas.
  36969. */
  36970. _beforeClearStage: Stage<SimpleStageAction>;
  36971. /**
  36972. * @hidden
  36973. * Defines the actions when collecting render targets for the frame.
  36974. */
  36975. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36976. /**
  36977. * @hidden
  36978. * Defines the actions happening for one camera in the frame.
  36979. */
  36980. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36981. /**
  36982. * @hidden
  36983. * Defines the actions happening during the per mesh ready checks.
  36984. */
  36985. _isReadyForMeshStage: Stage<MeshStageAction>;
  36986. /**
  36987. * @hidden
  36988. * Defines the actions happening before evaluate active mesh checks.
  36989. */
  36990. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36991. /**
  36992. * @hidden
  36993. * Defines the actions happening during the evaluate sub mesh checks.
  36994. */
  36995. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36996. /**
  36997. * @hidden
  36998. * Defines the actions happening during the active mesh stage.
  36999. */
  37000. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37001. /**
  37002. * @hidden
  37003. * Defines the actions happening during the per camera render target step.
  37004. */
  37005. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37006. /**
  37007. * @hidden
  37008. * Defines the actions happening just before the active camera is drawing.
  37009. */
  37010. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37011. /**
  37012. * @hidden
  37013. * Defines the actions happening just before a render target is drawing.
  37014. */
  37015. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37016. /**
  37017. * @hidden
  37018. * Defines the actions happening just before a rendering group is drawing.
  37019. */
  37020. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37021. /**
  37022. * @hidden
  37023. * Defines the actions happening just before a mesh is drawing.
  37024. */
  37025. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37026. /**
  37027. * @hidden
  37028. * Defines the actions happening just after a mesh has been drawn.
  37029. */
  37030. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37031. /**
  37032. * @hidden
  37033. * Defines the actions happening just after a rendering group has been drawn.
  37034. */
  37035. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37036. /**
  37037. * @hidden
  37038. * Defines the actions happening just after the active camera has been drawn.
  37039. */
  37040. _afterCameraDrawStage: Stage<CameraStageAction>;
  37041. /**
  37042. * @hidden
  37043. * Defines the actions happening just after a render target has been drawn.
  37044. */
  37045. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37046. /**
  37047. * @hidden
  37048. * Defines the actions happening just after rendering all cameras and computing intersections.
  37049. */
  37050. _afterRenderStage: Stage<SimpleStageAction>;
  37051. /**
  37052. * @hidden
  37053. * Defines the actions happening when a pointer move event happens.
  37054. */
  37055. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37056. /**
  37057. * @hidden
  37058. * Defines the actions happening when a pointer down event happens.
  37059. */
  37060. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37061. /**
  37062. * @hidden
  37063. * Defines the actions happening when a pointer up event happens.
  37064. */
  37065. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37066. /**
  37067. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37068. */
  37069. private geometriesByUniqueId;
  37070. /**
  37071. * Creates a new Scene
  37072. * @param engine defines the engine to use to render this scene
  37073. * @param options defines the scene options
  37074. */
  37075. constructor(engine: Engine, options?: SceneOptions);
  37076. /**
  37077. * Gets a string idenfifying the name of the class
  37078. * @returns "Scene" string
  37079. */
  37080. getClassName(): string;
  37081. private _defaultMeshCandidates;
  37082. /**
  37083. * @hidden
  37084. */
  37085. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37086. private _defaultSubMeshCandidates;
  37087. /**
  37088. * @hidden
  37089. */
  37090. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37091. /**
  37092. * Sets the default candidate providers for the scene.
  37093. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37094. * and getCollidingSubMeshCandidates to their default function
  37095. */
  37096. setDefaultCandidateProviders(): void;
  37097. /**
  37098. * Gets the mesh that is currently under the pointer
  37099. */
  37100. get meshUnderPointer(): Nullable<AbstractMesh>;
  37101. /**
  37102. * Gets or sets the current on-screen X position of the pointer
  37103. */
  37104. get pointerX(): number;
  37105. set pointerX(value: number);
  37106. /**
  37107. * Gets or sets the current on-screen Y position of the pointer
  37108. */
  37109. get pointerY(): number;
  37110. set pointerY(value: number);
  37111. /**
  37112. * Gets the cached material (ie. the latest rendered one)
  37113. * @returns the cached material
  37114. */
  37115. getCachedMaterial(): Nullable<Material>;
  37116. /**
  37117. * Gets the cached effect (ie. the latest rendered one)
  37118. * @returns the cached effect
  37119. */
  37120. getCachedEffect(): Nullable<Effect>;
  37121. /**
  37122. * Gets the cached visibility state (ie. the latest rendered one)
  37123. * @returns the cached visibility state
  37124. */
  37125. getCachedVisibility(): Nullable<number>;
  37126. /**
  37127. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37128. * @param material defines the current material
  37129. * @param effect defines the current effect
  37130. * @param visibility defines the current visibility state
  37131. * @returns true if one parameter is not cached
  37132. */
  37133. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37134. /**
  37135. * Gets the engine associated with the scene
  37136. * @returns an Engine
  37137. */
  37138. getEngine(): Engine;
  37139. /**
  37140. * Gets the total number of vertices rendered per frame
  37141. * @returns the total number of vertices rendered per frame
  37142. */
  37143. getTotalVertices(): number;
  37144. /**
  37145. * Gets the performance counter for total vertices
  37146. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37147. */
  37148. get totalVerticesPerfCounter(): PerfCounter;
  37149. /**
  37150. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37151. * @returns the total number of active indices rendered per frame
  37152. */
  37153. getActiveIndices(): number;
  37154. /**
  37155. * Gets the performance counter for active indices
  37156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37157. */
  37158. get totalActiveIndicesPerfCounter(): PerfCounter;
  37159. /**
  37160. * Gets the total number of active particles rendered per frame
  37161. * @returns the total number of active particles rendered per frame
  37162. */
  37163. getActiveParticles(): number;
  37164. /**
  37165. * Gets the performance counter for active particles
  37166. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37167. */
  37168. get activeParticlesPerfCounter(): PerfCounter;
  37169. /**
  37170. * Gets the total number of active bones rendered per frame
  37171. * @returns the total number of active bones rendered per frame
  37172. */
  37173. getActiveBones(): number;
  37174. /**
  37175. * Gets the performance counter for active bones
  37176. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37177. */
  37178. get activeBonesPerfCounter(): PerfCounter;
  37179. /**
  37180. * Gets the array of active meshes
  37181. * @returns an array of AbstractMesh
  37182. */
  37183. getActiveMeshes(): SmartArray<AbstractMesh>;
  37184. /**
  37185. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37186. * @returns a number
  37187. */
  37188. getAnimationRatio(): number;
  37189. /**
  37190. * Gets an unique Id for the current render phase
  37191. * @returns a number
  37192. */
  37193. getRenderId(): number;
  37194. /**
  37195. * Gets an unique Id for the current frame
  37196. * @returns a number
  37197. */
  37198. getFrameId(): number;
  37199. /** Call this function if you want to manually increment the render Id*/
  37200. incrementRenderId(): void;
  37201. private _createUbo;
  37202. /**
  37203. * Use this method to simulate a pointer move on a mesh
  37204. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37205. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37206. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37207. * @returns the current scene
  37208. */
  37209. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37210. /**
  37211. * Use this method to simulate a pointer down on a mesh
  37212. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37213. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37214. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37215. * @returns the current scene
  37216. */
  37217. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37218. /**
  37219. * Use this method to simulate a pointer up on a mesh
  37220. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37221. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37222. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37223. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37224. * @returns the current scene
  37225. */
  37226. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37227. /**
  37228. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37229. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37230. * @returns true if the pointer was captured
  37231. */
  37232. isPointerCaptured(pointerId?: number): boolean;
  37233. /**
  37234. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37235. * @param attachUp defines if you want to attach events to pointerup
  37236. * @param attachDown defines if you want to attach events to pointerdown
  37237. * @param attachMove defines if you want to attach events to pointermove
  37238. */
  37239. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37240. /** Detaches all event handlers*/
  37241. detachControl(): void;
  37242. /**
  37243. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37244. * Delay loaded resources are not taking in account
  37245. * @return true if all required resources are ready
  37246. */
  37247. isReady(): boolean;
  37248. /** Resets all cached information relative to material (including effect and visibility) */
  37249. resetCachedMaterial(): void;
  37250. /**
  37251. * Registers a function to be called before every frame render
  37252. * @param func defines the function to register
  37253. */
  37254. registerBeforeRender(func: () => void): void;
  37255. /**
  37256. * Unregisters a function called before every frame render
  37257. * @param func defines the function to unregister
  37258. */
  37259. unregisterBeforeRender(func: () => void): void;
  37260. /**
  37261. * Registers a function to be called after every frame render
  37262. * @param func defines the function to register
  37263. */
  37264. registerAfterRender(func: () => void): void;
  37265. /**
  37266. * Unregisters a function called after every frame render
  37267. * @param func defines the function to unregister
  37268. */
  37269. unregisterAfterRender(func: () => void): void;
  37270. private _executeOnceBeforeRender;
  37271. /**
  37272. * The provided function will run before render once and will be disposed afterwards.
  37273. * A timeout delay can be provided so that the function will be executed in N ms.
  37274. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37275. * @param func The function to be executed.
  37276. * @param timeout optional delay in ms
  37277. */
  37278. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37279. /** @hidden */
  37280. _addPendingData(data: any): void;
  37281. /** @hidden */
  37282. _removePendingData(data: any): void;
  37283. /**
  37284. * Returns the number of items waiting to be loaded
  37285. * @returns the number of items waiting to be loaded
  37286. */
  37287. getWaitingItemsCount(): number;
  37288. /**
  37289. * Returns a boolean indicating if the scene is still loading data
  37290. */
  37291. get isLoading(): boolean;
  37292. /**
  37293. * Registers a function to be executed when the scene is ready
  37294. * @param {Function} func - the function to be executed
  37295. */
  37296. executeWhenReady(func: () => void): void;
  37297. /**
  37298. * Returns a promise that resolves when the scene is ready
  37299. * @returns A promise that resolves when the scene is ready
  37300. */
  37301. whenReadyAsync(): Promise<void>;
  37302. /** @hidden */
  37303. _checkIsReady(): void;
  37304. /**
  37305. * Gets all animatable attached to the scene
  37306. */
  37307. get animatables(): Animatable[];
  37308. /**
  37309. * Resets the last animation time frame.
  37310. * Useful to override when animations start running when loading a scene for the first time.
  37311. */
  37312. resetLastAnimationTimeFrame(): void;
  37313. /**
  37314. * Gets the current view matrix
  37315. * @returns a Matrix
  37316. */
  37317. getViewMatrix(): Matrix;
  37318. /**
  37319. * Gets the current projection matrix
  37320. * @returns a Matrix
  37321. */
  37322. getProjectionMatrix(): Matrix;
  37323. /**
  37324. * Gets the current transform matrix
  37325. * @returns a Matrix made of View * Projection
  37326. */
  37327. getTransformMatrix(): Matrix;
  37328. /**
  37329. * Sets the current transform matrix
  37330. * @param viewL defines the View matrix to use
  37331. * @param projectionL defines the Projection matrix to use
  37332. * @param viewR defines the right View matrix to use (if provided)
  37333. * @param projectionR defines the right Projection matrix to use (if provided)
  37334. */
  37335. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37336. /**
  37337. * Gets the uniform buffer used to store scene data
  37338. * @returns a UniformBuffer
  37339. */
  37340. getSceneUniformBuffer(): UniformBuffer;
  37341. /**
  37342. * Gets an unique (relatively to the current scene) Id
  37343. * @returns an unique number for the scene
  37344. */
  37345. getUniqueId(): number;
  37346. /**
  37347. * Add a mesh to the list of scene's meshes
  37348. * @param newMesh defines the mesh to add
  37349. * @param recursive if all child meshes should also be added to the scene
  37350. */
  37351. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37352. /**
  37353. * Remove a mesh for the list of scene's meshes
  37354. * @param toRemove defines the mesh to remove
  37355. * @param recursive if all child meshes should also be removed from the scene
  37356. * @returns the index where the mesh was in the mesh list
  37357. */
  37358. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37359. /**
  37360. * Add a transform node to the list of scene's transform nodes
  37361. * @param newTransformNode defines the transform node to add
  37362. */
  37363. addTransformNode(newTransformNode: TransformNode): void;
  37364. /**
  37365. * Remove a transform node for the list of scene's transform nodes
  37366. * @param toRemove defines the transform node to remove
  37367. * @returns the index where the transform node was in the transform node list
  37368. */
  37369. removeTransformNode(toRemove: TransformNode): number;
  37370. /**
  37371. * Remove a skeleton for the list of scene's skeletons
  37372. * @param toRemove defines the skeleton to remove
  37373. * @returns the index where the skeleton was in the skeleton list
  37374. */
  37375. removeSkeleton(toRemove: Skeleton): number;
  37376. /**
  37377. * Remove a morph target for the list of scene's morph targets
  37378. * @param toRemove defines the morph target to remove
  37379. * @returns the index where the morph target was in the morph target list
  37380. */
  37381. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37382. /**
  37383. * Remove a light for the list of scene's lights
  37384. * @param toRemove defines the light to remove
  37385. * @returns the index where the light was in the light list
  37386. */
  37387. removeLight(toRemove: Light): number;
  37388. /**
  37389. * Remove a camera for the list of scene's cameras
  37390. * @param toRemove defines the camera to remove
  37391. * @returns the index where the camera was in the camera list
  37392. */
  37393. removeCamera(toRemove: Camera): number;
  37394. /**
  37395. * Remove a particle system for the list of scene's particle systems
  37396. * @param toRemove defines the particle system to remove
  37397. * @returns the index where the particle system was in the particle system list
  37398. */
  37399. removeParticleSystem(toRemove: IParticleSystem): number;
  37400. /**
  37401. * Remove a animation for the list of scene's animations
  37402. * @param toRemove defines the animation to remove
  37403. * @returns the index where the animation was in the animation list
  37404. */
  37405. removeAnimation(toRemove: Animation): number;
  37406. /**
  37407. * Will stop the animation of the given target
  37408. * @param target - the target
  37409. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37410. * @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)
  37411. */
  37412. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37413. /**
  37414. * Removes the given animation group from this scene.
  37415. * @param toRemove The animation group to remove
  37416. * @returns The index of the removed animation group
  37417. */
  37418. removeAnimationGroup(toRemove: AnimationGroup): number;
  37419. /**
  37420. * Removes the given multi-material from this scene.
  37421. * @param toRemove The multi-material to remove
  37422. * @returns The index of the removed multi-material
  37423. */
  37424. removeMultiMaterial(toRemove: MultiMaterial): number;
  37425. /**
  37426. * Removes the given material from this scene.
  37427. * @param toRemove The material to remove
  37428. * @returns The index of the removed material
  37429. */
  37430. removeMaterial(toRemove: Material): number;
  37431. /**
  37432. * Removes the given action manager from this scene.
  37433. * @param toRemove The action manager to remove
  37434. * @returns The index of the removed action manager
  37435. */
  37436. removeActionManager(toRemove: AbstractActionManager): number;
  37437. /**
  37438. * Removes the given texture from this scene.
  37439. * @param toRemove The texture to remove
  37440. * @returns The index of the removed texture
  37441. */
  37442. removeTexture(toRemove: BaseTexture): number;
  37443. /**
  37444. * Adds the given light to this scene
  37445. * @param newLight The light to add
  37446. */
  37447. addLight(newLight: Light): void;
  37448. /**
  37449. * Sorts the list list based on light priorities
  37450. */
  37451. sortLightsByPriority(): void;
  37452. /**
  37453. * Adds the given camera to this scene
  37454. * @param newCamera The camera to add
  37455. */
  37456. addCamera(newCamera: Camera): void;
  37457. /**
  37458. * Adds the given skeleton to this scene
  37459. * @param newSkeleton The skeleton to add
  37460. */
  37461. addSkeleton(newSkeleton: Skeleton): void;
  37462. /**
  37463. * Adds the given particle system to this scene
  37464. * @param newParticleSystem The particle system to add
  37465. */
  37466. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37467. /**
  37468. * Adds the given animation to this scene
  37469. * @param newAnimation The animation to add
  37470. */
  37471. addAnimation(newAnimation: Animation): void;
  37472. /**
  37473. * Adds the given animation group to this scene.
  37474. * @param newAnimationGroup The animation group to add
  37475. */
  37476. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37477. /**
  37478. * Adds the given multi-material to this scene
  37479. * @param newMultiMaterial The multi-material to add
  37480. */
  37481. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37482. /**
  37483. * Adds the given material to this scene
  37484. * @param newMaterial The material to add
  37485. */
  37486. addMaterial(newMaterial: Material): void;
  37487. /**
  37488. * Adds the given morph target to this scene
  37489. * @param newMorphTargetManager The morph target to add
  37490. */
  37491. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37492. /**
  37493. * Adds the given geometry to this scene
  37494. * @param newGeometry The geometry to add
  37495. */
  37496. addGeometry(newGeometry: Geometry): void;
  37497. /**
  37498. * Adds the given action manager to this scene
  37499. * @param newActionManager The action manager to add
  37500. */
  37501. addActionManager(newActionManager: AbstractActionManager): void;
  37502. /**
  37503. * Adds the given texture to this scene.
  37504. * @param newTexture The texture to add
  37505. */
  37506. addTexture(newTexture: BaseTexture): void;
  37507. /**
  37508. * Switch active camera
  37509. * @param newCamera defines the new active camera
  37510. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37511. */
  37512. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37513. /**
  37514. * sets the active camera of the scene using its ID
  37515. * @param id defines the camera's ID
  37516. * @return the new active camera or null if none found.
  37517. */
  37518. setActiveCameraByID(id: string): Nullable<Camera>;
  37519. /**
  37520. * sets the active camera of the scene using its name
  37521. * @param name defines the camera's name
  37522. * @returns the new active camera or null if none found.
  37523. */
  37524. setActiveCameraByName(name: string): Nullable<Camera>;
  37525. /**
  37526. * get an animation group using its name
  37527. * @param name defines the material's name
  37528. * @return the animation group or null if none found.
  37529. */
  37530. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37531. /**
  37532. * Get a material using its unique id
  37533. * @param uniqueId defines the material's unique id
  37534. * @return the material or null if none found.
  37535. */
  37536. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37537. /**
  37538. * get a material using its id
  37539. * @param id defines the material's ID
  37540. * @return the material or null if none found.
  37541. */
  37542. getMaterialByID(id: string): Nullable<Material>;
  37543. /**
  37544. * Gets a the last added material using a given id
  37545. * @param id defines the material's ID
  37546. * @return the last material with the given id or null if none found.
  37547. */
  37548. getLastMaterialByID(id: string): Nullable<Material>;
  37549. /**
  37550. * Gets a material using its name
  37551. * @param name defines the material's name
  37552. * @return the material or null if none found.
  37553. */
  37554. getMaterialByName(name: string): Nullable<Material>;
  37555. /**
  37556. * Get a texture using its unique id
  37557. * @param uniqueId defines the texture's unique id
  37558. * @return the texture or null if none found.
  37559. */
  37560. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37561. /**
  37562. * Gets a camera using its id
  37563. * @param id defines the id to look for
  37564. * @returns the camera or null if not found
  37565. */
  37566. getCameraByID(id: string): Nullable<Camera>;
  37567. /**
  37568. * Gets a camera using its unique id
  37569. * @param uniqueId defines the unique id to look for
  37570. * @returns the camera or null if not found
  37571. */
  37572. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37573. /**
  37574. * Gets a camera using its name
  37575. * @param name defines the camera's name
  37576. * @return the camera or null if none found.
  37577. */
  37578. getCameraByName(name: string): Nullable<Camera>;
  37579. /**
  37580. * Gets a bone using its id
  37581. * @param id defines the bone's id
  37582. * @return the bone or null if not found
  37583. */
  37584. getBoneByID(id: string): Nullable<Bone>;
  37585. /**
  37586. * Gets a bone using its id
  37587. * @param name defines the bone's name
  37588. * @return the bone or null if not found
  37589. */
  37590. getBoneByName(name: string): Nullable<Bone>;
  37591. /**
  37592. * Gets a light node using its name
  37593. * @param name defines the the light's name
  37594. * @return the light or null if none found.
  37595. */
  37596. getLightByName(name: string): Nullable<Light>;
  37597. /**
  37598. * Gets a light node using its id
  37599. * @param id defines the light's id
  37600. * @return the light or null if none found.
  37601. */
  37602. getLightByID(id: string): Nullable<Light>;
  37603. /**
  37604. * Gets a light node using its scene-generated unique ID
  37605. * @param uniqueId defines the light's unique id
  37606. * @return the light or null if none found.
  37607. */
  37608. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37609. /**
  37610. * Gets a particle system by id
  37611. * @param id defines the particle system id
  37612. * @return the corresponding system or null if none found
  37613. */
  37614. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37615. /**
  37616. * Gets a geometry using its ID
  37617. * @param id defines the geometry's id
  37618. * @return the geometry or null if none found.
  37619. */
  37620. getGeometryByID(id: string): Nullable<Geometry>;
  37621. private _getGeometryByUniqueID;
  37622. /**
  37623. * Add a new geometry to this scene
  37624. * @param geometry defines the geometry to be added to the scene.
  37625. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37626. * @return a boolean defining if the geometry was added or not
  37627. */
  37628. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37629. /**
  37630. * Removes an existing geometry
  37631. * @param geometry defines the geometry to be removed from the scene
  37632. * @return a boolean defining if the geometry was removed or not
  37633. */
  37634. removeGeometry(geometry: Geometry): boolean;
  37635. /**
  37636. * Gets the list of geometries attached to the scene
  37637. * @returns an array of Geometry
  37638. */
  37639. getGeometries(): Geometry[];
  37640. /**
  37641. * Gets the first added mesh found of a given ID
  37642. * @param id defines the id to search for
  37643. * @return the mesh found or null if not found at all
  37644. */
  37645. getMeshByID(id: string): Nullable<AbstractMesh>;
  37646. /**
  37647. * Gets a list of meshes using their id
  37648. * @param id defines the id to search for
  37649. * @returns a list of meshes
  37650. */
  37651. getMeshesByID(id: string): Array<AbstractMesh>;
  37652. /**
  37653. * Gets the first added transform node found of a given ID
  37654. * @param id defines the id to search for
  37655. * @return the found transform node or null if not found at all.
  37656. */
  37657. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37658. /**
  37659. * Gets a transform node with its auto-generated unique id
  37660. * @param uniqueId efines the unique id to search for
  37661. * @return the found transform node or null if not found at all.
  37662. */
  37663. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37664. /**
  37665. * Gets a list of transform nodes using their id
  37666. * @param id defines the id to search for
  37667. * @returns a list of transform nodes
  37668. */
  37669. getTransformNodesByID(id: string): Array<TransformNode>;
  37670. /**
  37671. * Gets a mesh with its auto-generated unique id
  37672. * @param uniqueId defines the unique id to search for
  37673. * @return the found mesh or null if not found at all.
  37674. */
  37675. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37676. /**
  37677. * Gets a the last added mesh using a given id
  37678. * @param id defines the id to search for
  37679. * @return the found mesh or null if not found at all.
  37680. */
  37681. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37682. /**
  37683. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37684. * @param id defines the id to search for
  37685. * @return the found node or null if not found at all
  37686. */
  37687. getLastEntryByID(id: string): Nullable<Node>;
  37688. /**
  37689. * Gets a node (Mesh, Camera, Light) using a given id
  37690. * @param id defines the id to search for
  37691. * @return the found node or null if not found at all
  37692. */
  37693. getNodeByID(id: string): Nullable<Node>;
  37694. /**
  37695. * Gets a node (Mesh, Camera, Light) using a given name
  37696. * @param name defines the name to search for
  37697. * @return the found node or null if not found at all.
  37698. */
  37699. getNodeByName(name: string): Nullable<Node>;
  37700. /**
  37701. * Gets a mesh using a given name
  37702. * @param name defines the name to search for
  37703. * @return the found mesh or null if not found at all.
  37704. */
  37705. getMeshByName(name: string): Nullable<AbstractMesh>;
  37706. /**
  37707. * Gets a transform node using a given name
  37708. * @param name defines the name to search for
  37709. * @return the found transform node or null if not found at all.
  37710. */
  37711. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37712. /**
  37713. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37714. * @param id defines the id to search for
  37715. * @return the found skeleton or null if not found at all.
  37716. */
  37717. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37718. /**
  37719. * Gets a skeleton using a given auto generated unique id
  37720. * @param uniqueId defines the unique id to search for
  37721. * @return the found skeleton or null if not found at all.
  37722. */
  37723. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37724. /**
  37725. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37726. * @param id defines the id to search for
  37727. * @return the found skeleton or null if not found at all.
  37728. */
  37729. getSkeletonById(id: string): Nullable<Skeleton>;
  37730. /**
  37731. * Gets a skeleton using a given name
  37732. * @param name defines the name to search for
  37733. * @return the found skeleton or null if not found at all.
  37734. */
  37735. getSkeletonByName(name: string): Nullable<Skeleton>;
  37736. /**
  37737. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37738. * @param id defines the id to search for
  37739. * @return the found morph target manager or null if not found at all.
  37740. */
  37741. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37742. /**
  37743. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37744. * @param id defines the id to search for
  37745. * @return the found morph target or null if not found at all.
  37746. */
  37747. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37748. /**
  37749. * Gets a boolean indicating if the given mesh is active
  37750. * @param mesh defines the mesh to look for
  37751. * @returns true if the mesh is in the active list
  37752. */
  37753. isActiveMesh(mesh: AbstractMesh): boolean;
  37754. /**
  37755. * Return a unique id as a string which can serve as an identifier for the scene
  37756. */
  37757. get uid(): string;
  37758. /**
  37759. * Add an externaly attached data from its key.
  37760. * This method call will fail and return false, if such key already exists.
  37761. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37762. * @param key the unique key that identifies the data
  37763. * @param data the data object to associate to the key for this Engine instance
  37764. * @return true if no such key were already present and the data was added successfully, false otherwise
  37765. */
  37766. addExternalData<T>(key: string, data: T): boolean;
  37767. /**
  37768. * Get an externaly attached data from its key
  37769. * @param key the unique key that identifies the data
  37770. * @return the associated data, if present (can be null), or undefined if not present
  37771. */
  37772. getExternalData<T>(key: string): Nullable<T>;
  37773. /**
  37774. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37775. * @param key the unique key that identifies the data
  37776. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37777. * @return the associated data, can be null if the factory returned null.
  37778. */
  37779. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37780. /**
  37781. * Remove an externaly attached data from the Engine instance
  37782. * @param key the unique key that identifies the data
  37783. * @return true if the data was successfully removed, false if it doesn't exist
  37784. */
  37785. removeExternalData(key: string): boolean;
  37786. private _evaluateSubMesh;
  37787. /**
  37788. * Clear the processed materials smart array preventing retention point in material dispose.
  37789. */
  37790. freeProcessedMaterials(): void;
  37791. private _preventFreeActiveMeshesAndRenderingGroups;
  37792. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37793. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37794. * when disposing several meshes in a row or a hierarchy of meshes.
  37795. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37796. */
  37797. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37798. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37799. /**
  37800. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37801. */
  37802. freeActiveMeshes(): void;
  37803. /**
  37804. * Clear the info related to rendering groups preventing retention points during dispose.
  37805. */
  37806. freeRenderingGroups(): void;
  37807. /** @hidden */
  37808. _isInIntermediateRendering(): boolean;
  37809. /**
  37810. * Lambda returning the list of potentially active meshes.
  37811. */
  37812. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37813. /**
  37814. * Lambda returning the list of potentially active sub meshes.
  37815. */
  37816. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37817. /**
  37818. * Lambda returning the list of potentially intersecting sub meshes.
  37819. */
  37820. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37821. /**
  37822. * Lambda returning the list of potentially colliding sub meshes.
  37823. */
  37824. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37825. private _activeMeshesFrozen;
  37826. private _skipEvaluateActiveMeshesCompletely;
  37827. /**
  37828. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37829. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37830. * @returns the current scene
  37831. */
  37832. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37833. /**
  37834. * Use this function to restart evaluating active meshes on every frame
  37835. * @returns the current scene
  37836. */
  37837. unfreezeActiveMeshes(): Scene;
  37838. private _evaluateActiveMeshes;
  37839. private _activeMesh;
  37840. /**
  37841. * Update the transform matrix to update from the current active camera
  37842. * @param force defines a boolean used to force the update even if cache is up to date
  37843. */
  37844. updateTransformMatrix(force?: boolean): void;
  37845. private _bindFrameBuffer;
  37846. /** @hidden */
  37847. _allowPostProcessClearColor: boolean;
  37848. /** @hidden */
  37849. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37850. private _processSubCameras;
  37851. private _checkIntersections;
  37852. /** @hidden */
  37853. _advancePhysicsEngineStep(step: number): void;
  37854. /**
  37855. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37856. */
  37857. getDeterministicFrameTime: () => number;
  37858. /** @hidden */
  37859. _animate(): void;
  37860. /** Execute all animations (for a frame) */
  37861. animate(): void;
  37862. /**
  37863. * Render the scene
  37864. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37865. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37866. */
  37867. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37868. /**
  37869. * Freeze all materials
  37870. * A frozen material will not be updatable but should be faster to render
  37871. */
  37872. freezeMaterials(): void;
  37873. /**
  37874. * Unfreeze all materials
  37875. * A frozen material will not be updatable but should be faster to render
  37876. */
  37877. unfreezeMaterials(): void;
  37878. /**
  37879. * Releases all held ressources
  37880. */
  37881. dispose(): void;
  37882. /**
  37883. * Gets if the scene is already disposed
  37884. */
  37885. get isDisposed(): boolean;
  37886. /**
  37887. * Call this function to reduce memory footprint of the scene.
  37888. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37889. */
  37890. clearCachedVertexData(): void;
  37891. /**
  37892. * This function will remove the local cached buffer data from texture.
  37893. * It will save memory but will prevent the texture from being rebuilt
  37894. */
  37895. cleanCachedTextureBuffer(): void;
  37896. /**
  37897. * Get the world extend vectors with an optional filter
  37898. *
  37899. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37900. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37901. */
  37902. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37903. min: Vector3;
  37904. max: Vector3;
  37905. };
  37906. /**
  37907. * Creates a ray that can be used to pick in the scene
  37908. * @param x defines the x coordinate of the origin (on-screen)
  37909. * @param y defines the y coordinate of the origin (on-screen)
  37910. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37911. * @param camera defines the camera to use for the picking
  37912. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37913. * @returns a Ray
  37914. */
  37915. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37916. /**
  37917. * Creates a ray that can be used to pick in the scene
  37918. * @param x defines the x coordinate of the origin (on-screen)
  37919. * @param y defines the y coordinate of the origin (on-screen)
  37920. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37921. * @param result defines the ray where to store the picking ray
  37922. * @param camera defines the camera to use for the picking
  37923. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37924. * @returns the current scene
  37925. */
  37926. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37927. /**
  37928. * Creates a ray that can be used to pick in the scene
  37929. * @param x defines the x coordinate of the origin (on-screen)
  37930. * @param y defines the y coordinate of the origin (on-screen)
  37931. * @param camera defines the camera to use for the picking
  37932. * @returns a Ray
  37933. */
  37934. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37935. /**
  37936. * Creates a ray that can be used to pick in the scene
  37937. * @param x defines the x coordinate of the origin (on-screen)
  37938. * @param y defines the y coordinate of the origin (on-screen)
  37939. * @param result defines the ray where to store the picking ray
  37940. * @param camera defines the camera to use for the picking
  37941. * @returns the current scene
  37942. */
  37943. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37944. /** Launch a ray to try to pick a mesh in the scene
  37945. * @param x position on screen
  37946. * @param y position on screen
  37947. * @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
  37948. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37949. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37950. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37951. * @returns a PickingInfo
  37952. */
  37953. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37954. /** Use the given ray to pick a mesh in the scene
  37955. * @param ray The ray to use to pick meshes
  37956. * @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
  37957. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37958. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37959. * @returns a PickingInfo
  37960. */
  37961. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37962. /**
  37963. * Launch a ray to try to pick a mesh in the scene
  37964. * @param x X position on screen
  37965. * @param y Y position on screen
  37966. * @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
  37967. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37968. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37969. * @returns an array of PickingInfo
  37970. */
  37971. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37972. /**
  37973. * Launch a ray to try to pick a mesh in the scene
  37974. * @param ray Ray to use
  37975. * @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
  37976. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37977. * @returns an array of PickingInfo
  37978. */
  37979. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37980. /**
  37981. * Force the value of meshUnderPointer
  37982. * @param mesh defines the mesh to use
  37983. */
  37984. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37985. /**
  37986. * Gets the mesh under the pointer
  37987. * @returns a Mesh or null if no mesh is under the pointer
  37988. */
  37989. getPointerOverMesh(): Nullable<AbstractMesh>;
  37990. /** @hidden */
  37991. _rebuildGeometries(): void;
  37992. /** @hidden */
  37993. _rebuildTextures(): void;
  37994. private _getByTags;
  37995. /**
  37996. * Get a list of meshes by tags
  37997. * @param tagsQuery defines the tags query to use
  37998. * @param forEach defines a predicate used to filter results
  37999. * @returns an array of Mesh
  38000. */
  38001. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38002. /**
  38003. * Get a list of cameras by tags
  38004. * @param tagsQuery defines the tags query to use
  38005. * @param forEach defines a predicate used to filter results
  38006. * @returns an array of Camera
  38007. */
  38008. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38009. /**
  38010. * Get a list of lights by tags
  38011. * @param tagsQuery defines the tags query to use
  38012. * @param forEach defines a predicate used to filter results
  38013. * @returns an array of Light
  38014. */
  38015. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38016. /**
  38017. * Get a list of materials by tags
  38018. * @param tagsQuery defines the tags query to use
  38019. * @param forEach defines a predicate used to filter results
  38020. * @returns an array of Material
  38021. */
  38022. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38023. /**
  38024. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38025. * This allowed control for front to back rendering or reversly depending of the special needs.
  38026. *
  38027. * @param renderingGroupId The rendering group id corresponding to its index
  38028. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38029. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38030. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38031. */
  38032. 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;
  38033. /**
  38034. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38035. *
  38036. * @param renderingGroupId The rendering group id corresponding to its index
  38037. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38038. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38039. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38040. */
  38041. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38042. /**
  38043. * Gets the current auto clear configuration for one rendering group of the rendering
  38044. * manager.
  38045. * @param index the rendering group index to get the information for
  38046. * @returns The auto clear setup for the requested rendering group
  38047. */
  38048. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38049. private _blockMaterialDirtyMechanism;
  38050. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38051. get blockMaterialDirtyMechanism(): boolean;
  38052. set blockMaterialDirtyMechanism(value: boolean);
  38053. /**
  38054. * Will flag all materials as dirty to trigger new shader compilation
  38055. * @param flag defines the flag used to specify which material part must be marked as dirty
  38056. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38057. */
  38058. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38059. /** @hidden */
  38060. _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;
  38061. /** @hidden */
  38062. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38063. /** @hidden */
  38064. _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;
  38065. /** @hidden */
  38066. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38067. /** @hidden */
  38068. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38069. /** @hidden */
  38070. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38071. }
  38072. }
  38073. declare module "babylonjs/assetContainer" {
  38074. import { AbstractScene } from "babylonjs/abstractScene";
  38075. import { Scene } from "babylonjs/scene";
  38076. import { Mesh } from "babylonjs/Meshes/mesh";
  38077. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38078. import { Skeleton } from "babylonjs/Bones/skeleton";
  38079. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38080. import { Animatable } from "babylonjs/Animations/animatable";
  38081. import { Nullable } from "babylonjs/types";
  38082. import { Node } from "babylonjs/node";
  38083. /**
  38084. * Set of assets to keep when moving a scene into an asset container.
  38085. */
  38086. export class KeepAssets extends AbstractScene {
  38087. }
  38088. /**
  38089. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38090. */
  38091. export class InstantiatedEntries {
  38092. /**
  38093. * List of new root nodes (eg. nodes with no parent)
  38094. */
  38095. rootNodes: TransformNode[];
  38096. /**
  38097. * List of new skeletons
  38098. */
  38099. skeletons: Skeleton[];
  38100. /**
  38101. * List of new animation groups
  38102. */
  38103. animationGroups: AnimationGroup[];
  38104. }
  38105. /**
  38106. * Container with a set of assets that can be added or removed from a scene.
  38107. */
  38108. export class AssetContainer extends AbstractScene {
  38109. private _wasAddedToScene;
  38110. /**
  38111. * The scene the AssetContainer belongs to.
  38112. */
  38113. scene: Scene;
  38114. /**
  38115. * Instantiates an AssetContainer.
  38116. * @param scene The scene the AssetContainer belongs to.
  38117. */
  38118. constructor(scene: Scene);
  38119. /**
  38120. * Instantiate or clone all meshes and add the new ones to the scene.
  38121. * Skeletons and animation groups will all be cloned
  38122. * @param nameFunction defines an optional function used to get new names for clones
  38123. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38124. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38125. */
  38126. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38127. /**
  38128. * Adds all the assets from the container to the scene.
  38129. */
  38130. addAllToScene(): void;
  38131. /**
  38132. * Removes all the assets in the container from the scene
  38133. */
  38134. removeAllFromScene(): void;
  38135. /**
  38136. * Disposes all the assets in the container
  38137. */
  38138. dispose(): void;
  38139. private _moveAssets;
  38140. /**
  38141. * Removes all the assets contained in the scene and adds them to the container.
  38142. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38143. */
  38144. moveAllFromScene(keepAssets?: KeepAssets): void;
  38145. /**
  38146. * 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.
  38147. * @returns the root mesh
  38148. */
  38149. createRootMesh(): Mesh;
  38150. /**
  38151. * Merge animations from this asset container into a scene
  38152. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38153. * @param animatables set of animatables to retarget to a node from the scene
  38154. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38155. */
  38156. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38157. }
  38158. }
  38159. declare module "babylonjs/abstractScene" {
  38160. import { Scene } from "babylonjs/scene";
  38161. import { Nullable } from "babylonjs/types";
  38162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38163. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38164. import { Geometry } from "babylonjs/Meshes/geometry";
  38165. import { Skeleton } from "babylonjs/Bones/skeleton";
  38166. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38167. import { AssetContainer } from "babylonjs/assetContainer";
  38168. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38169. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38170. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38171. import { Material } from "babylonjs/Materials/material";
  38172. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38173. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38174. import { Camera } from "babylonjs/Cameras/camera";
  38175. import { Light } from "babylonjs/Lights/light";
  38176. import { Node } from "babylonjs/node";
  38177. import { Animation } from "babylonjs/Animations/animation";
  38178. /**
  38179. * Defines how the parser contract is defined.
  38180. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38181. */
  38182. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38183. /**
  38184. * Defines how the individual parser contract is defined.
  38185. * These parser can parse an individual asset
  38186. */
  38187. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38188. /**
  38189. * Base class of the scene acting as a container for the different elements composing a scene.
  38190. * This class is dynamically extended by the different components of the scene increasing
  38191. * flexibility and reducing coupling
  38192. */
  38193. export abstract class AbstractScene {
  38194. /**
  38195. * Stores the list of available parsers in the application.
  38196. */
  38197. private static _BabylonFileParsers;
  38198. /**
  38199. * Stores the list of available individual parsers in the application.
  38200. */
  38201. private static _IndividualBabylonFileParsers;
  38202. /**
  38203. * Adds a parser in the list of available ones
  38204. * @param name Defines the name of the parser
  38205. * @param parser Defines the parser to add
  38206. */
  38207. static AddParser(name: string, parser: BabylonFileParser): void;
  38208. /**
  38209. * Gets a general parser from the list of avaialble ones
  38210. * @param name Defines the name of the parser
  38211. * @returns the requested parser or null
  38212. */
  38213. static GetParser(name: string): Nullable<BabylonFileParser>;
  38214. /**
  38215. * Adds n individual parser in the list of available ones
  38216. * @param name Defines the name of the parser
  38217. * @param parser Defines the parser to add
  38218. */
  38219. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38220. /**
  38221. * Gets an individual parser from the list of avaialble ones
  38222. * @param name Defines the name of the parser
  38223. * @returns the requested parser or null
  38224. */
  38225. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38226. /**
  38227. * Parser json data and populate both a scene and its associated container object
  38228. * @param jsonData Defines the data to parse
  38229. * @param scene Defines the scene to parse the data for
  38230. * @param container Defines the container attached to the parsing sequence
  38231. * @param rootUrl Defines the root url of the data
  38232. */
  38233. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38234. /**
  38235. * Gets the list of root nodes (ie. nodes with no parent)
  38236. */
  38237. rootNodes: Node[];
  38238. /** All of the cameras added to this scene
  38239. * @see http://doc.babylonjs.com/babylon101/cameras
  38240. */
  38241. cameras: Camera[];
  38242. /**
  38243. * All of the lights added to this scene
  38244. * @see http://doc.babylonjs.com/babylon101/lights
  38245. */
  38246. lights: Light[];
  38247. /**
  38248. * All of the (abstract) meshes added to this scene
  38249. */
  38250. meshes: AbstractMesh[];
  38251. /**
  38252. * The list of skeletons added to the scene
  38253. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38254. */
  38255. skeletons: Skeleton[];
  38256. /**
  38257. * All of the particle systems added to this scene
  38258. * @see http://doc.babylonjs.com/babylon101/particles
  38259. */
  38260. particleSystems: IParticleSystem[];
  38261. /**
  38262. * Gets a list of Animations associated with the scene
  38263. */
  38264. animations: Animation[];
  38265. /**
  38266. * All of the animation groups added to this scene
  38267. * @see http://doc.babylonjs.com/how_to/group
  38268. */
  38269. animationGroups: AnimationGroup[];
  38270. /**
  38271. * All of the multi-materials added to this scene
  38272. * @see http://doc.babylonjs.com/how_to/multi_materials
  38273. */
  38274. multiMaterials: MultiMaterial[];
  38275. /**
  38276. * All of the materials added to this scene
  38277. * In the context of a Scene, it is not supposed to be modified manually.
  38278. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38279. * Note also that the order of the Material within the array is not significant and might change.
  38280. * @see http://doc.babylonjs.com/babylon101/materials
  38281. */
  38282. materials: Material[];
  38283. /**
  38284. * The list of morph target managers added to the scene
  38285. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38286. */
  38287. morphTargetManagers: MorphTargetManager[];
  38288. /**
  38289. * The list of geometries used in the scene.
  38290. */
  38291. geometries: Geometry[];
  38292. /**
  38293. * All of the tranform nodes added to this scene
  38294. * In the context of a Scene, it is not supposed to be modified manually.
  38295. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38296. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38297. * @see http://doc.babylonjs.com/how_to/transformnode
  38298. */
  38299. transformNodes: TransformNode[];
  38300. /**
  38301. * ActionManagers available on the scene.
  38302. */
  38303. actionManagers: AbstractActionManager[];
  38304. /**
  38305. * Textures to keep.
  38306. */
  38307. textures: BaseTexture[];
  38308. /**
  38309. * Environment texture for the scene
  38310. */
  38311. environmentTexture: Nullable<BaseTexture>;
  38312. /**
  38313. * @returns all meshes, lights, cameras, transformNodes and bones
  38314. */
  38315. getNodes(): Array<Node>;
  38316. }
  38317. }
  38318. declare module "babylonjs/Audio/sound" {
  38319. import { Observable } from "babylonjs/Misc/observable";
  38320. import { Vector3 } from "babylonjs/Maths/math.vector";
  38321. import { Nullable } from "babylonjs/types";
  38322. import { Scene } from "babylonjs/scene";
  38323. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38324. /**
  38325. * Interface used to define options for Sound class
  38326. */
  38327. export interface ISoundOptions {
  38328. /**
  38329. * Does the sound autoplay once loaded.
  38330. */
  38331. autoplay?: boolean;
  38332. /**
  38333. * Does the sound loop after it finishes playing once.
  38334. */
  38335. loop?: boolean;
  38336. /**
  38337. * Sound's volume
  38338. */
  38339. volume?: number;
  38340. /**
  38341. * Is it a spatial sound?
  38342. */
  38343. spatialSound?: boolean;
  38344. /**
  38345. * Maximum distance to hear that sound
  38346. */
  38347. maxDistance?: number;
  38348. /**
  38349. * Uses user defined attenuation function
  38350. */
  38351. useCustomAttenuation?: boolean;
  38352. /**
  38353. * Define the roll off factor of spatial sounds.
  38354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38355. */
  38356. rolloffFactor?: number;
  38357. /**
  38358. * Define the reference distance the sound should be heard perfectly.
  38359. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38360. */
  38361. refDistance?: number;
  38362. /**
  38363. * Define the distance attenuation model the sound will follow.
  38364. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38365. */
  38366. distanceModel?: string;
  38367. /**
  38368. * Defines the playback speed (1 by default)
  38369. */
  38370. playbackRate?: number;
  38371. /**
  38372. * Defines if the sound is from a streaming source
  38373. */
  38374. streaming?: boolean;
  38375. /**
  38376. * Defines an optional length (in seconds) inside the sound file
  38377. */
  38378. length?: number;
  38379. /**
  38380. * Defines an optional offset (in seconds) inside the sound file
  38381. */
  38382. offset?: number;
  38383. /**
  38384. * If true, URLs will not be required to state the audio file codec to use.
  38385. */
  38386. skipCodecCheck?: boolean;
  38387. }
  38388. /**
  38389. * Defines a sound that can be played in the application.
  38390. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38391. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38392. */
  38393. export class Sound {
  38394. /**
  38395. * The name of the sound in the scene.
  38396. */
  38397. name: string;
  38398. /**
  38399. * Does the sound autoplay once loaded.
  38400. */
  38401. autoplay: boolean;
  38402. /**
  38403. * Does the sound loop after it finishes playing once.
  38404. */
  38405. loop: boolean;
  38406. /**
  38407. * Does the sound use a custom attenuation curve to simulate the falloff
  38408. * happening when the source gets further away from the camera.
  38409. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38410. */
  38411. useCustomAttenuation: boolean;
  38412. /**
  38413. * The sound track id this sound belongs to.
  38414. */
  38415. soundTrackId: number;
  38416. /**
  38417. * Is this sound currently played.
  38418. */
  38419. isPlaying: boolean;
  38420. /**
  38421. * Is this sound currently paused.
  38422. */
  38423. isPaused: boolean;
  38424. /**
  38425. * Does this sound enables spatial sound.
  38426. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38427. */
  38428. spatialSound: boolean;
  38429. /**
  38430. * Define the reference distance the sound should be heard perfectly.
  38431. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38432. */
  38433. refDistance: number;
  38434. /**
  38435. * Define the roll off factor of spatial sounds.
  38436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38437. */
  38438. rolloffFactor: number;
  38439. /**
  38440. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38442. */
  38443. maxDistance: number;
  38444. /**
  38445. * Define the distance attenuation model the sound will follow.
  38446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38447. */
  38448. distanceModel: string;
  38449. /**
  38450. * @hidden
  38451. * Back Compat
  38452. **/
  38453. onended: () => any;
  38454. /**
  38455. * Observable event when the current playing sound finishes.
  38456. */
  38457. onEndedObservable: Observable<Sound>;
  38458. private _panningModel;
  38459. private _playbackRate;
  38460. private _streaming;
  38461. private _startTime;
  38462. private _startOffset;
  38463. private _position;
  38464. /** @hidden */
  38465. _positionInEmitterSpace: boolean;
  38466. private _localDirection;
  38467. private _volume;
  38468. private _isReadyToPlay;
  38469. private _isDirectional;
  38470. private _readyToPlayCallback;
  38471. private _audioBuffer;
  38472. private _soundSource;
  38473. private _streamingSource;
  38474. private _soundPanner;
  38475. private _soundGain;
  38476. private _inputAudioNode;
  38477. private _outputAudioNode;
  38478. private _coneInnerAngle;
  38479. private _coneOuterAngle;
  38480. private _coneOuterGain;
  38481. private _scene;
  38482. private _connectedTransformNode;
  38483. private _customAttenuationFunction;
  38484. private _registerFunc;
  38485. private _isOutputConnected;
  38486. private _htmlAudioElement;
  38487. private _urlType;
  38488. private _length?;
  38489. private _offset?;
  38490. /** @hidden */
  38491. static _SceneComponentInitialization: (scene: Scene) => void;
  38492. /**
  38493. * Create a sound and attach it to a scene
  38494. * @param name Name of your sound
  38495. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38496. * @param scene defines the scene the sound belongs to
  38497. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38498. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38499. */
  38500. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38501. /**
  38502. * Release the sound and its associated resources
  38503. */
  38504. dispose(): void;
  38505. /**
  38506. * Gets if the sounds is ready to be played or not.
  38507. * @returns true if ready, otherwise false
  38508. */
  38509. isReady(): boolean;
  38510. private _soundLoaded;
  38511. /**
  38512. * Sets the data of the sound from an audiobuffer
  38513. * @param audioBuffer The audioBuffer containing the data
  38514. */
  38515. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38516. /**
  38517. * Updates the current sounds options such as maxdistance, loop...
  38518. * @param options A JSON object containing values named as the object properties
  38519. */
  38520. updateOptions(options: ISoundOptions): void;
  38521. private _createSpatialParameters;
  38522. private _updateSpatialParameters;
  38523. /**
  38524. * Switch the panning model to HRTF:
  38525. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38527. */
  38528. switchPanningModelToHRTF(): void;
  38529. /**
  38530. * Switch the panning model to Equal Power:
  38531. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38533. */
  38534. switchPanningModelToEqualPower(): void;
  38535. private _switchPanningModel;
  38536. /**
  38537. * Connect this sound to a sound track audio node like gain...
  38538. * @param soundTrackAudioNode the sound track audio node to connect to
  38539. */
  38540. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38541. /**
  38542. * Transform this sound into a directional source
  38543. * @param coneInnerAngle Size of the inner cone in degree
  38544. * @param coneOuterAngle Size of the outer cone in degree
  38545. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38546. */
  38547. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38548. /**
  38549. * Gets or sets the inner angle for the directional cone.
  38550. */
  38551. get directionalConeInnerAngle(): number;
  38552. /**
  38553. * Gets or sets the inner angle for the directional cone.
  38554. */
  38555. set directionalConeInnerAngle(value: number);
  38556. /**
  38557. * Gets or sets the outer angle for the directional cone.
  38558. */
  38559. get directionalConeOuterAngle(): number;
  38560. /**
  38561. * Gets or sets the outer angle for the directional cone.
  38562. */
  38563. set directionalConeOuterAngle(value: number);
  38564. /**
  38565. * Sets the position of the emitter if spatial sound is enabled
  38566. * @param newPosition Defines the new posisiton
  38567. */
  38568. setPosition(newPosition: Vector3): void;
  38569. /**
  38570. * Sets the local direction of the emitter if spatial sound is enabled
  38571. * @param newLocalDirection Defines the new local direction
  38572. */
  38573. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38574. private _updateDirection;
  38575. /** @hidden */
  38576. updateDistanceFromListener(): void;
  38577. /**
  38578. * Sets a new custom attenuation function for the sound.
  38579. * @param callback Defines the function used for the attenuation
  38580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38581. */
  38582. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38583. /**
  38584. * Play the sound
  38585. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38586. * @param offset (optional) Start the sound at a specific time in seconds
  38587. * @param length (optional) Sound duration (in seconds)
  38588. */
  38589. play(time?: number, offset?: number, length?: number): void;
  38590. private _onended;
  38591. /**
  38592. * Stop the sound
  38593. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38594. */
  38595. stop(time?: number): void;
  38596. /**
  38597. * Put the sound in pause
  38598. */
  38599. pause(): void;
  38600. /**
  38601. * Sets a dedicated volume for this sounds
  38602. * @param newVolume Define the new volume of the sound
  38603. * @param time Define time for gradual change to new volume
  38604. */
  38605. setVolume(newVolume: number, time?: number): void;
  38606. /**
  38607. * Set the sound play back rate
  38608. * @param newPlaybackRate Define the playback rate the sound should be played at
  38609. */
  38610. setPlaybackRate(newPlaybackRate: number): void;
  38611. /**
  38612. * Gets the volume of the sound.
  38613. * @returns the volume of the sound
  38614. */
  38615. getVolume(): number;
  38616. /**
  38617. * Attach the sound to a dedicated mesh
  38618. * @param transformNode The transform node to connect the sound with
  38619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38620. */
  38621. attachToMesh(transformNode: TransformNode): void;
  38622. /**
  38623. * Detach the sound from the previously attached mesh
  38624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38625. */
  38626. detachFromMesh(): void;
  38627. private _onRegisterAfterWorldMatrixUpdate;
  38628. /**
  38629. * Clone the current sound in the scene.
  38630. * @returns the new sound clone
  38631. */
  38632. clone(): Nullable<Sound>;
  38633. /**
  38634. * Gets the current underlying audio buffer containing the data
  38635. * @returns the audio buffer
  38636. */
  38637. getAudioBuffer(): Nullable<AudioBuffer>;
  38638. /**
  38639. * Serializes the Sound in a JSON representation
  38640. * @returns the JSON representation of the sound
  38641. */
  38642. serialize(): any;
  38643. /**
  38644. * Parse a JSON representation of a sound to innstantiate in a given scene
  38645. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38646. * @param scene Define the scene the new parsed sound should be created in
  38647. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38648. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38649. * @returns the newly parsed sound
  38650. */
  38651. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38652. }
  38653. }
  38654. declare module "babylonjs/Actions/directAudioActions" {
  38655. import { Action } from "babylonjs/Actions/action";
  38656. import { Condition } from "babylonjs/Actions/condition";
  38657. import { Sound } from "babylonjs/Audio/sound";
  38658. /**
  38659. * This defines an action helpful to play a defined sound on a triggered action.
  38660. */
  38661. export class PlaySoundAction extends Action {
  38662. private _sound;
  38663. /**
  38664. * Instantiate the action
  38665. * @param triggerOptions defines the trigger options
  38666. * @param sound defines the sound to play
  38667. * @param condition defines the trigger related conditions
  38668. */
  38669. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38670. /** @hidden */
  38671. _prepare(): void;
  38672. /**
  38673. * Execute the action and play the sound.
  38674. */
  38675. execute(): void;
  38676. /**
  38677. * Serializes the actions and its related information.
  38678. * @param parent defines the object to serialize in
  38679. * @returns the serialized object
  38680. */
  38681. serialize(parent: any): any;
  38682. }
  38683. /**
  38684. * This defines an action helpful to stop a defined sound on a triggered action.
  38685. */
  38686. export class StopSoundAction extends Action {
  38687. private _sound;
  38688. /**
  38689. * Instantiate the action
  38690. * @param triggerOptions defines the trigger options
  38691. * @param sound defines the sound to stop
  38692. * @param condition defines the trigger related conditions
  38693. */
  38694. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38695. /** @hidden */
  38696. _prepare(): void;
  38697. /**
  38698. * Execute the action and stop the sound.
  38699. */
  38700. execute(): void;
  38701. /**
  38702. * Serializes the actions and its related information.
  38703. * @param parent defines the object to serialize in
  38704. * @returns the serialized object
  38705. */
  38706. serialize(parent: any): any;
  38707. }
  38708. }
  38709. declare module "babylonjs/Actions/interpolateValueAction" {
  38710. import { Action } from "babylonjs/Actions/action";
  38711. import { Condition } from "babylonjs/Actions/condition";
  38712. import { Observable } from "babylonjs/Misc/observable";
  38713. /**
  38714. * This defines an action responsible to change the value of a property
  38715. * by interpolating between its current value and the newly set one once triggered.
  38716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38717. */
  38718. export class InterpolateValueAction extends Action {
  38719. /**
  38720. * Defines the path of the property where the value should be interpolated
  38721. */
  38722. propertyPath: string;
  38723. /**
  38724. * Defines the target value at the end of the interpolation.
  38725. */
  38726. value: any;
  38727. /**
  38728. * Defines the time it will take for the property to interpolate to the value.
  38729. */
  38730. duration: number;
  38731. /**
  38732. * Defines if the other scene animations should be stopped when the action has been triggered
  38733. */
  38734. stopOtherAnimations?: boolean;
  38735. /**
  38736. * Defines a callback raised once the interpolation animation has been done.
  38737. */
  38738. onInterpolationDone?: () => void;
  38739. /**
  38740. * Observable triggered once the interpolation animation has been done.
  38741. */
  38742. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38743. private _target;
  38744. private _effectiveTarget;
  38745. private _property;
  38746. /**
  38747. * Instantiate the action
  38748. * @param triggerOptions defines the trigger options
  38749. * @param target defines the object containing the value to interpolate
  38750. * @param propertyPath defines the path to the property in the target object
  38751. * @param value defines the target value at the end of the interpolation
  38752. * @param duration deines the time it will take for the property to interpolate to the value.
  38753. * @param condition defines the trigger related conditions
  38754. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38755. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38756. */
  38757. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38758. /** @hidden */
  38759. _prepare(): void;
  38760. /**
  38761. * Execute the action starts the value interpolation.
  38762. */
  38763. execute(): void;
  38764. /**
  38765. * Serializes the actions and its related information.
  38766. * @param parent defines the object to serialize in
  38767. * @returns the serialized object
  38768. */
  38769. serialize(parent: any): any;
  38770. }
  38771. }
  38772. declare module "babylonjs/Actions/index" {
  38773. export * from "babylonjs/Actions/abstractActionManager";
  38774. export * from "babylonjs/Actions/action";
  38775. export * from "babylonjs/Actions/actionEvent";
  38776. export * from "babylonjs/Actions/actionManager";
  38777. export * from "babylonjs/Actions/condition";
  38778. export * from "babylonjs/Actions/directActions";
  38779. export * from "babylonjs/Actions/directAudioActions";
  38780. export * from "babylonjs/Actions/interpolateValueAction";
  38781. }
  38782. declare module "babylonjs/Animations/index" {
  38783. export * from "babylonjs/Animations/animatable";
  38784. export * from "babylonjs/Animations/animation";
  38785. export * from "babylonjs/Animations/animationGroup";
  38786. export * from "babylonjs/Animations/animationPropertiesOverride";
  38787. export * from "babylonjs/Animations/easing";
  38788. export * from "babylonjs/Animations/runtimeAnimation";
  38789. export * from "babylonjs/Animations/animationEvent";
  38790. export * from "babylonjs/Animations/animationGroup";
  38791. export * from "babylonjs/Animations/animationKey";
  38792. export * from "babylonjs/Animations/animationRange";
  38793. export * from "babylonjs/Animations/animatable.interface";
  38794. }
  38795. declare module "babylonjs/Audio/soundTrack" {
  38796. import { Sound } from "babylonjs/Audio/sound";
  38797. import { Analyser } from "babylonjs/Audio/analyser";
  38798. import { Scene } from "babylonjs/scene";
  38799. /**
  38800. * Options allowed during the creation of a sound track.
  38801. */
  38802. export interface ISoundTrackOptions {
  38803. /**
  38804. * The volume the sound track should take during creation
  38805. */
  38806. volume?: number;
  38807. /**
  38808. * Define if the sound track is the main sound track of the scene
  38809. */
  38810. mainTrack?: boolean;
  38811. }
  38812. /**
  38813. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38814. * It will be also used in a future release to apply effects on a specific track.
  38815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38816. */
  38817. export class SoundTrack {
  38818. /**
  38819. * The unique identifier of the sound track in the scene.
  38820. */
  38821. id: number;
  38822. /**
  38823. * The list of sounds included in the sound track.
  38824. */
  38825. soundCollection: Array<Sound>;
  38826. private _outputAudioNode;
  38827. private _scene;
  38828. private _connectedAnalyser;
  38829. private _options;
  38830. private _isInitialized;
  38831. /**
  38832. * Creates a new sound track.
  38833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38834. * @param scene Define the scene the sound track belongs to
  38835. * @param options
  38836. */
  38837. constructor(scene: Scene, options?: ISoundTrackOptions);
  38838. private _initializeSoundTrackAudioGraph;
  38839. /**
  38840. * Release the sound track and its associated resources
  38841. */
  38842. dispose(): void;
  38843. /**
  38844. * Adds a sound to this sound track
  38845. * @param sound define the cound to add
  38846. * @ignoreNaming
  38847. */
  38848. AddSound(sound: Sound): void;
  38849. /**
  38850. * Removes a sound to this sound track
  38851. * @param sound define the cound to remove
  38852. * @ignoreNaming
  38853. */
  38854. RemoveSound(sound: Sound): void;
  38855. /**
  38856. * Set a global volume for the full sound track.
  38857. * @param newVolume Define the new volume of the sound track
  38858. */
  38859. setVolume(newVolume: number): void;
  38860. /**
  38861. * Switch the panning model to HRTF:
  38862. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38864. */
  38865. switchPanningModelToHRTF(): void;
  38866. /**
  38867. * Switch the panning model to Equal Power:
  38868. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38870. */
  38871. switchPanningModelToEqualPower(): void;
  38872. /**
  38873. * Connect the sound track to an audio analyser allowing some amazing
  38874. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38876. * @param analyser The analyser to connect to the engine
  38877. */
  38878. connectToAnalyser(analyser: Analyser): void;
  38879. }
  38880. }
  38881. declare module "babylonjs/Audio/audioSceneComponent" {
  38882. import { Sound } from "babylonjs/Audio/sound";
  38883. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38884. import { Nullable } from "babylonjs/types";
  38885. import { Vector3 } from "babylonjs/Maths/math.vector";
  38886. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38887. import { Scene } from "babylonjs/scene";
  38888. import { AbstractScene } from "babylonjs/abstractScene";
  38889. import "babylonjs/Audio/audioEngine";
  38890. module "babylonjs/abstractScene" {
  38891. interface AbstractScene {
  38892. /**
  38893. * The list of sounds used in the scene.
  38894. */
  38895. sounds: Nullable<Array<Sound>>;
  38896. }
  38897. }
  38898. module "babylonjs/scene" {
  38899. interface Scene {
  38900. /**
  38901. * @hidden
  38902. * Backing field
  38903. */
  38904. _mainSoundTrack: SoundTrack;
  38905. /**
  38906. * The main sound track played by the scene.
  38907. * It cotains your primary collection of sounds.
  38908. */
  38909. mainSoundTrack: SoundTrack;
  38910. /**
  38911. * The list of sound tracks added to the scene
  38912. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38913. */
  38914. soundTracks: Nullable<Array<SoundTrack>>;
  38915. /**
  38916. * Gets a sound using a given name
  38917. * @param name defines the name to search for
  38918. * @return the found sound or null if not found at all.
  38919. */
  38920. getSoundByName(name: string): Nullable<Sound>;
  38921. /**
  38922. * Gets or sets if audio support is enabled
  38923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38924. */
  38925. audioEnabled: boolean;
  38926. /**
  38927. * Gets or sets if audio will be output to headphones
  38928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38929. */
  38930. headphone: boolean;
  38931. /**
  38932. * Gets or sets custom audio listener position provider
  38933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38934. */
  38935. audioListenerPositionProvider: Nullable<() => Vector3>;
  38936. /**
  38937. * Gets or sets a refresh rate when using 3D audio positioning
  38938. */
  38939. audioPositioningRefreshRate: number;
  38940. }
  38941. }
  38942. /**
  38943. * Defines the sound scene component responsible to manage any sounds
  38944. * in a given scene.
  38945. */
  38946. export class AudioSceneComponent implements ISceneSerializableComponent {
  38947. /**
  38948. * The component name helpfull to identify the component in the list of scene components.
  38949. */
  38950. readonly name: string;
  38951. /**
  38952. * The scene the component belongs to.
  38953. */
  38954. scene: Scene;
  38955. private _audioEnabled;
  38956. /**
  38957. * Gets whether audio is enabled or not.
  38958. * Please use related enable/disable method to switch state.
  38959. */
  38960. get audioEnabled(): boolean;
  38961. private _headphone;
  38962. /**
  38963. * Gets whether audio is outputing to headphone or not.
  38964. * Please use the according Switch methods to change output.
  38965. */
  38966. get headphone(): boolean;
  38967. /**
  38968. * Gets or sets a refresh rate when using 3D audio positioning
  38969. */
  38970. audioPositioningRefreshRate: number;
  38971. private _audioListenerPositionProvider;
  38972. /**
  38973. * Gets the current audio listener position provider
  38974. */
  38975. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38976. /**
  38977. * Sets a custom listener position for all sounds in the scene
  38978. * By default, this is the position of the first active camera
  38979. */
  38980. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38981. /**
  38982. * Creates a new instance of the component for the given scene
  38983. * @param scene Defines the scene to register the component in
  38984. */
  38985. constructor(scene: Scene);
  38986. /**
  38987. * Registers the component in a given scene
  38988. */
  38989. register(): void;
  38990. /**
  38991. * Rebuilds the elements related to this component in case of
  38992. * context lost for instance.
  38993. */
  38994. rebuild(): void;
  38995. /**
  38996. * Serializes the component data to the specified json object
  38997. * @param serializationObject The object to serialize to
  38998. */
  38999. serialize(serializationObject: any): void;
  39000. /**
  39001. * Adds all the elements from the container to the scene
  39002. * @param container the container holding the elements
  39003. */
  39004. addFromContainer(container: AbstractScene): void;
  39005. /**
  39006. * Removes all the elements in the container from the scene
  39007. * @param container contains the elements to remove
  39008. * @param dispose if the removed element should be disposed (default: false)
  39009. */
  39010. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39011. /**
  39012. * Disposes the component and the associated ressources.
  39013. */
  39014. dispose(): void;
  39015. /**
  39016. * Disables audio in the associated scene.
  39017. */
  39018. disableAudio(): void;
  39019. /**
  39020. * Enables audio in the associated scene.
  39021. */
  39022. enableAudio(): void;
  39023. /**
  39024. * Switch audio to headphone output.
  39025. */
  39026. switchAudioModeForHeadphones(): void;
  39027. /**
  39028. * Switch audio to normal speakers.
  39029. */
  39030. switchAudioModeForNormalSpeakers(): void;
  39031. private _cachedCameraDirection;
  39032. private _cachedCameraPosition;
  39033. private _lastCheck;
  39034. private _afterRender;
  39035. }
  39036. }
  39037. declare module "babylonjs/Audio/weightedsound" {
  39038. import { Sound } from "babylonjs/Audio/sound";
  39039. /**
  39040. * Wraps one or more Sound objects and selects one with random weight for playback.
  39041. */
  39042. export class WeightedSound {
  39043. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39044. loop: boolean;
  39045. private _coneInnerAngle;
  39046. private _coneOuterAngle;
  39047. private _volume;
  39048. /** A Sound is currently playing. */
  39049. isPlaying: boolean;
  39050. /** A Sound is currently paused. */
  39051. isPaused: boolean;
  39052. private _sounds;
  39053. private _weights;
  39054. private _currentIndex?;
  39055. /**
  39056. * Creates a new WeightedSound from the list of sounds given.
  39057. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39058. * @param sounds Array of Sounds that will be selected from.
  39059. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39060. */
  39061. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39062. /**
  39063. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39064. */
  39065. get directionalConeInnerAngle(): number;
  39066. /**
  39067. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39068. */
  39069. set directionalConeInnerAngle(value: number);
  39070. /**
  39071. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39072. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39073. */
  39074. get directionalConeOuterAngle(): number;
  39075. /**
  39076. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39077. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39078. */
  39079. set directionalConeOuterAngle(value: number);
  39080. /**
  39081. * Playback volume.
  39082. */
  39083. get volume(): number;
  39084. /**
  39085. * Playback volume.
  39086. */
  39087. set volume(value: number);
  39088. private _onended;
  39089. /**
  39090. * Suspend playback
  39091. */
  39092. pause(): void;
  39093. /**
  39094. * Stop playback
  39095. */
  39096. stop(): void;
  39097. /**
  39098. * Start playback.
  39099. * @param startOffset Position the clip head at a specific time in seconds.
  39100. */
  39101. play(startOffset?: number): void;
  39102. }
  39103. }
  39104. declare module "babylonjs/Audio/index" {
  39105. export * from "babylonjs/Audio/analyser";
  39106. export * from "babylonjs/Audio/audioEngine";
  39107. export * from "babylonjs/Audio/audioSceneComponent";
  39108. export * from "babylonjs/Audio/sound";
  39109. export * from "babylonjs/Audio/soundTrack";
  39110. export * from "babylonjs/Audio/weightedsound";
  39111. }
  39112. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39113. import { Behavior } from "babylonjs/Behaviors/behavior";
  39114. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39115. import { BackEase } from "babylonjs/Animations/easing";
  39116. /**
  39117. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39118. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39119. */
  39120. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39121. /**
  39122. * Gets the name of the behavior.
  39123. */
  39124. get name(): string;
  39125. /**
  39126. * The easing function used by animations
  39127. */
  39128. static EasingFunction: BackEase;
  39129. /**
  39130. * The easing mode used by animations
  39131. */
  39132. static EasingMode: number;
  39133. /**
  39134. * The duration of the animation, in milliseconds
  39135. */
  39136. transitionDuration: number;
  39137. /**
  39138. * Length of the distance animated by the transition when lower radius is reached
  39139. */
  39140. lowerRadiusTransitionRange: number;
  39141. /**
  39142. * Length of the distance animated by the transition when upper radius is reached
  39143. */
  39144. upperRadiusTransitionRange: number;
  39145. private _autoTransitionRange;
  39146. /**
  39147. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39148. */
  39149. get autoTransitionRange(): boolean;
  39150. /**
  39151. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39152. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39153. */
  39154. set autoTransitionRange(value: boolean);
  39155. private _attachedCamera;
  39156. private _onAfterCheckInputsObserver;
  39157. private _onMeshTargetChangedObserver;
  39158. /**
  39159. * Initializes the behavior.
  39160. */
  39161. init(): void;
  39162. /**
  39163. * Attaches the behavior to its arc rotate camera.
  39164. * @param camera Defines the camera to attach the behavior to
  39165. */
  39166. attach(camera: ArcRotateCamera): void;
  39167. /**
  39168. * Detaches the behavior from its current arc rotate camera.
  39169. */
  39170. detach(): void;
  39171. private _radiusIsAnimating;
  39172. private _radiusBounceTransition;
  39173. private _animatables;
  39174. private _cachedWheelPrecision;
  39175. /**
  39176. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39177. * @param radiusLimit The limit to check against.
  39178. * @return Bool to indicate if at limit.
  39179. */
  39180. private _isRadiusAtLimit;
  39181. /**
  39182. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39183. * @param radiusDelta The delta by which to animate to. Can be negative.
  39184. */
  39185. private _applyBoundRadiusAnimation;
  39186. /**
  39187. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39188. */
  39189. protected _clearAnimationLocks(): void;
  39190. /**
  39191. * Stops and removes all animations that have been applied to the camera
  39192. */
  39193. stopAllAnimations(): void;
  39194. }
  39195. }
  39196. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39197. import { Behavior } from "babylonjs/Behaviors/behavior";
  39198. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39199. import { ExponentialEase } from "babylonjs/Animations/easing";
  39200. import { Nullable } from "babylonjs/types";
  39201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39202. import { Vector3 } from "babylonjs/Maths/math.vector";
  39203. /**
  39204. * 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.
  39205. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39206. */
  39207. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39208. /**
  39209. * Gets the name of the behavior.
  39210. */
  39211. get name(): string;
  39212. private _mode;
  39213. private _radiusScale;
  39214. private _positionScale;
  39215. private _defaultElevation;
  39216. private _elevationReturnTime;
  39217. private _elevationReturnWaitTime;
  39218. private _zoomStopsAnimation;
  39219. private _framingTime;
  39220. /**
  39221. * The easing function used by animations
  39222. */
  39223. static EasingFunction: ExponentialEase;
  39224. /**
  39225. * The easing mode used by animations
  39226. */
  39227. static EasingMode: number;
  39228. /**
  39229. * Sets the current mode used by the behavior
  39230. */
  39231. set mode(mode: number);
  39232. /**
  39233. * Gets current mode used by the behavior.
  39234. */
  39235. get mode(): number;
  39236. /**
  39237. * Sets the scale applied to the radius (1 by default)
  39238. */
  39239. set radiusScale(radius: number);
  39240. /**
  39241. * Gets the scale applied to the radius
  39242. */
  39243. get radiusScale(): number;
  39244. /**
  39245. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39246. */
  39247. set positionScale(scale: number);
  39248. /**
  39249. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39250. */
  39251. get positionScale(): number;
  39252. /**
  39253. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39254. * behaviour is triggered, in radians.
  39255. */
  39256. set defaultElevation(elevation: number);
  39257. /**
  39258. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39259. * behaviour is triggered, in radians.
  39260. */
  39261. get defaultElevation(): number;
  39262. /**
  39263. * Sets the time (in milliseconds) taken to return to the default beta position.
  39264. * Negative value indicates camera should not return to default.
  39265. */
  39266. set elevationReturnTime(speed: number);
  39267. /**
  39268. * Gets the time (in milliseconds) taken to return to the default beta position.
  39269. * Negative value indicates camera should not return to default.
  39270. */
  39271. get elevationReturnTime(): number;
  39272. /**
  39273. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39274. */
  39275. set elevationReturnWaitTime(time: number);
  39276. /**
  39277. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39278. */
  39279. get elevationReturnWaitTime(): number;
  39280. /**
  39281. * Sets the flag that indicates if user zooming should stop animation.
  39282. */
  39283. set zoomStopsAnimation(flag: boolean);
  39284. /**
  39285. * Gets the flag that indicates if user zooming should stop animation.
  39286. */
  39287. get zoomStopsAnimation(): boolean;
  39288. /**
  39289. * Sets the transition time when framing the mesh, in milliseconds
  39290. */
  39291. set framingTime(time: number);
  39292. /**
  39293. * Gets the transition time when framing the mesh, in milliseconds
  39294. */
  39295. get framingTime(): number;
  39296. /**
  39297. * Define if the behavior should automatically change the configured
  39298. * camera limits and sensibilities.
  39299. */
  39300. autoCorrectCameraLimitsAndSensibility: boolean;
  39301. private _onPrePointerObservableObserver;
  39302. private _onAfterCheckInputsObserver;
  39303. private _onMeshTargetChangedObserver;
  39304. private _attachedCamera;
  39305. private _isPointerDown;
  39306. private _lastInteractionTime;
  39307. /**
  39308. * Initializes the behavior.
  39309. */
  39310. init(): void;
  39311. /**
  39312. * Attaches the behavior to its arc rotate camera.
  39313. * @param camera Defines the camera to attach the behavior to
  39314. */
  39315. attach(camera: ArcRotateCamera): void;
  39316. /**
  39317. * Detaches the behavior from its current arc rotate camera.
  39318. */
  39319. detach(): void;
  39320. private _animatables;
  39321. private _betaIsAnimating;
  39322. private _betaTransition;
  39323. private _radiusTransition;
  39324. private _vectorTransition;
  39325. /**
  39326. * Targets the given mesh and updates zoom level accordingly.
  39327. * @param mesh The mesh to target.
  39328. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39329. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39330. */
  39331. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39332. /**
  39333. * Targets the given mesh with its children and updates zoom level accordingly.
  39334. * @param mesh The mesh to target.
  39335. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39336. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39337. */
  39338. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39339. /**
  39340. * Targets the given meshes with their children and updates zoom level accordingly.
  39341. * @param meshes The mesh to target.
  39342. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39343. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39344. */
  39345. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39346. /**
  39347. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39348. * @param minimumWorld Determines the smaller position of the bounding box extend
  39349. * @param maximumWorld Determines the bigger position of the bounding box extend
  39350. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39351. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39352. */
  39353. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39354. /**
  39355. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39356. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39357. * frustum width.
  39358. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39359. * to fully enclose the mesh in the viewing frustum.
  39360. */
  39361. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39362. /**
  39363. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39364. * is automatically returned to its default position (expected to be above ground plane).
  39365. */
  39366. private _maintainCameraAboveGround;
  39367. /**
  39368. * Returns the frustum slope based on the canvas ratio and camera FOV
  39369. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39370. */
  39371. private _getFrustumSlope;
  39372. /**
  39373. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39374. */
  39375. private _clearAnimationLocks;
  39376. /**
  39377. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39378. */
  39379. private _applyUserInteraction;
  39380. /**
  39381. * Stops and removes all animations that have been applied to the camera
  39382. */
  39383. stopAllAnimations(): void;
  39384. /**
  39385. * Gets a value indicating if the user is moving the camera
  39386. */
  39387. get isUserIsMoving(): boolean;
  39388. /**
  39389. * The camera can move all the way towards the mesh.
  39390. */
  39391. static IgnoreBoundsSizeMode: number;
  39392. /**
  39393. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39394. */
  39395. static FitFrustumSidesMode: number;
  39396. }
  39397. }
  39398. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39399. import { Nullable } from "babylonjs/types";
  39400. import { Camera } from "babylonjs/Cameras/camera";
  39401. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39402. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39403. /**
  39404. * Base class for Camera Pointer Inputs.
  39405. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39406. * for example usage.
  39407. */
  39408. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39409. /**
  39410. * Defines the camera the input is attached to.
  39411. */
  39412. abstract camera: Camera;
  39413. /**
  39414. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39415. */
  39416. protected _altKey: boolean;
  39417. protected _ctrlKey: boolean;
  39418. protected _metaKey: boolean;
  39419. protected _shiftKey: boolean;
  39420. /**
  39421. * Which mouse buttons were pressed at time of last mouse event.
  39422. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39423. */
  39424. protected _buttonsPressed: number;
  39425. /**
  39426. * Defines the buttons associated with the input to handle camera move.
  39427. */
  39428. buttons: number[];
  39429. /**
  39430. * Attach the input controls to a specific dom element to get the input from.
  39431. * @param element Defines the element the controls should be listened from
  39432. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39433. */
  39434. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39435. /**
  39436. * Detach the current controls from the specified dom element.
  39437. * @param element Defines the element to stop listening the inputs from
  39438. */
  39439. detachControl(element: Nullable<HTMLElement>): void;
  39440. /**
  39441. * Gets the class name of the current input.
  39442. * @returns the class name
  39443. */
  39444. getClassName(): string;
  39445. /**
  39446. * Get the friendly name associated with the input class.
  39447. * @returns the input friendly name
  39448. */
  39449. getSimpleName(): string;
  39450. /**
  39451. * Called on pointer POINTERDOUBLETAP event.
  39452. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39453. */
  39454. protected onDoubleTap(type: string): void;
  39455. /**
  39456. * Called on pointer POINTERMOVE event if only a single touch is active.
  39457. * Override this method to provide functionality.
  39458. */
  39459. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39460. /**
  39461. * Called on pointer POINTERMOVE event if multiple touches are active.
  39462. * Override this method to provide functionality.
  39463. */
  39464. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39465. /**
  39466. * Called on JS contextmenu event.
  39467. * Override this method to provide functionality.
  39468. */
  39469. protected onContextMenu(evt: PointerEvent): void;
  39470. /**
  39471. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39472. * press.
  39473. * Override this method to provide functionality.
  39474. */
  39475. protected onButtonDown(evt: PointerEvent): void;
  39476. /**
  39477. * Called each time a new POINTERUP event occurs. Ie, for each button
  39478. * release.
  39479. * Override this method to provide functionality.
  39480. */
  39481. protected onButtonUp(evt: PointerEvent): void;
  39482. /**
  39483. * Called when window becomes inactive.
  39484. * Override this method to provide functionality.
  39485. */
  39486. protected onLostFocus(): void;
  39487. private _pointerInput;
  39488. private _observer;
  39489. private _onLostFocus;
  39490. private pointA;
  39491. private pointB;
  39492. }
  39493. }
  39494. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39495. import { Nullable } from "babylonjs/types";
  39496. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39497. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39498. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39499. /**
  39500. * Manage the pointers inputs to control an arc rotate camera.
  39501. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39502. */
  39503. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39504. /**
  39505. * Defines the camera the input is attached to.
  39506. */
  39507. camera: ArcRotateCamera;
  39508. /**
  39509. * Gets the class name of the current input.
  39510. * @returns the class name
  39511. */
  39512. getClassName(): string;
  39513. /**
  39514. * Defines the buttons associated with the input to handle camera move.
  39515. */
  39516. buttons: number[];
  39517. /**
  39518. * Defines the pointer angular sensibility along the X axis or how fast is
  39519. * the camera rotating.
  39520. */
  39521. angularSensibilityX: number;
  39522. /**
  39523. * Defines the pointer angular sensibility along the Y axis or how fast is
  39524. * the camera rotating.
  39525. */
  39526. angularSensibilityY: number;
  39527. /**
  39528. * Defines the pointer pinch precision or how fast is the camera zooming.
  39529. */
  39530. pinchPrecision: number;
  39531. /**
  39532. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39533. * from 0.
  39534. * It defines the percentage of current camera.radius to use as delta when
  39535. * pinch zoom is used.
  39536. */
  39537. pinchDeltaPercentage: number;
  39538. /**
  39539. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39540. * that any object in the plane at the camera's target point will scale
  39541. * perfectly with finger motion.
  39542. * Overrides pinchDeltaPercentage and pinchPrecision.
  39543. */
  39544. useNaturalPinchZoom: boolean;
  39545. /**
  39546. * Defines the pointer panning sensibility or how fast is the camera moving.
  39547. */
  39548. panningSensibility: number;
  39549. /**
  39550. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39551. */
  39552. multiTouchPanning: boolean;
  39553. /**
  39554. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39555. * zoom (pinch) through multitouch.
  39556. */
  39557. multiTouchPanAndZoom: boolean;
  39558. /**
  39559. * Revers pinch action direction.
  39560. */
  39561. pinchInwards: boolean;
  39562. private _isPanClick;
  39563. private _twoFingerActivityCount;
  39564. private _isPinching;
  39565. /**
  39566. * Called on pointer POINTERMOVE event if only a single touch is active.
  39567. */
  39568. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39569. /**
  39570. * Called on pointer POINTERDOUBLETAP event.
  39571. */
  39572. protected onDoubleTap(type: string): void;
  39573. /**
  39574. * Called on pointer POINTERMOVE event if multiple touches are active.
  39575. */
  39576. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39577. /**
  39578. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39579. * press.
  39580. */
  39581. protected onButtonDown(evt: PointerEvent): void;
  39582. /**
  39583. * Called each time a new POINTERUP event occurs. Ie, for each button
  39584. * release.
  39585. */
  39586. protected onButtonUp(evt: PointerEvent): void;
  39587. /**
  39588. * Called when window becomes inactive.
  39589. */
  39590. protected onLostFocus(): void;
  39591. }
  39592. }
  39593. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39594. import { Nullable } from "babylonjs/types";
  39595. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39596. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39597. /**
  39598. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39599. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39600. */
  39601. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39602. /**
  39603. * Defines the camera the input is attached to.
  39604. */
  39605. camera: ArcRotateCamera;
  39606. /**
  39607. * Defines the list of key codes associated with the up action (increase alpha)
  39608. */
  39609. keysUp: number[];
  39610. /**
  39611. * Defines the list of key codes associated with the down action (decrease alpha)
  39612. */
  39613. keysDown: number[];
  39614. /**
  39615. * Defines the list of key codes associated with the left action (increase beta)
  39616. */
  39617. keysLeft: number[];
  39618. /**
  39619. * Defines the list of key codes associated with the right action (decrease beta)
  39620. */
  39621. keysRight: number[];
  39622. /**
  39623. * Defines the list of key codes associated with the reset action.
  39624. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39625. */
  39626. keysReset: number[];
  39627. /**
  39628. * Defines the panning sensibility of the inputs.
  39629. * (How fast is the camera panning)
  39630. */
  39631. panningSensibility: number;
  39632. /**
  39633. * Defines the zooming sensibility of the inputs.
  39634. * (How fast is the camera zooming)
  39635. */
  39636. zoomingSensibility: number;
  39637. /**
  39638. * Defines whether maintaining the alt key down switch the movement mode from
  39639. * orientation to zoom.
  39640. */
  39641. useAltToZoom: boolean;
  39642. /**
  39643. * Rotation speed of the camera
  39644. */
  39645. angularSpeed: number;
  39646. private _keys;
  39647. private _ctrlPressed;
  39648. private _altPressed;
  39649. private _onCanvasBlurObserver;
  39650. private _onKeyboardObserver;
  39651. private _engine;
  39652. private _scene;
  39653. /**
  39654. * Attach the input controls to a specific dom element to get the input from.
  39655. * @param element Defines the element the controls should be listened from
  39656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39657. */
  39658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39659. /**
  39660. * Detach the current controls from the specified dom element.
  39661. * @param element Defines the element to stop listening the inputs from
  39662. */
  39663. detachControl(element: Nullable<HTMLElement>): void;
  39664. /**
  39665. * Update the current camera state depending on the inputs that have been used this frame.
  39666. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39667. */
  39668. checkInputs(): void;
  39669. /**
  39670. * Gets the class name of the current intput.
  39671. * @returns the class name
  39672. */
  39673. getClassName(): string;
  39674. /**
  39675. * Get the friendly name associated with the input class.
  39676. * @returns the input friendly name
  39677. */
  39678. getSimpleName(): string;
  39679. }
  39680. }
  39681. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39682. import { Nullable } from "babylonjs/types";
  39683. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39684. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39685. /**
  39686. * Manage the mouse wheel inputs to control an arc rotate camera.
  39687. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39688. */
  39689. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39690. /**
  39691. * Defines the camera the input is attached to.
  39692. */
  39693. camera: ArcRotateCamera;
  39694. /**
  39695. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39696. */
  39697. wheelPrecision: number;
  39698. /**
  39699. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39700. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39701. */
  39702. wheelDeltaPercentage: number;
  39703. private _wheel;
  39704. private _observer;
  39705. private computeDeltaFromMouseWheelLegacyEvent;
  39706. /**
  39707. * Attach the input controls to a specific dom element to get the input from.
  39708. * @param element Defines the element the controls should be listened from
  39709. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39710. */
  39711. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39712. /**
  39713. * Detach the current controls from the specified dom element.
  39714. * @param element Defines the element to stop listening the inputs from
  39715. */
  39716. detachControl(element: Nullable<HTMLElement>): void;
  39717. /**
  39718. * Gets the class name of the current intput.
  39719. * @returns the class name
  39720. */
  39721. getClassName(): string;
  39722. /**
  39723. * Get the friendly name associated with the input class.
  39724. * @returns the input friendly name
  39725. */
  39726. getSimpleName(): string;
  39727. }
  39728. }
  39729. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39730. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39731. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39732. /**
  39733. * Default Inputs manager for the ArcRotateCamera.
  39734. * It groups all the default supported inputs for ease of use.
  39735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39736. */
  39737. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39738. /**
  39739. * Instantiates a new ArcRotateCameraInputsManager.
  39740. * @param camera Defines the camera the inputs belong to
  39741. */
  39742. constructor(camera: ArcRotateCamera);
  39743. /**
  39744. * Add mouse wheel input support to the input manager.
  39745. * @returns the current input manager
  39746. */
  39747. addMouseWheel(): ArcRotateCameraInputsManager;
  39748. /**
  39749. * Add pointers input support to the input manager.
  39750. * @returns the current input manager
  39751. */
  39752. addPointers(): ArcRotateCameraInputsManager;
  39753. /**
  39754. * Add keyboard input support to the input manager.
  39755. * @returns the current input manager
  39756. */
  39757. addKeyboard(): ArcRotateCameraInputsManager;
  39758. }
  39759. }
  39760. declare module "babylonjs/Cameras/arcRotateCamera" {
  39761. import { Observable } from "babylonjs/Misc/observable";
  39762. import { Nullable } from "babylonjs/types";
  39763. import { Scene } from "babylonjs/scene";
  39764. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39766. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39767. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39768. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39769. import { Camera } from "babylonjs/Cameras/camera";
  39770. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39771. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39772. import { Collider } from "babylonjs/Collisions/collider";
  39773. /**
  39774. * This represents an orbital type of camera.
  39775. *
  39776. * 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.
  39777. * 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.
  39778. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39779. */
  39780. export class ArcRotateCamera extends TargetCamera {
  39781. /**
  39782. * Defines the rotation angle of the camera along the longitudinal axis.
  39783. */
  39784. alpha: number;
  39785. /**
  39786. * Defines the rotation angle of the camera along the latitudinal axis.
  39787. */
  39788. beta: number;
  39789. /**
  39790. * Defines the radius of the camera from it s target point.
  39791. */
  39792. radius: number;
  39793. protected _target: Vector3;
  39794. protected _targetHost: Nullable<AbstractMesh>;
  39795. /**
  39796. * Defines the target point of the camera.
  39797. * The camera looks towards it form the radius distance.
  39798. */
  39799. get target(): Vector3;
  39800. set target(value: Vector3);
  39801. /**
  39802. * Define the current local position of the camera in the scene
  39803. */
  39804. get position(): Vector3;
  39805. set position(newPosition: Vector3);
  39806. protected _upVector: Vector3;
  39807. protected _upToYMatrix: Matrix;
  39808. protected _YToUpMatrix: Matrix;
  39809. /**
  39810. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39811. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39812. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39813. */
  39814. set upVector(vec: Vector3);
  39815. get upVector(): Vector3;
  39816. /**
  39817. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39818. */
  39819. setMatUp(): void;
  39820. /**
  39821. * Current inertia value on the longitudinal axis.
  39822. * The bigger this number the longer it will take for the camera to stop.
  39823. */
  39824. inertialAlphaOffset: number;
  39825. /**
  39826. * Current inertia value on the latitudinal axis.
  39827. * The bigger this number the longer it will take for the camera to stop.
  39828. */
  39829. inertialBetaOffset: number;
  39830. /**
  39831. * Current inertia value on the radius axis.
  39832. * The bigger this number the longer it will take for the camera to stop.
  39833. */
  39834. inertialRadiusOffset: number;
  39835. /**
  39836. * Minimum allowed angle on the longitudinal axis.
  39837. * This can help limiting how the Camera is able to move in the scene.
  39838. */
  39839. lowerAlphaLimit: Nullable<number>;
  39840. /**
  39841. * Maximum allowed angle on the longitudinal axis.
  39842. * This can help limiting how the Camera is able to move in the scene.
  39843. */
  39844. upperAlphaLimit: Nullable<number>;
  39845. /**
  39846. * Minimum allowed angle on the latitudinal axis.
  39847. * This can help limiting how the Camera is able to move in the scene.
  39848. */
  39849. lowerBetaLimit: number;
  39850. /**
  39851. * Maximum allowed angle on the latitudinal axis.
  39852. * This can help limiting how the Camera is able to move in the scene.
  39853. */
  39854. upperBetaLimit: number;
  39855. /**
  39856. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39857. * This can help limiting how the Camera is able to move in the scene.
  39858. */
  39859. lowerRadiusLimit: Nullable<number>;
  39860. /**
  39861. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39862. * This can help limiting how the Camera is able to move in the scene.
  39863. */
  39864. upperRadiusLimit: Nullable<number>;
  39865. /**
  39866. * Defines the current inertia value used during panning of the camera along the X axis.
  39867. */
  39868. inertialPanningX: number;
  39869. /**
  39870. * Defines the current inertia value used during panning of the camera along the Y axis.
  39871. */
  39872. inertialPanningY: number;
  39873. /**
  39874. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39875. * Basically if your fingers moves away from more than this distance you will be considered
  39876. * in pinch mode.
  39877. */
  39878. pinchToPanMaxDistance: number;
  39879. /**
  39880. * Defines the maximum distance the camera can pan.
  39881. * This could help keeping the cammera always in your scene.
  39882. */
  39883. panningDistanceLimit: Nullable<number>;
  39884. /**
  39885. * Defines the target of the camera before paning.
  39886. */
  39887. panningOriginTarget: Vector3;
  39888. /**
  39889. * Defines the value of the inertia used during panning.
  39890. * 0 would mean stop inertia and one would mean no decelleration at all.
  39891. */
  39892. panningInertia: number;
  39893. /**
  39894. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39895. */
  39896. get angularSensibilityX(): number;
  39897. set angularSensibilityX(value: number);
  39898. /**
  39899. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39900. */
  39901. get angularSensibilityY(): number;
  39902. set angularSensibilityY(value: number);
  39903. /**
  39904. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39905. */
  39906. get pinchPrecision(): number;
  39907. set pinchPrecision(value: number);
  39908. /**
  39909. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39910. * It will be used instead of pinchDeltaPrecision if different from 0.
  39911. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39912. */
  39913. get pinchDeltaPercentage(): number;
  39914. set pinchDeltaPercentage(value: number);
  39915. /**
  39916. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39917. * and pinch delta percentage.
  39918. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39919. * that any object in the plane at the camera's target point will scale
  39920. * perfectly with finger motion.
  39921. */
  39922. get useNaturalPinchZoom(): boolean;
  39923. set useNaturalPinchZoom(value: boolean);
  39924. /**
  39925. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39926. */
  39927. get panningSensibility(): number;
  39928. set panningSensibility(value: number);
  39929. /**
  39930. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39931. */
  39932. get keysUp(): number[];
  39933. set keysUp(value: number[]);
  39934. /**
  39935. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39936. */
  39937. get keysDown(): number[];
  39938. set keysDown(value: number[]);
  39939. /**
  39940. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39941. */
  39942. get keysLeft(): number[];
  39943. set keysLeft(value: number[]);
  39944. /**
  39945. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39946. */
  39947. get keysRight(): number[];
  39948. set keysRight(value: number[]);
  39949. /**
  39950. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39951. */
  39952. get wheelPrecision(): number;
  39953. set wheelPrecision(value: number);
  39954. /**
  39955. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39956. * It will be used instead of pinchDeltaPrecision if different from 0.
  39957. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39958. */
  39959. get wheelDeltaPercentage(): number;
  39960. set wheelDeltaPercentage(value: number);
  39961. /**
  39962. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39963. */
  39964. zoomOnFactor: number;
  39965. /**
  39966. * Defines a screen offset for the camera position.
  39967. */
  39968. targetScreenOffset: Vector2;
  39969. /**
  39970. * Allows the camera to be completely reversed.
  39971. * If false the camera can not arrive upside down.
  39972. */
  39973. allowUpsideDown: boolean;
  39974. /**
  39975. * Define if double tap/click is used to restore the previously saved state of the camera.
  39976. */
  39977. useInputToRestoreState: boolean;
  39978. /** @hidden */
  39979. _viewMatrix: Matrix;
  39980. /** @hidden */
  39981. _useCtrlForPanning: boolean;
  39982. /** @hidden */
  39983. _panningMouseButton: number;
  39984. /**
  39985. * Defines the input associated to the camera.
  39986. */
  39987. inputs: ArcRotateCameraInputsManager;
  39988. /** @hidden */
  39989. _reset: () => void;
  39990. /**
  39991. * Defines the allowed panning axis.
  39992. */
  39993. panningAxis: Vector3;
  39994. protected _localDirection: Vector3;
  39995. protected _transformedDirection: Vector3;
  39996. private _bouncingBehavior;
  39997. /**
  39998. * Gets the bouncing behavior of the camera if it has been enabled.
  39999. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40000. */
  40001. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40002. /**
  40003. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40004. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40005. */
  40006. get useBouncingBehavior(): boolean;
  40007. set useBouncingBehavior(value: boolean);
  40008. private _framingBehavior;
  40009. /**
  40010. * Gets the framing behavior of the camera if it has been enabled.
  40011. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40012. */
  40013. get framingBehavior(): Nullable<FramingBehavior>;
  40014. /**
  40015. * Defines if the framing behavior of the camera is enabled on the camera.
  40016. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40017. */
  40018. get useFramingBehavior(): boolean;
  40019. set useFramingBehavior(value: boolean);
  40020. private _autoRotationBehavior;
  40021. /**
  40022. * Gets the auto rotation behavior of the camera if it has been enabled.
  40023. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40024. */
  40025. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40026. /**
  40027. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40028. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40029. */
  40030. get useAutoRotationBehavior(): boolean;
  40031. set useAutoRotationBehavior(value: boolean);
  40032. /**
  40033. * Observable triggered when the mesh target has been changed on the camera.
  40034. */
  40035. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40036. /**
  40037. * Event raised when the camera is colliding with a mesh.
  40038. */
  40039. onCollide: (collidedMesh: AbstractMesh) => void;
  40040. /**
  40041. * Defines whether the camera should check collision with the objects oh the scene.
  40042. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40043. */
  40044. checkCollisions: boolean;
  40045. /**
  40046. * Defines the collision radius of the camera.
  40047. * This simulates a sphere around the camera.
  40048. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40049. */
  40050. collisionRadius: Vector3;
  40051. protected _collider: Collider;
  40052. protected _previousPosition: Vector3;
  40053. protected _collisionVelocity: Vector3;
  40054. protected _newPosition: Vector3;
  40055. protected _previousAlpha: number;
  40056. protected _previousBeta: number;
  40057. protected _previousRadius: number;
  40058. protected _collisionTriggered: boolean;
  40059. protected _targetBoundingCenter: Nullable<Vector3>;
  40060. private _computationVector;
  40061. /**
  40062. * Instantiates a new ArcRotateCamera in a given scene
  40063. * @param name Defines the name of the camera
  40064. * @param alpha Defines the camera rotation along the logitudinal axis
  40065. * @param beta Defines the camera rotation along the latitudinal axis
  40066. * @param radius Defines the camera distance from its target
  40067. * @param target Defines the camera target
  40068. * @param scene Defines the scene the camera belongs to
  40069. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40070. */
  40071. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40072. /** @hidden */
  40073. _initCache(): void;
  40074. /** @hidden */
  40075. _updateCache(ignoreParentClass?: boolean): void;
  40076. protected _getTargetPosition(): Vector3;
  40077. private _storedAlpha;
  40078. private _storedBeta;
  40079. private _storedRadius;
  40080. private _storedTarget;
  40081. private _storedTargetScreenOffset;
  40082. /**
  40083. * Stores the current state of the camera (alpha, beta, radius and target)
  40084. * @returns the camera itself
  40085. */
  40086. storeState(): Camera;
  40087. /**
  40088. * @hidden
  40089. * Restored camera state. You must call storeState() first
  40090. */
  40091. _restoreStateValues(): boolean;
  40092. /** @hidden */
  40093. _isSynchronizedViewMatrix(): boolean;
  40094. /**
  40095. * Attached controls to the current camera.
  40096. * @param element Defines the element the controls should be listened from
  40097. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40098. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40099. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40100. */
  40101. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40102. /**
  40103. * Detach the current controls from the camera.
  40104. * The camera will stop reacting to inputs.
  40105. * @param element Defines the element to stop listening the inputs from
  40106. */
  40107. detachControl(element: HTMLElement): void;
  40108. /** @hidden */
  40109. _checkInputs(): void;
  40110. protected _checkLimits(): void;
  40111. /**
  40112. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40113. */
  40114. rebuildAnglesAndRadius(): void;
  40115. /**
  40116. * Use a position to define the current camera related information like alpha, beta and radius
  40117. * @param position Defines the position to set the camera at
  40118. */
  40119. setPosition(position: Vector3): void;
  40120. /**
  40121. * Defines the target the camera should look at.
  40122. * This will automatically adapt alpha beta and radius to fit within the new target.
  40123. * @param target Defines the new target as a Vector or a mesh
  40124. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40125. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40126. */
  40127. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40128. /** @hidden */
  40129. _getViewMatrix(): Matrix;
  40130. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40131. /**
  40132. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40133. * @param meshes Defines the mesh to zoom on
  40134. * @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)
  40135. */
  40136. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40137. /**
  40138. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40139. * The target will be changed but the radius
  40140. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40141. * @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)
  40142. */
  40143. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40144. min: Vector3;
  40145. max: Vector3;
  40146. distance: number;
  40147. }, doNotUpdateMaxZ?: boolean): void;
  40148. /**
  40149. * @override
  40150. * Override Camera.createRigCamera
  40151. */
  40152. createRigCamera(name: string, cameraIndex: number): Camera;
  40153. /**
  40154. * @hidden
  40155. * @override
  40156. * Override Camera._updateRigCameras
  40157. */
  40158. _updateRigCameras(): void;
  40159. /**
  40160. * Destroy the camera and release the current resources hold by it.
  40161. */
  40162. dispose(): void;
  40163. /**
  40164. * Gets the current object class name.
  40165. * @return the class name
  40166. */
  40167. getClassName(): string;
  40168. }
  40169. }
  40170. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40171. import { Behavior } from "babylonjs/Behaviors/behavior";
  40172. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40173. /**
  40174. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40175. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40176. */
  40177. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40178. /**
  40179. * Gets the name of the behavior.
  40180. */
  40181. get name(): string;
  40182. private _zoomStopsAnimation;
  40183. private _idleRotationSpeed;
  40184. private _idleRotationWaitTime;
  40185. private _idleRotationSpinupTime;
  40186. /**
  40187. * Sets the flag that indicates if user zooming should stop animation.
  40188. */
  40189. set zoomStopsAnimation(flag: boolean);
  40190. /**
  40191. * Gets the flag that indicates if user zooming should stop animation.
  40192. */
  40193. get zoomStopsAnimation(): boolean;
  40194. /**
  40195. * Sets the default speed at which the camera rotates around the model.
  40196. */
  40197. set idleRotationSpeed(speed: number);
  40198. /**
  40199. * Gets the default speed at which the camera rotates around the model.
  40200. */
  40201. get idleRotationSpeed(): number;
  40202. /**
  40203. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40204. */
  40205. set idleRotationWaitTime(time: number);
  40206. /**
  40207. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40208. */
  40209. get idleRotationWaitTime(): number;
  40210. /**
  40211. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40212. */
  40213. set idleRotationSpinupTime(time: number);
  40214. /**
  40215. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40216. */
  40217. get idleRotationSpinupTime(): number;
  40218. /**
  40219. * Gets a value indicating if the camera is currently rotating because of this behavior
  40220. */
  40221. get rotationInProgress(): boolean;
  40222. private _onPrePointerObservableObserver;
  40223. private _onAfterCheckInputsObserver;
  40224. private _attachedCamera;
  40225. private _isPointerDown;
  40226. private _lastFrameTime;
  40227. private _lastInteractionTime;
  40228. private _cameraRotationSpeed;
  40229. /**
  40230. * Initializes the behavior.
  40231. */
  40232. init(): void;
  40233. /**
  40234. * Attaches the behavior to its arc rotate camera.
  40235. * @param camera Defines the camera to attach the behavior to
  40236. */
  40237. attach(camera: ArcRotateCamera): void;
  40238. /**
  40239. * Detaches the behavior from its current arc rotate camera.
  40240. */
  40241. detach(): void;
  40242. /**
  40243. * Returns true if user is scrolling.
  40244. * @return true if user is scrolling.
  40245. */
  40246. private _userIsZooming;
  40247. private _lastFrameRadius;
  40248. private _shouldAnimationStopForInteraction;
  40249. /**
  40250. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40251. */
  40252. private _applyUserInteraction;
  40253. private _userIsMoving;
  40254. }
  40255. }
  40256. declare module "babylonjs/Behaviors/Cameras/index" {
  40257. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40258. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40259. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40260. }
  40261. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40262. import { Mesh } from "babylonjs/Meshes/mesh";
  40263. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40264. import { Behavior } from "babylonjs/Behaviors/behavior";
  40265. /**
  40266. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40267. */
  40268. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40269. private ui;
  40270. /**
  40271. * The name of the behavior
  40272. */
  40273. name: string;
  40274. /**
  40275. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40276. */
  40277. distanceAwayFromFace: number;
  40278. /**
  40279. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40280. */
  40281. distanceAwayFromBottomOfFace: number;
  40282. private _faceVectors;
  40283. private _target;
  40284. private _scene;
  40285. private _onRenderObserver;
  40286. private _tmpMatrix;
  40287. private _tmpVector;
  40288. /**
  40289. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40290. * @param ui The transform node that should be attched to the mesh
  40291. */
  40292. constructor(ui: TransformNode);
  40293. /**
  40294. * Initializes the behavior
  40295. */
  40296. init(): void;
  40297. private _closestFace;
  40298. private _zeroVector;
  40299. private _lookAtTmpMatrix;
  40300. private _lookAtToRef;
  40301. /**
  40302. * Attaches the AttachToBoxBehavior to the passed in mesh
  40303. * @param target The mesh that the specified node will be attached to
  40304. */
  40305. attach(target: Mesh): void;
  40306. /**
  40307. * Detaches the behavior from the mesh
  40308. */
  40309. detach(): void;
  40310. }
  40311. }
  40312. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40313. import { Behavior } from "babylonjs/Behaviors/behavior";
  40314. import { Mesh } from "babylonjs/Meshes/mesh";
  40315. /**
  40316. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40317. */
  40318. export class FadeInOutBehavior implements Behavior<Mesh> {
  40319. /**
  40320. * Time in milliseconds to delay before fading in (Default: 0)
  40321. */
  40322. delay: number;
  40323. /**
  40324. * Time in milliseconds for the mesh to fade in (Default: 300)
  40325. */
  40326. fadeInTime: number;
  40327. private _millisecondsPerFrame;
  40328. private _hovered;
  40329. private _hoverValue;
  40330. private _ownerNode;
  40331. /**
  40332. * Instatiates the FadeInOutBehavior
  40333. */
  40334. constructor();
  40335. /**
  40336. * The name of the behavior
  40337. */
  40338. get name(): string;
  40339. /**
  40340. * Initializes the behavior
  40341. */
  40342. init(): void;
  40343. /**
  40344. * Attaches the fade behavior on the passed in mesh
  40345. * @param ownerNode The mesh that will be faded in/out once attached
  40346. */
  40347. attach(ownerNode: Mesh): void;
  40348. /**
  40349. * Detaches the behavior from the mesh
  40350. */
  40351. detach(): void;
  40352. /**
  40353. * Triggers the mesh to begin fading in or out
  40354. * @param value if the object should fade in or out (true to fade in)
  40355. */
  40356. fadeIn(value: boolean): void;
  40357. private _update;
  40358. private _setAllVisibility;
  40359. }
  40360. }
  40361. declare module "babylonjs/Misc/pivotTools" {
  40362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40363. /**
  40364. * Class containing a set of static utilities functions for managing Pivots
  40365. * @hidden
  40366. */
  40367. export class PivotTools {
  40368. private static _PivotCached;
  40369. private static _OldPivotPoint;
  40370. private static _PivotTranslation;
  40371. private static _PivotTmpVector;
  40372. /** @hidden */
  40373. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40374. /** @hidden */
  40375. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40376. }
  40377. }
  40378. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40379. import { Scene } from "babylonjs/scene";
  40380. import { Vector4 } from "babylonjs/Maths/math.vector";
  40381. import { Mesh } from "babylonjs/Meshes/mesh";
  40382. import { Nullable } from "babylonjs/types";
  40383. import { Plane } from "babylonjs/Maths/math.plane";
  40384. /**
  40385. * Class containing static functions to help procedurally build meshes
  40386. */
  40387. export class PlaneBuilder {
  40388. /**
  40389. * Creates a plane mesh
  40390. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40391. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40392. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40394. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40396. * @param name defines the name of the mesh
  40397. * @param options defines the options used to create the mesh
  40398. * @param scene defines the hosting scene
  40399. * @returns the plane mesh
  40400. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40401. */
  40402. static CreatePlane(name: string, options: {
  40403. size?: number;
  40404. width?: number;
  40405. height?: number;
  40406. sideOrientation?: number;
  40407. frontUVs?: Vector4;
  40408. backUVs?: Vector4;
  40409. updatable?: boolean;
  40410. sourcePlane?: Plane;
  40411. }, scene?: Nullable<Scene>): Mesh;
  40412. }
  40413. }
  40414. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40415. import { Behavior } from "babylonjs/Behaviors/behavior";
  40416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40417. import { Observable } from "babylonjs/Misc/observable";
  40418. import { Vector3 } from "babylonjs/Maths/math.vector";
  40419. import { Ray } from "babylonjs/Culling/ray";
  40420. import "babylonjs/Meshes/Builders/planeBuilder";
  40421. /**
  40422. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40423. */
  40424. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40425. private static _AnyMouseID;
  40426. /**
  40427. * Abstract mesh the behavior is set on
  40428. */
  40429. attachedNode: AbstractMesh;
  40430. private _dragPlane;
  40431. private _scene;
  40432. private _pointerObserver;
  40433. private _beforeRenderObserver;
  40434. private static _planeScene;
  40435. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40436. /**
  40437. * 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)
  40438. */
  40439. maxDragAngle: number;
  40440. /**
  40441. * @hidden
  40442. */
  40443. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40444. /**
  40445. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40446. */
  40447. currentDraggingPointerID: number;
  40448. /**
  40449. * The last position where the pointer hit the drag plane in world space
  40450. */
  40451. lastDragPosition: Vector3;
  40452. /**
  40453. * If the behavior is currently in a dragging state
  40454. */
  40455. dragging: boolean;
  40456. /**
  40457. * 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)
  40458. */
  40459. dragDeltaRatio: number;
  40460. /**
  40461. * If the drag plane orientation should be updated during the dragging (Default: true)
  40462. */
  40463. updateDragPlane: boolean;
  40464. private _debugMode;
  40465. private _moving;
  40466. /**
  40467. * Fires each time the attached mesh is dragged with the pointer
  40468. * * delta between last drag position and current drag position in world space
  40469. * * dragDistance along the drag axis
  40470. * * dragPlaneNormal normal of the current drag plane used during the drag
  40471. * * dragPlanePoint in world space where the drag intersects the drag plane
  40472. */
  40473. onDragObservable: Observable<{
  40474. delta: Vector3;
  40475. dragPlanePoint: Vector3;
  40476. dragPlaneNormal: Vector3;
  40477. dragDistance: number;
  40478. pointerId: number;
  40479. }>;
  40480. /**
  40481. * Fires each time a drag begins (eg. mouse down on mesh)
  40482. */
  40483. onDragStartObservable: Observable<{
  40484. dragPlanePoint: Vector3;
  40485. pointerId: number;
  40486. }>;
  40487. /**
  40488. * Fires each time a drag ends (eg. mouse release after drag)
  40489. */
  40490. onDragEndObservable: Observable<{
  40491. dragPlanePoint: Vector3;
  40492. pointerId: number;
  40493. }>;
  40494. /**
  40495. * If the attached mesh should be moved when dragged
  40496. */
  40497. moveAttached: boolean;
  40498. /**
  40499. * If the drag behavior will react to drag events (Default: true)
  40500. */
  40501. enabled: boolean;
  40502. /**
  40503. * If pointer events should start and release the drag (Default: true)
  40504. */
  40505. startAndReleaseDragOnPointerEvents: boolean;
  40506. /**
  40507. * If camera controls should be detached during the drag
  40508. */
  40509. detachCameraControls: boolean;
  40510. /**
  40511. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40512. */
  40513. useObjectOrientationForDragging: boolean;
  40514. private _options;
  40515. /**
  40516. * Gets the options used by the behavior
  40517. */
  40518. get options(): {
  40519. dragAxis?: Vector3;
  40520. dragPlaneNormal?: Vector3;
  40521. };
  40522. /**
  40523. * Sets the options used by the behavior
  40524. */
  40525. set options(options: {
  40526. dragAxis?: Vector3;
  40527. dragPlaneNormal?: Vector3;
  40528. });
  40529. /**
  40530. * Creates a pointer drag behavior that can be attached to a mesh
  40531. * @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)
  40532. */
  40533. constructor(options?: {
  40534. dragAxis?: Vector3;
  40535. dragPlaneNormal?: Vector3;
  40536. });
  40537. /**
  40538. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40539. */
  40540. validateDrag: (targetPosition: Vector3) => boolean;
  40541. /**
  40542. * The name of the behavior
  40543. */
  40544. get name(): string;
  40545. /**
  40546. * Initializes the behavior
  40547. */
  40548. init(): void;
  40549. private _tmpVector;
  40550. private _alternatePickedPoint;
  40551. private _worldDragAxis;
  40552. private _targetPosition;
  40553. private _attachedElement;
  40554. /**
  40555. * Attaches the drag behavior the passed in mesh
  40556. * @param ownerNode The mesh that will be dragged around once attached
  40557. * @param predicate Predicate to use for pick filtering
  40558. */
  40559. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40560. /**
  40561. * Force relase the drag action by code.
  40562. */
  40563. releaseDrag(): void;
  40564. private _startDragRay;
  40565. private _lastPointerRay;
  40566. /**
  40567. * Simulates the start of a pointer drag event on the behavior
  40568. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40569. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40570. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40571. */
  40572. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40573. private _startDrag;
  40574. private _dragDelta;
  40575. private _moveDrag;
  40576. private _pickWithRayOnDragPlane;
  40577. private _pointA;
  40578. private _pointB;
  40579. private _pointC;
  40580. private _lineA;
  40581. private _lineB;
  40582. private _localAxis;
  40583. private _lookAt;
  40584. private _updateDragPlanePosition;
  40585. /**
  40586. * Detaches the behavior from the mesh
  40587. */
  40588. detach(): void;
  40589. }
  40590. }
  40591. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40592. import { Mesh } from "babylonjs/Meshes/mesh";
  40593. import { Behavior } from "babylonjs/Behaviors/behavior";
  40594. /**
  40595. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40596. */
  40597. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40598. private _dragBehaviorA;
  40599. private _dragBehaviorB;
  40600. private _startDistance;
  40601. private _initialScale;
  40602. private _targetScale;
  40603. private _ownerNode;
  40604. private _sceneRenderObserver;
  40605. /**
  40606. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40607. */
  40608. constructor();
  40609. /**
  40610. * The name of the behavior
  40611. */
  40612. get name(): string;
  40613. /**
  40614. * Initializes the behavior
  40615. */
  40616. init(): void;
  40617. private _getCurrentDistance;
  40618. /**
  40619. * Attaches the scale behavior the passed in mesh
  40620. * @param ownerNode The mesh that will be scaled around once attached
  40621. */
  40622. attach(ownerNode: Mesh): void;
  40623. /**
  40624. * Detaches the behavior from the mesh
  40625. */
  40626. detach(): void;
  40627. }
  40628. }
  40629. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40630. import { Behavior } from "babylonjs/Behaviors/behavior";
  40631. import { Mesh } from "babylonjs/Meshes/mesh";
  40632. import { Observable } from "babylonjs/Misc/observable";
  40633. /**
  40634. * 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
  40635. */
  40636. export class SixDofDragBehavior implements Behavior<Mesh> {
  40637. private static _virtualScene;
  40638. private _ownerNode;
  40639. private _sceneRenderObserver;
  40640. private _scene;
  40641. private _targetPosition;
  40642. private _virtualOriginMesh;
  40643. private _virtualDragMesh;
  40644. private _pointerObserver;
  40645. private _moving;
  40646. private _startingOrientation;
  40647. /**
  40648. * 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)
  40649. */
  40650. private zDragFactor;
  40651. /**
  40652. * If the object should rotate to face the drag origin
  40653. */
  40654. rotateDraggedObject: boolean;
  40655. /**
  40656. * If the behavior is currently in a dragging state
  40657. */
  40658. dragging: boolean;
  40659. /**
  40660. * 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)
  40661. */
  40662. dragDeltaRatio: number;
  40663. /**
  40664. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40665. */
  40666. currentDraggingPointerID: number;
  40667. /**
  40668. * If camera controls should be detached during the drag
  40669. */
  40670. detachCameraControls: boolean;
  40671. /**
  40672. * Fires each time a drag starts
  40673. */
  40674. onDragStartObservable: Observable<{}>;
  40675. /**
  40676. * Fires each time a drag ends (eg. mouse release after drag)
  40677. */
  40678. onDragEndObservable: Observable<{}>;
  40679. /**
  40680. * 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
  40681. */
  40682. constructor();
  40683. /**
  40684. * The name of the behavior
  40685. */
  40686. get name(): string;
  40687. /**
  40688. * Initializes the behavior
  40689. */
  40690. init(): void;
  40691. /**
  40692. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40693. */
  40694. private get _pointerCamera();
  40695. /**
  40696. * Attaches the scale behavior the passed in mesh
  40697. * @param ownerNode The mesh that will be scaled around once attached
  40698. */
  40699. attach(ownerNode: Mesh): void;
  40700. /**
  40701. * Detaches the behavior from the mesh
  40702. */
  40703. detach(): void;
  40704. }
  40705. }
  40706. declare module "babylonjs/Behaviors/Meshes/index" {
  40707. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40708. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40709. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40710. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40711. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40712. }
  40713. declare module "babylonjs/Behaviors/index" {
  40714. export * from "babylonjs/Behaviors/behavior";
  40715. export * from "babylonjs/Behaviors/Cameras/index";
  40716. export * from "babylonjs/Behaviors/Meshes/index";
  40717. }
  40718. declare module "babylonjs/Bones/boneIKController" {
  40719. import { Bone } from "babylonjs/Bones/bone";
  40720. import { Vector3 } from "babylonjs/Maths/math.vector";
  40721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40722. import { Nullable } from "babylonjs/types";
  40723. /**
  40724. * Class used to apply inverse kinematics to bones
  40725. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40726. */
  40727. export class BoneIKController {
  40728. private static _tmpVecs;
  40729. private static _tmpQuat;
  40730. private static _tmpMats;
  40731. /**
  40732. * Gets or sets the target mesh
  40733. */
  40734. targetMesh: AbstractMesh;
  40735. /** Gets or sets the mesh used as pole */
  40736. poleTargetMesh: AbstractMesh;
  40737. /**
  40738. * Gets or sets the bone used as pole
  40739. */
  40740. poleTargetBone: Nullable<Bone>;
  40741. /**
  40742. * Gets or sets the target position
  40743. */
  40744. targetPosition: Vector3;
  40745. /**
  40746. * Gets or sets the pole target position
  40747. */
  40748. poleTargetPosition: Vector3;
  40749. /**
  40750. * Gets or sets the pole target local offset
  40751. */
  40752. poleTargetLocalOffset: Vector3;
  40753. /**
  40754. * Gets or sets the pole angle
  40755. */
  40756. poleAngle: number;
  40757. /**
  40758. * Gets or sets the mesh associated with the controller
  40759. */
  40760. mesh: AbstractMesh;
  40761. /**
  40762. * 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)
  40763. */
  40764. slerpAmount: number;
  40765. private _bone1Quat;
  40766. private _bone1Mat;
  40767. private _bone2Ang;
  40768. private _bone1;
  40769. private _bone2;
  40770. private _bone1Length;
  40771. private _bone2Length;
  40772. private _maxAngle;
  40773. private _maxReach;
  40774. private _rightHandedSystem;
  40775. private _bendAxis;
  40776. private _slerping;
  40777. private _adjustRoll;
  40778. /**
  40779. * Gets or sets maximum allowed angle
  40780. */
  40781. get maxAngle(): number;
  40782. set maxAngle(value: number);
  40783. /**
  40784. * Creates a new BoneIKController
  40785. * @param mesh defines the mesh to control
  40786. * @param bone defines the bone to control
  40787. * @param options defines options to set up the controller
  40788. */
  40789. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40790. targetMesh?: AbstractMesh;
  40791. poleTargetMesh?: AbstractMesh;
  40792. poleTargetBone?: Bone;
  40793. poleTargetLocalOffset?: Vector3;
  40794. poleAngle?: number;
  40795. bendAxis?: Vector3;
  40796. maxAngle?: number;
  40797. slerpAmount?: number;
  40798. });
  40799. private _setMaxAngle;
  40800. /**
  40801. * Force the controller to update the bones
  40802. */
  40803. update(): void;
  40804. }
  40805. }
  40806. declare module "babylonjs/Bones/boneLookController" {
  40807. import { Vector3 } from "babylonjs/Maths/math.vector";
  40808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40809. import { Bone } from "babylonjs/Bones/bone";
  40810. import { Space } from "babylonjs/Maths/math.axis";
  40811. /**
  40812. * Class used to make a bone look toward a point in space
  40813. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40814. */
  40815. export class BoneLookController {
  40816. private static _tmpVecs;
  40817. private static _tmpQuat;
  40818. private static _tmpMats;
  40819. /**
  40820. * The target Vector3 that the bone will look at
  40821. */
  40822. target: Vector3;
  40823. /**
  40824. * The mesh that the bone is attached to
  40825. */
  40826. mesh: AbstractMesh;
  40827. /**
  40828. * The bone that will be looking to the target
  40829. */
  40830. bone: Bone;
  40831. /**
  40832. * The up axis of the coordinate system that is used when the bone is rotated
  40833. */
  40834. upAxis: Vector3;
  40835. /**
  40836. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40837. */
  40838. upAxisSpace: Space;
  40839. /**
  40840. * Used to make an adjustment to the yaw of the bone
  40841. */
  40842. adjustYaw: number;
  40843. /**
  40844. * Used to make an adjustment to the pitch of the bone
  40845. */
  40846. adjustPitch: number;
  40847. /**
  40848. * Used to make an adjustment to the roll of the bone
  40849. */
  40850. adjustRoll: number;
  40851. /**
  40852. * 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)
  40853. */
  40854. slerpAmount: number;
  40855. private _minYaw;
  40856. private _maxYaw;
  40857. private _minPitch;
  40858. private _maxPitch;
  40859. private _minYawSin;
  40860. private _minYawCos;
  40861. private _maxYawSin;
  40862. private _maxYawCos;
  40863. private _midYawConstraint;
  40864. private _minPitchTan;
  40865. private _maxPitchTan;
  40866. private _boneQuat;
  40867. private _slerping;
  40868. private _transformYawPitch;
  40869. private _transformYawPitchInv;
  40870. private _firstFrameSkipped;
  40871. private _yawRange;
  40872. private _fowardAxis;
  40873. /**
  40874. * Gets or sets the minimum yaw angle that the bone can look to
  40875. */
  40876. get minYaw(): number;
  40877. set minYaw(value: number);
  40878. /**
  40879. * Gets or sets the maximum yaw angle that the bone can look to
  40880. */
  40881. get maxYaw(): number;
  40882. set maxYaw(value: number);
  40883. /**
  40884. * Gets or sets the minimum pitch angle that the bone can look to
  40885. */
  40886. get minPitch(): number;
  40887. set minPitch(value: number);
  40888. /**
  40889. * Gets or sets the maximum pitch angle that the bone can look to
  40890. */
  40891. get maxPitch(): number;
  40892. set maxPitch(value: number);
  40893. /**
  40894. * Create a BoneLookController
  40895. * @param mesh the mesh that the bone belongs to
  40896. * @param bone the bone that will be looking to the target
  40897. * @param target the target Vector3 to look at
  40898. * @param options optional settings:
  40899. * * maxYaw: the maximum angle the bone will yaw to
  40900. * * minYaw: the minimum angle the bone will yaw to
  40901. * * maxPitch: the maximum angle the bone will pitch to
  40902. * * minPitch: the minimum angle the bone will yaw to
  40903. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40904. * * upAxis: the up axis of the coordinate system
  40905. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40906. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40907. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40908. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40909. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40910. * * adjustRoll: used to make an adjustment to the roll of the bone
  40911. **/
  40912. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40913. maxYaw?: number;
  40914. minYaw?: number;
  40915. maxPitch?: number;
  40916. minPitch?: number;
  40917. slerpAmount?: number;
  40918. upAxis?: Vector3;
  40919. upAxisSpace?: Space;
  40920. yawAxis?: Vector3;
  40921. pitchAxis?: Vector3;
  40922. adjustYaw?: number;
  40923. adjustPitch?: number;
  40924. adjustRoll?: number;
  40925. });
  40926. /**
  40927. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40928. */
  40929. update(): void;
  40930. private _getAngleDiff;
  40931. private _getAngleBetween;
  40932. private _isAngleBetween;
  40933. }
  40934. }
  40935. declare module "babylonjs/Bones/index" {
  40936. export * from "babylonjs/Bones/bone";
  40937. export * from "babylonjs/Bones/boneIKController";
  40938. export * from "babylonjs/Bones/boneLookController";
  40939. export * from "babylonjs/Bones/skeleton";
  40940. }
  40941. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40942. import { Nullable } from "babylonjs/types";
  40943. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40944. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40945. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40946. /**
  40947. * Manage the gamepad inputs to control an arc rotate camera.
  40948. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40949. */
  40950. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40951. /**
  40952. * Defines the camera the input is attached to.
  40953. */
  40954. camera: ArcRotateCamera;
  40955. /**
  40956. * Defines the gamepad the input is gathering event from.
  40957. */
  40958. gamepad: Nullable<Gamepad>;
  40959. /**
  40960. * Defines the gamepad rotation sensiblity.
  40961. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40962. */
  40963. gamepadRotationSensibility: number;
  40964. /**
  40965. * Defines the gamepad move sensiblity.
  40966. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40967. */
  40968. gamepadMoveSensibility: number;
  40969. private _yAxisScale;
  40970. /**
  40971. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40972. */
  40973. get invertYAxis(): boolean;
  40974. set invertYAxis(value: boolean);
  40975. private _onGamepadConnectedObserver;
  40976. private _onGamepadDisconnectedObserver;
  40977. /**
  40978. * Attach the input controls to a specific dom element to get the input from.
  40979. * @param element Defines the element the controls should be listened from
  40980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40981. */
  40982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40983. /**
  40984. * Detach the current controls from the specified dom element.
  40985. * @param element Defines the element to stop listening the inputs from
  40986. */
  40987. detachControl(element: Nullable<HTMLElement>): void;
  40988. /**
  40989. * Update the current camera state depending on the inputs that have been used this frame.
  40990. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40991. */
  40992. checkInputs(): void;
  40993. /**
  40994. * Gets the class name of the current intput.
  40995. * @returns the class name
  40996. */
  40997. getClassName(): string;
  40998. /**
  40999. * Get the friendly name associated with the input class.
  41000. * @returns the input friendly name
  41001. */
  41002. getSimpleName(): string;
  41003. }
  41004. }
  41005. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41006. import { Nullable } from "babylonjs/types";
  41007. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41008. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41009. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41010. interface ArcRotateCameraInputsManager {
  41011. /**
  41012. * Add orientation input support to the input manager.
  41013. * @returns the current input manager
  41014. */
  41015. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41016. }
  41017. }
  41018. /**
  41019. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41021. */
  41022. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41023. /**
  41024. * Defines the camera the input is attached to.
  41025. */
  41026. camera: ArcRotateCamera;
  41027. /**
  41028. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41029. */
  41030. alphaCorrection: number;
  41031. /**
  41032. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41033. */
  41034. gammaCorrection: number;
  41035. private _alpha;
  41036. private _gamma;
  41037. private _dirty;
  41038. private _deviceOrientationHandler;
  41039. /**
  41040. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41041. */
  41042. constructor();
  41043. /**
  41044. * Attach the input controls to a specific dom element to get the input from.
  41045. * @param element Defines the element the controls should be listened from
  41046. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41047. */
  41048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41049. /** @hidden */
  41050. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41051. /**
  41052. * Update the current camera state depending on the inputs that have been used this frame.
  41053. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41054. */
  41055. checkInputs(): void;
  41056. /**
  41057. * Detach the current controls from the specified dom element.
  41058. * @param element Defines the element to stop listening the inputs from
  41059. */
  41060. detachControl(element: Nullable<HTMLElement>): void;
  41061. /**
  41062. * Gets the class name of the current intput.
  41063. * @returns the class name
  41064. */
  41065. getClassName(): string;
  41066. /**
  41067. * Get the friendly name associated with the input class.
  41068. * @returns the input friendly name
  41069. */
  41070. getSimpleName(): string;
  41071. }
  41072. }
  41073. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41074. import { Nullable } from "babylonjs/types";
  41075. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41076. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41077. /**
  41078. * Listen to mouse events to control the camera.
  41079. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41080. */
  41081. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41082. /**
  41083. * Defines the camera the input is attached to.
  41084. */
  41085. camera: FlyCamera;
  41086. /**
  41087. * Defines if touch is enabled. (Default is true.)
  41088. */
  41089. touchEnabled: boolean;
  41090. /**
  41091. * Defines the buttons associated with the input to handle camera rotation.
  41092. */
  41093. buttons: number[];
  41094. /**
  41095. * Assign buttons for Yaw control.
  41096. */
  41097. buttonsYaw: number[];
  41098. /**
  41099. * Assign buttons for Pitch control.
  41100. */
  41101. buttonsPitch: number[];
  41102. /**
  41103. * Assign buttons for Roll control.
  41104. */
  41105. buttonsRoll: number[];
  41106. /**
  41107. * Detect if any button is being pressed while mouse is moved.
  41108. * -1 = Mouse locked.
  41109. * 0 = Left button.
  41110. * 1 = Middle Button.
  41111. * 2 = Right Button.
  41112. */
  41113. activeButton: number;
  41114. /**
  41115. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41116. * Higher values reduce its sensitivity.
  41117. */
  41118. angularSensibility: number;
  41119. private _mousemoveCallback;
  41120. private _observer;
  41121. private _rollObserver;
  41122. private previousPosition;
  41123. private noPreventDefault;
  41124. private element;
  41125. /**
  41126. * Listen to mouse events to control the camera.
  41127. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41128. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41129. */
  41130. constructor(touchEnabled?: boolean);
  41131. /**
  41132. * Attach the mouse control to the HTML DOM element.
  41133. * @param element Defines the element that listens to the input events.
  41134. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41135. */
  41136. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41137. /**
  41138. * Detach the current controls from the specified dom element.
  41139. * @param element Defines the element to stop listening the inputs from
  41140. */
  41141. detachControl(element: Nullable<HTMLElement>): void;
  41142. /**
  41143. * Gets the class name of the current input.
  41144. * @returns the class name.
  41145. */
  41146. getClassName(): string;
  41147. /**
  41148. * Get the friendly name associated with the input class.
  41149. * @returns the input's friendly name.
  41150. */
  41151. getSimpleName(): string;
  41152. private _pointerInput;
  41153. private _onMouseMove;
  41154. /**
  41155. * Rotate camera by mouse offset.
  41156. */
  41157. private rotateCamera;
  41158. }
  41159. }
  41160. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41161. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41162. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41163. /**
  41164. * Default Inputs manager for the FlyCamera.
  41165. * It groups all the default supported inputs for ease of use.
  41166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41167. */
  41168. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41169. /**
  41170. * Instantiates a new FlyCameraInputsManager.
  41171. * @param camera Defines the camera the inputs belong to.
  41172. */
  41173. constructor(camera: FlyCamera);
  41174. /**
  41175. * Add keyboard input support to the input manager.
  41176. * @returns the new FlyCameraKeyboardMoveInput().
  41177. */
  41178. addKeyboard(): FlyCameraInputsManager;
  41179. /**
  41180. * Add mouse input support to the input manager.
  41181. * @param touchEnabled Enable touch screen support.
  41182. * @returns the new FlyCameraMouseInput().
  41183. */
  41184. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41185. }
  41186. }
  41187. declare module "babylonjs/Cameras/flyCamera" {
  41188. import { Scene } from "babylonjs/scene";
  41189. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41191. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41192. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41193. /**
  41194. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41195. * such as in a 3D Space Shooter or a Flight Simulator.
  41196. */
  41197. export class FlyCamera extends TargetCamera {
  41198. /**
  41199. * Define the collision ellipsoid of the camera.
  41200. * This is helpful for simulating a camera body, like a player's body.
  41201. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41202. */
  41203. ellipsoid: Vector3;
  41204. /**
  41205. * Define an offset for the position of the ellipsoid around the camera.
  41206. * This can be helpful if the camera is attached away from the player's body center,
  41207. * such as at its head.
  41208. */
  41209. ellipsoidOffset: Vector3;
  41210. /**
  41211. * Enable or disable collisions of the camera with the rest of the scene objects.
  41212. */
  41213. checkCollisions: boolean;
  41214. /**
  41215. * Enable or disable gravity on the camera.
  41216. */
  41217. applyGravity: boolean;
  41218. /**
  41219. * Define the current direction the camera is moving to.
  41220. */
  41221. cameraDirection: Vector3;
  41222. /**
  41223. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41224. * This overrides and empties cameraRotation.
  41225. */
  41226. rotationQuaternion: Quaternion;
  41227. /**
  41228. * Track Roll to maintain the wanted Rolling when looking around.
  41229. */
  41230. _trackRoll: number;
  41231. /**
  41232. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41233. */
  41234. rollCorrect: number;
  41235. /**
  41236. * Mimic a banked turn, Rolling the camera when Yawing.
  41237. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41238. */
  41239. bankedTurn: boolean;
  41240. /**
  41241. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41242. */
  41243. bankedTurnLimit: number;
  41244. /**
  41245. * Value of 0 disables the banked Roll.
  41246. * Value of 1 is equal to the Yaw angle in radians.
  41247. */
  41248. bankedTurnMultiplier: number;
  41249. /**
  41250. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41251. */
  41252. inputs: FlyCameraInputsManager;
  41253. /**
  41254. * Gets the input sensibility for mouse input.
  41255. * Higher values reduce sensitivity.
  41256. */
  41257. get angularSensibility(): number;
  41258. /**
  41259. * Sets the input sensibility for a mouse input.
  41260. * Higher values reduce sensitivity.
  41261. */
  41262. set angularSensibility(value: number);
  41263. /**
  41264. * Get the keys for camera movement forward.
  41265. */
  41266. get keysForward(): number[];
  41267. /**
  41268. * Set the keys for camera movement forward.
  41269. */
  41270. set keysForward(value: number[]);
  41271. /**
  41272. * Get the keys for camera movement backward.
  41273. */
  41274. get keysBackward(): number[];
  41275. set keysBackward(value: number[]);
  41276. /**
  41277. * Get the keys for camera movement up.
  41278. */
  41279. get keysUp(): number[];
  41280. /**
  41281. * Set the keys for camera movement up.
  41282. */
  41283. set keysUp(value: number[]);
  41284. /**
  41285. * Get the keys for camera movement down.
  41286. */
  41287. get keysDown(): number[];
  41288. /**
  41289. * Set the keys for camera movement down.
  41290. */
  41291. set keysDown(value: number[]);
  41292. /**
  41293. * Get the keys for camera movement left.
  41294. */
  41295. get keysLeft(): number[];
  41296. /**
  41297. * Set the keys for camera movement left.
  41298. */
  41299. set keysLeft(value: number[]);
  41300. /**
  41301. * Set the keys for camera movement right.
  41302. */
  41303. get keysRight(): number[];
  41304. /**
  41305. * Set the keys for camera movement right.
  41306. */
  41307. set keysRight(value: number[]);
  41308. /**
  41309. * Event raised when the camera collides with a mesh in the scene.
  41310. */
  41311. onCollide: (collidedMesh: AbstractMesh) => void;
  41312. private _collider;
  41313. private _needMoveForGravity;
  41314. private _oldPosition;
  41315. private _diffPosition;
  41316. private _newPosition;
  41317. /** @hidden */
  41318. _localDirection: Vector3;
  41319. /** @hidden */
  41320. _transformedDirection: Vector3;
  41321. /**
  41322. * Instantiates a FlyCamera.
  41323. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41324. * such as in a 3D Space Shooter or a Flight Simulator.
  41325. * @param name Define the name of the camera in the scene.
  41326. * @param position Define the starting position of the camera in the scene.
  41327. * @param scene Define the scene the camera belongs to.
  41328. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41329. */
  41330. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41331. /**
  41332. * Attach a control to the HTML DOM element.
  41333. * @param element Defines the element that listens to the input events.
  41334. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41335. */
  41336. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41337. /**
  41338. * Detach a control from the HTML DOM element.
  41339. * The camera will stop reacting to that input.
  41340. * @param element Defines the element that listens to the input events.
  41341. */
  41342. detachControl(element: HTMLElement): void;
  41343. private _collisionMask;
  41344. /**
  41345. * Get the mask that the camera ignores in collision events.
  41346. */
  41347. get collisionMask(): number;
  41348. /**
  41349. * Set the mask that the camera ignores in collision events.
  41350. */
  41351. set collisionMask(mask: number);
  41352. /** @hidden */
  41353. _collideWithWorld(displacement: Vector3): void;
  41354. /** @hidden */
  41355. private _onCollisionPositionChange;
  41356. /** @hidden */
  41357. _checkInputs(): void;
  41358. /** @hidden */
  41359. _decideIfNeedsToMove(): boolean;
  41360. /** @hidden */
  41361. _updatePosition(): void;
  41362. /**
  41363. * Restore the Roll to its target value at the rate specified.
  41364. * @param rate - Higher means slower restoring.
  41365. * @hidden
  41366. */
  41367. restoreRoll(rate: number): void;
  41368. /**
  41369. * Destroy the camera and release the current resources held by it.
  41370. */
  41371. dispose(): void;
  41372. /**
  41373. * Get the current object class name.
  41374. * @returns the class name.
  41375. */
  41376. getClassName(): string;
  41377. }
  41378. }
  41379. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41380. import { Nullable } from "babylonjs/types";
  41381. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41382. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41383. /**
  41384. * Listen to keyboard events to control the camera.
  41385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41386. */
  41387. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41388. /**
  41389. * Defines the camera the input is attached to.
  41390. */
  41391. camera: FlyCamera;
  41392. /**
  41393. * The list of keyboard keys used to control the forward move of the camera.
  41394. */
  41395. keysForward: number[];
  41396. /**
  41397. * The list of keyboard keys used to control the backward move of the camera.
  41398. */
  41399. keysBackward: number[];
  41400. /**
  41401. * The list of keyboard keys used to control the forward move of the camera.
  41402. */
  41403. keysUp: number[];
  41404. /**
  41405. * The list of keyboard keys used to control the backward move of the camera.
  41406. */
  41407. keysDown: number[];
  41408. /**
  41409. * The list of keyboard keys used to control the right strafe move of the camera.
  41410. */
  41411. keysRight: number[];
  41412. /**
  41413. * The list of keyboard keys used to control the left strafe move of the camera.
  41414. */
  41415. keysLeft: number[];
  41416. private _keys;
  41417. private _onCanvasBlurObserver;
  41418. private _onKeyboardObserver;
  41419. private _engine;
  41420. private _scene;
  41421. /**
  41422. * Attach the input controls to a specific dom element to get the input from.
  41423. * @param element Defines the element the controls should be listened from
  41424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41425. */
  41426. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41427. /**
  41428. * Detach the current controls from the specified dom element.
  41429. * @param element Defines the element to stop listening the inputs from
  41430. */
  41431. detachControl(element: Nullable<HTMLElement>): void;
  41432. /**
  41433. * Gets the class name of the current intput.
  41434. * @returns the class name
  41435. */
  41436. getClassName(): string;
  41437. /** @hidden */
  41438. _onLostFocus(e: FocusEvent): void;
  41439. /**
  41440. * Get the friendly name associated with the input class.
  41441. * @returns the input friendly name
  41442. */
  41443. getSimpleName(): string;
  41444. /**
  41445. * Update the current camera state depending on the inputs that have been used this frame.
  41446. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41447. */
  41448. checkInputs(): void;
  41449. }
  41450. }
  41451. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41452. import { Nullable } from "babylonjs/types";
  41453. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41454. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41455. /**
  41456. * Manage the mouse wheel inputs to control a follow camera.
  41457. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41458. */
  41459. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41460. /**
  41461. * Defines the camera the input is attached to.
  41462. */
  41463. camera: FollowCamera;
  41464. /**
  41465. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41466. */
  41467. axisControlRadius: boolean;
  41468. /**
  41469. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41470. */
  41471. axisControlHeight: boolean;
  41472. /**
  41473. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41474. */
  41475. axisControlRotation: boolean;
  41476. /**
  41477. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41478. * relation to mouseWheel events.
  41479. */
  41480. wheelPrecision: number;
  41481. /**
  41482. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41483. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41484. */
  41485. wheelDeltaPercentage: number;
  41486. private _wheel;
  41487. private _observer;
  41488. /**
  41489. * Attach the input controls to a specific dom element to get the input from.
  41490. * @param element Defines the element the controls should be listened from
  41491. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41492. */
  41493. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41494. /**
  41495. * Detach the current controls from the specified dom element.
  41496. * @param element Defines the element to stop listening the inputs from
  41497. */
  41498. detachControl(element: Nullable<HTMLElement>): void;
  41499. /**
  41500. * Gets the class name of the current intput.
  41501. * @returns the class name
  41502. */
  41503. getClassName(): string;
  41504. /**
  41505. * Get the friendly name associated with the input class.
  41506. * @returns the input friendly name
  41507. */
  41508. getSimpleName(): string;
  41509. }
  41510. }
  41511. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41512. import { Nullable } from "babylonjs/types";
  41513. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41514. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41515. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41516. /**
  41517. * Manage the pointers inputs to control an follow camera.
  41518. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41519. */
  41520. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41521. /**
  41522. * Defines the camera the input is attached to.
  41523. */
  41524. camera: FollowCamera;
  41525. /**
  41526. * Gets the class name of the current input.
  41527. * @returns the class name
  41528. */
  41529. getClassName(): string;
  41530. /**
  41531. * Defines the pointer angular sensibility along the X axis or how fast is
  41532. * the camera rotating.
  41533. * A negative number will reverse the axis direction.
  41534. */
  41535. angularSensibilityX: number;
  41536. /**
  41537. * Defines the pointer angular sensibility along the Y axis or how fast is
  41538. * the camera rotating.
  41539. * A negative number will reverse the axis direction.
  41540. */
  41541. angularSensibilityY: number;
  41542. /**
  41543. * Defines the pointer pinch precision or how fast is the camera zooming.
  41544. * A negative number will reverse the axis direction.
  41545. */
  41546. pinchPrecision: number;
  41547. /**
  41548. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41549. * from 0.
  41550. * It defines the percentage of current camera.radius to use as delta when
  41551. * pinch zoom is used.
  41552. */
  41553. pinchDeltaPercentage: number;
  41554. /**
  41555. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41556. */
  41557. axisXControlRadius: boolean;
  41558. /**
  41559. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41560. */
  41561. axisXControlHeight: boolean;
  41562. /**
  41563. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41564. */
  41565. axisXControlRotation: boolean;
  41566. /**
  41567. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41568. */
  41569. axisYControlRadius: boolean;
  41570. /**
  41571. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41572. */
  41573. axisYControlHeight: boolean;
  41574. /**
  41575. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41576. */
  41577. axisYControlRotation: boolean;
  41578. /**
  41579. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41580. */
  41581. axisPinchControlRadius: boolean;
  41582. /**
  41583. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41584. */
  41585. axisPinchControlHeight: boolean;
  41586. /**
  41587. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41588. */
  41589. axisPinchControlRotation: boolean;
  41590. /**
  41591. * Log error messages if basic misconfiguration has occurred.
  41592. */
  41593. warningEnable: boolean;
  41594. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41595. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41596. private _warningCounter;
  41597. private _warning;
  41598. }
  41599. }
  41600. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41601. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41602. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41603. /**
  41604. * Default Inputs manager for the FollowCamera.
  41605. * It groups all the default supported inputs for ease of use.
  41606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41607. */
  41608. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41609. /**
  41610. * Instantiates a new FollowCameraInputsManager.
  41611. * @param camera Defines the camera the inputs belong to
  41612. */
  41613. constructor(camera: FollowCamera);
  41614. /**
  41615. * Add keyboard input support to the input manager.
  41616. * @returns the current input manager
  41617. */
  41618. addKeyboard(): FollowCameraInputsManager;
  41619. /**
  41620. * Add mouse wheel input support to the input manager.
  41621. * @returns the current input manager
  41622. */
  41623. addMouseWheel(): FollowCameraInputsManager;
  41624. /**
  41625. * Add pointers input support to the input manager.
  41626. * @returns the current input manager
  41627. */
  41628. addPointers(): FollowCameraInputsManager;
  41629. /**
  41630. * Add orientation input support to the input manager.
  41631. * @returns the current input manager
  41632. */
  41633. addVRDeviceOrientation(): FollowCameraInputsManager;
  41634. }
  41635. }
  41636. declare module "babylonjs/Cameras/followCamera" {
  41637. import { Nullable } from "babylonjs/types";
  41638. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41639. import { Scene } from "babylonjs/scene";
  41640. import { Vector3 } from "babylonjs/Maths/math.vector";
  41641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41642. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41643. /**
  41644. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41645. * an arc rotate version arcFollowCamera are available.
  41646. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41647. */
  41648. export class FollowCamera extends TargetCamera {
  41649. /**
  41650. * Distance the follow camera should follow an object at
  41651. */
  41652. radius: number;
  41653. /**
  41654. * Minimum allowed distance of the camera to the axis of rotation
  41655. * (The camera can not get closer).
  41656. * This can help limiting how the Camera is able to move in the scene.
  41657. */
  41658. lowerRadiusLimit: Nullable<number>;
  41659. /**
  41660. * Maximum allowed distance of the camera to the axis of rotation
  41661. * (The camera can not get further).
  41662. * This can help limiting how the Camera is able to move in the scene.
  41663. */
  41664. upperRadiusLimit: Nullable<number>;
  41665. /**
  41666. * Define a rotation offset between the camera and the object it follows
  41667. */
  41668. rotationOffset: number;
  41669. /**
  41670. * Minimum allowed angle to camera position relative to target object.
  41671. * This can help limiting how the Camera is able to move in the scene.
  41672. */
  41673. lowerRotationOffsetLimit: Nullable<number>;
  41674. /**
  41675. * Maximum allowed angle to camera position relative to target object.
  41676. * This can help limiting how the Camera is able to move in the scene.
  41677. */
  41678. upperRotationOffsetLimit: Nullable<number>;
  41679. /**
  41680. * Define a height offset between the camera and the object it follows.
  41681. * It can help following an object from the top (like a car chaing a plane)
  41682. */
  41683. heightOffset: number;
  41684. /**
  41685. * Minimum allowed height of camera position relative to target object.
  41686. * This can help limiting how the Camera is able to move in the scene.
  41687. */
  41688. lowerHeightOffsetLimit: Nullable<number>;
  41689. /**
  41690. * Maximum allowed height of camera position relative to target object.
  41691. * This can help limiting how the Camera is able to move in the scene.
  41692. */
  41693. upperHeightOffsetLimit: Nullable<number>;
  41694. /**
  41695. * Define how fast the camera can accelerate to follow it s target.
  41696. */
  41697. cameraAcceleration: number;
  41698. /**
  41699. * Define the speed limit of the camera following an object.
  41700. */
  41701. maxCameraSpeed: number;
  41702. /**
  41703. * Define the target of the camera.
  41704. */
  41705. lockedTarget: Nullable<AbstractMesh>;
  41706. /**
  41707. * Defines the input associated with the camera.
  41708. */
  41709. inputs: FollowCameraInputsManager;
  41710. /**
  41711. * Instantiates the follow camera.
  41712. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41713. * @param name Define the name of the camera in the scene
  41714. * @param position Define the position of the camera
  41715. * @param scene Define the scene the camera belong to
  41716. * @param lockedTarget Define the target of the camera
  41717. */
  41718. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41719. private _follow;
  41720. /**
  41721. * Attached controls to the current camera.
  41722. * @param element Defines the element the controls should be listened from
  41723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41724. */
  41725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41726. /**
  41727. * Detach the current controls from the camera.
  41728. * The camera will stop reacting to inputs.
  41729. * @param element Defines the element to stop listening the inputs from
  41730. */
  41731. detachControl(element: HTMLElement): void;
  41732. /** @hidden */
  41733. _checkInputs(): void;
  41734. private _checkLimits;
  41735. /**
  41736. * Gets the camera class name.
  41737. * @returns the class name
  41738. */
  41739. getClassName(): string;
  41740. }
  41741. /**
  41742. * Arc Rotate version of the follow camera.
  41743. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41744. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41745. */
  41746. export class ArcFollowCamera extends TargetCamera {
  41747. /** The longitudinal angle of the camera */
  41748. alpha: number;
  41749. /** The latitudinal angle of the camera */
  41750. beta: number;
  41751. /** The radius of the camera from its target */
  41752. radius: number;
  41753. /** Define the camera target (the messh it should follow) */
  41754. target: Nullable<AbstractMesh>;
  41755. private _cartesianCoordinates;
  41756. /**
  41757. * Instantiates a new ArcFollowCamera
  41758. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41759. * @param name Define the name of the camera
  41760. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41761. * @param beta Define the rotation angle of the camera around the elevation axis
  41762. * @param radius Define the radius of the camera from its target point
  41763. * @param target Define the target of the camera
  41764. * @param scene Define the scene the camera belongs to
  41765. */
  41766. constructor(name: string,
  41767. /** The longitudinal angle of the camera */
  41768. alpha: number,
  41769. /** The latitudinal angle of the camera */
  41770. beta: number,
  41771. /** The radius of the camera from its target */
  41772. radius: number,
  41773. /** Define the camera target (the messh it should follow) */
  41774. target: Nullable<AbstractMesh>, scene: Scene);
  41775. private _follow;
  41776. /** @hidden */
  41777. _checkInputs(): void;
  41778. /**
  41779. * Returns the class name of the object.
  41780. * It is mostly used internally for serialization purposes.
  41781. */
  41782. getClassName(): string;
  41783. }
  41784. }
  41785. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41786. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41787. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41788. import { Nullable } from "babylonjs/types";
  41789. /**
  41790. * Manage the keyboard inputs to control the movement of a follow camera.
  41791. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41792. */
  41793. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41794. /**
  41795. * Defines the camera the input is attached to.
  41796. */
  41797. camera: FollowCamera;
  41798. /**
  41799. * Defines the list of key codes associated with the up action (increase heightOffset)
  41800. */
  41801. keysHeightOffsetIncr: number[];
  41802. /**
  41803. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41804. */
  41805. keysHeightOffsetDecr: number[];
  41806. /**
  41807. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41808. */
  41809. keysHeightOffsetModifierAlt: boolean;
  41810. /**
  41811. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41812. */
  41813. keysHeightOffsetModifierCtrl: boolean;
  41814. /**
  41815. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41816. */
  41817. keysHeightOffsetModifierShift: boolean;
  41818. /**
  41819. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41820. */
  41821. keysRotationOffsetIncr: number[];
  41822. /**
  41823. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41824. */
  41825. keysRotationOffsetDecr: number[];
  41826. /**
  41827. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41828. */
  41829. keysRotationOffsetModifierAlt: boolean;
  41830. /**
  41831. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41832. */
  41833. keysRotationOffsetModifierCtrl: boolean;
  41834. /**
  41835. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41836. */
  41837. keysRotationOffsetModifierShift: boolean;
  41838. /**
  41839. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41840. */
  41841. keysRadiusIncr: number[];
  41842. /**
  41843. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41844. */
  41845. keysRadiusDecr: number[];
  41846. /**
  41847. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41848. */
  41849. keysRadiusModifierAlt: boolean;
  41850. /**
  41851. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41852. */
  41853. keysRadiusModifierCtrl: boolean;
  41854. /**
  41855. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41856. */
  41857. keysRadiusModifierShift: boolean;
  41858. /**
  41859. * Defines the rate of change of heightOffset.
  41860. */
  41861. heightSensibility: number;
  41862. /**
  41863. * Defines the rate of change of rotationOffset.
  41864. */
  41865. rotationSensibility: number;
  41866. /**
  41867. * Defines the rate of change of radius.
  41868. */
  41869. radiusSensibility: number;
  41870. private _keys;
  41871. private _ctrlPressed;
  41872. private _altPressed;
  41873. private _shiftPressed;
  41874. private _onCanvasBlurObserver;
  41875. private _onKeyboardObserver;
  41876. private _engine;
  41877. private _scene;
  41878. /**
  41879. * Attach the input controls to a specific dom element to get the input from.
  41880. * @param element Defines the element the controls should be listened from
  41881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41882. */
  41883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41884. /**
  41885. * Detach the current controls from the specified dom element.
  41886. * @param element Defines the element to stop listening the inputs from
  41887. */
  41888. detachControl(element: Nullable<HTMLElement>): void;
  41889. /**
  41890. * Update the current camera state depending on the inputs that have been used this frame.
  41891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41892. */
  41893. checkInputs(): void;
  41894. /**
  41895. * Gets the class name of the current input.
  41896. * @returns the class name
  41897. */
  41898. getClassName(): string;
  41899. /**
  41900. * Get the friendly name associated with the input class.
  41901. * @returns the input friendly name
  41902. */
  41903. getSimpleName(): string;
  41904. /**
  41905. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41906. * allow modification of the heightOffset value.
  41907. */
  41908. private _modifierHeightOffset;
  41909. /**
  41910. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41911. * allow modification of the rotationOffset value.
  41912. */
  41913. private _modifierRotationOffset;
  41914. /**
  41915. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41916. * allow modification of the radius value.
  41917. */
  41918. private _modifierRadius;
  41919. }
  41920. }
  41921. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41922. import { Nullable } from "babylonjs/types";
  41923. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41924. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41925. import { Observable } from "babylonjs/Misc/observable";
  41926. module "babylonjs/Cameras/freeCameraInputsManager" {
  41927. interface FreeCameraInputsManager {
  41928. /**
  41929. * @hidden
  41930. */
  41931. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41932. /**
  41933. * Add orientation input support to the input manager.
  41934. * @returns the current input manager
  41935. */
  41936. addDeviceOrientation(): FreeCameraInputsManager;
  41937. }
  41938. }
  41939. /**
  41940. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41941. * Screen rotation is taken into account.
  41942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41943. */
  41944. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41945. private _camera;
  41946. private _screenOrientationAngle;
  41947. private _constantTranform;
  41948. private _screenQuaternion;
  41949. private _alpha;
  41950. private _beta;
  41951. private _gamma;
  41952. /**
  41953. * Can be used to detect if a device orientation sensor is available on a device
  41954. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41955. * @returns a promise that will resolve on orientation change
  41956. */
  41957. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41958. /**
  41959. * @hidden
  41960. */
  41961. _onDeviceOrientationChangedObservable: Observable<void>;
  41962. /**
  41963. * Instantiates a new input
  41964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41965. */
  41966. constructor();
  41967. /**
  41968. * Define the camera controlled by the input.
  41969. */
  41970. get camera(): FreeCamera;
  41971. set camera(camera: FreeCamera);
  41972. /**
  41973. * Attach the input controls to a specific dom element to get the input from.
  41974. * @param element Defines the element the controls should be listened from
  41975. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41976. */
  41977. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41978. private _orientationChanged;
  41979. private _deviceOrientation;
  41980. /**
  41981. * Detach the current controls from the specified dom element.
  41982. * @param element Defines the element to stop listening the inputs from
  41983. */
  41984. detachControl(element: Nullable<HTMLElement>): void;
  41985. /**
  41986. * Update the current camera state depending on the inputs that have been used this frame.
  41987. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41988. */
  41989. checkInputs(): void;
  41990. /**
  41991. * Gets the class name of the current intput.
  41992. * @returns the class name
  41993. */
  41994. getClassName(): string;
  41995. /**
  41996. * Get the friendly name associated with the input class.
  41997. * @returns the input friendly name
  41998. */
  41999. getSimpleName(): string;
  42000. }
  42001. }
  42002. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42003. import { Nullable } from "babylonjs/types";
  42004. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42005. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42006. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42007. /**
  42008. * Manage the gamepad inputs to control a free camera.
  42009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42010. */
  42011. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42012. /**
  42013. * Define the camera the input is attached to.
  42014. */
  42015. camera: FreeCamera;
  42016. /**
  42017. * Define the Gamepad controlling the input
  42018. */
  42019. gamepad: Nullable<Gamepad>;
  42020. /**
  42021. * Defines the gamepad rotation sensiblity.
  42022. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42023. */
  42024. gamepadAngularSensibility: number;
  42025. /**
  42026. * Defines the gamepad move sensiblity.
  42027. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42028. */
  42029. gamepadMoveSensibility: number;
  42030. private _yAxisScale;
  42031. /**
  42032. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42033. */
  42034. get invertYAxis(): boolean;
  42035. set invertYAxis(value: boolean);
  42036. private _onGamepadConnectedObserver;
  42037. private _onGamepadDisconnectedObserver;
  42038. private _cameraTransform;
  42039. private _deltaTransform;
  42040. private _vector3;
  42041. private _vector2;
  42042. /**
  42043. * Attach the input controls to a specific dom element to get the input from.
  42044. * @param element Defines the element the controls should be listened from
  42045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42046. */
  42047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42048. /**
  42049. * Detach the current controls from the specified dom element.
  42050. * @param element Defines the element to stop listening the inputs from
  42051. */
  42052. detachControl(element: Nullable<HTMLElement>): void;
  42053. /**
  42054. * Update the current camera state depending on the inputs that have been used this frame.
  42055. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42056. */
  42057. checkInputs(): void;
  42058. /**
  42059. * Gets the class name of the current intput.
  42060. * @returns the class name
  42061. */
  42062. getClassName(): string;
  42063. /**
  42064. * Get the friendly name associated with the input class.
  42065. * @returns the input friendly name
  42066. */
  42067. getSimpleName(): string;
  42068. }
  42069. }
  42070. declare module "babylonjs/Misc/virtualJoystick" {
  42071. import { Nullable } from "babylonjs/types";
  42072. import { Vector3 } from "babylonjs/Maths/math.vector";
  42073. /**
  42074. * Defines the potential axis of a Joystick
  42075. */
  42076. export enum JoystickAxis {
  42077. /** X axis */
  42078. X = 0,
  42079. /** Y axis */
  42080. Y = 1,
  42081. /** Z axis */
  42082. Z = 2
  42083. }
  42084. /**
  42085. * Class used to define virtual joystick (used in touch mode)
  42086. */
  42087. export class VirtualJoystick {
  42088. /**
  42089. * Gets or sets a boolean indicating that left and right values must be inverted
  42090. */
  42091. reverseLeftRight: boolean;
  42092. /**
  42093. * Gets or sets a boolean indicating that up and down values must be inverted
  42094. */
  42095. reverseUpDown: boolean;
  42096. /**
  42097. * Gets the offset value for the position (ie. the change of the position value)
  42098. */
  42099. deltaPosition: Vector3;
  42100. /**
  42101. * Gets a boolean indicating if the virtual joystick was pressed
  42102. */
  42103. pressed: boolean;
  42104. /**
  42105. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42106. */
  42107. static Canvas: Nullable<HTMLCanvasElement>;
  42108. private static _globalJoystickIndex;
  42109. private static vjCanvasContext;
  42110. private static vjCanvasWidth;
  42111. private static vjCanvasHeight;
  42112. private static halfWidth;
  42113. private _action;
  42114. private _axisTargetedByLeftAndRight;
  42115. private _axisTargetedByUpAndDown;
  42116. private _joystickSensibility;
  42117. private _inversedSensibility;
  42118. private _joystickPointerID;
  42119. private _joystickColor;
  42120. private _joystickPointerPos;
  42121. private _joystickPreviousPointerPos;
  42122. private _joystickPointerStartPos;
  42123. private _deltaJoystickVector;
  42124. private _leftJoystick;
  42125. private _touches;
  42126. private _onPointerDownHandlerRef;
  42127. private _onPointerMoveHandlerRef;
  42128. private _onPointerUpHandlerRef;
  42129. private _onResize;
  42130. /**
  42131. * Creates a new virtual joystick
  42132. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42133. */
  42134. constructor(leftJoystick?: boolean);
  42135. /**
  42136. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42137. * @param newJoystickSensibility defines the new sensibility
  42138. */
  42139. setJoystickSensibility(newJoystickSensibility: number): void;
  42140. private _onPointerDown;
  42141. private _onPointerMove;
  42142. private _onPointerUp;
  42143. /**
  42144. * Change the color of the virtual joystick
  42145. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42146. */
  42147. setJoystickColor(newColor: string): void;
  42148. /**
  42149. * Defines a callback to call when the joystick is touched
  42150. * @param action defines the callback
  42151. */
  42152. setActionOnTouch(action: () => any): void;
  42153. /**
  42154. * Defines which axis you'd like to control for left & right
  42155. * @param axis defines the axis to use
  42156. */
  42157. setAxisForLeftRight(axis: JoystickAxis): void;
  42158. /**
  42159. * Defines which axis you'd like to control for up & down
  42160. * @param axis defines the axis to use
  42161. */
  42162. setAxisForUpDown(axis: JoystickAxis): void;
  42163. private _drawVirtualJoystick;
  42164. /**
  42165. * Release internal HTML canvas
  42166. */
  42167. releaseCanvas(): void;
  42168. }
  42169. }
  42170. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42171. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42172. import { Nullable } from "babylonjs/types";
  42173. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42174. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42175. module "babylonjs/Cameras/freeCameraInputsManager" {
  42176. interface FreeCameraInputsManager {
  42177. /**
  42178. * Add virtual joystick input support to the input manager.
  42179. * @returns the current input manager
  42180. */
  42181. addVirtualJoystick(): FreeCameraInputsManager;
  42182. }
  42183. }
  42184. /**
  42185. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42187. */
  42188. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42189. /**
  42190. * Defines the camera the input is attached to.
  42191. */
  42192. camera: FreeCamera;
  42193. private _leftjoystick;
  42194. private _rightjoystick;
  42195. /**
  42196. * Gets the left stick of the virtual joystick.
  42197. * @returns The virtual Joystick
  42198. */
  42199. getLeftJoystick(): VirtualJoystick;
  42200. /**
  42201. * Gets the right stick of the virtual joystick.
  42202. * @returns The virtual Joystick
  42203. */
  42204. getRightJoystick(): VirtualJoystick;
  42205. /**
  42206. * Update the current camera state depending on the inputs that have been used this frame.
  42207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42208. */
  42209. checkInputs(): void;
  42210. /**
  42211. * Attach the input controls to a specific dom element to get the input from.
  42212. * @param element Defines the element the controls should be listened from
  42213. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42214. */
  42215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42216. /**
  42217. * Detach the current controls from the specified dom element.
  42218. * @param element Defines the element to stop listening the inputs from
  42219. */
  42220. detachControl(element: Nullable<HTMLElement>): void;
  42221. /**
  42222. * Gets the class name of the current intput.
  42223. * @returns the class name
  42224. */
  42225. getClassName(): string;
  42226. /**
  42227. * Get the friendly name associated with the input class.
  42228. * @returns the input friendly name
  42229. */
  42230. getSimpleName(): string;
  42231. }
  42232. }
  42233. declare module "babylonjs/Cameras/Inputs/index" {
  42234. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42235. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42236. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42237. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42238. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42239. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42240. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42241. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42242. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42243. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42244. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42245. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42246. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42247. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42248. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42249. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42250. }
  42251. declare module "babylonjs/Cameras/touchCamera" {
  42252. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42253. import { Scene } from "babylonjs/scene";
  42254. import { Vector3 } from "babylonjs/Maths/math.vector";
  42255. /**
  42256. * This represents a FPS type of camera controlled by touch.
  42257. * This is like a universal camera minus the Gamepad controls.
  42258. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42259. */
  42260. export class TouchCamera extends FreeCamera {
  42261. /**
  42262. * Defines the touch sensibility for rotation.
  42263. * The higher the faster.
  42264. */
  42265. get touchAngularSensibility(): number;
  42266. set touchAngularSensibility(value: number);
  42267. /**
  42268. * Defines the touch sensibility for move.
  42269. * The higher the faster.
  42270. */
  42271. get touchMoveSensibility(): number;
  42272. set touchMoveSensibility(value: number);
  42273. /**
  42274. * Instantiates a new touch camera.
  42275. * This represents a FPS type of camera controlled by touch.
  42276. * This is like a universal camera minus the Gamepad controls.
  42277. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42278. * @param name Define the name of the camera in the scene
  42279. * @param position Define the start position of the camera in the scene
  42280. * @param scene Define the scene the camera belongs to
  42281. */
  42282. constructor(name: string, position: Vector3, scene: Scene);
  42283. /**
  42284. * Gets the current object class name.
  42285. * @return the class name
  42286. */
  42287. getClassName(): string;
  42288. /** @hidden */
  42289. _setupInputs(): void;
  42290. }
  42291. }
  42292. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42293. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42294. import { Scene } from "babylonjs/scene";
  42295. import { Vector3 } from "babylonjs/Maths/math.vector";
  42296. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42297. import { Axis } from "babylonjs/Maths/math.axis";
  42298. /**
  42299. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42300. * being tilted forward or back and left or right.
  42301. */
  42302. export class DeviceOrientationCamera extends FreeCamera {
  42303. private _initialQuaternion;
  42304. private _quaternionCache;
  42305. private _tmpDragQuaternion;
  42306. private _disablePointerInputWhenUsingDeviceOrientation;
  42307. /**
  42308. * Creates a new device orientation camera
  42309. * @param name The name of the camera
  42310. * @param position The start position camera
  42311. * @param scene The scene the camera belongs to
  42312. */
  42313. constructor(name: string, position: Vector3, scene: Scene);
  42314. /**
  42315. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42316. */
  42317. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42318. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42319. private _dragFactor;
  42320. /**
  42321. * Enabled turning on the y axis when the orientation sensor is active
  42322. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42323. */
  42324. enableHorizontalDragging(dragFactor?: number): void;
  42325. /**
  42326. * Gets the current instance class name ("DeviceOrientationCamera").
  42327. * This helps avoiding instanceof at run time.
  42328. * @returns the class name
  42329. */
  42330. getClassName(): string;
  42331. /**
  42332. * @hidden
  42333. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42334. */
  42335. _checkInputs(): void;
  42336. /**
  42337. * Reset the camera to its default orientation on the specified axis only.
  42338. * @param axis The axis to reset
  42339. */
  42340. resetToCurrentRotation(axis?: Axis): void;
  42341. }
  42342. }
  42343. declare module "babylonjs/Gamepads/xboxGamepad" {
  42344. import { Observable } from "babylonjs/Misc/observable";
  42345. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42346. /**
  42347. * Defines supported buttons for XBox360 compatible gamepads
  42348. */
  42349. export enum Xbox360Button {
  42350. /** A */
  42351. A = 0,
  42352. /** B */
  42353. B = 1,
  42354. /** X */
  42355. X = 2,
  42356. /** Y */
  42357. Y = 3,
  42358. /** Left button */
  42359. LB = 4,
  42360. /** Right button */
  42361. RB = 5,
  42362. /** Back */
  42363. Back = 8,
  42364. /** Start */
  42365. Start = 9,
  42366. /** Left stick */
  42367. LeftStick = 10,
  42368. /** Right stick */
  42369. RightStick = 11
  42370. }
  42371. /** Defines values for XBox360 DPad */
  42372. export enum Xbox360Dpad {
  42373. /** Up */
  42374. Up = 12,
  42375. /** Down */
  42376. Down = 13,
  42377. /** Left */
  42378. Left = 14,
  42379. /** Right */
  42380. Right = 15
  42381. }
  42382. /**
  42383. * Defines a XBox360 gamepad
  42384. */
  42385. export class Xbox360Pad extends Gamepad {
  42386. private _leftTrigger;
  42387. private _rightTrigger;
  42388. private _onlefttriggerchanged;
  42389. private _onrighttriggerchanged;
  42390. private _onbuttondown;
  42391. private _onbuttonup;
  42392. private _ondpaddown;
  42393. private _ondpadup;
  42394. /** Observable raised when a button is pressed */
  42395. onButtonDownObservable: Observable<Xbox360Button>;
  42396. /** Observable raised when a button is released */
  42397. onButtonUpObservable: Observable<Xbox360Button>;
  42398. /** Observable raised when a pad is pressed */
  42399. onPadDownObservable: Observable<Xbox360Dpad>;
  42400. /** Observable raised when a pad is released */
  42401. onPadUpObservable: Observable<Xbox360Dpad>;
  42402. private _buttonA;
  42403. private _buttonB;
  42404. private _buttonX;
  42405. private _buttonY;
  42406. private _buttonBack;
  42407. private _buttonStart;
  42408. private _buttonLB;
  42409. private _buttonRB;
  42410. private _buttonLeftStick;
  42411. private _buttonRightStick;
  42412. private _dPadUp;
  42413. private _dPadDown;
  42414. private _dPadLeft;
  42415. private _dPadRight;
  42416. private _isXboxOnePad;
  42417. /**
  42418. * Creates a new XBox360 gamepad object
  42419. * @param id defines the id of this gamepad
  42420. * @param index defines its index
  42421. * @param gamepad defines the internal HTML gamepad object
  42422. * @param xboxOne defines if it is a XBox One gamepad
  42423. */
  42424. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42425. /**
  42426. * Defines the callback to call when left trigger is pressed
  42427. * @param callback defines the callback to use
  42428. */
  42429. onlefttriggerchanged(callback: (value: number) => void): void;
  42430. /**
  42431. * Defines the callback to call when right trigger is pressed
  42432. * @param callback defines the callback to use
  42433. */
  42434. onrighttriggerchanged(callback: (value: number) => void): void;
  42435. /**
  42436. * Gets the left trigger value
  42437. */
  42438. get leftTrigger(): number;
  42439. /**
  42440. * Sets the left trigger value
  42441. */
  42442. set leftTrigger(newValue: number);
  42443. /**
  42444. * Gets the right trigger value
  42445. */
  42446. get rightTrigger(): number;
  42447. /**
  42448. * Sets the right trigger value
  42449. */
  42450. set rightTrigger(newValue: number);
  42451. /**
  42452. * Defines the callback to call when a button is pressed
  42453. * @param callback defines the callback to use
  42454. */
  42455. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42456. /**
  42457. * Defines the callback to call when a button is released
  42458. * @param callback defines the callback to use
  42459. */
  42460. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42461. /**
  42462. * Defines the callback to call when a pad is pressed
  42463. * @param callback defines the callback to use
  42464. */
  42465. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42466. /**
  42467. * Defines the callback to call when a pad is released
  42468. * @param callback defines the callback to use
  42469. */
  42470. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42471. private _setButtonValue;
  42472. private _setDPadValue;
  42473. /**
  42474. * Gets the value of the `A` button
  42475. */
  42476. get buttonA(): number;
  42477. /**
  42478. * Sets the value of the `A` button
  42479. */
  42480. set buttonA(value: number);
  42481. /**
  42482. * Gets the value of the `B` button
  42483. */
  42484. get buttonB(): number;
  42485. /**
  42486. * Sets the value of the `B` button
  42487. */
  42488. set buttonB(value: number);
  42489. /**
  42490. * Gets the value of the `X` button
  42491. */
  42492. get buttonX(): number;
  42493. /**
  42494. * Sets the value of the `X` button
  42495. */
  42496. set buttonX(value: number);
  42497. /**
  42498. * Gets the value of the `Y` button
  42499. */
  42500. get buttonY(): number;
  42501. /**
  42502. * Sets the value of the `Y` button
  42503. */
  42504. set buttonY(value: number);
  42505. /**
  42506. * Gets the value of the `Start` button
  42507. */
  42508. get buttonStart(): number;
  42509. /**
  42510. * Sets the value of the `Start` button
  42511. */
  42512. set buttonStart(value: number);
  42513. /**
  42514. * Gets the value of the `Back` button
  42515. */
  42516. get buttonBack(): number;
  42517. /**
  42518. * Sets the value of the `Back` button
  42519. */
  42520. set buttonBack(value: number);
  42521. /**
  42522. * Gets the value of the `Left` button
  42523. */
  42524. get buttonLB(): number;
  42525. /**
  42526. * Sets the value of the `Left` button
  42527. */
  42528. set buttonLB(value: number);
  42529. /**
  42530. * Gets the value of the `Right` button
  42531. */
  42532. get buttonRB(): number;
  42533. /**
  42534. * Sets the value of the `Right` button
  42535. */
  42536. set buttonRB(value: number);
  42537. /**
  42538. * Gets the value of the Left joystick
  42539. */
  42540. get buttonLeftStick(): number;
  42541. /**
  42542. * Sets the value of the Left joystick
  42543. */
  42544. set buttonLeftStick(value: number);
  42545. /**
  42546. * Gets the value of the Right joystick
  42547. */
  42548. get buttonRightStick(): number;
  42549. /**
  42550. * Sets the value of the Right joystick
  42551. */
  42552. set buttonRightStick(value: number);
  42553. /**
  42554. * Gets the value of D-pad up
  42555. */
  42556. get dPadUp(): number;
  42557. /**
  42558. * Sets the value of D-pad up
  42559. */
  42560. set dPadUp(value: number);
  42561. /**
  42562. * Gets the value of D-pad down
  42563. */
  42564. get dPadDown(): number;
  42565. /**
  42566. * Sets the value of D-pad down
  42567. */
  42568. set dPadDown(value: number);
  42569. /**
  42570. * Gets the value of D-pad left
  42571. */
  42572. get dPadLeft(): number;
  42573. /**
  42574. * Sets the value of D-pad left
  42575. */
  42576. set dPadLeft(value: number);
  42577. /**
  42578. * Gets the value of D-pad right
  42579. */
  42580. get dPadRight(): number;
  42581. /**
  42582. * Sets the value of D-pad right
  42583. */
  42584. set dPadRight(value: number);
  42585. /**
  42586. * Force the gamepad to synchronize with device values
  42587. */
  42588. update(): void;
  42589. /**
  42590. * Disposes the gamepad
  42591. */
  42592. dispose(): void;
  42593. }
  42594. }
  42595. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42596. import { Observable } from "babylonjs/Misc/observable";
  42597. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42598. /**
  42599. * Defines supported buttons for DualShock compatible gamepads
  42600. */
  42601. export enum DualShockButton {
  42602. /** Cross */
  42603. Cross = 0,
  42604. /** Circle */
  42605. Circle = 1,
  42606. /** Square */
  42607. Square = 2,
  42608. /** Triangle */
  42609. Triangle = 3,
  42610. /** L1 */
  42611. L1 = 4,
  42612. /** R1 */
  42613. R1 = 5,
  42614. /** Share */
  42615. Share = 8,
  42616. /** Options */
  42617. Options = 9,
  42618. /** Left stick */
  42619. LeftStick = 10,
  42620. /** Right stick */
  42621. RightStick = 11
  42622. }
  42623. /** Defines values for DualShock DPad */
  42624. export enum DualShockDpad {
  42625. /** Up */
  42626. Up = 12,
  42627. /** Down */
  42628. Down = 13,
  42629. /** Left */
  42630. Left = 14,
  42631. /** Right */
  42632. Right = 15
  42633. }
  42634. /**
  42635. * Defines a DualShock gamepad
  42636. */
  42637. export class DualShockPad extends Gamepad {
  42638. private _leftTrigger;
  42639. private _rightTrigger;
  42640. private _onlefttriggerchanged;
  42641. private _onrighttriggerchanged;
  42642. private _onbuttondown;
  42643. private _onbuttonup;
  42644. private _ondpaddown;
  42645. private _ondpadup;
  42646. /** Observable raised when a button is pressed */
  42647. onButtonDownObservable: Observable<DualShockButton>;
  42648. /** Observable raised when a button is released */
  42649. onButtonUpObservable: Observable<DualShockButton>;
  42650. /** Observable raised when a pad is pressed */
  42651. onPadDownObservable: Observable<DualShockDpad>;
  42652. /** Observable raised when a pad is released */
  42653. onPadUpObservable: Observable<DualShockDpad>;
  42654. private _buttonCross;
  42655. private _buttonCircle;
  42656. private _buttonSquare;
  42657. private _buttonTriangle;
  42658. private _buttonShare;
  42659. private _buttonOptions;
  42660. private _buttonL1;
  42661. private _buttonR1;
  42662. private _buttonLeftStick;
  42663. private _buttonRightStick;
  42664. private _dPadUp;
  42665. private _dPadDown;
  42666. private _dPadLeft;
  42667. private _dPadRight;
  42668. /**
  42669. * Creates a new DualShock gamepad object
  42670. * @param id defines the id of this gamepad
  42671. * @param index defines its index
  42672. * @param gamepad defines the internal HTML gamepad object
  42673. */
  42674. constructor(id: string, index: number, gamepad: any);
  42675. /**
  42676. * Defines the callback to call when left trigger is pressed
  42677. * @param callback defines the callback to use
  42678. */
  42679. onlefttriggerchanged(callback: (value: number) => void): void;
  42680. /**
  42681. * Defines the callback to call when right trigger is pressed
  42682. * @param callback defines the callback to use
  42683. */
  42684. onrighttriggerchanged(callback: (value: number) => void): void;
  42685. /**
  42686. * Gets the left trigger value
  42687. */
  42688. get leftTrigger(): number;
  42689. /**
  42690. * Sets the left trigger value
  42691. */
  42692. set leftTrigger(newValue: number);
  42693. /**
  42694. * Gets the right trigger value
  42695. */
  42696. get rightTrigger(): number;
  42697. /**
  42698. * Sets the right trigger value
  42699. */
  42700. set rightTrigger(newValue: number);
  42701. /**
  42702. * Defines the callback to call when a button is pressed
  42703. * @param callback defines the callback to use
  42704. */
  42705. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42706. /**
  42707. * Defines the callback to call when a button is released
  42708. * @param callback defines the callback to use
  42709. */
  42710. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42711. /**
  42712. * Defines the callback to call when a pad is pressed
  42713. * @param callback defines the callback to use
  42714. */
  42715. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42716. /**
  42717. * Defines the callback to call when a pad is released
  42718. * @param callback defines the callback to use
  42719. */
  42720. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42721. private _setButtonValue;
  42722. private _setDPadValue;
  42723. /**
  42724. * Gets the value of the `Cross` button
  42725. */
  42726. get buttonCross(): number;
  42727. /**
  42728. * Sets the value of the `Cross` button
  42729. */
  42730. set buttonCross(value: number);
  42731. /**
  42732. * Gets the value of the `Circle` button
  42733. */
  42734. get buttonCircle(): number;
  42735. /**
  42736. * Sets the value of the `Circle` button
  42737. */
  42738. set buttonCircle(value: number);
  42739. /**
  42740. * Gets the value of the `Square` button
  42741. */
  42742. get buttonSquare(): number;
  42743. /**
  42744. * Sets the value of the `Square` button
  42745. */
  42746. set buttonSquare(value: number);
  42747. /**
  42748. * Gets the value of the `Triangle` button
  42749. */
  42750. get buttonTriangle(): number;
  42751. /**
  42752. * Sets the value of the `Triangle` button
  42753. */
  42754. set buttonTriangle(value: number);
  42755. /**
  42756. * Gets the value of the `Options` button
  42757. */
  42758. get buttonOptions(): number;
  42759. /**
  42760. * Sets the value of the `Options` button
  42761. */
  42762. set buttonOptions(value: number);
  42763. /**
  42764. * Gets the value of the `Share` button
  42765. */
  42766. get buttonShare(): number;
  42767. /**
  42768. * Sets the value of the `Share` button
  42769. */
  42770. set buttonShare(value: number);
  42771. /**
  42772. * Gets the value of the `L1` button
  42773. */
  42774. get buttonL1(): number;
  42775. /**
  42776. * Sets the value of the `L1` button
  42777. */
  42778. set buttonL1(value: number);
  42779. /**
  42780. * Gets the value of the `R1` button
  42781. */
  42782. get buttonR1(): number;
  42783. /**
  42784. * Sets the value of the `R1` button
  42785. */
  42786. set buttonR1(value: number);
  42787. /**
  42788. * Gets the value of the Left joystick
  42789. */
  42790. get buttonLeftStick(): number;
  42791. /**
  42792. * Sets the value of the Left joystick
  42793. */
  42794. set buttonLeftStick(value: number);
  42795. /**
  42796. * Gets the value of the Right joystick
  42797. */
  42798. get buttonRightStick(): number;
  42799. /**
  42800. * Sets the value of the Right joystick
  42801. */
  42802. set buttonRightStick(value: number);
  42803. /**
  42804. * Gets the value of D-pad up
  42805. */
  42806. get dPadUp(): number;
  42807. /**
  42808. * Sets the value of D-pad up
  42809. */
  42810. set dPadUp(value: number);
  42811. /**
  42812. * Gets the value of D-pad down
  42813. */
  42814. get dPadDown(): number;
  42815. /**
  42816. * Sets the value of D-pad down
  42817. */
  42818. set dPadDown(value: number);
  42819. /**
  42820. * Gets the value of D-pad left
  42821. */
  42822. get dPadLeft(): number;
  42823. /**
  42824. * Sets the value of D-pad left
  42825. */
  42826. set dPadLeft(value: number);
  42827. /**
  42828. * Gets the value of D-pad right
  42829. */
  42830. get dPadRight(): number;
  42831. /**
  42832. * Sets the value of D-pad right
  42833. */
  42834. set dPadRight(value: number);
  42835. /**
  42836. * Force the gamepad to synchronize with device values
  42837. */
  42838. update(): void;
  42839. /**
  42840. * Disposes the gamepad
  42841. */
  42842. dispose(): void;
  42843. }
  42844. }
  42845. declare module "babylonjs/Gamepads/gamepadManager" {
  42846. import { Observable } from "babylonjs/Misc/observable";
  42847. import { Nullable } from "babylonjs/types";
  42848. import { Scene } from "babylonjs/scene";
  42849. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42850. /**
  42851. * Manager for handling gamepads
  42852. */
  42853. export class GamepadManager {
  42854. private _scene?;
  42855. private _babylonGamepads;
  42856. private _oneGamepadConnected;
  42857. /** @hidden */
  42858. _isMonitoring: boolean;
  42859. private _gamepadEventSupported;
  42860. private _gamepadSupport?;
  42861. /**
  42862. * observable to be triggered when the gamepad controller has been connected
  42863. */
  42864. onGamepadConnectedObservable: Observable<Gamepad>;
  42865. /**
  42866. * observable to be triggered when the gamepad controller has been disconnected
  42867. */
  42868. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42869. private _onGamepadConnectedEvent;
  42870. private _onGamepadDisconnectedEvent;
  42871. /**
  42872. * Initializes the gamepad manager
  42873. * @param _scene BabylonJS scene
  42874. */
  42875. constructor(_scene?: Scene | undefined);
  42876. /**
  42877. * The gamepads in the game pad manager
  42878. */
  42879. get gamepads(): Gamepad[];
  42880. /**
  42881. * Get the gamepad controllers based on type
  42882. * @param type The type of gamepad controller
  42883. * @returns Nullable gamepad
  42884. */
  42885. getGamepadByType(type?: number): Nullable<Gamepad>;
  42886. /**
  42887. * Disposes the gamepad manager
  42888. */
  42889. dispose(): void;
  42890. private _addNewGamepad;
  42891. private _startMonitoringGamepads;
  42892. private _stopMonitoringGamepads;
  42893. /** @hidden */
  42894. _checkGamepadsStatus(): void;
  42895. private _updateGamepadObjects;
  42896. }
  42897. }
  42898. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42899. import { Nullable } from "babylonjs/types";
  42900. import { Scene } from "babylonjs/scene";
  42901. import { ISceneComponent } from "babylonjs/sceneComponent";
  42902. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42903. module "babylonjs/scene" {
  42904. interface Scene {
  42905. /** @hidden */
  42906. _gamepadManager: Nullable<GamepadManager>;
  42907. /**
  42908. * Gets the gamepad manager associated with the scene
  42909. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42910. */
  42911. gamepadManager: GamepadManager;
  42912. }
  42913. }
  42914. module "babylonjs/Cameras/freeCameraInputsManager" {
  42915. /**
  42916. * Interface representing a free camera inputs manager
  42917. */
  42918. interface FreeCameraInputsManager {
  42919. /**
  42920. * Adds gamepad input support to the FreeCameraInputsManager.
  42921. * @returns the FreeCameraInputsManager
  42922. */
  42923. addGamepad(): FreeCameraInputsManager;
  42924. }
  42925. }
  42926. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42927. /**
  42928. * Interface representing an arc rotate camera inputs manager
  42929. */
  42930. interface ArcRotateCameraInputsManager {
  42931. /**
  42932. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42933. * @returns the camera inputs manager
  42934. */
  42935. addGamepad(): ArcRotateCameraInputsManager;
  42936. }
  42937. }
  42938. /**
  42939. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42940. */
  42941. export class GamepadSystemSceneComponent implements ISceneComponent {
  42942. /**
  42943. * The component name helpfull to identify the component in the list of scene components.
  42944. */
  42945. readonly name: string;
  42946. /**
  42947. * The scene the component belongs to.
  42948. */
  42949. scene: Scene;
  42950. /**
  42951. * Creates a new instance of the component for the given scene
  42952. * @param scene Defines the scene to register the component in
  42953. */
  42954. constructor(scene: Scene);
  42955. /**
  42956. * Registers the component in a given scene
  42957. */
  42958. register(): void;
  42959. /**
  42960. * Rebuilds the elements related to this component in case of
  42961. * context lost for instance.
  42962. */
  42963. rebuild(): void;
  42964. /**
  42965. * Disposes the component and the associated ressources
  42966. */
  42967. dispose(): void;
  42968. private _beforeCameraUpdate;
  42969. }
  42970. }
  42971. declare module "babylonjs/Cameras/universalCamera" {
  42972. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42973. import { Scene } from "babylonjs/scene";
  42974. import { Vector3 } from "babylonjs/Maths/math.vector";
  42975. import "babylonjs/Gamepads/gamepadSceneComponent";
  42976. /**
  42977. * 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,
  42978. * which still works and will still be found in many Playgrounds.
  42979. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42980. */
  42981. export class UniversalCamera extends TouchCamera {
  42982. /**
  42983. * Defines the gamepad rotation sensiblity.
  42984. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42985. */
  42986. get gamepadAngularSensibility(): number;
  42987. set gamepadAngularSensibility(value: number);
  42988. /**
  42989. * Defines the gamepad move sensiblity.
  42990. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42991. */
  42992. get gamepadMoveSensibility(): number;
  42993. set gamepadMoveSensibility(value: number);
  42994. /**
  42995. * 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,
  42996. * which still works and will still be found in many Playgrounds.
  42997. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42998. * @param name Define the name of the camera in the scene
  42999. * @param position Define the start position of the camera in the scene
  43000. * @param scene Define the scene the camera belongs to
  43001. */
  43002. constructor(name: string, position: Vector3, scene: Scene);
  43003. /**
  43004. * Gets the current object class name.
  43005. * @return the class name
  43006. */
  43007. getClassName(): string;
  43008. }
  43009. }
  43010. declare module "babylonjs/Cameras/gamepadCamera" {
  43011. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43012. import { Scene } from "babylonjs/scene";
  43013. import { Vector3 } from "babylonjs/Maths/math.vector";
  43014. /**
  43015. * This represents a FPS type of camera. This is only here for back compat purpose.
  43016. * Please use the UniversalCamera instead as both are identical.
  43017. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43018. */
  43019. export class GamepadCamera extends UniversalCamera {
  43020. /**
  43021. * Instantiates a new Gamepad Camera
  43022. * This represents a FPS type of camera. This is only here for back compat purpose.
  43023. * Please use the UniversalCamera instead as both are identical.
  43024. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43025. * @param name Define the name of the camera in the scene
  43026. * @param position Define the start position of the camera in the scene
  43027. * @param scene Define the scene the camera belongs to
  43028. */
  43029. constructor(name: string, position: Vector3, scene: Scene);
  43030. /**
  43031. * Gets the current object class name.
  43032. * @return the class name
  43033. */
  43034. getClassName(): string;
  43035. }
  43036. }
  43037. declare module "babylonjs/Shaders/pass.fragment" {
  43038. /** @hidden */
  43039. export var passPixelShader: {
  43040. name: string;
  43041. shader: string;
  43042. };
  43043. }
  43044. declare module "babylonjs/Shaders/passCube.fragment" {
  43045. /** @hidden */
  43046. export var passCubePixelShader: {
  43047. name: string;
  43048. shader: string;
  43049. };
  43050. }
  43051. declare module "babylonjs/PostProcesses/passPostProcess" {
  43052. import { Nullable } from "babylonjs/types";
  43053. import { Camera } from "babylonjs/Cameras/camera";
  43054. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43055. import { Engine } from "babylonjs/Engines/engine";
  43056. import "babylonjs/Shaders/pass.fragment";
  43057. import "babylonjs/Shaders/passCube.fragment";
  43058. /**
  43059. * PassPostProcess which produces an output the same as it's input
  43060. */
  43061. export class PassPostProcess extends PostProcess {
  43062. /**
  43063. * Creates the PassPostProcess
  43064. * @param name The name of the effect.
  43065. * @param options The required width/height ratio to downsize to before computing the render pass.
  43066. * @param camera The camera to apply the render pass to.
  43067. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43068. * @param engine The engine which the post process will be applied. (default: current engine)
  43069. * @param reusable If the post process can be reused on the same frame. (default: false)
  43070. * @param textureType The type of texture to be used when performing the post processing.
  43071. * @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)
  43072. */
  43073. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43074. }
  43075. /**
  43076. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43077. */
  43078. export class PassCubePostProcess extends PostProcess {
  43079. private _face;
  43080. /**
  43081. * Gets or sets the cube face to display.
  43082. * * 0 is +X
  43083. * * 1 is -X
  43084. * * 2 is +Y
  43085. * * 3 is -Y
  43086. * * 4 is +Z
  43087. * * 5 is -Z
  43088. */
  43089. get face(): number;
  43090. set face(value: number);
  43091. /**
  43092. * Creates the PassCubePostProcess
  43093. * @param name The name of the effect.
  43094. * @param options The required width/height ratio to downsize to before computing the render pass.
  43095. * @param camera The camera to apply the render pass to.
  43096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43097. * @param engine The engine which the post process will be applied. (default: current engine)
  43098. * @param reusable If the post process can be reused on the same frame. (default: false)
  43099. * @param textureType The type of texture to be used when performing the post processing.
  43100. * @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)
  43101. */
  43102. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43103. }
  43104. }
  43105. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43106. /** @hidden */
  43107. export var anaglyphPixelShader: {
  43108. name: string;
  43109. shader: string;
  43110. };
  43111. }
  43112. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43113. import { Engine } from "babylonjs/Engines/engine";
  43114. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43115. import { Camera } from "babylonjs/Cameras/camera";
  43116. import "babylonjs/Shaders/anaglyph.fragment";
  43117. /**
  43118. * Postprocess used to generate anaglyphic rendering
  43119. */
  43120. export class AnaglyphPostProcess extends PostProcess {
  43121. private _passedProcess;
  43122. /**
  43123. * Creates a new AnaglyphPostProcess
  43124. * @param name defines postprocess name
  43125. * @param options defines creation options or target ratio scale
  43126. * @param rigCameras defines cameras using this postprocess
  43127. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43128. * @param engine defines hosting engine
  43129. * @param reusable defines if the postprocess will be reused multiple times per frame
  43130. */
  43131. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43132. }
  43133. }
  43134. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43135. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43136. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43137. import { Scene } from "babylonjs/scene";
  43138. import { Vector3 } from "babylonjs/Maths/math.vector";
  43139. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43140. /**
  43141. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43142. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43143. */
  43144. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43145. /**
  43146. * Creates a new AnaglyphArcRotateCamera
  43147. * @param name defines camera name
  43148. * @param alpha defines alpha angle (in radians)
  43149. * @param beta defines beta angle (in radians)
  43150. * @param radius defines radius
  43151. * @param target defines camera target
  43152. * @param interaxialDistance defines distance between each color axis
  43153. * @param scene defines the hosting scene
  43154. */
  43155. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43156. /**
  43157. * Gets camera class name
  43158. * @returns AnaglyphArcRotateCamera
  43159. */
  43160. getClassName(): string;
  43161. }
  43162. }
  43163. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43164. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  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 FreeCamera)
  43170. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43171. */
  43172. export class AnaglyphFreeCamera extends FreeCamera {
  43173. /**
  43174. * Creates a new AnaglyphFreeCamera
  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 AnaglyphFreeCamera
  43184. */
  43185. getClassName(): string;
  43186. }
  43187. }
  43188. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43189. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43190. import { Scene } from "babylonjs/scene";
  43191. import { Vector3 } from "babylonjs/Maths/math.vector";
  43192. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43193. /**
  43194. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43195. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43196. */
  43197. export class AnaglyphGamepadCamera extends GamepadCamera {
  43198. /**
  43199. * Creates a new AnaglyphGamepadCamera
  43200. * @param name defines camera name
  43201. * @param position defines initial position
  43202. * @param interaxialDistance defines distance between each color axis
  43203. * @param scene defines the hosting scene
  43204. */
  43205. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43206. /**
  43207. * Gets camera class name
  43208. * @returns AnaglyphGamepadCamera
  43209. */
  43210. getClassName(): string;
  43211. }
  43212. }
  43213. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43214. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43215. import { Scene } from "babylonjs/scene";
  43216. import { Vector3 } from "babylonjs/Maths/math.vector";
  43217. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43218. /**
  43219. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43220. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43221. */
  43222. export class AnaglyphUniversalCamera extends UniversalCamera {
  43223. /**
  43224. * Creates a new AnaglyphUniversalCamera
  43225. * @param name defines camera name
  43226. * @param position defines initial position
  43227. * @param interaxialDistance defines distance between each color axis
  43228. * @param scene defines the hosting scene
  43229. */
  43230. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43231. /**
  43232. * Gets camera class name
  43233. * @returns AnaglyphUniversalCamera
  43234. */
  43235. getClassName(): string;
  43236. }
  43237. }
  43238. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43239. /** @hidden */
  43240. export var stereoscopicInterlacePixelShader: {
  43241. name: string;
  43242. shader: string;
  43243. };
  43244. }
  43245. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43246. import { Camera } from "babylonjs/Cameras/camera";
  43247. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43248. import { Engine } from "babylonjs/Engines/engine";
  43249. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43250. /**
  43251. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43252. */
  43253. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43254. private _stepSize;
  43255. private _passedProcess;
  43256. /**
  43257. * Initializes a StereoscopicInterlacePostProcessI
  43258. * @param name The name of the effect.
  43259. * @param rigCameras The rig cameras to be appled to the post process
  43260. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43261. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43263. * @param engine The engine which the post process will be applied. (default: current engine)
  43264. * @param reusable If the post process can be reused on the same frame. (default: false)
  43265. */
  43266. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43267. }
  43268. /**
  43269. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43270. */
  43271. export class StereoscopicInterlacePostProcess extends PostProcess {
  43272. private _stepSize;
  43273. private _passedProcess;
  43274. /**
  43275. * Initializes a StereoscopicInterlacePostProcess
  43276. * @param name The name of the effect.
  43277. * @param rigCameras The rig cameras to be appled to the post process
  43278. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43280. * @param engine The engine which the post process will be applied. (default: current engine)
  43281. * @param reusable If the post process can be reused on the same frame. (default: false)
  43282. */
  43283. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43284. }
  43285. }
  43286. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43287. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43288. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43289. import { Scene } from "babylonjs/scene";
  43290. import { Vector3 } from "babylonjs/Maths/math.vector";
  43291. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43292. /**
  43293. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43294. * @see http://doc.babylonjs.com/features/cameras
  43295. */
  43296. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43297. /**
  43298. * Creates a new StereoscopicArcRotateCamera
  43299. * @param name defines camera name
  43300. * @param alpha defines alpha angle (in radians)
  43301. * @param beta defines beta angle (in radians)
  43302. * @param radius defines radius
  43303. * @param target defines camera target
  43304. * @param interaxialDistance defines distance between each color axis
  43305. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43306. * @param scene defines the hosting scene
  43307. */
  43308. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43309. /**
  43310. * Gets camera class name
  43311. * @returns StereoscopicArcRotateCamera
  43312. */
  43313. getClassName(): string;
  43314. }
  43315. }
  43316. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43317. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43318. import { Scene } from "babylonjs/scene";
  43319. import { Vector3 } from "babylonjs/Maths/math.vector";
  43320. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43321. /**
  43322. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43323. * @see http://doc.babylonjs.com/features/cameras
  43324. */
  43325. export class StereoscopicFreeCamera extends FreeCamera {
  43326. /**
  43327. * Creates a new StereoscopicFreeCamera
  43328. * @param name defines camera name
  43329. * @param position defines initial position
  43330. * @param interaxialDistance defines distance between each color axis
  43331. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43332. * @param scene defines the hosting scene
  43333. */
  43334. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43335. /**
  43336. * Gets camera class name
  43337. * @returns StereoscopicFreeCamera
  43338. */
  43339. getClassName(): string;
  43340. }
  43341. }
  43342. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43343. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43344. import { Scene } from "babylonjs/scene";
  43345. import { Vector3 } from "babylonjs/Maths/math.vector";
  43346. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43347. /**
  43348. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43349. * @see http://doc.babylonjs.com/features/cameras
  43350. */
  43351. export class StereoscopicGamepadCamera extends GamepadCamera {
  43352. /**
  43353. * Creates a new StereoscopicGamepadCamera
  43354. * @param name defines camera name
  43355. * @param position defines initial position
  43356. * @param interaxialDistance defines distance between each color axis
  43357. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43358. * @param scene defines the hosting scene
  43359. */
  43360. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43361. /**
  43362. * Gets camera class name
  43363. * @returns StereoscopicGamepadCamera
  43364. */
  43365. getClassName(): string;
  43366. }
  43367. }
  43368. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43369. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43370. import { Scene } from "babylonjs/scene";
  43371. import { Vector3 } from "babylonjs/Maths/math.vector";
  43372. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43373. /**
  43374. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43375. * @see http://doc.babylonjs.com/features/cameras
  43376. */
  43377. export class StereoscopicUniversalCamera extends UniversalCamera {
  43378. /**
  43379. * Creates a new StereoscopicUniversalCamera
  43380. * @param name defines camera name
  43381. * @param position defines initial position
  43382. * @param interaxialDistance defines distance between each color axis
  43383. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43384. * @param scene defines the hosting scene
  43385. */
  43386. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43387. /**
  43388. * Gets camera class name
  43389. * @returns StereoscopicUniversalCamera
  43390. */
  43391. getClassName(): string;
  43392. }
  43393. }
  43394. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43395. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43396. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43397. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43398. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43399. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43400. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43401. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43402. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43403. }
  43404. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43405. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43406. import { Scene } from "babylonjs/scene";
  43407. import { Vector3 } from "babylonjs/Maths/math.vector";
  43408. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43409. /**
  43410. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43411. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43412. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43413. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43414. */
  43415. export class VirtualJoysticksCamera extends FreeCamera {
  43416. /**
  43417. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43418. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43419. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43420. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43421. * @param name Define the name of the camera in the scene
  43422. * @param position Define the start position of the camera in the scene
  43423. * @param scene Define the scene the camera belongs to
  43424. */
  43425. constructor(name: string, position: Vector3, scene: Scene);
  43426. /**
  43427. * Gets the current object class name.
  43428. * @return the class name
  43429. */
  43430. getClassName(): string;
  43431. }
  43432. }
  43433. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43434. import { Matrix } from "babylonjs/Maths/math.vector";
  43435. /**
  43436. * This represents all the required metrics to create a VR camera.
  43437. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43438. */
  43439. export class VRCameraMetrics {
  43440. /**
  43441. * Define the horizontal resolution off the screen.
  43442. */
  43443. hResolution: number;
  43444. /**
  43445. * Define the vertical resolution off the screen.
  43446. */
  43447. vResolution: number;
  43448. /**
  43449. * Define the horizontal screen size.
  43450. */
  43451. hScreenSize: number;
  43452. /**
  43453. * Define the vertical screen size.
  43454. */
  43455. vScreenSize: number;
  43456. /**
  43457. * Define the vertical screen center position.
  43458. */
  43459. vScreenCenter: number;
  43460. /**
  43461. * Define the distance of the eyes to the screen.
  43462. */
  43463. eyeToScreenDistance: number;
  43464. /**
  43465. * Define the distance between both lenses
  43466. */
  43467. lensSeparationDistance: number;
  43468. /**
  43469. * Define the distance between both viewer's eyes.
  43470. */
  43471. interpupillaryDistance: number;
  43472. /**
  43473. * Define the distortion factor of the VR postprocess.
  43474. * Please, touch with care.
  43475. */
  43476. distortionK: number[];
  43477. /**
  43478. * Define the chromatic aberration correction factors for the VR post process.
  43479. */
  43480. chromaAbCorrection: number[];
  43481. /**
  43482. * Define the scale factor of the post process.
  43483. * The smaller the better but the slower.
  43484. */
  43485. postProcessScaleFactor: number;
  43486. /**
  43487. * Define an offset for the lens center.
  43488. */
  43489. lensCenterOffset: number;
  43490. /**
  43491. * Define if the current vr camera should compensate the distortion of the lense or not.
  43492. */
  43493. compensateDistortion: boolean;
  43494. /**
  43495. * Defines if multiview should be enabled when rendering (Default: false)
  43496. */
  43497. multiviewEnabled: boolean;
  43498. /**
  43499. * Gets the rendering aspect ratio based on the provided resolutions.
  43500. */
  43501. get aspectRatio(): number;
  43502. /**
  43503. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43504. */
  43505. get aspectRatioFov(): number;
  43506. /**
  43507. * @hidden
  43508. */
  43509. get leftHMatrix(): Matrix;
  43510. /**
  43511. * @hidden
  43512. */
  43513. get rightHMatrix(): Matrix;
  43514. /**
  43515. * @hidden
  43516. */
  43517. get leftPreViewMatrix(): Matrix;
  43518. /**
  43519. * @hidden
  43520. */
  43521. get rightPreViewMatrix(): Matrix;
  43522. /**
  43523. * Get the default VRMetrics based on the most generic setup.
  43524. * @returns the default vr metrics
  43525. */
  43526. static GetDefault(): VRCameraMetrics;
  43527. }
  43528. }
  43529. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43530. /** @hidden */
  43531. export var vrDistortionCorrectionPixelShader: {
  43532. name: string;
  43533. shader: string;
  43534. };
  43535. }
  43536. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43537. import { Camera } from "babylonjs/Cameras/camera";
  43538. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43539. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43540. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43541. /**
  43542. * VRDistortionCorrectionPostProcess used for mobile VR
  43543. */
  43544. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43545. private _isRightEye;
  43546. private _distortionFactors;
  43547. private _postProcessScaleFactor;
  43548. private _lensCenterOffset;
  43549. private _scaleIn;
  43550. private _scaleFactor;
  43551. private _lensCenter;
  43552. /**
  43553. * Initializes the VRDistortionCorrectionPostProcess
  43554. * @param name The name of the effect.
  43555. * @param camera The camera to apply the render pass to.
  43556. * @param isRightEye If this is for the right eye distortion
  43557. * @param vrMetrics All the required metrics for the VR camera
  43558. */
  43559. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43560. }
  43561. }
  43562. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43563. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43564. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43565. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43566. import { Scene } from "babylonjs/scene";
  43567. import { Vector3 } from "babylonjs/Maths/math.vector";
  43568. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43569. import "babylonjs/Cameras/RigModes/vrRigMode";
  43570. /**
  43571. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43572. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43573. */
  43574. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43575. /**
  43576. * Creates a new VRDeviceOrientationArcRotateCamera
  43577. * @param name defines camera name
  43578. * @param alpha defines the camera rotation along the logitudinal axis
  43579. * @param beta defines the camera rotation along the latitudinal axis
  43580. * @param radius defines the camera distance from its target
  43581. * @param target defines the camera target
  43582. * @param scene defines the scene the camera belongs to
  43583. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43584. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43585. */
  43586. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43587. /**
  43588. * Gets camera class name
  43589. * @returns VRDeviceOrientationArcRotateCamera
  43590. */
  43591. getClassName(): string;
  43592. }
  43593. }
  43594. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43595. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43596. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43597. import { Scene } from "babylonjs/scene";
  43598. import { Vector3 } from "babylonjs/Maths/math.vector";
  43599. import "babylonjs/Cameras/RigModes/vrRigMode";
  43600. /**
  43601. * Camera used to simulate VR rendering (based on FreeCamera)
  43602. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43603. */
  43604. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43605. /**
  43606. * Creates a new VRDeviceOrientationFreeCamera
  43607. * @param name defines camera name
  43608. * @param position defines the start position of the camera
  43609. * @param scene defines the scene the camera belongs to
  43610. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43611. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43612. */
  43613. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43614. /**
  43615. * Gets camera class name
  43616. * @returns VRDeviceOrientationFreeCamera
  43617. */
  43618. getClassName(): string;
  43619. }
  43620. }
  43621. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43622. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43623. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43624. import { Scene } from "babylonjs/scene";
  43625. import { Vector3 } from "babylonjs/Maths/math.vector";
  43626. import "babylonjs/Gamepads/gamepadSceneComponent";
  43627. /**
  43628. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43629. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43630. */
  43631. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43632. /**
  43633. * Creates a new VRDeviceOrientationGamepadCamera
  43634. * @param name defines camera name
  43635. * @param position defines the start position of the camera
  43636. * @param scene defines the scene the camera belongs to
  43637. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43638. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43639. */
  43640. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43641. /**
  43642. * Gets camera class name
  43643. * @returns VRDeviceOrientationGamepadCamera
  43644. */
  43645. getClassName(): string;
  43646. }
  43647. }
  43648. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43649. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43650. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43651. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43652. /** @hidden */
  43653. export var imageProcessingPixelShader: {
  43654. name: string;
  43655. shader: string;
  43656. };
  43657. }
  43658. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43659. import { Nullable } from "babylonjs/types";
  43660. import { Color4 } from "babylonjs/Maths/math.color";
  43661. import { Camera } from "babylonjs/Cameras/camera";
  43662. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43663. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43664. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43665. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43666. import { Engine } from "babylonjs/Engines/engine";
  43667. import "babylonjs/Shaders/imageProcessing.fragment";
  43668. import "babylonjs/Shaders/postprocess.vertex";
  43669. /**
  43670. * ImageProcessingPostProcess
  43671. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43672. */
  43673. export class ImageProcessingPostProcess extends PostProcess {
  43674. /**
  43675. * Default configuration related to image processing available in the PBR Material.
  43676. */
  43677. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43678. /**
  43679. * Gets the image processing configuration used either in this material.
  43680. */
  43681. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43682. /**
  43683. * Sets the Default image processing configuration used either in the this material.
  43684. *
  43685. * If sets to null, the scene one is in use.
  43686. */
  43687. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43688. /**
  43689. * Keep track of the image processing observer to allow dispose and replace.
  43690. */
  43691. private _imageProcessingObserver;
  43692. /**
  43693. * Attaches a new image processing configuration to the PBR Material.
  43694. * @param configuration
  43695. */
  43696. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43697. /**
  43698. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43699. */
  43700. get colorCurves(): Nullable<ColorCurves>;
  43701. /**
  43702. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43703. */
  43704. set colorCurves(value: Nullable<ColorCurves>);
  43705. /**
  43706. * Gets wether the color curves effect is enabled.
  43707. */
  43708. get colorCurvesEnabled(): boolean;
  43709. /**
  43710. * Sets wether the color curves effect is enabled.
  43711. */
  43712. set colorCurvesEnabled(value: boolean);
  43713. /**
  43714. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43715. */
  43716. get colorGradingTexture(): Nullable<BaseTexture>;
  43717. /**
  43718. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43719. */
  43720. set colorGradingTexture(value: Nullable<BaseTexture>);
  43721. /**
  43722. * Gets wether the color grading effect is enabled.
  43723. */
  43724. get colorGradingEnabled(): boolean;
  43725. /**
  43726. * Gets wether the color grading effect is enabled.
  43727. */
  43728. set colorGradingEnabled(value: boolean);
  43729. /**
  43730. * Gets exposure used in the effect.
  43731. */
  43732. get exposure(): number;
  43733. /**
  43734. * Sets exposure used in the effect.
  43735. */
  43736. set exposure(value: number);
  43737. /**
  43738. * Gets wether tonemapping is enabled or not.
  43739. */
  43740. get toneMappingEnabled(): boolean;
  43741. /**
  43742. * Sets wether tonemapping is enabled or not
  43743. */
  43744. set toneMappingEnabled(value: boolean);
  43745. /**
  43746. * Gets the type of tone mapping effect.
  43747. */
  43748. get toneMappingType(): number;
  43749. /**
  43750. * Sets the type of tone mapping effect.
  43751. */
  43752. set toneMappingType(value: number);
  43753. /**
  43754. * Gets contrast used in the effect.
  43755. */
  43756. get contrast(): number;
  43757. /**
  43758. * Sets contrast used in the effect.
  43759. */
  43760. set contrast(value: number);
  43761. /**
  43762. * Gets Vignette stretch size.
  43763. */
  43764. get vignetteStretch(): number;
  43765. /**
  43766. * Sets Vignette stretch size.
  43767. */
  43768. set vignetteStretch(value: number);
  43769. /**
  43770. * Gets Vignette centre X Offset.
  43771. */
  43772. get vignetteCentreX(): number;
  43773. /**
  43774. * Sets Vignette centre X Offset.
  43775. */
  43776. set vignetteCentreX(value: number);
  43777. /**
  43778. * Gets Vignette centre Y Offset.
  43779. */
  43780. get vignetteCentreY(): number;
  43781. /**
  43782. * Sets Vignette centre Y Offset.
  43783. */
  43784. set vignetteCentreY(value: number);
  43785. /**
  43786. * Gets Vignette weight or intensity of the vignette effect.
  43787. */
  43788. get vignetteWeight(): number;
  43789. /**
  43790. * Sets Vignette weight or intensity of the vignette effect.
  43791. */
  43792. set vignetteWeight(value: number);
  43793. /**
  43794. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43795. * if vignetteEnabled is set to true.
  43796. */
  43797. get vignetteColor(): Color4;
  43798. /**
  43799. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43800. * if vignetteEnabled is set to true.
  43801. */
  43802. set vignetteColor(value: Color4);
  43803. /**
  43804. * Gets Camera field of view used by the Vignette effect.
  43805. */
  43806. get vignetteCameraFov(): number;
  43807. /**
  43808. * Sets Camera field of view used by the Vignette effect.
  43809. */
  43810. set vignetteCameraFov(value: number);
  43811. /**
  43812. * Gets the vignette blend mode allowing different kind of effect.
  43813. */
  43814. get vignetteBlendMode(): number;
  43815. /**
  43816. * Sets the vignette blend mode allowing different kind of effect.
  43817. */
  43818. set vignetteBlendMode(value: number);
  43819. /**
  43820. * Gets wether the vignette effect is enabled.
  43821. */
  43822. get vignetteEnabled(): boolean;
  43823. /**
  43824. * Sets wether the vignette effect is enabled.
  43825. */
  43826. set vignetteEnabled(value: boolean);
  43827. private _fromLinearSpace;
  43828. /**
  43829. * Gets wether the input of the processing is in Gamma or Linear Space.
  43830. */
  43831. get fromLinearSpace(): boolean;
  43832. /**
  43833. * Sets wether the input of the processing is in Gamma or Linear Space.
  43834. */
  43835. set fromLinearSpace(value: boolean);
  43836. /**
  43837. * Defines cache preventing GC.
  43838. */
  43839. private _defines;
  43840. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43841. /**
  43842. * "ImageProcessingPostProcess"
  43843. * @returns "ImageProcessingPostProcess"
  43844. */
  43845. getClassName(): string;
  43846. protected _updateParameters(): void;
  43847. dispose(camera?: Camera): void;
  43848. }
  43849. }
  43850. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43851. import { Scene } from "babylonjs/scene";
  43852. import { Color3 } from "babylonjs/Maths/math.color";
  43853. import { Mesh } from "babylonjs/Meshes/mesh";
  43854. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43855. import { Nullable } from "babylonjs/types";
  43856. /**
  43857. * Class containing static functions to help procedurally build meshes
  43858. */
  43859. export class GroundBuilder {
  43860. /**
  43861. * Creates a ground mesh
  43862. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43863. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43865. * @param name defines the name of the mesh
  43866. * @param options defines the options used to create the mesh
  43867. * @param scene defines the hosting scene
  43868. * @returns the ground mesh
  43869. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43870. */
  43871. static CreateGround(name: string, options: {
  43872. width?: number;
  43873. height?: number;
  43874. subdivisions?: number;
  43875. subdivisionsX?: number;
  43876. subdivisionsY?: number;
  43877. updatable?: boolean;
  43878. }, scene: any): Mesh;
  43879. /**
  43880. * Creates a tiled ground mesh
  43881. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43882. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43883. * * 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
  43884. * * 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
  43885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43886. * @param name defines the name of the mesh
  43887. * @param options defines the options used to create the mesh
  43888. * @param scene defines the hosting scene
  43889. * @returns the tiled ground mesh
  43890. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43891. */
  43892. static CreateTiledGround(name: string, options: {
  43893. xmin: number;
  43894. zmin: number;
  43895. xmax: number;
  43896. zmax: number;
  43897. subdivisions?: {
  43898. w: number;
  43899. h: number;
  43900. };
  43901. precision?: {
  43902. w: number;
  43903. h: number;
  43904. };
  43905. updatable?: boolean;
  43906. }, scene?: Nullable<Scene>): Mesh;
  43907. /**
  43908. * Creates a ground mesh from a height map
  43909. * * The parameter `url` sets the URL of the height map image resource.
  43910. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43911. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43912. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43913. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43914. * * 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.
  43915. * * 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).
  43916. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43918. * @param name defines the name of the mesh
  43919. * @param url defines the url to the height map
  43920. * @param options defines the options used to create the mesh
  43921. * @param scene defines the hosting scene
  43922. * @returns the ground mesh
  43923. * @see https://doc.babylonjs.com/babylon101/height_map
  43924. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43925. */
  43926. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43927. width?: number;
  43928. height?: number;
  43929. subdivisions?: number;
  43930. minHeight?: number;
  43931. maxHeight?: number;
  43932. colorFilter?: Color3;
  43933. alphaFilter?: number;
  43934. updatable?: boolean;
  43935. onReady?: (mesh: GroundMesh) => void;
  43936. }, scene?: Nullable<Scene>): GroundMesh;
  43937. }
  43938. }
  43939. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43940. import { Vector4 } from "babylonjs/Maths/math.vector";
  43941. import { Mesh } from "babylonjs/Meshes/mesh";
  43942. /**
  43943. * Class containing static functions to help procedurally build meshes
  43944. */
  43945. export class TorusBuilder {
  43946. /**
  43947. * Creates a torus mesh
  43948. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43949. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43950. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43954. * @param name defines the name of the mesh
  43955. * @param options defines the options used to create the mesh
  43956. * @param scene defines the hosting scene
  43957. * @returns the torus mesh
  43958. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43959. */
  43960. static CreateTorus(name: string, options: {
  43961. diameter?: number;
  43962. thickness?: number;
  43963. tessellation?: number;
  43964. updatable?: boolean;
  43965. sideOrientation?: number;
  43966. frontUVs?: Vector4;
  43967. backUVs?: Vector4;
  43968. }, scene: any): Mesh;
  43969. }
  43970. }
  43971. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43972. import { Vector4 } from "babylonjs/Maths/math.vector";
  43973. import { Color4 } from "babylonjs/Maths/math.color";
  43974. import { Mesh } from "babylonjs/Meshes/mesh";
  43975. /**
  43976. * Class containing static functions to help procedurally build meshes
  43977. */
  43978. export class CylinderBuilder {
  43979. /**
  43980. * Creates a cylinder or a cone mesh
  43981. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43982. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43983. * * 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.
  43984. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43985. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43986. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43987. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43988. * * 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).
  43989. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43990. * * 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).
  43991. * * 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
  43992. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43993. * * 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
  43994. * * 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.
  43995. * * If `enclose` is false, a ring surface is one element.
  43996. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43997. * * 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
  43998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44001. * @param name defines the name of the mesh
  44002. * @param options defines the options used to create the mesh
  44003. * @param scene defines the hosting scene
  44004. * @returns the cylinder mesh
  44005. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44006. */
  44007. static CreateCylinder(name: string, options: {
  44008. height?: number;
  44009. diameterTop?: number;
  44010. diameterBottom?: number;
  44011. diameter?: number;
  44012. tessellation?: number;
  44013. subdivisions?: number;
  44014. arc?: number;
  44015. faceColors?: Color4[];
  44016. faceUV?: Vector4[];
  44017. updatable?: boolean;
  44018. hasRings?: boolean;
  44019. enclose?: boolean;
  44020. cap?: number;
  44021. sideOrientation?: number;
  44022. frontUVs?: Vector4;
  44023. backUVs?: Vector4;
  44024. }, scene: any): Mesh;
  44025. }
  44026. }
  44027. declare module "babylonjs/XR/webXRTypes" {
  44028. import { Nullable } from "babylonjs/types";
  44029. import { IDisposable } from "babylonjs/scene";
  44030. /**
  44031. * States of the webXR experience
  44032. */
  44033. export enum WebXRState {
  44034. /**
  44035. * Transitioning to being in XR mode
  44036. */
  44037. ENTERING_XR = 0,
  44038. /**
  44039. * Transitioning to non XR mode
  44040. */
  44041. EXITING_XR = 1,
  44042. /**
  44043. * In XR mode and presenting
  44044. */
  44045. IN_XR = 2,
  44046. /**
  44047. * Not entered XR mode
  44048. */
  44049. NOT_IN_XR = 3
  44050. }
  44051. /**
  44052. * Abstraction of the XR render target
  44053. */
  44054. export interface WebXRRenderTarget extends IDisposable {
  44055. /**
  44056. * xrpresent 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. }
  44071. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44072. import { Nullable } from "babylonjs/types";
  44073. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44074. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44075. /**
  44076. * COnfiguration object for WebXR output canvas
  44077. */
  44078. export class WebXRManagedOutputCanvasOptions {
  44079. /**
  44080. * An optional canvas in case you wish to create it yourself and provide it here.
  44081. * If not provided, a new canvas will be created
  44082. */
  44083. canvasElement?: HTMLCanvasElement;
  44084. /**
  44085. * Options for this XR Layer output
  44086. */
  44087. canvasOptions?: XRWebGLLayerOptions;
  44088. /**
  44089. * CSS styling for a newly created canvas (if not provided)
  44090. */
  44091. newCanvasCssStyle?: string;
  44092. /**
  44093. * Get the default values of the configuration object
  44094. * @returns default values of this configuration object
  44095. */
  44096. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44097. }
  44098. /**
  44099. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44100. */
  44101. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44102. private _options;
  44103. private _canvas;
  44104. private _engine;
  44105. /**
  44106. * Rendering context of the canvas which can be used to display/mirror xr content
  44107. */
  44108. canvasContext: WebGLRenderingContext;
  44109. /**
  44110. * xr layer for the canvas
  44111. */
  44112. xrLayer: Nullable<XRWebGLLayer>;
  44113. /**
  44114. * Initializes the canvas to be added/removed upon entering/exiting xr
  44115. * @param _xrSessionManager The XR Session manager
  44116. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44117. */
  44118. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44119. /**
  44120. * Disposes of the object
  44121. */
  44122. dispose(): void;
  44123. /**
  44124. * Initializes the xr layer for the session
  44125. * @param xrSession xr session
  44126. * @returns a promise that will resolve once the XR Layer has been created
  44127. */
  44128. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44129. private _addCanvas;
  44130. private _removeCanvas;
  44131. private _setManagedOutputCanvas;
  44132. }
  44133. }
  44134. declare module "babylonjs/XR/webXRSessionManager" {
  44135. import { Observable } from "babylonjs/Misc/observable";
  44136. import { Nullable } from "babylonjs/types";
  44137. import { IDisposable, Scene } from "babylonjs/scene";
  44138. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44139. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44140. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44141. /**
  44142. * Manages an XRSession to work with Babylon's engine
  44143. * @see https://doc.babylonjs.com/how_to/webxr
  44144. */
  44145. export class WebXRSessionManager implements IDisposable {
  44146. /** The scene which the session should be created for */
  44147. scene: Scene;
  44148. private _referenceSpace;
  44149. private _rttProvider;
  44150. private _sessionEnded;
  44151. private _xrNavigator;
  44152. private baseLayer;
  44153. /**
  44154. * The base reference space from which the session started. good if you want to reset your
  44155. * reference space
  44156. */
  44157. baseReferenceSpace: XRReferenceSpace;
  44158. /**
  44159. * Current XR frame
  44160. */
  44161. currentFrame: Nullable<XRFrame>;
  44162. /** WebXR timestamp updated every frame */
  44163. currentTimestamp: number;
  44164. /**
  44165. * Used just in case of a failure to initialize an immersive session.
  44166. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44167. */
  44168. defaultHeightCompensation: number;
  44169. /**
  44170. * Fires every time a new xrFrame arrives which can be used to update the camera
  44171. */
  44172. onXRFrameObservable: Observable<XRFrame>;
  44173. /**
  44174. * Fires when the reference space changed
  44175. */
  44176. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44177. /**
  44178. * Fires when the xr session is ended either by the device or manually done
  44179. */
  44180. onXRSessionEnded: Observable<any>;
  44181. /**
  44182. * Fires when the xr session is ended either by the device or manually done
  44183. */
  44184. onXRSessionInit: Observable<XRSession>;
  44185. /**
  44186. * Underlying xr session
  44187. */
  44188. session: XRSession;
  44189. /**
  44190. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44191. * or get the offset the player is currently at.
  44192. */
  44193. viewerReferenceSpace: XRReferenceSpace;
  44194. /**
  44195. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44196. * @param scene The scene which the session should be created for
  44197. */
  44198. constructor(
  44199. /** The scene which the session should be created for */
  44200. scene: Scene);
  44201. /**
  44202. * The current reference space used in this session. This reference space can constantly change!
  44203. * It is mainly used to offset the camera's position.
  44204. */
  44205. get referenceSpace(): XRReferenceSpace;
  44206. /**
  44207. * Set a new reference space and triggers the observable
  44208. */
  44209. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44210. /**
  44211. * Disposes of the session manager
  44212. */
  44213. dispose(): void;
  44214. /**
  44215. * Stops the xrSession and restores the render loop
  44216. * @returns Promise which resolves after it exits XR
  44217. */
  44218. exitXRAsync(): Promise<void>;
  44219. /**
  44220. * Gets the correct render target texture to be rendered this frame for this eye
  44221. * @param eye the eye for which to get the render target
  44222. * @returns the render target for the specified eye
  44223. */
  44224. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44225. /**
  44226. * Creates a WebXRRenderTarget object for the XR session
  44227. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44228. * @param options optional options to provide when creating a new render target
  44229. * @returns a WebXR render target to which the session can render
  44230. */
  44231. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44232. /**
  44233. * Initializes the manager
  44234. * After initialization enterXR can be called to start an XR session
  44235. * @returns Promise which resolves after it is initialized
  44236. */
  44237. initializeAsync(): Promise<void>;
  44238. /**
  44239. * Initializes an xr session
  44240. * @param xrSessionMode mode to initialize
  44241. * @param xrSessionInit defines optional and required values to pass to the session builder
  44242. * @returns a promise which will resolve once the session has been initialized
  44243. */
  44244. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44245. /**
  44246. * Checks if a session would be supported for the creation options specified
  44247. * @param sessionMode session mode to check if supported eg. immersive-vr
  44248. * @returns A Promise that resolves to true if supported and false if not
  44249. */
  44250. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44251. /**
  44252. * Resets the reference space to the one started the session
  44253. */
  44254. resetReferenceSpace(): void;
  44255. /**
  44256. * Starts rendering to the xr layer
  44257. */
  44258. runXRRenderLoop(): void;
  44259. /**
  44260. * Sets the reference space on the xr session
  44261. * @param referenceSpaceType space to set
  44262. * @returns a promise that will resolve once the reference space has been set
  44263. */
  44264. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44265. /**
  44266. * Updates the render state of the session
  44267. * @param state state to set
  44268. * @returns a promise that resolves once the render state has been updated
  44269. */
  44270. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44271. /**
  44272. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44273. * @param sessionMode defines the session to test
  44274. * @returns a promise with boolean as final value
  44275. */
  44276. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44277. private _createRenderTargetTexture;
  44278. }
  44279. }
  44280. declare module "babylonjs/XR/webXRCamera" {
  44281. import { Scene } from "babylonjs/scene";
  44282. import { Camera } from "babylonjs/Cameras/camera";
  44283. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44284. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44285. /**
  44286. * WebXR Camera which holds the views for the xrSession
  44287. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44288. */
  44289. export class WebXRCamera extends FreeCamera {
  44290. private _xrSessionManager;
  44291. private _firstFrame;
  44292. private _referenceQuaternion;
  44293. private _referencedPosition;
  44294. private _xrInvPositionCache;
  44295. private _xrInvQuaternionCache;
  44296. /**
  44297. * Should position compensation execute on first frame.
  44298. * This is used when copying the position from a native (non XR) camera
  44299. */
  44300. compensateOnFirstFrame: boolean;
  44301. /**
  44302. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44303. * @param name the name of the camera
  44304. * @param scene the scene to add the camera to
  44305. * @param _xrSessionManager a constructed xr session manager
  44306. */
  44307. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44308. /**
  44309. * Return the user's height, unrelated to the current ground.
  44310. * This will be the y position of this camera, when ground level is 0.
  44311. */
  44312. get realWorldHeight(): number;
  44313. /** @hidden */
  44314. _updateForDualEyeDebugging(): void;
  44315. /**
  44316. * Sets this camera's transformation based on a non-vr camera
  44317. * @param otherCamera the non-vr camera to copy the transformation from
  44318. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44319. */
  44320. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44321. /**
  44322. * Gets the current instance class name ("WebXRCamera").
  44323. * @returns the class name
  44324. */
  44325. getClassName(): string;
  44326. private _updateFromXRSession;
  44327. private _updateNumberOfRigCameras;
  44328. private _updateReferenceSpace;
  44329. private _updateReferenceSpaceOffset;
  44330. }
  44331. }
  44332. declare module "babylonjs/XR/webXRFeaturesManager" {
  44333. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44334. import { IDisposable } from "babylonjs/scene";
  44335. /**
  44336. * Defining the interface required for a (webxr) feature
  44337. */
  44338. export interface IWebXRFeature extends IDisposable {
  44339. /**
  44340. * Is this feature attached
  44341. */
  44342. attached: boolean;
  44343. /**
  44344. * Should auto-attach be disabled?
  44345. */
  44346. disableAutoAttach: boolean;
  44347. /**
  44348. * Attach the feature to the session
  44349. * Will usually be called by the features manager
  44350. *
  44351. * @param force should attachment be forced (even when already attached)
  44352. * @returns true if successful.
  44353. */
  44354. attach(force?: boolean): boolean;
  44355. /**
  44356. * Detach the feature from the session
  44357. * Will usually be called by the features manager
  44358. *
  44359. * @returns true if successful.
  44360. */
  44361. detach(): boolean;
  44362. }
  44363. /**
  44364. * A list of the currently available features without referencing them
  44365. */
  44366. export class WebXRFeatureName {
  44367. /**
  44368. * The name of the anchor system feature
  44369. */
  44370. static ANCHOR_SYSTEM: string;
  44371. /**
  44372. * The name of the background remover feature
  44373. */
  44374. static BACKGROUND_REMOVER: string;
  44375. /**
  44376. * The name of the hit test feature
  44377. */
  44378. static HIT_TEST: string;
  44379. /**
  44380. * physics impostors for xr controllers feature
  44381. */
  44382. static PHYSICS_CONTROLLERS: string;
  44383. /**
  44384. * The name of the plane detection feature
  44385. */
  44386. static PLANE_DETECTION: string;
  44387. /**
  44388. * The name of the pointer selection feature
  44389. */
  44390. static POINTER_SELECTION: string;
  44391. /**
  44392. * The name of the teleportation feature
  44393. */
  44394. static TELEPORTATION: string;
  44395. }
  44396. /**
  44397. * Defining the constructor of a feature. Used to register the modules.
  44398. */
  44399. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44400. /**
  44401. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44402. * It is mainly used in AR sessions.
  44403. *
  44404. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44405. */
  44406. export class WebXRFeaturesManager implements IDisposable {
  44407. private _xrSessionManager;
  44408. private static readonly _AvailableFeatures;
  44409. private _features;
  44410. /**
  44411. * constructs a new features manages.
  44412. *
  44413. * @param _xrSessionManager an instance of WebXRSessionManager
  44414. */
  44415. constructor(_xrSessionManager: WebXRSessionManager);
  44416. /**
  44417. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44418. * Mainly used internally.
  44419. *
  44420. * @param featureName the name of the feature to register
  44421. * @param constructorFunction the function used to construct the module
  44422. * @param version the (babylon) version of the module
  44423. * @param stable is that a stable version of this module
  44424. */
  44425. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44426. /**
  44427. * Returns a constructor of a specific feature.
  44428. *
  44429. * @param featureName the name of the feature to construct
  44430. * @param version the version of the feature to load
  44431. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44432. * @param options optional options provided to the module.
  44433. * @returns a function that, when called, will return a new instance of this feature
  44434. */
  44435. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44436. /**
  44437. * Can be used to return the list of features currently registered
  44438. *
  44439. * @returns an Array of available features
  44440. */
  44441. static GetAvailableFeatures(): string[];
  44442. /**
  44443. * Gets the versions available for a specific feature
  44444. * @param featureName the name of the feature
  44445. * @returns an array with the available versions
  44446. */
  44447. static GetAvailableVersions(featureName: string): string[];
  44448. /**
  44449. * Return the latest unstable version of this feature
  44450. * @param featureName the name of the feature to search
  44451. * @returns the version number. if not found will return -1
  44452. */
  44453. static GetLatestVersionOfFeature(featureName: string): number;
  44454. /**
  44455. * Return the latest stable version of this feature
  44456. * @param featureName the name of the feature to search
  44457. * @returns the version number. if not found will return -1
  44458. */
  44459. static GetStableVersionOfFeature(featureName: string): number;
  44460. /**
  44461. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44462. * Can be used during a session to start a feature
  44463. * @param featureName the name of feature to attach
  44464. */
  44465. attachFeature(featureName: string): void;
  44466. /**
  44467. * Can be used inside a session or when the session ends to detach a specific feature
  44468. * @param featureName the name of the feature to detach
  44469. */
  44470. detachFeature(featureName: string): void;
  44471. /**
  44472. * Used to disable an already-enabled feature
  44473. * The feature will be disposed and will be recreated once enabled.
  44474. * @param featureName the feature to disable
  44475. * @returns true if disable was successful
  44476. */
  44477. disableFeature(featureName: string | {
  44478. Name: string;
  44479. }): boolean;
  44480. /**
  44481. * dispose this features manager
  44482. */
  44483. dispose(): void;
  44484. /**
  44485. * 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.
  44486. * 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.
  44487. *
  44488. * @param featureName the name of the feature to load or the class of the feature
  44489. * @param version optional version to load. if not provided the latest version will be enabled
  44490. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44491. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44492. * @returns a new constructed feature or throws an error if feature not found.
  44493. */
  44494. enableFeature(featureName: string | {
  44495. Name: string;
  44496. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44497. /**
  44498. * get the implementation of an enabled feature.
  44499. * @param featureName the name of the feature to load
  44500. * @returns the feature class, if found
  44501. */
  44502. getEnabledFeature(featureName: string): IWebXRFeature;
  44503. /**
  44504. * Get the list of enabled features
  44505. * @returns an array of enabled features
  44506. */
  44507. getEnabledFeatures(): string[];
  44508. }
  44509. }
  44510. declare module "babylonjs/XR/webXRExperienceHelper" {
  44511. import { Observable } from "babylonjs/Misc/observable";
  44512. import { IDisposable, Scene } from "babylonjs/scene";
  44513. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44514. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44515. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44516. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44517. /**
  44518. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44519. * @see https://doc.babylonjs.com/how_to/webxr
  44520. */
  44521. export class WebXRExperienceHelper implements IDisposable {
  44522. private scene;
  44523. private _nonVRCamera;
  44524. private _originalSceneAutoClear;
  44525. private _supported;
  44526. /**
  44527. * Camera used to render xr content
  44528. */
  44529. camera: WebXRCamera;
  44530. /** A features manager for this xr session */
  44531. featuresManager: WebXRFeaturesManager;
  44532. /**
  44533. * Observers registered here will be triggered after the camera's initial transformation is set
  44534. * This can be used to set a different ground level or an extra rotation.
  44535. *
  44536. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44537. * to the position set after this observable is done executing.
  44538. */
  44539. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44540. /**
  44541. * Fires when the state of the experience helper has changed
  44542. */
  44543. onStateChangedObservable: Observable<WebXRState>;
  44544. /** Session manager used to keep track of xr session */
  44545. sessionManager: WebXRSessionManager;
  44546. /**
  44547. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44548. */
  44549. state: WebXRState;
  44550. /**
  44551. * Creates a WebXRExperienceHelper
  44552. * @param scene The scene the helper should be created in
  44553. */
  44554. private constructor();
  44555. /**
  44556. * Creates the experience helper
  44557. * @param scene the scene to attach the experience helper to
  44558. * @returns a promise for the experience helper
  44559. */
  44560. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44561. /**
  44562. * Disposes of the experience helper
  44563. */
  44564. dispose(): void;
  44565. /**
  44566. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44567. * @param sessionMode options for the XR session
  44568. * @param referenceSpaceType frame of reference of the XR session
  44569. * @param renderTarget the output canvas that will be used to enter XR mode
  44570. * @returns promise that resolves after xr mode has entered
  44571. */
  44572. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44573. /**
  44574. * Exits XR mode and returns the scene to its original state
  44575. * @returns promise that resolves after xr mode has exited
  44576. */
  44577. exitXRAsync(): Promise<void>;
  44578. private _nonXRToXRCamera;
  44579. private _setState;
  44580. }
  44581. }
  44582. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44583. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44584. import { Observable } from "babylonjs/Misc/observable";
  44585. import { IDisposable } from "babylonjs/scene";
  44586. /**
  44587. * X-Y values for axes in WebXR
  44588. */
  44589. export interface IWebXRMotionControllerAxesValue {
  44590. /**
  44591. * The value of the x axis
  44592. */
  44593. x: number;
  44594. /**
  44595. * The value of the y-axis
  44596. */
  44597. y: number;
  44598. }
  44599. /**
  44600. * changed / previous values for the values of this component
  44601. */
  44602. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44603. /**
  44604. * current (this frame) value
  44605. */
  44606. current: T;
  44607. /**
  44608. * previous (last change) value
  44609. */
  44610. previous: T;
  44611. }
  44612. /**
  44613. * Represents changes in the component between current frame and last values recorded
  44614. */
  44615. export interface IWebXRMotionControllerComponentChanges {
  44616. /**
  44617. * will be populated with previous and current values if axes changed
  44618. */
  44619. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44620. /**
  44621. * will be populated with previous and current values if pressed changed
  44622. */
  44623. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44624. /**
  44625. * will be populated with previous and current values if touched changed
  44626. */
  44627. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44628. /**
  44629. * will be populated with previous and current values if value changed
  44630. */
  44631. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44632. }
  44633. /**
  44634. * This class represents a single component (for example button or thumbstick) of a motion controller
  44635. */
  44636. export class WebXRControllerComponent implements IDisposable {
  44637. /**
  44638. * the id of this component
  44639. */
  44640. id: string;
  44641. /**
  44642. * the type of the component
  44643. */
  44644. type: MotionControllerComponentType;
  44645. private _buttonIndex;
  44646. private _axesIndices;
  44647. private _axes;
  44648. private _changes;
  44649. private _currentValue;
  44650. private _hasChanges;
  44651. private _pressed;
  44652. private _touched;
  44653. /**
  44654. * button component type
  44655. */
  44656. static BUTTON_TYPE: MotionControllerComponentType;
  44657. /**
  44658. * squeeze component type
  44659. */
  44660. static SQUEEZE_TYPE: MotionControllerComponentType;
  44661. /**
  44662. * Thumbstick component type
  44663. */
  44664. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44665. /**
  44666. * Touchpad component type
  44667. */
  44668. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44669. /**
  44670. * trigger component type
  44671. */
  44672. static TRIGGER_TYPE: MotionControllerComponentType;
  44673. /**
  44674. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44675. * the axes data changes
  44676. */
  44677. onAxisValueChangedObservable: Observable<{
  44678. x: number;
  44679. y: number;
  44680. }>;
  44681. /**
  44682. * Observers registered here will be triggered when the state of a button changes
  44683. * State change is either pressed / touched / value
  44684. */
  44685. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44686. /**
  44687. * Creates a new component for a motion controller.
  44688. * It is created by the motion controller itself
  44689. *
  44690. * @param id the id of this component
  44691. * @param type the type of the component
  44692. * @param _buttonIndex index in the buttons array of the gamepad
  44693. * @param _axesIndices indices of the values in the axes array of the gamepad
  44694. */
  44695. constructor(
  44696. /**
  44697. * the id of this component
  44698. */
  44699. id: string,
  44700. /**
  44701. * the type of the component
  44702. */
  44703. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44704. /**
  44705. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44706. */
  44707. get axes(): IWebXRMotionControllerAxesValue;
  44708. /**
  44709. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44710. */
  44711. get changes(): IWebXRMotionControllerComponentChanges;
  44712. /**
  44713. * Return whether or not the component changed the last frame
  44714. */
  44715. get hasChanges(): boolean;
  44716. /**
  44717. * is the button currently pressed
  44718. */
  44719. get pressed(): boolean;
  44720. /**
  44721. * is the button currently touched
  44722. */
  44723. get touched(): boolean;
  44724. /**
  44725. * Get the current value of this component
  44726. */
  44727. get value(): number;
  44728. /**
  44729. * Dispose this component
  44730. */
  44731. dispose(): void;
  44732. /**
  44733. * Are there axes correlating to this component
  44734. * @return true is axes data is available
  44735. */
  44736. isAxes(): boolean;
  44737. /**
  44738. * Is this component a button (hence - pressable)
  44739. * @returns true if can be pressed
  44740. */
  44741. isButton(): boolean;
  44742. /**
  44743. * update this component using the gamepad object it is in. Called on every frame
  44744. * @param nativeController the native gamepad controller object
  44745. */
  44746. update(nativeController: IMinimalMotionControllerObject): void;
  44747. }
  44748. }
  44749. declare module "babylonjs/Loading/sceneLoader" {
  44750. import { Observable } from "babylonjs/Misc/observable";
  44751. import { Nullable } from "babylonjs/types";
  44752. import { Scene } from "babylonjs/scene";
  44753. import { Engine } from "babylonjs/Engines/engine";
  44754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44755. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44756. import { AssetContainer } from "babylonjs/assetContainer";
  44757. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44758. import { Skeleton } from "babylonjs/Bones/skeleton";
  44759. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44760. import { WebRequest } from "babylonjs/Misc/webRequest";
  44761. /**
  44762. * Class used to represent data loading progression
  44763. */
  44764. export class SceneLoaderProgressEvent {
  44765. /** defines if data length to load can be evaluated */
  44766. readonly lengthComputable: boolean;
  44767. /** defines the loaded data length */
  44768. readonly loaded: number;
  44769. /** defines the data length to load */
  44770. readonly total: number;
  44771. /**
  44772. * Create a new progress event
  44773. * @param lengthComputable defines if data length to load can be evaluated
  44774. * @param loaded defines the loaded data length
  44775. * @param total defines the data length to load
  44776. */
  44777. constructor(
  44778. /** defines if data length to load can be evaluated */
  44779. lengthComputable: boolean,
  44780. /** defines the loaded data length */
  44781. loaded: number,
  44782. /** defines the data length to load */
  44783. total: number);
  44784. /**
  44785. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44786. * @param event defines the source event
  44787. * @returns a new SceneLoaderProgressEvent
  44788. */
  44789. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44790. }
  44791. /**
  44792. * Interface used by SceneLoader plugins to define supported file extensions
  44793. */
  44794. export interface ISceneLoaderPluginExtensions {
  44795. /**
  44796. * Defines the list of supported extensions
  44797. */
  44798. [extension: string]: {
  44799. isBinary: boolean;
  44800. };
  44801. }
  44802. /**
  44803. * Interface used by SceneLoader plugin factory
  44804. */
  44805. export interface ISceneLoaderPluginFactory {
  44806. /**
  44807. * Defines the name of the factory
  44808. */
  44809. name: string;
  44810. /**
  44811. * Function called to create a new plugin
  44812. * @return the new plugin
  44813. */
  44814. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44815. /**
  44816. * The callback that returns true if the data can be directly loaded.
  44817. * @param data string containing the file data
  44818. * @returns if the data can be loaded directly
  44819. */
  44820. canDirectLoad?(data: string): boolean;
  44821. }
  44822. /**
  44823. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44824. */
  44825. export interface ISceneLoaderPluginBase {
  44826. /**
  44827. * The friendly name of this plugin.
  44828. */
  44829. name: string;
  44830. /**
  44831. * The file extensions supported by this plugin.
  44832. */
  44833. extensions: string | ISceneLoaderPluginExtensions;
  44834. /**
  44835. * The callback called when loading from a url.
  44836. * @param scene scene loading this url
  44837. * @param url url to load
  44838. * @param onSuccess callback called when the file successfully loads
  44839. * @param onProgress callback called while file is loading (if the server supports this mode)
  44840. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44841. * @param onError callback called when the file fails to load
  44842. * @returns a file request object
  44843. */
  44844. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44845. /**
  44846. * The callback called when loading from a file object.
  44847. * @param scene scene loading this file
  44848. * @param file defines the file to load
  44849. * @param onSuccess defines the callback to call when data is loaded
  44850. * @param onProgress defines the callback to call during loading process
  44851. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44852. * @param onError defines the callback to call when an error occurs
  44853. * @returns a file request object
  44854. */
  44855. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44856. /**
  44857. * The callback that returns true if the data can be directly loaded.
  44858. * @param data string containing the file data
  44859. * @returns if the data can be loaded directly
  44860. */
  44861. canDirectLoad?(data: string): boolean;
  44862. /**
  44863. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44864. * @param scene scene loading this data
  44865. * @param data string containing the data
  44866. * @returns data to pass to the plugin
  44867. */
  44868. directLoad?(scene: Scene, data: string): any;
  44869. /**
  44870. * The callback that allows custom handling of the root url based on the response url.
  44871. * @param rootUrl the original root url
  44872. * @param responseURL the response url if available
  44873. * @returns the new root url
  44874. */
  44875. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44876. }
  44877. /**
  44878. * Interface used to define a SceneLoader plugin
  44879. */
  44880. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44881. /**
  44882. * Import meshes into a scene.
  44883. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44884. * @param scene The scene to import into
  44885. * @param data The data to import
  44886. * @param rootUrl The root url for scene and resources
  44887. * @param meshes The meshes array to import into
  44888. * @param particleSystems The particle systems array to import into
  44889. * @param skeletons The skeletons array to import into
  44890. * @param onError The callback when import fails
  44891. * @returns True if successful or false otherwise
  44892. */
  44893. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44894. /**
  44895. * Load into a scene.
  44896. * @param scene The scene to load into
  44897. * @param data The data to import
  44898. * @param rootUrl The root url for scene and resources
  44899. * @param onError The callback when import fails
  44900. * @returns True if successful or false otherwise
  44901. */
  44902. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44903. /**
  44904. * Load into an asset container.
  44905. * @param scene The scene to load into
  44906. * @param data The data to import
  44907. * @param rootUrl The root url for scene and resources
  44908. * @param onError The callback when import fails
  44909. * @returns The loaded asset container
  44910. */
  44911. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44912. }
  44913. /**
  44914. * Interface used to define an async SceneLoader plugin
  44915. */
  44916. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44917. /**
  44918. * Import meshes into a scene.
  44919. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44920. * @param scene The scene to import into
  44921. * @param data The data to import
  44922. * @param rootUrl The root url for scene and resources
  44923. * @param onProgress The callback when the load progresses
  44924. * @param fileName Defines the name of the file to load
  44925. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44926. */
  44927. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44928. meshes: AbstractMesh[];
  44929. particleSystems: IParticleSystem[];
  44930. skeletons: Skeleton[];
  44931. animationGroups: AnimationGroup[];
  44932. }>;
  44933. /**
  44934. * Load into a scene.
  44935. * @param scene The scene to load into
  44936. * @param data The data to import
  44937. * @param rootUrl The root url for scene and resources
  44938. * @param onProgress The callback when the load progresses
  44939. * @param fileName Defines the name of the file to load
  44940. * @returns Nothing
  44941. */
  44942. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44943. /**
  44944. * Load into an asset container.
  44945. * @param scene The scene to load into
  44946. * @param data The data to import
  44947. * @param rootUrl The root url for scene and resources
  44948. * @param onProgress The callback when the load progresses
  44949. * @param fileName Defines the name of the file to load
  44950. * @returns The loaded asset container
  44951. */
  44952. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44953. }
  44954. /**
  44955. * Mode that determines how to handle old animation groups before loading new ones.
  44956. */
  44957. export enum SceneLoaderAnimationGroupLoadingMode {
  44958. /**
  44959. * Reset all old animations to initial state then dispose them.
  44960. */
  44961. Clean = 0,
  44962. /**
  44963. * Stop all old animations.
  44964. */
  44965. Stop = 1,
  44966. /**
  44967. * Restart old animations from first frame.
  44968. */
  44969. Sync = 2,
  44970. /**
  44971. * Old animations remains untouched.
  44972. */
  44973. NoSync = 3
  44974. }
  44975. /**
  44976. * Class used to load scene from various file formats using registered plugins
  44977. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44978. */
  44979. export class SceneLoader {
  44980. /**
  44981. * No logging while loading
  44982. */
  44983. static readonly NO_LOGGING: number;
  44984. /**
  44985. * Minimal logging while loading
  44986. */
  44987. static readonly MINIMAL_LOGGING: number;
  44988. /**
  44989. * Summary logging while loading
  44990. */
  44991. static readonly SUMMARY_LOGGING: number;
  44992. /**
  44993. * Detailled logging while loading
  44994. */
  44995. static readonly DETAILED_LOGGING: number;
  44996. /**
  44997. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44998. */
  44999. static get ForceFullSceneLoadingForIncremental(): boolean;
  45000. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45001. /**
  45002. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45003. */
  45004. static get ShowLoadingScreen(): boolean;
  45005. static set ShowLoadingScreen(value: boolean);
  45006. /**
  45007. * Defines the current logging level (while loading the scene)
  45008. * @ignorenaming
  45009. */
  45010. static get loggingLevel(): number;
  45011. static set loggingLevel(value: number);
  45012. /**
  45013. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45014. */
  45015. static get CleanBoneMatrixWeights(): boolean;
  45016. static set CleanBoneMatrixWeights(value: boolean);
  45017. /**
  45018. * Event raised when a plugin is used to load a scene
  45019. */
  45020. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45021. private static _registeredPlugins;
  45022. private static _getDefaultPlugin;
  45023. private static _getPluginForExtension;
  45024. private static _getPluginForDirectLoad;
  45025. private static _getPluginForFilename;
  45026. private static _getDirectLoad;
  45027. private static _loadData;
  45028. private static _getFileInfo;
  45029. /**
  45030. * Gets a plugin that can load the given extension
  45031. * @param extension defines the extension to load
  45032. * @returns a plugin or null if none works
  45033. */
  45034. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45035. /**
  45036. * Gets a boolean indicating that the given extension can be loaded
  45037. * @param extension defines the extension to load
  45038. * @returns true if the extension is supported
  45039. */
  45040. static IsPluginForExtensionAvailable(extension: string): boolean;
  45041. /**
  45042. * Adds a new plugin to the list of registered plugins
  45043. * @param plugin defines the plugin to add
  45044. */
  45045. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45046. /**
  45047. * Import meshes into a scene
  45048. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45049. * @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)
  45050. * @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)
  45051. * @param scene the instance of BABYLON.Scene to append to
  45052. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45053. * @param onProgress a callback with a progress event for each file being loaded
  45054. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45055. * @param pluginExtension the extension used to determine the plugin
  45056. * @returns The loaded plugin
  45057. */
  45058. 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>;
  45059. /**
  45060. * Import meshes into a scene
  45061. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45062. * @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)
  45063. * @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)
  45064. * @param scene the instance of BABYLON.Scene to append to
  45065. * @param onProgress a callback with a progress event for each file being loaded
  45066. * @param pluginExtension the extension used to determine the plugin
  45067. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45068. */
  45069. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45070. meshes: AbstractMesh[];
  45071. particleSystems: IParticleSystem[];
  45072. skeletons: Skeleton[];
  45073. animationGroups: AnimationGroup[];
  45074. }>;
  45075. /**
  45076. * Load a scene
  45077. * @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)
  45078. * @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)
  45079. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45080. * @param onSuccess a callback with the scene when import succeeds
  45081. * @param onProgress a callback with a progress event for each file being loaded
  45082. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45083. * @param pluginExtension the extension used to determine the plugin
  45084. * @returns The loaded plugin
  45085. */
  45086. 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>;
  45087. /**
  45088. * Load a scene
  45089. * @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)
  45090. * @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)
  45091. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45092. * @param onProgress a callback with a progress event for each file being loaded
  45093. * @param pluginExtension the extension used to determine the plugin
  45094. * @returns The loaded scene
  45095. */
  45096. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45097. /**
  45098. * Append a scene
  45099. * @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)
  45100. * @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)
  45101. * @param scene is the instance of BABYLON.Scene to append to
  45102. * @param onSuccess a callback with the scene when import succeeds
  45103. * @param onProgress a callback with a progress event for each file being loaded
  45104. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45105. * @param pluginExtension the extension used to determine the plugin
  45106. * @returns The loaded plugin
  45107. */
  45108. 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>;
  45109. /**
  45110. * Append a scene
  45111. * @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)
  45112. * @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)
  45113. * @param scene is the instance of BABYLON.Scene to append to
  45114. * @param onProgress a callback with a progress event for each file being loaded
  45115. * @param pluginExtension the extension used to determine the plugin
  45116. * @returns The given scene
  45117. */
  45118. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45119. /**
  45120. * Load a scene into an asset container
  45121. * @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)
  45122. * @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)
  45123. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45124. * @param onSuccess a callback with the scene when import succeeds
  45125. * @param onProgress a callback with a progress event for each file being loaded
  45126. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45127. * @param pluginExtension the extension used to determine the plugin
  45128. * @returns The loaded plugin
  45129. */
  45130. 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>;
  45131. /**
  45132. * Load a scene into an asset container
  45133. * @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)
  45134. * @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)
  45135. * @param scene is the instance of Scene to append to
  45136. * @param onProgress a callback with a progress event for each file being loaded
  45137. * @param pluginExtension the extension used to determine the plugin
  45138. * @returns The loaded asset container
  45139. */
  45140. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45141. /**
  45142. * Import animations from a file into a scene
  45143. * @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)
  45144. * @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)
  45145. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45146. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45147. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45148. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45149. * @param onSuccess a callback with the scene when import succeeds
  45150. * @param onProgress a callback with a progress event for each file being loaded
  45151. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45152. */
  45153. 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;
  45154. /**
  45155. * Import animations from a file into a scene
  45156. * @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)
  45157. * @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)
  45158. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45159. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45160. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45161. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45162. * @param onSuccess a callback with the scene when import succeeds
  45163. * @param onProgress a callback with a progress event for each file being loaded
  45164. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45165. * @returns the updated scene with imported animations
  45166. */
  45167. 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>;
  45168. }
  45169. }
  45170. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45171. import { IDisposable, Scene } from "babylonjs/scene";
  45172. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45173. import { Observable } from "babylonjs/Misc/observable";
  45174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45175. import { Nullable } from "babylonjs/types";
  45176. /**
  45177. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45178. */
  45179. export type MotionControllerHandness = "none" | "left" | "right";
  45180. /**
  45181. * The type of components available in motion controllers.
  45182. * This is not the name of the component.
  45183. */
  45184. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45185. /**
  45186. * The state of a controller component
  45187. */
  45188. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45189. /**
  45190. * The schema of motion controller layout.
  45191. * No object will be initialized using this interface
  45192. * This is used just to define the profile.
  45193. */
  45194. export interface IMotionControllerLayout {
  45195. /**
  45196. * Path to load the assets. Usually relative to the base path
  45197. */
  45198. assetPath: string;
  45199. /**
  45200. * Available components (unsorted)
  45201. */
  45202. components: {
  45203. /**
  45204. * A map of component Ids
  45205. */
  45206. [componentId: string]: {
  45207. /**
  45208. * The type of input the component outputs
  45209. */
  45210. type: MotionControllerComponentType;
  45211. /**
  45212. * The indices of this component in the gamepad object
  45213. */
  45214. gamepadIndices: {
  45215. /**
  45216. * Index of button
  45217. */
  45218. button?: number;
  45219. /**
  45220. * If available, index of x-axis
  45221. */
  45222. xAxis?: number;
  45223. /**
  45224. * If available, index of y-axis
  45225. */
  45226. yAxis?: number;
  45227. };
  45228. /**
  45229. * The mesh's root node name
  45230. */
  45231. rootNodeName: string;
  45232. /**
  45233. * Animation definitions for this model
  45234. */
  45235. visualResponses: {
  45236. [stateKey: string]: {
  45237. /**
  45238. * What property will be animated
  45239. */
  45240. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45241. /**
  45242. * What states influence this visual response
  45243. */
  45244. states: MotionControllerComponentStateType[];
  45245. /**
  45246. * Type of animation - movement or visibility
  45247. */
  45248. valueNodeProperty: "transform" | "visibility";
  45249. /**
  45250. * Base node name to move. Its position will be calculated according to the min and max nodes
  45251. */
  45252. valueNodeName?: string;
  45253. /**
  45254. * Minimum movement node
  45255. */
  45256. minNodeName?: string;
  45257. /**
  45258. * Max movement node
  45259. */
  45260. maxNodeName?: string;
  45261. };
  45262. };
  45263. /**
  45264. * If touch enabled, what is the name of node to display user feedback
  45265. */
  45266. touchPointNodeName?: string;
  45267. };
  45268. };
  45269. /**
  45270. * Is it xr standard mapping or not
  45271. */
  45272. gamepadMapping: "" | "xr-standard";
  45273. /**
  45274. * Base root node of this entire model
  45275. */
  45276. rootNodeName: string;
  45277. /**
  45278. * Defines the main button component id
  45279. */
  45280. selectComponentId: string;
  45281. }
  45282. /**
  45283. * A definition for the layout map in the input profile
  45284. */
  45285. export interface IMotionControllerLayoutMap {
  45286. /**
  45287. * Layouts with handness type as a key
  45288. */
  45289. [handness: string]: IMotionControllerLayout;
  45290. }
  45291. /**
  45292. * The XR Input profile schema
  45293. * Profiles can be found here:
  45294. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45295. */
  45296. export interface IMotionControllerProfile {
  45297. /**
  45298. * fallback profiles for this profileId
  45299. */
  45300. fallbackProfileIds: string[];
  45301. /**
  45302. * The layout map, with handness as key
  45303. */
  45304. layouts: IMotionControllerLayoutMap;
  45305. /**
  45306. * The id of this profile
  45307. * correlates to the profile(s) in the xrInput.profiles array
  45308. */
  45309. profileId: string;
  45310. }
  45311. /**
  45312. * A helper-interface for the 3 meshes needed for controller button animation
  45313. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45314. */
  45315. export interface IMotionControllerButtonMeshMap {
  45316. /**
  45317. * the mesh that defines the pressed value mesh position.
  45318. * This is used to find the max-position of this button
  45319. */
  45320. pressedMesh: AbstractMesh;
  45321. /**
  45322. * the mesh that defines the unpressed value mesh position.
  45323. * This is used to find the min (or initial) position of this button
  45324. */
  45325. unpressedMesh: AbstractMesh;
  45326. /**
  45327. * The mesh that will be changed when value changes
  45328. */
  45329. valueMesh: AbstractMesh;
  45330. }
  45331. /**
  45332. * A helper-interface for the 3 meshes needed for controller axis animation.
  45333. * This will be expanded when touchpad animations are fully supported
  45334. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45335. */
  45336. export interface IMotionControllerMeshMap {
  45337. /**
  45338. * the mesh that defines the maximum value mesh position.
  45339. */
  45340. maxMesh?: AbstractMesh;
  45341. /**
  45342. * the mesh that defines the minimum value mesh position.
  45343. */
  45344. minMesh?: AbstractMesh;
  45345. /**
  45346. * The mesh that will be changed when axis value changes
  45347. */
  45348. valueMesh: AbstractMesh;
  45349. }
  45350. /**
  45351. * The elements needed for change-detection of the gamepad objects in motion controllers
  45352. */
  45353. export interface IMinimalMotionControllerObject {
  45354. /**
  45355. * Available axes of this controller
  45356. */
  45357. axes: number[];
  45358. /**
  45359. * An array of available buttons
  45360. */
  45361. buttons: Array<{
  45362. /**
  45363. * Value of the button/trigger
  45364. */
  45365. value: number;
  45366. /**
  45367. * If the button/trigger is currently touched
  45368. */
  45369. touched: boolean;
  45370. /**
  45371. * If the button/trigger is currently pressed
  45372. */
  45373. pressed: boolean;
  45374. }>;
  45375. }
  45376. /**
  45377. * An Abstract Motion controller
  45378. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45379. * Each component has an observable to check for changes in value and state
  45380. */
  45381. export abstract class WebXRAbstractMotionController implements IDisposable {
  45382. protected scene: Scene;
  45383. protected layout: IMotionControllerLayout;
  45384. /**
  45385. * The gamepad object correlating to this controller
  45386. */
  45387. gamepadObject: IMinimalMotionControllerObject;
  45388. /**
  45389. * handness (left/right/none) of this controller
  45390. */
  45391. handness: MotionControllerHandness;
  45392. private _initComponent;
  45393. private _modelReady;
  45394. /**
  45395. * A map of components (WebXRControllerComponent) in this motion controller
  45396. * Components have a ComponentType and can also have both button and axis definitions
  45397. */
  45398. readonly components: {
  45399. [id: string]: WebXRControllerComponent;
  45400. };
  45401. /**
  45402. * Disable the model's animation. Can be set at any time.
  45403. */
  45404. disableAnimation: boolean;
  45405. /**
  45406. * Observers registered here will be triggered when the model of this controller is done loading
  45407. */
  45408. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45409. /**
  45410. * The profile id of this motion controller
  45411. */
  45412. abstract profileId: string;
  45413. /**
  45414. * The root mesh of the model. It is null if the model was not yet initialized
  45415. */
  45416. rootMesh: Nullable<AbstractMesh>;
  45417. /**
  45418. * constructs a new abstract motion controller
  45419. * @param scene the scene to which the model of the controller will be added
  45420. * @param layout The profile layout to load
  45421. * @param gamepadObject The gamepad object correlating to this controller
  45422. * @param handness handness (left/right/none) of this controller
  45423. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45424. */
  45425. constructor(scene: Scene, layout: IMotionControllerLayout,
  45426. /**
  45427. * The gamepad object correlating to this controller
  45428. */
  45429. gamepadObject: IMinimalMotionControllerObject,
  45430. /**
  45431. * handness (left/right/none) of this controller
  45432. */
  45433. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45434. /**
  45435. * Dispose this controller, the model mesh and all its components
  45436. */
  45437. dispose(): void;
  45438. /**
  45439. * Returns all components of specific type
  45440. * @param type the type to search for
  45441. * @return an array of components with this type
  45442. */
  45443. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45444. /**
  45445. * get a component based an its component id as defined in layout.components
  45446. * @param id the id of the component
  45447. * @returns the component correlates to the id or undefined if not found
  45448. */
  45449. getComponent(id: string): WebXRControllerComponent;
  45450. /**
  45451. * Get the list of components available in this motion controller
  45452. * @returns an array of strings correlating to available components
  45453. */
  45454. getComponentIds(): string[];
  45455. /**
  45456. * Get the first component of specific type
  45457. * @param type type of component to find
  45458. * @return a controller component or null if not found
  45459. */
  45460. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45461. /**
  45462. * Get the main (Select) component of this controller as defined in the layout
  45463. * @returns the main component of this controller
  45464. */
  45465. getMainComponent(): WebXRControllerComponent;
  45466. /**
  45467. * Loads the model correlating to this controller
  45468. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45469. * @returns A promise fulfilled with the result of the model loading
  45470. */
  45471. loadModel(): Promise<boolean>;
  45472. /**
  45473. * Update this model using the current XRFrame
  45474. * @param xrFrame the current xr frame to use and update the model
  45475. */
  45476. updateFromXRFrame(xrFrame: XRFrame): void;
  45477. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45478. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45479. /**
  45480. * Moves the axis on the controller mesh based on its current state
  45481. * @param axis the index of the axis
  45482. * @param axisValue the value of the axis which determines the meshes new position
  45483. * @hidden
  45484. */
  45485. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45486. /**
  45487. * Update the model itself with the current frame data
  45488. * @param xrFrame the frame to use for updating the model mesh
  45489. */
  45490. protected updateModel(xrFrame: XRFrame): void;
  45491. /**
  45492. * Get the filename and path for this controller's model
  45493. * @returns a map of filename and path
  45494. */
  45495. protected abstract _getFilenameAndPath(): {
  45496. filename: string;
  45497. path: string;
  45498. };
  45499. /**
  45500. * This function is called before the mesh is loaded. It checks for loading constraints.
  45501. * For example, this function can check if the GLB loader is available
  45502. * If this function returns false, the generic controller will be loaded instead
  45503. * @returns Is the client ready to load the mesh
  45504. */
  45505. protected abstract _getModelLoadingConstraints(): boolean;
  45506. /**
  45507. * This function will be called after the model was successfully loaded and can be used
  45508. * for mesh transformations before it is available for the user
  45509. * @param meshes the loaded meshes
  45510. */
  45511. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45512. /**
  45513. * Set the root mesh for this controller. Important for the WebXR controller class
  45514. * @param meshes the loaded meshes
  45515. */
  45516. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45517. /**
  45518. * A function executed each frame that updates the mesh (if needed)
  45519. * @param xrFrame the current xrFrame
  45520. */
  45521. protected abstract _updateModel(xrFrame: XRFrame): void;
  45522. private _getGenericFilenameAndPath;
  45523. private _getGenericParentMesh;
  45524. }
  45525. }
  45526. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45527. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45529. import { Scene } from "babylonjs/scene";
  45530. /**
  45531. * A generic trigger-only motion controller for WebXR
  45532. */
  45533. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45534. /**
  45535. * Static version of the profile id of this controller
  45536. */
  45537. static ProfileId: string;
  45538. profileId: string;
  45539. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45540. protected _getFilenameAndPath(): {
  45541. filename: string;
  45542. path: string;
  45543. };
  45544. protected _getModelLoadingConstraints(): boolean;
  45545. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45546. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45547. protected _updateModel(): void;
  45548. }
  45549. }
  45550. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45551. import { Vector4 } from "babylonjs/Maths/math.vector";
  45552. import { Mesh } from "babylonjs/Meshes/mesh";
  45553. import { Scene } from "babylonjs/scene";
  45554. import { Nullable } from "babylonjs/types";
  45555. /**
  45556. * Class containing static functions to help procedurally build meshes
  45557. */
  45558. export class SphereBuilder {
  45559. /**
  45560. * Creates a sphere mesh
  45561. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45562. * * 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`)
  45563. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45564. * * 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
  45565. * * 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)
  45566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45569. * @param name defines the name of the mesh
  45570. * @param options defines the options used to create the mesh
  45571. * @param scene defines the hosting scene
  45572. * @returns the sphere mesh
  45573. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45574. */
  45575. static CreateSphere(name: string, options: {
  45576. segments?: number;
  45577. diameter?: number;
  45578. diameterX?: number;
  45579. diameterY?: number;
  45580. diameterZ?: number;
  45581. arc?: number;
  45582. slice?: number;
  45583. sideOrientation?: number;
  45584. frontUVs?: Vector4;
  45585. backUVs?: Vector4;
  45586. updatable?: boolean;
  45587. }, scene?: Nullable<Scene>): Mesh;
  45588. }
  45589. }
  45590. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45592. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45593. import { Scene } from "babylonjs/scene";
  45594. /**
  45595. * A profiled motion controller has its profile loaded from an online repository.
  45596. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45597. */
  45598. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45599. private _repositoryUrl;
  45600. private _buttonMeshMapping;
  45601. private _touchDots;
  45602. /**
  45603. * The profile ID of this controller. Will be populated when the controller initializes.
  45604. */
  45605. profileId: string;
  45606. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45607. dispose(): void;
  45608. protected _getFilenameAndPath(): {
  45609. filename: string;
  45610. path: string;
  45611. };
  45612. protected _getModelLoadingConstraints(): boolean;
  45613. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45614. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45615. protected _updateModel(_xrFrame: XRFrame): void;
  45616. }
  45617. }
  45618. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45619. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45620. import { Scene } from "babylonjs/scene";
  45621. /**
  45622. * A construction function type to create a new controller based on an xrInput object
  45623. */
  45624. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45625. /**
  45626. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45627. *
  45628. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45629. * it should be replaced with auto-loaded controllers.
  45630. *
  45631. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45632. */
  45633. export class WebXRMotionControllerManager {
  45634. private static _AvailableControllers;
  45635. private static _Fallbacks;
  45636. private static _ProfileLoadingPromises;
  45637. private static _ProfilesList;
  45638. /**
  45639. * The base URL of the online controller repository. Can be changed at any time.
  45640. */
  45641. static BaseRepositoryUrl: string;
  45642. /**
  45643. * Which repository gets priority - local or online
  45644. */
  45645. static PrioritizeOnlineRepository: boolean;
  45646. /**
  45647. * Use the online repository, or use only locally-defined controllers
  45648. */
  45649. static UseOnlineRepository: boolean;
  45650. /**
  45651. * Clear the cache used for profile loading and reload when requested again
  45652. */
  45653. static ClearProfilesCache(): void;
  45654. /**
  45655. * Register the default fallbacks.
  45656. * This function is called automatically when this file is imported.
  45657. */
  45658. static DefaultFallbacks(): void;
  45659. /**
  45660. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45661. * @param profileId the profile to which a fallback needs to be found
  45662. * @return an array with corresponding fallback profiles
  45663. */
  45664. static FindFallbackWithProfileId(profileId: string): string[];
  45665. /**
  45666. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45667. * The order of search:
  45668. *
  45669. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45670. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45671. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45672. * 4) return the generic trigger controller if none were found
  45673. *
  45674. * @param xrInput the xrInput to which a new controller is initialized
  45675. * @param scene the scene to which the model will be added
  45676. * @param forceProfile force a certain profile for this controller
  45677. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45678. */
  45679. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45680. /**
  45681. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45682. *
  45683. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45684. *
  45685. * @param type the profile type to register
  45686. * @param constructFunction the function to be called when loading this profile
  45687. */
  45688. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45689. /**
  45690. * Register a fallback to a specific profile.
  45691. * @param profileId the profileId that will receive the fallbacks
  45692. * @param fallbacks A list of fallback profiles
  45693. */
  45694. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45695. /**
  45696. * Will update the list of profiles available in the repository
  45697. * @return a promise that resolves to a map of profiles available online
  45698. */
  45699. static UpdateProfilesList(): Promise<{
  45700. [profile: string]: string;
  45701. }>;
  45702. private static _LoadProfileFromRepository;
  45703. private static _LoadProfilesFromAvailableControllers;
  45704. }
  45705. }
  45706. declare module "babylonjs/XR/webXRInputSource" {
  45707. import { Observable } from "babylonjs/Misc/observable";
  45708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45709. import { Ray } from "babylonjs/Culling/ray";
  45710. import { Scene } from "babylonjs/scene";
  45711. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45712. /**
  45713. * Configuration options for the WebXR controller creation
  45714. */
  45715. export interface IWebXRControllerOptions {
  45716. /**
  45717. * Should the controller mesh be animated when a user interacts with it
  45718. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45719. */
  45720. disableMotionControllerAnimation?: boolean;
  45721. /**
  45722. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45723. */
  45724. doNotLoadControllerMesh?: boolean;
  45725. /**
  45726. * Force a specific controller type for this controller.
  45727. * This can be used when creating your own profile or when testing different controllers
  45728. */
  45729. forceControllerProfile?: string;
  45730. }
  45731. /**
  45732. * Represents an XR controller
  45733. */
  45734. export class WebXRInputSource {
  45735. private _scene;
  45736. /** The underlying input source for the controller */
  45737. inputSource: XRInputSource;
  45738. private _options;
  45739. private _tmpQuaternion;
  45740. private _tmpVector;
  45741. private _uniqueId;
  45742. /**
  45743. * 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
  45744. */
  45745. grip?: AbstractMesh;
  45746. /**
  45747. * If available, this is the gamepad object related to this controller.
  45748. * Using this object it is possible to get click events and trackpad changes of the
  45749. * webxr controller that is currently being used.
  45750. */
  45751. motionController?: WebXRAbstractMotionController;
  45752. /**
  45753. * Event that fires when the controller is removed/disposed.
  45754. * The object provided as event data is this controller, after associated assets were disposed.
  45755. * uniqueId is still available.
  45756. */
  45757. onDisposeObservable: Observable<WebXRInputSource>;
  45758. /**
  45759. * Will be triggered when the mesh associated with the motion controller is done loading.
  45760. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45761. * A shortened version of controller -> motion controller -> on mesh loaded.
  45762. */
  45763. onMeshLoadedObservable: Observable<AbstractMesh>;
  45764. /**
  45765. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45766. */
  45767. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45768. /**
  45769. * Pointer which can be used to select objects or attach a visible laser to
  45770. */
  45771. pointer: AbstractMesh;
  45772. /**
  45773. * Creates the controller
  45774. * @see https://doc.babylonjs.com/how_to/webxr
  45775. * @param _scene the scene which the controller should be associated to
  45776. * @param inputSource the underlying input source for the controller
  45777. * @param _options options for this controller creation
  45778. */
  45779. constructor(_scene: Scene,
  45780. /** The underlying input source for the controller */
  45781. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45782. /**
  45783. * Get this controllers unique id
  45784. */
  45785. get uniqueId(): string;
  45786. /**
  45787. * Disposes of the object
  45788. */
  45789. dispose(): void;
  45790. /**
  45791. * Gets a world space ray coming from the pointer or grip
  45792. * @param result the resulting ray
  45793. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45794. */
  45795. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45796. /**
  45797. * Updates the controller pose based on the given XRFrame
  45798. * @param xrFrame xr frame to update the pose with
  45799. * @param referenceSpace reference space to use
  45800. */
  45801. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45802. }
  45803. }
  45804. declare module "babylonjs/XR/webXRInput" {
  45805. import { Observable } from "babylonjs/Misc/observable";
  45806. import { IDisposable } from "babylonjs/scene";
  45807. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45808. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45809. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45810. /**
  45811. * The schema for initialization options of the XR Input class
  45812. */
  45813. export interface IWebXRInputOptions {
  45814. /**
  45815. * If set to true no model will be automatically loaded
  45816. */
  45817. doNotLoadControllerMeshes?: boolean;
  45818. /**
  45819. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45820. * If not found, the xr input profile data will be used.
  45821. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45822. */
  45823. forceInputProfile?: string;
  45824. /**
  45825. * Do not send a request to the controller repository to load the profile.
  45826. *
  45827. * Instead, use the controllers available in babylon itself.
  45828. */
  45829. disableOnlineControllerRepository?: boolean;
  45830. /**
  45831. * A custom URL for the controllers repository
  45832. */
  45833. customControllersRepositoryURL?: string;
  45834. /**
  45835. * Should the controller model's components not move according to the user input
  45836. */
  45837. disableControllerAnimation?: boolean;
  45838. }
  45839. /**
  45840. * XR input used to track XR inputs such as controllers/rays
  45841. */
  45842. export class WebXRInput implements IDisposable {
  45843. /**
  45844. * the xr session manager for this session
  45845. */
  45846. xrSessionManager: WebXRSessionManager;
  45847. /**
  45848. * the WebXR camera for this session. Mainly used for teleportation
  45849. */
  45850. xrCamera: WebXRCamera;
  45851. private readonly options;
  45852. /**
  45853. * XR controllers being tracked
  45854. */
  45855. controllers: Array<WebXRInputSource>;
  45856. private _frameObserver;
  45857. private _sessionEndedObserver;
  45858. private _sessionInitObserver;
  45859. /**
  45860. * Event when a controller has been connected/added
  45861. */
  45862. onControllerAddedObservable: Observable<WebXRInputSource>;
  45863. /**
  45864. * Event when a controller has been removed/disconnected
  45865. */
  45866. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45867. /**
  45868. * Initializes the WebXRInput
  45869. * @param xrSessionManager the xr session manager for this session
  45870. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45871. * @param options = initialization options for this xr input
  45872. */
  45873. constructor(
  45874. /**
  45875. * the xr session manager for this session
  45876. */
  45877. xrSessionManager: WebXRSessionManager,
  45878. /**
  45879. * the WebXR camera for this session. Mainly used for teleportation
  45880. */
  45881. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45882. private _onInputSourcesChange;
  45883. private _addAndRemoveControllers;
  45884. /**
  45885. * Disposes of the object
  45886. */
  45887. dispose(): void;
  45888. }
  45889. }
  45890. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45891. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45892. import { Observable, EventState } from "babylonjs/Misc/observable";
  45893. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45894. /**
  45895. * This is the base class for all WebXR features.
  45896. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45897. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45898. */
  45899. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45900. protected _xrSessionManager: WebXRSessionManager;
  45901. private _attached;
  45902. private _removeOnDetach;
  45903. /**
  45904. * Should auto-attach be disabled?
  45905. */
  45906. disableAutoAttach: boolean;
  45907. /**
  45908. * Construct a new (abstract) WebXR feature
  45909. * @param _xrSessionManager the xr session manager for this feature
  45910. */
  45911. constructor(_xrSessionManager: WebXRSessionManager);
  45912. /**
  45913. * Is this feature attached
  45914. */
  45915. get attached(): boolean;
  45916. /**
  45917. * attach this feature
  45918. *
  45919. * @param force should attachment be forced (even when already attached)
  45920. * @returns true if successful, false is failed or already attached
  45921. */
  45922. attach(force?: boolean): boolean;
  45923. /**
  45924. * detach this feature.
  45925. *
  45926. * @returns true if successful, false if failed or already detached
  45927. */
  45928. detach(): boolean;
  45929. /**
  45930. * Dispose this feature and all of the resources attached
  45931. */
  45932. dispose(): void;
  45933. /**
  45934. * This is used to register callbacks that will automatically be removed when detach is called.
  45935. * @param observable the observable to which the observer will be attached
  45936. * @param callback the callback to register
  45937. */
  45938. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45939. /**
  45940. * Code in this function will be executed on each xrFrame received from the browser.
  45941. * This function will not execute after the feature is detached.
  45942. * @param _xrFrame the current frame
  45943. */
  45944. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45945. }
  45946. }
  45947. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45948. import { IDisposable, Scene } from "babylonjs/scene";
  45949. import { Nullable } from "babylonjs/types";
  45950. import { Observable } from "babylonjs/Misc/observable";
  45951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45952. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45953. import { Camera } from "babylonjs/Cameras/camera";
  45954. /**
  45955. * Renders a layer on top of an existing scene
  45956. */
  45957. export class UtilityLayerRenderer implements IDisposable {
  45958. /** the original scene that will be rendered on top of */
  45959. originalScene: Scene;
  45960. private _pointerCaptures;
  45961. private _lastPointerEvents;
  45962. private static _DefaultUtilityLayer;
  45963. private static _DefaultKeepDepthUtilityLayer;
  45964. private _sharedGizmoLight;
  45965. private _renderCamera;
  45966. /**
  45967. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45968. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  45969. * @returns the camera that is used when rendering the utility layer
  45970. */
  45971. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  45972. /**
  45973. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45974. * @param cam the camera that should be used when rendering the utility layer
  45975. */
  45976. setRenderCamera(cam: Nullable<Camera>): void;
  45977. /**
  45978. * @hidden
  45979. * Light which used by gizmos to get light shading
  45980. */
  45981. _getSharedGizmoLight(): HemisphericLight;
  45982. /**
  45983. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45984. */
  45985. pickUtilitySceneFirst: boolean;
  45986. /**
  45987. * 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)
  45988. */
  45989. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45990. /**
  45991. * 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)
  45992. */
  45993. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45994. /**
  45995. * The scene that is rendered on top of the original scene
  45996. */
  45997. utilityLayerScene: Scene;
  45998. /**
  45999. * If the utility layer should automatically be rendered on top of existing scene
  46000. */
  46001. shouldRender: boolean;
  46002. /**
  46003. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46004. */
  46005. onlyCheckPointerDownEvents: boolean;
  46006. /**
  46007. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46008. */
  46009. processAllEvents: boolean;
  46010. /**
  46011. * Observable raised when the pointer move from the utility layer scene to the main scene
  46012. */
  46013. onPointerOutObservable: Observable<number>;
  46014. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46015. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46016. private _afterRenderObserver;
  46017. private _sceneDisposeObserver;
  46018. private _originalPointerObserver;
  46019. /**
  46020. * Instantiates a UtilityLayerRenderer
  46021. * @param originalScene the original scene that will be rendered on top of
  46022. * @param handleEvents boolean indicating if the utility layer should handle events
  46023. */
  46024. constructor(
  46025. /** the original scene that will be rendered on top of */
  46026. originalScene: Scene, handleEvents?: boolean);
  46027. private _notifyObservers;
  46028. /**
  46029. * Renders the utility layers scene on top of the original scene
  46030. */
  46031. render(): void;
  46032. /**
  46033. * Disposes of the renderer
  46034. */
  46035. dispose(): void;
  46036. private _updateCamera;
  46037. }
  46038. }
  46039. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46040. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46042. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46043. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46044. import { Scene } from "babylonjs/scene";
  46045. import { Nullable } from "babylonjs/types";
  46046. import { Color3 } from "babylonjs/Maths/math.color";
  46047. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46048. /**
  46049. * Options interface for the pointer selection module
  46050. */
  46051. export interface IWebXRControllerPointerSelectionOptions {
  46052. /**
  46053. * if provided, this scene will be used to render meshes.
  46054. */
  46055. customUtilityLayerScene?: Scene;
  46056. /**
  46057. * 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)
  46058. * If not disabled, the last picked point will be used to execute a pointer up event
  46059. * If disabled, pointer up event will be triggered right after the pointer down event.
  46060. * Used in screen and gaze target ray mode only
  46061. */
  46062. disablePointerUpOnTouchOut: boolean;
  46063. /**
  46064. * For gaze mode (time to select instead of press)
  46065. */
  46066. forceGazeMode: boolean;
  46067. /**
  46068. * 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
  46069. * to start a new countdown to the pointer down event.
  46070. * Defaults to 1.
  46071. */
  46072. gazeModePointerMovedFactor?: number;
  46073. /**
  46074. * Different button type to use instead of the main component
  46075. */
  46076. overrideButtonId?: string;
  46077. /**
  46078. * use this rendering group id for the meshes (optional)
  46079. */
  46080. renderingGroupId?: number;
  46081. /**
  46082. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46083. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46084. * 3000 means 3 seconds between pointing at something and selecting it
  46085. */
  46086. timeToSelect?: number;
  46087. /**
  46088. * Should meshes created here be added to a utility layer or the main scene
  46089. */
  46090. useUtilityLayer?: boolean;
  46091. /**
  46092. * the xr input to use with this pointer selection
  46093. */
  46094. xrInput: WebXRInput;
  46095. }
  46096. /**
  46097. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46098. */
  46099. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46100. private readonly _options;
  46101. private static _idCounter;
  46102. private _attachController;
  46103. private _controllers;
  46104. private _scene;
  46105. private _tmpVectorForPickCompare;
  46106. /**
  46107. * The module's name
  46108. */
  46109. static readonly Name: string;
  46110. /**
  46111. * The (Babylon) version of this module.
  46112. * This is an integer representing the implementation version.
  46113. * This number does not correspond to the WebXR specs version
  46114. */
  46115. static readonly Version: number;
  46116. /**
  46117. * Disable lighting on the laser pointer (so it will always be visible)
  46118. */
  46119. disablePointerLighting: boolean;
  46120. /**
  46121. * Disable lighting on the selection mesh (so it will always be visible)
  46122. */
  46123. disableSelectionMeshLighting: boolean;
  46124. /**
  46125. * Should the laser pointer be displayed
  46126. */
  46127. displayLaserPointer: boolean;
  46128. /**
  46129. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46130. */
  46131. displaySelectionMesh: boolean;
  46132. /**
  46133. * This color will be set to the laser pointer when selection is triggered
  46134. */
  46135. laserPointerPickedColor: Color3;
  46136. /**
  46137. * Default color of the laser pointer
  46138. */
  46139. lasterPointerDefaultColor: Color3;
  46140. /**
  46141. * default color of the selection ring
  46142. */
  46143. selectionMeshDefaultColor: Color3;
  46144. /**
  46145. * This color will be applied to the selection ring when selection is triggered
  46146. */
  46147. selectionMeshPickedColor: Color3;
  46148. /**
  46149. * constructs a new background remover module
  46150. * @param _xrSessionManager the session manager for this module
  46151. * @param _options read-only options to be used in this module
  46152. */
  46153. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46154. /**
  46155. * attach this feature
  46156. * Will usually be called by the features manager
  46157. *
  46158. * @returns true if successful.
  46159. */
  46160. attach(): boolean;
  46161. /**
  46162. * detach this feature.
  46163. * Will usually be called by the features manager
  46164. *
  46165. * @returns true if successful.
  46166. */
  46167. detach(): boolean;
  46168. /**
  46169. * Will get the mesh under a specific pointer.
  46170. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46171. * @param controllerId the controllerId to check
  46172. * @returns The mesh under pointer or null if no mesh is under the pointer
  46173. */
  46174. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46175. /**
  46176. * Get the xr controller that correlates to the pointer id in the pointer event
  46177. *
  46178. * @param id the pointer id to search for
  46179. * @returns the controller that correlates to this id or null if not found
  46180. */
  46181. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46182. protected _onXRFrame(_xrFrame: XRFrame): void;
  46183. private _attachGazeMode;
  46184. private _attachScreenRayMode;
  46185. private _attachTrackedPointerRayMode;
  46186. private _convertNormalToDirectionOfRay;
  46187. private _detachController;
  46188. private _generateNewMeshPair;
  46189. private _pickingMoved;
  46190. private _updatePointerDistance;
  46191. }
  46192. }
  46193. declare module "babylonjs/XR/webXREnterExitUI" {
  46194. import { Nullable } from "babylonjs/types";
  46195. import { Observable } from "babylonjs/Misc/observable";
  46196. import { IDisposable, Scene } from "babylonjs/scene";
  46197. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46198. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46199. /**
  46200. * Button which can be used to enter a different mode of XR
  46201. */
  46202. export class WebXREnterExitUIButton {
  46203. /** button element */
  46204. element: HTMLElement;
  46205. /** XR initialization options for the button */
  46206. sessionMode: XRSessionMode;
  46207. /** Reference space type */
  46208. referenceSpaceType: XRReferenceSpaceType;
  46209. /**
  46210. * Creates a WebXREnterExitUIButton
  46211. * @param element button element
  46212. * @param sessionMode XR initialization session mode
  46213. * @param referenceSpaceType the type of reference space to be used
  46214. */
  46215. constructor(
  46216. /** button element */
  46217. element: HTMLElement,
  46218. /** XR initialization options for the button */
  46219. sessionMode: XRSessionMode,
  46220. /** Reference space type */
  46221. referenceSpaceType: XRReferenceSpaceType);
  46222. /**
  46223. * Extendable function which can be used to update the button's visuals when the state changes
  46224. * @param activeButton the current active button in the UI
  46225. */
  46226. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46227. }
  46228. /**
  46229. * Options to create the webXR UI
  46230. */
  46231. export class WebXREnterExitUIOptions {
  46232. /**
  46233. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46234. */
  46235. customButtons?: Array<WebXREnterExitUIButton>;
  46236. /**
  46237. * A reference space type to use when creating the default button.
  46238. * Default is local-floor
  46239. */
  46240. referenceSpaceType?: XRReferenceSpaceType;
  46241. /**
  46242. * Context to enter xr with
  46243. */
  46244. renderTarget?: Nullable<WebXRRenderTarget>;
  46245. /**
  46246. * A session mode to use when creating the default button.
  46247. * Default is immersive-vr
  46248. */
  46249. sessionMode?: XRSessionMode;
  46250. }
  46251. /**
  46252. * UI to allow the user to enter/exit XR mode
  46253. */
  46254. export class WebXREnterExitUI implements IDisposable {
  46255. private scene;
  46256. /** version of the options passed to this UI */
  46257. options: WebXREnterExitUIOptions;
  46258. private _activeButton;
  46259. private _buttons;
  46260. private _overlay;
  46261. /**
  46262. * Fired every time the active button is changed.
  46263. *
  46264. * When xr is entered via a button that launches xr that button will be the callback parameter
  46265. *
  46266. * When exiting xr the callback parameter will be null)
  46267. */
  46268. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46269. /**
  46270. *
  46271. * @param scene babylon scene object to use
  46272. * @param options (read-only) version of the options passed to this UI
  46273. */
  46274. private constructor();
  46275. /**
  46276. * Creates UI to allow the user to enter/exit XR mode
  46277. * @param scene the scene to add the ui to
  46278. * @param helper the xr experience helper to enter/exit xr with
  46279. * @param options options to configure the UI
  46280. * @returns the created ui
  46281. */
  46282. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46283. /**
  46284. * Disposes of the XR UI component
  46285. */
  46286. dispose(): void;
  46287. private _updateButtons;
  46288. }
  46289. }
  46290. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46291. import { Vector3 } from "babylonjs/Maths/math.vector";
  46292. import { Color4 } from "babylonjs/Maths/math.color";
  46293. import { Nullable } from "babylonjs/types";
  46294. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46295. import { Scene } from "babylonjs/scene";
  46296. /**
  46297. * Class containing static functions to help procedurally build meshes
  46298. */
  46299. export class LinesBuilder {
  46300. /**
  46301. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46302. * * 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
  46303. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46304. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46305. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46306. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46307. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46308. * * 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
  46309. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46311. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46312. * @param name defines the name of the new line system
  46313. * @param options defines the options used to create the line system
  46314. * @param scene defines the hosting scene
  46315. * @returns a new line system mesh
  46316. */
  46317. static CreateLineSystem(name: string, options: {
  46318. lines: Vector3[][];
  46319. updatable?: boolean;
  46320. instance?: Nullable<LinesMesh>;
  46321. colors?: Nullable<Color4[][]>;
  46322. useVertexAlpha?: boolean;
  46323. }, scene: Nullable<Scene>): LinesMesh;
  46324. /**
  46325. * Creates a line mesh
  46326. * 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
  46327. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46328. * * The parameter `points` is an array successive Vector3
  46329. * * 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
  46330. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46331. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46332. * * When updating an instance, remember that only point positions can change, not the number of points
  46333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46334. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46335. * @param name defines the name of the new line system
  46336. * @param options defines the options used to create the line system
  46337. * @param scene defines the hosting scene
  46338. * @returns a new line mesh
  46339. */
  46340. static CreateLines(name: string, options: {
  46341. points: Vector3[];
  46342. updatable?: boolean;
  46343. instance?: Nullable<LinesMesh>;
  46344. colors?: Color4[];
  46345. useVertexAlpha?: boolean;
  46346. }, scene?: Nullable<Scene>): LinesMesh;
  46347. /**
  46348. * Creates a dashed line mesh
  46349. * * 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
  46350. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46351. * * The parameter `points` is an array successive Vector3
  46352. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46353. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46354. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46355. * * 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
  46356. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46357. * * When updating an instance, remember that only point positions can change, not the number of points
  46358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46359. * @param name defines the name of the mesh
  46360. * @param options defines the options used to create the mesh
  46361. * @param scene defines the hosting scene
  46362. * @returns the dashed line mesh
  46363. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46364. */
  46365. static CreateDashedLines(name: string, options: {
  46366. points: Vector3[];
  46367. dashSize?: number;
  46368. gapSize?: number;
  46369. dashNb?: number;
  46370. updatable?: boolean;
  46371. instance?: LinesMesh;
  46372. useVertexAlpha?: boolean;
  46373. }, scene?: Nullable<Scene>): LinesMesh;
  46374. }
  46375. }
  46376. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46377. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46378. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46379. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46381. import { Vector3 } from "babylonjs/Maths/math.vector";
  46382. import { Material } from "babylonjs/Materials/material";
  46383. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46384. import { Scene } from "babylonjs/scene";
  46385. /**
  46386. * The options container for the teleportation module
  46387. */
  46388. export interface IWebXRTeleportationOptions {
  46389. /**
  46390. * if provided, this scene will be used to render meshes.
  46391. */
  46392. customUtilityLayerScene?: Scene;
  46393. /**
  46394. * Values to configure the default target mesh
  46395. */
  46396. defaultTargetMeshOptions?: {
  46397. /**
  46398. * Fill color of the teleportation area
  46399. */
  46400. teleportationFillColor?: string;
  46401. /**
  46402. * Border color for the teleportation area
  46403. */
  46404. teleportationBorderColor?: string;
  46405. /**
  46406. * Disable the mesh's animation sequence
  46407. */
  46408. disableAnimation?: boolean;
  46409. /**
  46410. * Disable lighting on the material or the ring and arrow
  46411. */
  46412. disableLighting?: boolean;
  46413. /**
  46414. * Override the default material of the torus and arrow
  46415. */
  46416. torusArrowMaterial?: Material;
  46417. };
  46418. /**
  46419. * A list of meshes to use as floor meshes.
  46420. * Meshes can be added and removed after initializing the feature using the
  46421. * addFloorMesh and removeFloorMesh functions
  46422. * If empty, rotation will still work
  46423. */
  46424. floorMeshes?: AbstractMesh[];
  46425. /**
  46426. * use this rendering group id for the meshes (optional)
  46427. */
  46428. renderingGroupId?: number;
  46429. /**
  46430. * Should teleportation move only to snap points
  46431. */
  46432. snapPointsOnly?: boolean;
  46433. /**
  46434. * An array of points to which the teleportation will snap to.
  46435. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46436. */
  46437. snapPositions?: Vector3[];
  46438. /**
  46439. * How close should the teleportation ray be in order to snap to position.
  46440. * Default to 0.8 units (meters)
  46441. */
  46442. snapToPositionRadius?: number;
  46443. /**
  46444. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46445. * If you want to support rotation, make sure your mesh has a direction indicator.
  46446. *
  46447. * When left untouched, the default mesh will be initialized.
  46448. */
  46449. teleportationTargetMesh?: AbstractMesh;
  46450. /**
  46451. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46452. */
  46453. timeToTeleport?: number;
  46454. /**
  46455. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46456. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46457. */
  46458. useMainComponentOnly?: boolean;
  46459. /**
  46460. * Should meshes created here be added to a utility layer or the main scene
  46461. */
  46462. useUtilityLayer?: boolean;
  46463. /**
  46464. * Babylon XR Input class for controller
  46465. */
  46466. xrInput: WebXRInput;
  46467. }
  46468. /**
  46469. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46470. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46471. * the input of the attached controllers.
  46472. */
  46473. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46474. private _options;
  46475. private _controllers;
  46476. private _currentTeleportationControllerId;
  46477. private _floorMeshes;
  46478. private _quadraticBezierCurve;
  46479. private _selectionFeature;
  46480. private _snapToPositions;
  46481. private _snappedToPoint;
  46482. private _teleportationRingMaterial?;
  46483. private _tmpRay;
  46484. private _tmpVector;
  46485. /**
  46486. * The module's name
  46487. */
  46488. static readonly Name: string;
  46489. /**
  46490. * The (Babylon) version of this module.
  46491. * This is an integer representing the implementation version.
  46492. * This number does not correspond to the webxr specs version
  46493. */
  46494. static readonly Version: number;
  46495. /**
  46496. * Is movement backwards enabled
  46497. */
  46498. backwardsMovementEnabled: boolean;
  46499. /**
  46500. * Distance to travel when moving backwards
  46501. */
  46502. backwardsTeleportationDistance: number;
  46503. /**
  46504. * The distance from the user to the inspection point in the direction of the controller
  46505. * A higher number will allow the user to move further
  46506. * defaults to 5 (meters, in xr units)
  46507. */
  46508. parabolicCheckRadius: number;
  46509. /**
  46510. * Should the module support parabolic ray on top of direct ray
  46511. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46512. * Very helpful when moving between floors / different heights
  46513. */
  46514. parabolicRayEnabled: boolean;
  46515. /**
  46516. * How much rotation should be applied when rotating right and left
  46517. */
  46518. rotationAngle: number;
  46519. /**
  46520. * Is rotation enabled when moving forward?
  46521. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46522. */
  46523. rotationEnabled: boolean;
  46524. /**
  46525. * constructs a new anchor system
  46526. * @param _xrSessionManager an instance of WebXRSessionManager
  46527. * @param _options configuration object for this feature
  46528. */
  46529. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46530. /**
  46531. * Get the snapPointsOnly flag
  46532. */
  46533. get snapPointsOnly(): boolean;
  46534. /**
  46535. * Sets the snapPointsOnly flag
  46536. * @param snapToPoints should teleportation be exclusively to snap points
  46537. */
  46538. set snapPointsOnly(snapToPoints: boolean);
  46539. /**
  46540. * Add a new mesh to the floor meshes array
  46541. * @param mesh the mesh to use as floor mesh
  46542. */
  46543. addFloorMesh(mesh: AbstractMesh): void;
  46544. /**
  46545. * Add a new snap-to point to fix teleportation to this position
  46546. * @param newSnapPoint The new Snap-To point
  46547. */
  46548. addSnapPoint(newSnapPoint: Vector3): void;
  46549. attach(): boolean;
  46550. detach(): boolean;
  46551. dispose(): void;
  46552. /**
  46553. * Remove a mesh from the floor meshes array
  46554. * @param mesh the mesh to remove
  46555. */
  46556. removeFloorMesh(mesh: AbstractMesh): void;
  46557. /**
  46558. * Remove a mesh from the floor meshes array using its name
  46559. * @param name the mesh name to remove
  46560. */
  46561. removeFloorMeshByName(name: string): void;
  46562. /**
  46563. * 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
  46564. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46565. * @returns was the point found and removed or not
  46566. */
  46567. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46568. /**
  46569. * This function sets a selection feature that will be disabled when
  46570. * the forward ray is shown and will be reattached when hidden.
  46571. * This is used to remove the selection rays when moving.
  46572. * @param selectionFeature the feature to disable when forward movement is enabled
  46573. */
  46574. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46575. protected _onXRFrame(_xrFrame: XRFrame): void;
  46576. private _attachController;
  46577. private _createDefaultTargetMesh;
  46578. private _detachController;
  46579. private _findClosestSnapPointWithRadius;
  46580. private _setTargetMeshPosition;
  46581. private _setTargetMeshVisibility;
  46582. private _showParabolicPath;
  46583. private _teleportForward;
  46584. }
  46585. }
  46586. declare module "babylonjs/XR/webXRDefaultExperience" {
  46587. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46588. import { Scene } from "babylonjs/scene";
  46589. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46590. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46591. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46592. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46594. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46595. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46596. /**
  46597. * Options for the default xr helper
  46598. */
  46599. export class WebXRDefaultExperienceOptions {
  46600. /**
  46601. * Enable or disable default UI to enter XR
  46602. */
  46603. disableDefaultUI?: boolean;
  46604. /**
  46605. * Should teleportation not initialize. defaults to false.
  46606. */
  46607. disableTeleportation?: boolean;
  46608. /**
  46609. * Floor meshes that will be used for teleport
  46610. */
  46611. floorMeshes?: Array<AbstractMesh>;
  46612. /**
  46613. * If set to true, the first frame will not be used to reset position
  46614. * The first frame is mainly used when copying transformation from the old camera
  46615. * Mainly used in AR
  46616. */
  46617. ignoreNativeCameraTransformation?: boolean;
  46618. /**
  46619. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46620. */
  46621. inputOptions?: IWebXRInputOptions;
  46622. /**
  46623. * optional configuration for the output canvas
  46624. */
  46625. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46626. /**
  46627. * optional UI options. This can be used among other to change session mode and reference space type
  46628. */
  46629. uiOptions?: WebXREnterExitUIOptions;
  46630. /**
  46631. * When loading teleportation and pointer select, use stable versions instead of latest.
  46632. */
  46633. useStablePlugins?: boolean;
  46634. }
  46635. /**
  46636. * Default experience which provides a similar setup to the previous webVRExperience
  46637. */
  46638. export class WebXRDefaultExperience {
  46639. /**
  46640. * Base experience
  46641. */
  46642. baseExperience: WebXRExperienceHelper;
  46643. /**
  46644. * Enables ui for entering/exiting xr
  46645. */
  46646. enterExitUI: WebXREnterExitUI;
  46647. /**
  46648. * Input experience extension
  46649. */
  46650. input: WebXRInput;
  46651. /**
  46652. * Enables laser pointer and selection
  46653. */
  46654. pointerSelection: WebXRControllerPointerSelection;
  46655. /**
  46656. * Default target xr should render to
  46657. */
  46658. renderTarget: WebXRRenderTarget;
  46659. /**
  46660. * Enables teleportation
  46661. */
  46662. teleportation: WebXRMotionControllerTeleportation;
  46663. private constructor();
  46664. /**
  46665. * Creates the default xr experience
  46666. * @param scene scene
  46667. * @param options options for basic configuration
  46668. * @returns resulting WebXRDefaultExperience
  46669. */
  46670. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46671. /**
  46672. * DIsposes of the experience helper
  46673. */
  46674. dispose(): void;
  46675. }
  46676. }
  46677. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46678. import { Observable } from "babylonjs/Misc/observable";
  46679. import { Nullable } from "babylonjs/types";
  46680. import { Camera } from "babylonjs/Cameras/camera";
  46681. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46682. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46683. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46684. import { Scene } from "babylonjs/scene";
  46685. import { Vector3 } from "babylonjs/Maths/math.vector";
  46686. import { Color3 } from "babylonjs/Maths/math.color";
  46687. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46689. import { Mesh } from "babylonjs/Meshes/mesh";
  46690. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46691. import { EasingFunction } from "babylonjs/Animations/easing";
  46692. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46693. import "babylonjs/Meshes/Builders/groundBuilder";
  46694. import "babylonjs/Meshes/Builders/torusBuilder";
  46695. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46696. import "babylonjs/Gamepads/gamepadSceneComponent";
  46697. import "babylonjs/Animations/animatable";
  46698. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46699. /**
  46700. * Options to modify the vr teleportation behavior.
  46701. */
  46702. export interface VRTeleportationOptions {
  46703. /**
  46704. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46705. */
  46706. floorMeshName?: string;
  46707. /**
  46708. * A list of meshes to be used as the teleportation floor. (default: empty)
  46709. */
  46710. floorMeshes?: Mesh[];
  46711. /**
  46712. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46713. */
  46714. teleportationMode?: number;
  46715. /**
  46716. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46717. */
  46718. teleportationTime?: number;
  46719. /**
  46720. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46721. */
  46722. teleportationSpeed?: number;
  46723. /**
  46724. * The easing function used in the animation or null for Linear. (default CircleEase)
  46725. */
  46726. easingFunction?: EasingFunction;
  46727. }
  46728. /**
  46729. * Options to modify the vr experience helper's behavior.
  46730. */
  46731. export interface VRExperienceHelperOptions extends WebVROptions {
  46732. /**
  46733. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46734. */
  46735. createDeviceOrientationCamera?: boolean;
  46736. /**
  46737. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46738. */
  46739. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46740. /**
  46741. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46742. */
  46743. laserToggle?: boolean;
  46744. /**
  46745. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46746. */
  46747. floorMeshes?: Mesh[];
  46748. /**
  46749. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46750. */
  46751. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46752. /**
  46753. * Defines if WebXR should be used instead of WebVR (if available)
  46754. */
  46755. useXR?: boolean;
  46756. }
  46757. /**
  46758. * Event containing information after VR has been entered
  46759. */
  46760. export class OnAfterEnteringVRObservableEvent {
  46761. /**
  46762. * If entering vr was successful
  46763. */
  46764. success: boolean;
  46765. }
  46766. /**
  46767. * Helps to quickly add VR support to an existing scene.
  46768. * See http://doc.babylonjs.com/how_to/webvr_helper
  46769. */
  46770. export class VRExperienceHelper {
  46771. /** Options to modify the vr experience helper's behavior. */
  46772. webVROptions: VRExperienceHelperOptions;
  46773. private _scene;
  46774. private _position;
  46775. private _btnVR;
  46776. private _btnVRDisplayed;
  46777. private _webVRsupported;
  46778. private _webVRready;
  46779. private _webVRrequesting;
  46780. private _webVRpresenting;
  46781. private _hasEnteredVR;
  46782. private _fullscreenVRpresenting;
  46783. private _inputElement;
  46784. private _webVRCamera;
  46785. private _vrDeviceOrientationCamera;
  46786. private _deviceOrientationCamera;
  46787. private _existingCamera;
  46788. private _onKeyDown;
  46789. private _onVrDisplayPresentChange;
  46790. private _onVRDisplayChanged;
  46791. private _onVRRequestPresentStart;
  46792. private _onVRRequestPresentComplete;
  46793. /**
  46794. * 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)
  46795. */
  46796. enableGazeEvenWhenNoPointerLock: boolean;
  46797. /**
  46798. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46799. */
  46800. exitVROnDoubleTap: boolean;
  46801. /**
  46802. * Observable raised right before entering VR.
  46803. */
  46804. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46805. /**
  46806. * Observable raised when entering VR has completed.
  46807. */
  46808. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46809. /**
  46810. * Observable raised when exiting VR.
  46811. */
  46812. onExitingVRObservable: Observable<VRExperienceHelper>;
  46813. /**
  46814. * Observable raised when controller mesh is loaded.
  46815. */
  46816. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46817. /** Return this.onEnteringVRObservable
  46818. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46819. */
  46820. get onEnteringVR(): Observable<VRExperienceHelper>;
  46821. /** Return this.onExitingVRObservable
  46822. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46823. */
  46824. get onExitingVR(): Observable<VRExperienceHelper>;
  46825. /** Return this.onControllerMeshLoadedObservable
  46826. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46827. */
  46828. get onControllerMeshLoaded(): Observable<WebVRController>;
  46829. private _rayLength;
  46830. private _useCustomVRButton;
  46831. private _teleportationRequested;
  46832. private _teleportActive;
  46833. private _floorMeshName;
  46834. private _floorMeshesCollection;
  46835. private _teleportationMode;
  46836. private _teleportationTime;
  46837. private _teleportationSpeed;
  46838. private _teleportationEasing;
  46839. private _rotationAllowed;
  46840. private _teleportBackwardsVector;
  46841. private _teleportationTarget;
  46842. private _isDefaultTeleportationTarget;
  46843. private _postProcessMove;
  46844. private _teleportationFillColor;
  46845. private _teleportationBorderColor;
  46846. private _rotationAngle;
  46847. private _haloCenter;
  46848. private _cameraGazer;
  46849. private _padSensibilityUp;
  46850. private _padSensibilityDown;
  46851. private _leftController;
  46852. private _rightController;
  46853. private _gazeColor;
  46854. private _laserColor;
  46855. private _pickedLaserColor;
  46856. private _pickedGazeColor;
  46857. /**
  46858. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46859. */
  46860. onNewMeshSelected: Observable<AbstractMesh>;
  46861. /**
  46862. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46863. * This observable will provide the mesh and the controller used to select the mesh
  46864. */
  46865. onMeshSelectedWithController: Observable<{
  46866. mesh: AbstractMesh;
  46867. controller: WebVRController;
  46868. }>;
  46869. /**
  46870. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46871. */
  46872. onNewMeshPicked: Observable<PickingInfo>;
  46873. private _circleEase;
  46874. /**
  46875. * Observable raised before camera teleportation
  46876. */
  46877. onBeforeCameraTeleport: Observable<Vector3>;
  46878. /**
  46879. * Observable raised after camera teleportation
  46880. */
  46881. onAfterCameraTeleport: Observable<Vector3>;
  46882. /**
  46883. * Observable raised when current selected mesh gets unselected
  46884. */
  46885. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46886. private _raySelectionPredicate;
  46887. /**
  46888. * To be optionaly changed by user to define custom ray selection
  46889. */
  46890. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46891. /**
  46892. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46893. */
  46894. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46895. /**
  46896. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46897. */
  46898. teleportationEnabled: boolean;
  46899. private _defaultHeight;
  46900. private _teleportationInitialized;
  46901. private _interactionsEnabled;
  46902. private _interactionsRequested;
  46903. private _displayGaze;
  46904. private _displayLaserPointer;
  46905. /**
  46906. * The mesh used to display where the user is going to teleport.
  46907. */
  46908. get teleportationTarget(): Mesh;
  46909. /**
  46910. * Sets the mesh to be used to display where the user is going to teleport.
  46911. */
  46912. set teleportationTarget(value: Mesh);
  46913. /**
  46914. * 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
  46915. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46916. * See http://doc.babylonjs.com/resources/baking_transformations
  46917. */
  46918. get gazeTrackerMesh(): Mesh;
  46919. set gazeTrackerMesh(value: Mesh);
  46920. /**
  46921. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46922. */
  46923. updateGazeTrackerScale: boolean;
  46924. /**
  46925. * If the gaze trackers color should be updated when selecting meshes
  46926. */
  46927. updateGazeTrackerColor: boolean;
  46928. /**
  46929. * If the controller laser color should be updated when selecting meshes
  46930. */
  46931. updateControllerLaserColor: boolean;
  46932. /**
  46933. * The gaze tracking mesh corresponding to the left controller
  46934. */
  46935. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46936. /**
  46937. * The gaze tracking mesh corresponding to the right controller
  46938. */
  46939. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46940. /**
  46941. * If the ray of the gaze should be displayed.
  46942. */
  46943. get displayGaze(): boolean;
  46944. /**
  46945. * Sets if the ray of the gaze should be displayed.
  46946. */
  46947. set displayGaze(value: boolean);
  46948. /**
  46949. * If the ray of the LaserPointer should be displayed.
  46950. */
  46951. get displayLaserPointer(): boolean;
  46952. /**
  46953. * Sets if the ray of the LaserPointer should be displayed.
  46954. */
  46955. set displayLaserPointer(value: boolean);
  46956. /**
  46957. * The deviceOrientationCamera used as the camera when not in VR.
  46958. */
  46959. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46960. /**
  46961. * Based on the current WebVR support, returns the current VR camera used.
  46962. */
  46963. get currentVRCamera(): Nullable<Camera>;
  46964. /**
  46965. * The webVRCamera which is used when in VR.
  46966. */
  46967. get webVRCamera(): WebVRFreeCamera;
  46968. /**
  46969. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46970. */
  46971. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46972. /**
  46973. * The html button that is used to trigger entering into VR.
  46974. */
  46975. get vrButton(): Nullable<HTMLButtonElement>;
  46976. private get _teleportationRequestInitiated();
  46977. /**
  46978. * Defines whether or not Pointer lock should be requested when switching to
  46979. * full screen.
  46980. */
  46981. requestPointerLockOnFullScreen: boolean;
  46982. /**
  46983. * If asking to force XR, this will be populated with the default xr experience
  46984. */
  46985. xr: WebXRDefaultExperience;
  46986. /**
  46987. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46988. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46989. */
  46990. xrTestDone: boolean;
  46991. /**
  46992. * Instantiates a VRExperienceHelper.
  46993. * Helps to quickly add VR support to an existing scene.
  46994. * @param scene The scene the VRExperienceHelper belongs to.
  46995. * @param webVROptions Options to modify the vr experience helper's behavior.
  46996. */
  46997. constructor(scene: Scene,
  46998. /** Options to modify the vr experience helper's behavior. */
  46999. webVROptions?: VRExperienceHelperOptions);
  47000. private completeVRInit;
  47001. private _onDefaultMeshLoaded;
  47002. private _onResize;
  47003. private _onFullscreenChange;
  47004. /**
  47005. * Gets a value indicating if we are currently in VR mode.
  47006. */
  47007. get isInVRMode(): boolean;
  47008. private onVrDisplayPresentChange;
  47009. private onVRDisplayChanged;
  47010. private moveButtonToBottomRight;
  47011. private displayVRButton;
  47012. private updateButtonVisibility;
  47013. private _cachedAngularSensibility;
  47014. /**
  47015. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47016. * Otherwise, will use the fullscreen API.
  47017. */
  47018. enterVR(): void;
  47019. /**
  47020. * Attempt to exit VR, or fullscreen.
  47021. */
  47022. exitVR(): void;
  47023. /**
  47024. * The position of the vr experience helper.
  47025. */
  47026. get position(): Vector3;
  47027. /**
  47028. * Sets the position of the vr experience helper.
  47029. */
  47030. set position(value: Vector3);
  47031. /**
  47032. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47033. */
  47034. enableInteractions(): void;
  47035. private get _noControllerIsActive();
  47036. private beforeRender;
  47037. private _isTeleportationFloor;
  47038. /**
  47039. * Adds a floor mesh to be used for teleportation.
  47040. * @param floorMesh the mesh to be used for teleportation.
  47041. */
  47042. addFloorMesh(floorMesh: Mesh): void;
  47043. /**
  47044. * Removes a floor mesh from being used for teleportation.
  47045. * @param floorMesh the mesh to be removed.
  47046. */
  47047. removeFloorMesh(floorMesh: Mesh): void;
  47048. /**
  47049. * Enables interactions and teleportation using the VR controllers and gaze.
  47050. * @param vrTeleportationOptions options to modify teleportation behavior.
  47051. */
  47052. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47053. private _onNewGamepadConnected;
  47054. private _tryEnableInteractionOnController;
  47055. private _onNewGamepadDisconnected;
  47056. private _enableInteractionOnController;
  47057. private _checkTeleportWithRay;
  47058. private _checkRotate;
  47059. private _checkTeleportBackwards;
  47060. private _enableTeleportationOnController;
  47061. private _createTeleportationCircles;
  47062. private _displayTeleportationTarget;
  47063. private _hideTeleportationTarget;
  47064. private _rotateCamera;
  47065. private _moveTeleportationSelectorTo;
  47066. private _workingVector;
  47067. private _workingQuaternion;
  47068. private _workingMatrix;
  47069. /**
  47070. * Time Constant Teleportation Mode
  47071. */
  47072. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47073. /**
  47074. * Speed Constant Teleportation Mode
  47075. */
  47076. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47077. /**
  47078. * Teleports the users feet to the desired location
  47079. * @param location The location where the user's feet should be placed
  47080. */
  47081. teleportCamera(location: Vector3): void;
  47082. private _convertNormalToDirectionOfRay;
  47083. private _castRayAndSelectObject;
  47084. private _notifySelectedMeshUnselected;
  47085. /**
  47086. * Permanently set new colors for the laser pointer
  47087. * @param color the new laser color
  47088. * @param pickedColor the new laser color when picked mesh detected
  47089. */
  47090. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47091. /**
  47092. * Set lighting enabled / disabled on the laser pointer of both controllers
  47093. * @param enabled should the lighting be enabled on the laser pointer
  47094. */
  47095. setLaserLightingState(enabled?: boolean): void;
  47096. /**
  47097. * Permanently set new colors for the gaze pointer
  47098. * @param color the new gaze color
  47099. * @param pickedColor the new gaze color when picked mesh detected
  47100. */
  47101. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47102. /**
  47103. * Sets the color of the laser ray from the vr controllers.
  47104. * @param color new color for the ray.
  47105. */
  47106. changeLaserColor(color: Color3): void;
  47107. /**
  47108. * Sets the color of the ray from the vr headsets gaze.
  47109. * @param color new color for the ray.
  47110. */
  47111. changeGazeColor(color: Color3): void;
  47112. /**
  47113. * Exits VR and disposes of the vr experience helper
  47114. */
  47115. dispose(): void;
  47116. /**
  47117. * Gets the name of the VRExperienceHelper class
  47118. * @returns "VRExperienceHelper"
  47119. */
  47120. getClassName(): string;
  47121. }
  47122. }
  47123. declare module "babylonjs/Cameras/VR/index" {
  47124. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47125. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47126. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47127. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47128. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47129. export * from "babylonjs/Cameras/VR/webVRCamera";
  47130. }
  47131. declare module "babylonjs/Cameras/RigModes/index" {
  47132. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47133. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47134. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47135. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47136. }
  47137. declare module "babylonjs/Cameras/index" {
  47138. export * from "babylonjs/Cameras/Inputs/index";
  47139. export * from "babylonjs/Cameras/cameraInputsManager";
  47140. export * from "babylonjs/Cameras/camera";
  47141. export * from "babylonjs/Cameras/targetCamera";
  47142. export * from "babylonjs/Cameras/freeCamera";
  47143. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47144. export * from "babylonjs/Cameras/touchCamera";
  47145. export * from "babylonjs/Cameras/arcRotateCamera";
  47146. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47147. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47148. export * from "babylonjs/Cameras/flyCamera";
  47149. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47150. export * from "babylonjs/Cameras/followCamera";
  47151. export * from "babylonjs/Cameras/followCameraInputsManager";
  47152. export * from "babylonjs/Cameras/gamepadCamera";
  47153. export * from "babylonjs/Cameras/Stereoscopic/index";
  47154. export * from "babylonjs/Cameras/universalCamera";
  47155. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47156. export * from "babylonjs/Cameras/VR/index";
  47157. export * from "babylonjs/Cameras/RigModes/index";
  47158. }
  47159. declare module "babylonjs/Collisions/index" {
  47160. export * from "babylonjs/Collisions/collider";
  47161. export * from "babylonjs/Collisions/collisionCoordinator";
  47162. export * from "babylonjs/Collisions/pickingInfo";
  47163. export * from "babylonjs/Collisions/intersectionInfo";
  47164. export * from "babylonjs/Collisions/meshCollisionData";
  47165. }
  47166. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47167. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47168. import { Vector3 } from "babylonjs/Maths/math.vector";
  47169. import { Ray } from "babylonjs/Culling/ray";
  47170. import { Plane } from "babylonjs/Maths/math.plane";
  47171. /**
  47172. * Contains an array of blocks representing the octree
  47173. */
  47174. export interface IOctreeContainer<T> {
  47175. /**
  47176. * Blocks within the octree
  47177. */
  47178. blocks: Array<OctreeBlock<T>>;
  47179. }
  47180. /**
  47181. * Class used to store a cell in an octree
  47182. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47183. */
  47184. export class OctreeBlock<T> {
  47185. /**
  47186. * Gets the content of the current block
  47187. */
  47188. entries: T[];
  47189. /**
  47190. * Gets the list of block children
  47191. */
  47192. blocks: Array<OctreeBlock<T>>;
  47193. private _depth;
  47194. private _maxDepth;
  47195. private _capacity;
  47196. private _minPoint;
  47197. private _maxPoint;
  47198. private _boundingVectors;
  47199. private _creationFunc;
  47200. /**
  47201. * Creates a new block
  47202. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47203. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47204. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47205. * @param depth defines the current depth of this block in the octree
  47206. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47207. * @param creationFunc defines a callback to call when an element is added to the block
  47208. */
  47209. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47210. /**
  47211. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47212. */
  47213. get capacity(): number;
  47214. /**
  47215. * Gets the minimum vector (in world space) of the block's bounding box
  47216. */
  47217. get minPoint(): Vector3;
  47218. /**
  47219. * Gets the maximum vector (in world space) of the block's bounding box
  47220. */
  47221. get maxPoint(): Vector3;
  47222. /**
  47223. * Add a new element to this block
  47224. * @param entry defines the element to add
  47225. */
  47226. addEntry(entry: T): void;
  47227. /**
  47228. * Remove an element from this block
  47229. * @param entry defines the element to remove
  47230. */
  47231. removeEntry(entry: T): void;
  47232. /**
  47233. * Add an array of elements to this block
  47234. * @param entries defines the array of elements to add
  47235. */
  47236. addEntries(entries: T[]): void;
  47237. /**
  47238. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47239. * @param frustumPlanes defines the frustum planes to test
  47240. * @param selection defines the array to store current content if selection is positive
  47241. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47242. */
  47243. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47244. /**
  47245. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47246. * @param sphereCenter defines the bounding sphere center
  47247. * @param sphereRadius defines the bounding sphere radius
  47248. * @param selection defines the array to store current content if selection is positive
  47249. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47250. */
  47251. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47252. /**
  47253. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47254. * @param ray defines the ray to test with
  47255. * @param selection defines the array to store current content if selection is positive
  47256. */
  47257. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47258. /**
  47259. * Subdivide the content into child blocks (this block will then be empty)
  47260. */
  47261. createInnerBlocks(): void;
  47262. /**
  47263. * @hidden
  47264. */
  47265. 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;
  47266. }
  47267. }
  47268. declare module "babylonjs/Culling/Octrees/octree" {
  47269. import { SmartArray } from "babylonjs/Misc/smartArray";
  47270. import { Vector3 } from "babylonjs/Maths/math.vector";
  47271. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47273. import { Ray } from "babylonjs/Culling/ray";
  47274. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47275. import { Plane } from "babylonjs/Maths/math.plane";
  47276. /**
  47277. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47278. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47279. */
  47280. export class Octree<T> {
  47281. /** 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.) */
  47282. maxDepth: number;
  47283. /**
  47284. * Blocks within the octree containing objects
  47285. */
  47286. blocks: Array<OctreeBlock<T>>;
  47287. /**
  47288. * Content stored in the octree
  47289. */
  47290. dynamicContent: T[];
  47291. private _maxBlockCapacity;
  47292. private _selectionContent;
  47293. private _creationFunc;
  47294. /**
  47295. * Creates a octree
  47296. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47297. * @param creationFunc function to be used to instatiate the octree
  47298. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47299. * @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.)
  47300. */
  47301. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47302. /** 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.) */
  47303. maxDepth?: number);
  47304. /**
  47305. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47306. * @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);
  47307. * @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);
  47308. * @param entries meshes to be added to the octree blocks
  47309. */
  47310. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47311. /**
  47312. * Adds a mesh to the octree
  47313. * @param entry Mesh to add to the octree
  47314. */
  47315. addMesh(entry: T): void;
  47316. /**
  47317. * Remove an element from the octree
  47318. * @param entry defines the element to remove
  47319. */
  47320. removeMesh(entry: T): void;
  47321. /**
  47322. * Selects an array of meshes within the frustum
  47323. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47324. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47325. * @returns array of meshes within the frustum
  47326. */
  47327. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47328. /**
  47329. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47330. * @param sphereCenter defines the bounding sphere center
  47331. * @param sphereRadius defines the bounding sphere radius
  47332. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47333. * @returns an array of objects that intersect the sphere
  47334. */
  47335. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47336. /**
  47337. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47338. * @param ray defines the ray to test with
  47339. * @returns array of intersected objects
  47340. */
  47341. intersectsRay(ray: Ray): SmartArray<T>;
  47342. /**
  47343. * Adds a mesh into the octree block if it intersects the block
  47344. */
  47345. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47346. /**
  47347. * Adds a submesh into the octree block if it intersects the block
  47348. */
  47349. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47350. }
  47351. }
  47352. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47353. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47354. import { Scene } from "babylonjs/scene";
  47355. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47357. import { Ray } from "babylonjs/Culling/ray";
  47358. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47359. import { Collider } from "babylonjs/Collisions/collider";
  47360. module "babylonjs/scene" {
  47361. interface Scene {
  47362. /**
  47363. * @hidden
  47364. * Backing Filed
  47365. */
  47366. _selectionOctree: Octree<AbstractMesh>;
  47367. /**
  47368. * Gets the octree used to boost mesh selection (picking)
  47369. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47370. */
  47371. selectionOctree: Octree<AbstractMesh>;
  47372. /**
  47373. * Creates or updates the octree used to boost selection (picking)
  47374. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47375. * @param maxCapacity defines the maximum capacity per leaf
  47376. * @param maxDepth defines the maximum depth of the octree
  47377. * @returns an octree of AbstractMesh
  47378. */
  47379. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47380. }
  47381. }
  47382. module "babylonjs/Meshes/abstractMesh" {
  47383. interface AbstractMesh {
  47384. /**
  47385. * @hidden
  47386. * Backing Field
  47387. */
  47388. _submeshesOctree: Octree<SubMesh>;
  47389. /**
  47390. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47391. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47392. * @param maxCapacity defines the maximum size of each block (64 by default)
  47393. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47394. * @returns the new octree
  47395. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47396. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47397. */
  47398. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47399. }
  47400. }
  47401. /**
  47402. * Defines the octree scene component responsible to manage any octrees
  47403. * in a given scene.
  47404. */
  47405. export class OctreeSceneComponent {
  47406. /**
  47407. * The component name help to identify the component in the list of scene components.
  47408. */
  47409. readonly name: string;
  47410. /**
  47411. * The scene the component belongs to.
  47412. */
  47413. scene: Scene;
  47414. /**
  47415. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47416. */
  47417. readonly checksIsEnabled: boolean;
  47418. /**
  47419. * Creates a new instance of the component for the given scene
  47420. * @param scene Defines the scene to register the component in
  47421. */
  47422. constructor(scene: Scene);
  47423. /**
  47424. * Registers the component in a given scene
  47425. */
  47426. register(): void;
  47427. /**
  47428. * Return the list of active meshes
  47429. * @returns the list of active meshes
  47430. */
  47431. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47432. /**
  47433. * Return the list of active sub meshes
  47434. * @param mesh The mesh to get the candidates sub meshes from
  47435. * @returns the list of active sub meshes
  47436. */
  47437. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47438. private _tempRay;
  47439. /**
  47440. * Return the list of sub meshes intersecting with a given local ray
  47441. * @param mesh defines the mesh to find the submesh for
  47442. * @param localRay defines the ray in local space
  47443. * @returns the list of intersecting sub meshes
  47444. */
  47445. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47446. /**
  47447. * Return the list of sub meshes colliding with a collider
  47448. * @param mesh defines the mesh to find the submesh for
  47449. * @param collider defines the collider to evaluate the collision against
  47450. * @returns the list of colliding sub meshes
  47451. */
  47452. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47453. /**
  47454. * Rebuilds the elements related to this component in case of
  47455. * context lost for instance.
  47456. */
  47457. rebuild(): void;
  47458. /**
  47459. * Disposes the component and the associated ressources.
  47460. */
  47461. dispose(): void;
  47462. }
  47463. }
  47464. declare module "babylonjs/Culling/Octrees/index" {
  47465. export * from "babylonjs/Culling/Octrees/octree";
  47466. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47467. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47468. }
  47469. declare module "babylonjs/Culling/index" {
  47470. export * from "babylonjs/Culling/boundingBox";
  47471. export * from "babylonjs/Culling/boundingInfo";
  47472. export * from "babylonjs/Culling/boundingSphere";
  47473. export * from "babylonjs/Culling/Octrees/index";
  47474. export * from "babylonjs/Culling/ray";
  47475. }
  47476. declare module "babylonjs/Gizmos/gizmo" {
  47477. import { Nullable } from "babylonjs/types";
  47478. import { IDisposable } from "babylonjs/scene";
  47479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47480. import { Mesh } from "babylonjs/Meshes/mesh";
  47481. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47482. /**
  47483. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47484. */
  47485. export class Gizmo implements IDisposable {
  47486. /** The utility layer the gizmo will be added to */
  47487. gizmoLayer: UtilityLayerRenderer;
  47488. /**
  47489. * The root mesh of the gizmo
  47490. */
  47491. _rootMesh: Mesh;
  47492. private _attachedMesh;
  47493. /**
  47494. * Ratio for the scale of the gizmo (Default: 1)
  47495. */
  47496. scaleRatio: number;
  47497. /**
  47498. * If a custom mesh has been set (Default: false)
  47499. */
  47500. protected _customMeshSet: boolean;
  47501. /**
  47502. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47503. * * When set, interactions will be enabled
  47504. */
  47505. get attachedMesh(): Nullable<AbstractMesh>;
  47506. set attachedMesh(value: Nullable<AbstractMesh>);
  47507. /**
  47508. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47509. * @param mesh The mesh to replace the default mesh of the gizmo
  47510. */
  47511. setCustomMesh(mesh: Mesh): void;
  47512. /**
  47513. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47514. */
  47515. updateGizmoRotationToMatchAttachedMesh: boolean;
  47516. /**
  47517. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47518. */
  47519. updateGizmoPositionToMatchAttachedMesh: boolean;
  47520. /**
  47521. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47522. */
  47523. updateScale: boolean;
  47524. protected _interactionsEnabled: boolean;
  47525. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47526. private _beforeRenderObserver;
  47527. private _tempVector;
  47528. /**
  47529. * Creates a gizmo
  47530. * @param gizmoLayer The utility layer the gizmo will be added to
  47531. */
  47532. constructor(
  47533. /** The utility layer the gizmo will be added to */
  47534. gizmoLayer?: UtilityLayerRenderer);
  47535. /**
  47536. * Updates the gizmo to match the attached mesh's position/rotation
  47537. */
  47538. protected _update(): void;
  47539. /**
  47540. * Disposes of the gizmo
  47541. */
  47542. dispose(): void;
  47543. }
  47544. }
  47545. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47546. import { Observable } from "babylonjs/Misc/observable";
  47547. import { Nullable } from "babylonjs/types";
  47548. import { Vector3 } from "babylonjs/Maths/math.vector";
  47549. import { Color3 } from "babylonjs/Maths/math.color";
  47550. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47552. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47553. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47554. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47555. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47556. import { Scene } from "babylonjs/scene";
  47557. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47558. /**
  47559. * Single plane drag gizmo
  47560. */
  47561. export class PlaneDragGizmo extends Gizmo {
  47562. /**
  47563. * Drag behavior responsible for the gizmos dragging interactions
  47564. */
  47565. dragBehavior: PointerDragBehavior;
  47566. private _pointerObserver;
  47567. /**
  47568. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47569. */
  47570. snapDistance: number;
  47571. /**
  47572. * Event that fires each time the gizmo snaps to a new location.
  47573. * * snapDistance is the the change in distance
  47574. */
  47575. onSnapObservable: Observable<{
  47576. snapDistance: number;
  47577. }>;
  47578. private _plane;
  47579. private _coloredMaterial;
  47580. private _hoverMaterial;
  47581. private _isEnabled;
  47582. private _parent;
  47583. /** @hidden */
  47584. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47585. /** @hidden */
  47586. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47587. /**
  47588. * Creates a PlaneDragGizmo
  47589. * @param gizmoLayer The utility layer the gizmo will be added to
  47590. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47591. * @param color The color of the gizmo
  47592. */
  47593. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47594. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47595. /**
  47596. * If the gizmo is enabled
  47597. */
  47598. set isEnabled(value: boolean);
  47599. get isEnabled(): boolean;
  47600. /**
  47601. * Disposes of the gizmo
  47602. */
  47603. dispose(): void;
  47604. }
  47605. }
  47606. declare module "babylonjs/Gizmos/positionGizmo" {
  47607. import { Observable } from "babylonjs/Misc/observable";
  47608. import { Nullable } from "babylonjs/types";
  47609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47610. import { Mesh } from "babylonjs/Meshes/mesh";
  47611. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47612. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47613. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47614. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47615. /**
  47616. * Gizmo that enables dragging a mesh along 3 axis
  47617. */
  47618. export class PositionGizmo extends Gizmo {
  47619. /**
  47620. * Internal gizmo used for interactions on the x axis
  47621. */
  47622. xGizmo: AxisDragGizmo;
  47623. /**
  47624. * Internal gizmo used for interactions on the y axis
  47625. */
  47626. yGizmo: AxisDragGizmo;
  47627. /**
  47628. * Internal gizmo used for interactions on the z axis
  47629. */
  47630. zGizmo: AxisDragGizmo;
  47631. /**
  47632. * Internal gizmo used for interactions on the yz plane
  47633. */
  47634. xPlaneGizmo: PlaneDragGizmo;
  47635. /**
  47636. * Internal gizmo used for interactions on the xz plane
  47637. */
  47638. yPlaneGizmo: PlaneDragGizmo;
  47639. /**
  47640. * Internal gizmo used for interactions on the xy plane
  47641. */
  47642. zPlaneGizmo: PlaneDragGizmo;
  47643. /**
  47644. * private variables
  47645. */
  47646. private _meshAttached;
  47647. private _updateGizmoRotationToMatchAttachedMesh;
  47648. private _snapDistance;
  47649. private _scaleRatio;
  47650. /** Fires an event when any of it's sub gizmos are dragged */
  47651. onDragStartObservable: Observable<unknown>;
  47652. /** Fires an event when any of it's sub gizmos are released from dragging */
  47653. onDragEndObservable: Observable<unknown>;
  47654. /**
  47655. * If set to true, planar drag is enabled
  47656. */
  47657. private _planarGizmoEnabled;
  47658. get attachedMesh(): Nullable<AbstractMesh>;
  47659. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47660. /**
  47661. * Creates a PositionGizmo
  47662. * @param gizmoLayer The utility layer the gizmo will be added to
  47663. */
  47664. constructor(gizmoLayer?: UtilityLayerRenderer);
  47665. /**
  47666. * If the planar drag gizmo is enabled
  47667. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47668. */
  47669. set planarGizmoEnabled(value: boolean);
  47670. get planarGizmoEnabled(): boolean;
  47671. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47672. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47673. /**
  47674. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47675. */
  47676. set snapDistance(value: number);
  47677. get snapDistance(): number;
  47678. /**
  47679. * Ratio for the scale of the gizmo (Default: 1)
  47680. */
  47681. set scaleRatio(value: number);
  47682. get scaleRatio(): number;
  47683. /**
  47684. * Disposes of the gizmo
  47685. */
  47686. dispose(): void;
  47687. /**
  47688. * CustomMeshes are not supported by this gizmo
  47689. * @param mesh The mesh to replace the default mesh of the gizmo
  47690. */
  47691. setCustomMesh(mesh: Mesh): void;
  47692. }
  47693. }
  47694. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47695. import { Observable } from "babylonjs/Misc/observable";
  47696. import { Nullable } from "babylonjs/types";
  47697. import { Vector3 } from "babylonjs/Maths/math.vector";
  47698. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47700. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47701. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47702. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47703. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47704. import { Scene } from "babylonjs/scene";
  47705. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47706. import { Color3 } from "babylonjs/Maths/math.color";
  47707. /**
  47708. * Single axis drag gizmo
  47709. */
  47710. export class AxisDragGizmo extends Gizmo {
  47711. /**
  47712. * Drag behavior responsible for the gizmos dragging interactions
  47713. */
  47714. dragBehavior: PointerDragBehavior;
  47715. private _pointerObserver;
  47716. /**
  47717. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47718. */
  47719. snapDistance: number;
  47720. /**
  47721. * Event that fires each time the gizmo snaps to a new location.
  47722. * * snapDistance is the the change in distance
  47723. */
  47724. onSnapObservable: Observable<{
  47725. snapDistance: number;
  47726. }>;
  47727. private _isEnabled;
  47728. private _parent;
  47729. private _arrow;
  47730. private _coloredMaterial;
  47731. private _hoverMaterial;
  47732. /** @hidden */
  47733. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47734. /** @hidden */
  47735. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47736. /**
  47737. * Creates an AxisDragGizmo
  47738. * @param gizmoLayer The utility layer the gizmo will be added to
  47739. * @param dragAxis The axis which the gizmo will be able to drag on
  47740. * @param color The color of the gizmo
  47741. */
  47742. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47743. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47744. /**
  47745. * If the gizmo is enabled
  47746. */
  47747. set isEnabled(value: boolean);
  47748. get isEnabled(): boolean;
  47749. /**
  47750. * Disposes of the gizmo
  47751. */
  47752. dispose(): void;
  47753. }
  47754. }
  47755. declare module "babylonjs/Debug/axesViewer" {
  47756. import { Vector3 } from "babylonjs/Maths/math.vector";
  47757. import { Nullable } from "babylonjs/types";
  47758. import { Scene } from "babylonjs/scene";
  47759. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47760. /**
  47761. * The Axes viewer will show 3 axes in a specific point in space
  47762. */
  47763. export class AxesViewer {
  47764. private _xAxis;
  47765. private _yAxis;
  47766. private _zAxis;
  47767. private _scaleLinesFactor;
  47768. private _instanced;
  47769. /**
  47770. * Gets the hosting scene
  47771. */
  47772. scene: Scene;
  47773. /**
  47774. * Gets or sets a number used to scale line length
  47775. */
  47776. scaleLines: number;
  47777. /** Gets the node hierarchy used to render x-axis */
  47778. get xAxis(): TransformNode;
  47779. /** Gets the node hierarchy used to render y-axis */
  47780. get yAxis(): TransformNode;
  47781. /** Gets the node hierarchy used to render z-axis */
  47782. get zAxis(): TransformNode;
  47783. /**
  47784. * Creates a new AxesViewer
  47785. * @param scene defines the hosting scene
  47786. * @param scaleLines defines a number used to scale line length (1 by default)
  47787. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47788. * @param xAxis defines the node hierarchy used to render the x-axis
  47789. * @param yAxis defines the node hierarchy used to render the y-axis
  47790. * @param zAxis defines the node hierarchy used to render the z-axis
  47791. */
  47792. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47793. /**
  47794. * Force the viewer to update
  47795. * @param position defines the position of the viewer
  47796. * @param xaxis defines the x axis of the viewer
  47797. * @param yaxis defines the y axis of the viewer
  47798. * @param zaxis defines the z axis of the viewer
  47799. */
  47800. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47801. /**
  47802. * Creates an instance of this axes viewer.
  47803. * @returns a new axes viewer with instanced meshes
  47804. */
  47805. createInstance(): AxesViewer;
  47806. /** Releases resources */
  47807. dispose(): void;
  47808. private static _SetRenderingGroupId;
  47809. }
  47810. }
  47811. declare module "babylonjs/Debug/boneAxesViewer" {
  47812. import { Nullable } from "babylonjs/types";
  47813. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47814. import { Vector3 } from "babylonjs/Maths/math.vector";
  47815. import { Mesh } from "babylonjs/Meshes/mesh";
  47816. import { Bone } from "babylonjs/Bones/bone";
  47817. import { Scene } from "babylonjs/scene";
  47818. /**
  47819. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47820. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47821. */
  47822. export class BoneAxesViewer extends AxesViewer {
  47823. /**
  47824. * Gets or sets the target mesh where to display the axes viewer
  47825. */
  47826. mesh: Nullable<Mesh>;
  47827. /**
  47828. * Gets or sets the target bone where to display the axes viewer
  47829. */
  47830. bone: Nullable<Bone>;
  47831. /** Gets current position */
  47832. pos: Vector3;
  47833. /** Gets direction of X axis */
  47834. xaxis: Vector3;
  47835. /** Gets direction of Y axis */
  47836. yaxis: Vector3;
  47837. /** Gets direction of Z axis */
  47838. zaxis: Vector3;
  47839. /**
  47840. * Creates a new BoneAxesViewer
  47841. * @param scene defines the hosting scene
  47842. * @param bone defines the target bone
  47843. * @param mesh defines the target mesh
  47844. * @param scaleLines defines a scaling factor for line length (1 by default)
  47845. */
  47846. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47847. /**
  47848. * Force the viewer to update
  47849. */
  47850. update(): void;
  47851. /** Releases resources */
  47852. dispose(): void;
  47853. }
  47854. }
  47855. declare module "babylonjs/Debug/debugLayer" {
  47856. import { Scene } from "babylonjs/scene";
  47857. /**
  47858. * Interface used to define scene explorer extensibility option
  47859. */
  47860. export interface IExplorerExtensibilityOption {
  47861. /**
  47862. * Define the option label
  47863. */
  47864. label: string;
  47865. /**
  47866. * Defines the action to execute on click
  47867. */
  47868. action: (entity: any) => void;
  47869. }
  47870. /**
  47871. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47872. */
  47873. export interface IExplorerExtensibilityGroup {
  47874. /**
  47875. * Defines a predicate to test if a given type mut be extended
  47876. */
  47877. predicate: (entity: any) => boolean;
  47878. /**
  47879. * Gets the list of options added to a type
  47880. */
  47881. entries: IExplorerExtensibilityOption[];
  47882. }
  47883. /**
  47884. * Interface used to define the options to use to create the Inspector
  47885. */
  47886. export interface IInspectorOptions {
  47887. /**
  47888. * Display in overlay mode (default: false)
  47889. */
  47890. overlay?: boolean;
  47891. /**
  47892. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47893. */
  47894. globalRoot?: HTMLElement;
  47895. /**
  47896. * Display the Scene explorer
  47897. */
  47898. showExplorer?: boolean;
  47899. /**
  47900. * Display the property inspector
  47901. */
  47902. showInspector?: boolean;
  47903. /**
  47904. * Display in embed mode (both panes on the right)
  47905. */
  47906. embedMode?: boolean;
  47907. /**
  47908. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47909. */
  47910. handleResize?: boolean;
  47911. /**
  47912. * Allow the panes to popup (default: true)
  47913. */
  47914. enablePopup?: boolean;
  47915. /**
  47916. * Allow the panes to be closed by users (default: true)
  47917. */
  47918. enableClose?: boolean;
  47919. /**
  47920. * Optional list of extensibility entries
  47921. */
  47922. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47923. /**
  47924. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47925. */
  47926. inspectorURL?: string;
  47927. /**
  47928. * Optional initial tab (default to DebugLayerTab.Properties)
  47929. */
  47930. initialTab?: DebugLayerTab;
  47931. }
  47932. module "babylonjs/scene" {
  47933. interface Scene {
  47934. /**
  47935. * @hidden
  47936. * Backing field
  47937. */
  47938. _debugLayer: DebugLayer;
  47939. /**
  47940. * Gets the debug layer (aka Inspector) associated with the scene
  47941. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47942. */
  47943. debugLayer: DebugLayer;
  47944. }
  47945. }
  47946. /**
  47947. * Enum of inspector action tab
  47948. */
  47949. export enum DebugLayerTab {
  47950. /**
  47951. * Properties tag (default)
  47952. */
  47953. Properties = 0,
  47954. /**
  47955. * Debug tab
  47956. */
  47957. Debug = 1,
  47958. /**
  47959. * Statistics tab
  47960. */
  47961. Statistics = 2,
  47962. /**
  47963. * Tools tab
  47964. */
  47965. Tools = 3,
  47966. /**
  47967. * Settings tab
  47968. */
  47969. Settings = 4
  47970. }
  47971. /**
  47972. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47973. * what is happening in your scene
  47974. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47975. */
  47976. export class DebugLayer {
  47977. /**
  47978. * Define the url to get the inspector script from.
  47979. * By default it uses the babylonjs CDN.
  47980. * @ignoreNaming
  47981. */
  47982. static InspectorURL: string;
  47983. private _scene;
  47984. private BJSINSPECTOR;
  47985. private _onPropertyChangedObservable?;
  47986. /**
  47987. * Observable triggered when a property is changed through the inspector.
  47988. */
  47989. get onPropertyChangedObservable(): any;
  47990. /**
  47991. * Instantiates a new debug layer.
  47992. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47993. * what is happening in your scene
  47994. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47995. * @param scene Defines the scene to inspect
  47996. */
  47997. constructor(scene: Scene);
  47998. /** Creates the inspector window. */
  47999. private _createInspector;
  48000. /**
  48001. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48002. * @param entity defines the entity to select
  48003. * @param lineContainerTitle defines the specific block to highlight
  48004. */
  48005. select(entity: any, lineContainerTitle?: string): void;
  48006. /** Get the inspector from bundle or global */
  48007. private _getGlobalInspector;
  48008. /**
  48009. * Get if the inspector is visible or not.
  48010. * @returns true if visible otherwise, false
  48011. */
  48012. isVisible(): boolean;
  48013. /**
  48014. * Hide the inspector and close its window.
  48015. */
  48016. hide(): void;
  48017. /**
  48018. * Launch the debugLayer.
  48019. * @param config Define the configuration of the inspector
  48020. * @return a promise fulfilled when the debug layer is visible
  48021. */
  48022. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48023. }
  48024. }
  48025. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48026. import { Nullable } from "babylonjs/types";
  48027. import { Scene } from "babylonjs/scene";
  48028. import { Vector4 } from "babylonjs/Maths/math.vector";
  48029. import { Color4 } from "babylonjs/Maths/math.color";
  48030. import { Mesh } from "babylonjs/Meshes/mesh";
  48031. /**
  48032. * Class containing static functions to help procedurally build meshes
  48033. */
  48034. export class BoxBuilder {
  48035. /**
  48036. * Creates a box mesh
  48037. * * The parameter `size` sets the size (float) of each box side (default 1)
  48038. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48039. * * 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)
  48040. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48042. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48044. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48045. * @param name defines the name of the mesh
  48046. * @param options defines the options used to create the mesh
  48047. * @param scene defines the hosting scene
  48048. * @returns the box mesh
  48049. */
  48050. static CreateBox(name: string, options: {
  48051. size?: number;
  48052. width?: number;
  48053. height?: number;
  48054. depth?: number;
  48055. faceUV?: Vector4[];
  48056. faceColors?: Color4[];
  48057. sideOrientation?: number;
  48058. frontUVs?: Vector4;
  48059. backUVs?: Vector4;
  48060. wrap?: boolean;
  48061. topBaseAt?: number;
  48062. bottomBaseAt?: number;
  48063. updatable?: boolean;
  48064. }, scene?: Nullable<Scene>): Mesh;
  48065. }
  48066. }
  48067. declare module "babylonjs/Debug/physicsViewer" {
  48068. import { Nullable } from "babylonjs/types";
  48069. import { Scene } from "babylonjs/scene";
  48070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48071. import { Mesh } from "babylonjs/Meshes/mesh";
  48072. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48073. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48074. /**
  48075. * Used to show the physics impostor around the specific mesh
  48076. */
  48077. export class PhysicsViewer {
  48078. /** @hidden */
  48079. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48080. /** @hidden */
  48081. protected _meshes: Array<Nullable<AbstractMesh>>;
  48082. /** @hidden */
  48083. protected _scene: Nullable<Scene>;
  48084. /** @hidden */
  48085. protected _numMeshes: number;
  48086. /** @hidden */
  48087. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48088. private _renderFunction;
  48089. private _utilityLayer;
  48090. private _debugBoxMesh;
  48091. private _debugSphereMesh;
  48092. private _debugCylinderMesh;
  48093. private _debugMaterial;
  48094. private _debugMeshMeshes;
  48095. /**
  48096. * Creates a new PhysicsViewer
  48097. * @param scene defines the hosting scene
  48098. */
  48099. constructor(scene: Scene);
  48100. /** @hidden */
  48101. protected _updateDebugMeshes(): void;
  48102. /**
  48103. * Renders a specified physic impostor
  48104. * @param impostor defines the impostor to render
  48105. * @param targetMesh defines the mesh represented by the impostor
  48106. * @returns the new debug mesh used to render the impostor
  48107. */
  48108. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48109. /**
  48110. * Hides a specified physic impostor
  48111. * @param impostor defines the impostor to hide
  48112. */
  48113. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48114. private _getDebugMaterial;
  48115. private _getDebugBoxMesh;
  48116. private _getDebugSphereMesh;
  48117. private _getDebugCylinderMesh;
  48118. private _getDebugMeshMesh;
  48119. private _getDebugMesh;
  48120. /** Releases all resources */
  48121. dispose(): void;
  48122. }
  48123. }
  48124. declare module "babylonjs/Debug/rayHelper" {
  48125. import { Nullable } from "babylonjs/types";
  48126. import { Ray } from "babylonjs/Culling/ray";
  48127. import { Vector3 } from "babylonjs/Maths/math.vector";
  48128. import { Color3 } from "babylonjs/Maths/math.color";
  48129. import { Scene } from "babylonjs/scene";
  48130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48131. import "babylonjs/Meshes/Builders/linesBuilder";
  48132. /**
  48133. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48134. * in order to better appreciate the issue one might have.
  48135. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48136. */
  48137. export class RayHelper {
  48138. /**
  48139. * Defines the ray we are currently tryin to visualize.
  48140. */
  48141. ray: Nullable<Ray>;
  48142. private _renderPoints;
  48143. private _renderLine;
  48144. private _renderFunction;
  48145. private _scene;
  48146. private _updateToMeshFunction;
  48147. private _attachedToMesh;
  48148. private _meshSpaceDirection;
  48149. private _meshSpaceOrigin;
  48150. /**
  48151. * Helper function to create a colored helper in a scene in one line.
  48152. * @param ray Defines the ray we are currently tryin to visualize
  48153. * @param scene Defines the scene the ray is used in
  48154. * @param color Defines the color we want to see the ray in
  48155. * @returns The newly created ray helper.
  48156. */
  48157. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48158. /**
  48159. * Instantiate a new ray helper.
  48160. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48161. * in order to better appreciate the issue one might have.
  48162. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48163. * @param ray Defines the ray we are currently tryin to visualize
  48164. */
  48165. constructor(ray: Ray);
  48166. /**
  48167. * Shows the ray we are willing to debug.
  48168. * @param scene Defines the scene the ray needs to be rendered in
  48169. * @param color Defines the color the ray needs to be rendered in
  48170. */
  48171. show(scene: Scene, color?: Color3): void;
  48172. /**
  48173. * Hides the ray we are debugging.
  48174. */
  48175. hide(): void;
  48176. private _render;
  48177. /**
  48178. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48179. * @param mesh Defines the mesh we want the helper attached to
  48180. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48181. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48182. * @param length Defines the length of the ray
  48183. */
  48184. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48185. /**
  48186. * Detach the ray helper from the mesh it has previously been attached to.
  48187. */
  48188. detachFromMesh(): void;
  48189. private _updateToMesh;
  48190. /**
  48191. * Dispose the helper and release its associated resources.
  48192. */
  48193. dispose(): void;
  48194. }
  48195. }
  48196. declare module "babylonjs/Debug/skeletonViewer" {
  48197. import { Color3 } from "babylonjs/Maths/math.color";
  48198. import { Scene } from "babylonjs/scene";
  48199. import { Nullable } from "babylonjs/types";
  48200. import { Skeleton } from "babylonjs/Bones/skeleton";
  48201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48202. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48203. /**
  48204. * Class used to render a debug view of a given skeleton
  48205. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48206. */
  48207. export class SkeletonViewer {
  48208. /** defines the skeleton to render */
  48209. skeleton: Skeleton;
  48210. /** defines the mesh attached to the skeleton */
  48211. mesh: AbstractMesh;
  48212. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48213. autoUpdateBonesMatrices: boolean;
  48214. /** defines the rendering group id to use with the viewer */
  48215. renderingGroupId: number;
  48216. /** Gets or sets the color used to render the skeleton */
  48217. color: Color3;
  48218. private _scene;
  48219. private _debugLines;
  48220. private _debugMesh;
  48221. private _isEnabled;
  48222. private _renderFunction;
  48223. private _utilityLayer;
  48224. /**
  48225. * Returns the mesh used to render the bones
  48226. */
  48227. get debugMesh(): Nullable<LinesMesh>;
  48228. /**
  48229. * Creates a new SkeletonViewer
  48230. * @param skeleton defines the skeleton to render
  48231. * @param mesh defines the mesh attached to the skeleton
  48232. * @param scene defines the hosting scene
  48233. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48234. * @param renderingGroupId defines the rendering group id to use with the viewer
  48235. */
  48236. constructor(
  48237. /** defines the skeleton to render */
  48238. skeleton: Skeleton,
  48239. /** defines the mesh attached to the skeleton */
  48240. mesh: AbstractMesh, scene: Scene,
  48241. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48242. autoUpdateBonesMatrices?: boolean,
  48243. /** defines the rendering group id to use with the viewer */
  48244. renderingGroupId?: number);
  48245. /** Gets or sets a boolean indicating if the viewer is enabled */
  48246. set isEnabled(value: boolean);
  48247. get isEnabled(): boolean;
  48248. private _getBonePosition;
  48249. private _getLinesForBonesWithLength;
  48250. private _getLinesForBonesNoLength;
  48251. /** Update the viewer to sync with current skeleton state */
  48252. update(): void;
  48253. /** Release associated resources */
  48254. dispose(): void;
  48255. }
  48256. }
  48257. declare module "babylonjs/Debug/index" {
  48258. export * from "babylonjs/Debug/axesViewer";
  48259. export * from "babylonjs/Debug/boneAxesViewer";
  48260. export * from "babylonjs/Debug/debugLayer";
  48261. export * from "babylonjs/Debug/physicsViewer";
  48262. export * from "babylonjs/Debug/rayHelper";
  48263. export * from "babylonjs/Debug/skeletonViewer";
  48264. }
  48265. declare module "babylonjs/Engines/nullEngine" {
  48266. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48267. import { Engine } from "babylonjs/Engines/engine";
  48268. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48269. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48270. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48271. import { Effect } from "babylonjs/Materials/effect";
  48272. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48273. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48274. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48275. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48276. /**
  48277. * Options to create the null engine
  48278. */
  48279. export class NullEngineOptions {
  48280. /**
  48281. * Render width (Default: 512)
  48282. */
  48283. renderWidth: number;
  48284. /**
  48285. * Render height (Default: 256)
  48286. */
  48287. renderHeight: number;
  48288. /**
  48289. * Texture size (Default: 512)
  48290. */
  48291. textureSize: number;
  48292. /**
  48293. * If delta time between frames should be constant
  48294. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48295. */
  48296. deterministicLockstep: boolean;
  48297. /**
  48298. * Maximum about of steps between frames (Default: 4)
  48299. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48300. */
  48301. lockstepMaxSteps: number;
  48302. }
  48303. /**
  48304. * The null engine class provides support for headless version of babylon.js.
  48305. * This can be used in server side scenario or for testing purposes
  48306. */
  48307. export class NullEngine extends Engine {
  48308. private _options;
  48309. /**
  48310. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48311. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48312. * @returns true if engine is in deterministic lock step mode
  48313. */
  48314. isDeterministicLockStep(): boolean;
  48315. /**
  48316. * Gets the max steps when engine is running in deterministic lock step
  48317. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48318. * @returns the max steps
  48319. */
  48320. getLockstepMaxSteps(): number;
  48321. /**
  48322. * Gets the current hardware scaling level.
  48323. * By default the hardware scaling level is computed from the window device ratio.
  48324. * 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.
  48325. * @returns a number indicating the current hardware scaling level
  48326. */
  48327. getHardwareScalingLevel(): number;
  48328. constructor(options?: NullEngineOptions);
  48329. /**
  48330. * Creates a vertex buffer
  48331. * @param vertices the data for the vertex buffer
  48332. * @returns the new WebGL static buffer
  48333. */
  48334. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48335. /**
  48336. * Creates a new index buffer
  48337. * @param indices defines the content of the index buffer
  48338. * @param updatable defines if the index buffer must be updatable
  48339. * @returns a new webGL buffer
  48340. */
  48341. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48342. /**
  48343. * Clear the current render buffer or the current render target (if any is set up)
  48344. * @param color defines the color to use
  48345. * @param backBuffer defines if the back buffer must be cleared
  48346. * @param depth defines if the depth buffer must be cleared
  48347. * @param stencil defines if the stencil buffer must be cleared
  48348. */
  48349. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48350. /**
  48351. * Gets the current render width
  48352. * @param useScreen defines if screen size must be used (or the current render target if any)
  48353. * @returns a number defining the current render width
  48354. */
  48355. getRenderWidth(useScreen?: boolean): number;
  48356. /**
  48357. * Gets the current render height
  48358. * @param useScreen defines if screen size must be used (or the current render target if any)
  48359. * @returns a number defining the current render height
  48360. */
  48361. getRenderHeight(useScreen?: boolean): number;
  48362. /**
  48363. * Set the WebGL's viewport
  48364. * @param viewport defines the viewport element to be used
  48365. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48366. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48367. */
  48368. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48369. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48370. /**
  48371. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48372. * @param pipelineContext defines the pipeline context to use
  48373. * @param uniformsNames defines the list of uniform names
  48374. * @returns an array of webGL uniform locations
  48375. */
  48376. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48377. /**
  48378. * Gets the lsit of active attributes for a given webGL program
  48379. * @param pipelineContext defines the pipeline context to use
  48380. * @param attributesNames defines the list of attribute names to get
  48381. * @returns an array of indices indicating the offset of each attribute
  48382. */
  48383. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48384. /**
  48385. * Binds an effect to the webGL context
  48386. * @param effect defines the effect to bind
  48387. */
  48388. bindSamplers(effect: Effect): void;
  48389. /**
  48390. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48391. * @param effect defines the effect to activate
  48392. */
  48393. enableEffect(effect: Effect): void;
  48394. /**
  48395. * Set various states to the webGL context
  48396. * @param culling defines backface culling state
  48397. * @param zOffset defines the value to apply to zOffset (0 by default)
  48398. * @param force defines if states must be applied even if cache is up to date
  48399. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48400. */
  48401. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48402. /**
  48403. * Set the value of an uniform to an array of int32
  48404. * @param uniform defines the webGL uniform location where to store the value
  48405. * @param array defines the array of int32 to store
  48406. */
  48407. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48408. /**
  48409. * Set the value of an uniform to an array of int32 (stored as vec2)
  48410. * @param uniform defines the webGL uniform location where to store the value
  48411. * @param array defines the array of int32 to store
  48412. */
  48413. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48414. /**
  48415. * Set the value of an uniform to an array of int32 (stored as vec3)
  48416. * @param uniform defines the webGL uniform location where to store the value
  48417. * @param array defines the array of int32 to store
  48418. */
  48419. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48420. /**
  48421. * Set the value of an uniform to an array of int32 (stored as vec4)
  48422. * @param uniform defines the webGL uniform location where to store the value
  48423. * @param array defines the array of int32 to store
  48424. */
  48425. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48426. /**
  48427. * Set the value of an uniform to an array of float32
  48428. * @param uniform defines the webGL uniform location where to store the value
  48429. * @param array defines the array of float32 to store
  48430. */
  48431. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48432. /**
  48433. * Set the value of an uniform to an array of float32 (stored as vec2)
  48434. * @param uniform defines the webGL uniform location where to store the value
  48435. * @param array defines the array of float32 to store
  48436. */
  48437. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48438. /**
  48439. * Set the value of an uniform to an array of float32 (stored as vec3)
  48440. * @param uniform defines the webGL uniform location where to store the value
  48441. * @param array defines the array of float32 to store
  48442. */
  48443. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48444. /**
  48445. * Set the value of an uniform to an array of float32 (stored as vec4)
  48446. * @param uniform defines the webGL uniform location where to store the value
  48447. * @param array defines the array of float32 to store
  48448. */
  48449. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48450. /**
  48451. * Set the value of an uniform to an array of number
  48452. * @param uniform defines the webGL uniform location where to store the value
  48453. * @param array defines the array of number to store
  48454. */
  48455. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48456. /**
  48457. * Set the value of an uniform to an array of number (stored as vec2)
  48458. * @param uniform defines the webGL uniform location where to store the value
  48459. * @param array defines the array of number to store
  48460. */
  48461. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48462. /**
  48463. * Set the value of an uniform to an array of number (stored as vec3)
  48464. * @param uniform defines the webGL uniform location where to store the value
  48465. * @param array defines the array of number to store
  48466. */
  48467. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48468. /**
  48469. * Set the value of an uniform to an array of number (stored as vec4)
  48470. * @param uniform defines the webGL uniform location where to store the value
  48471. * @param array defines the array of number to store
  48472. */
  48473. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48474. /**
  48475. * Set the value of an uniform to an array of float32 (stored as matrices)
  48476. * @param uniform defines the webGL uniform location where to store the value
  48477. * @param matrices defines the array of float32 to store
  48478. */
  48479. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48480. /**
  48481. * Set the value of an uniform to a matrix (3x3)
  48482. * @param uniform defines the webGL uniform location where to store the value
  48483. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48484. */
  48485. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48486. /**
  48487. * Set the value of an uniform to a matrix (2x2)
  48488. * @param uniform defines the webGL uniform location where to store the value
  48489. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48490. */
  48491. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48492. /**
  48493. * Set the value of an uniform to a number (float)
  48494. * @param uniform defines the webGL uniform location where to store the value
  48495. * @param value defines the float number to store
  48496. */
  48497. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48498. /**
  48499. * Set the value of an uniform to a vec2
  48500. * @param uniform defines the webGL uniform location where to store the value
  48501. * @param x defines the 1st component of the value
  48502. * @param y defines the 2nd component of the value
  48503. */
  48504. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48505. /**
  48506. * Set the value of an uniform to a vec3
  48507. * @param uniform defines the webGL uniform location where to store the value
  48508. * @param x defines the 1st component of the value
  48509. * @param y defines the 2nd component of the value
  48510. * @param z defines the 3rd component of the value
  48511. */
  48512. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48513. /**
  48514. * Set the value of an uniform to a boolean
  48515. * @param uniform defines the webGL uniform location where to store the value
  48516. * @param bool defines the boolean to store
  48517. */
  48518. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48519. /**
  48520. * Set the value of an uniform to a vec4
  48521. * @param uniform defines the webGL uniform location where to store the value
  48522. * @param x defines the 1st component of the value
  48523. * @param y defines the 2nd component of the value
  48524. * @param z defines the 3rd component of the value
  48525. * @param w defines the 4th component of the value
  48526. */
  48527. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48528. /**
  48529. * Sets the current alpha mode
  48530. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48531. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48532. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48533. */
  48534. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48535. /**
  48536. * Bind webGl buffers directly to the webGL context
  48537. * @param vertexBuffers defines the vertex buffer to bind
  48538. * @param indexBuffer defines the index buffer to bind
  48539. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48540. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48541. * @param effect defines the effect associated with the vertex buffer
  48542. */
  48543. bindBuffers(vertexBuffers: {
  48544. [key: string]: VertexBuffer;
  48545. }, indexBuffer: DataBuffer, effect: Effect): void;
  48546. /**
  48547. * Force the entire cache to be cleared
  48548. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48549. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48550. */
  48551. wipeCaches(bruteForce?: boolean): void;
  48552. /**
  48553. * Send a draw order
  48554. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48555. * @param indexStart defines the starting index
  48556. * @param indexCount defines the number of index to draw
  48557. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48558. */
  48559. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48560. /**
  48561. * Draw a list of indexed primitives
  48562. * @param fillMode defines the primitive to use
  48563. * @param indexStart defines the starting index
  48564. * @param indexCount defines the number of index to draw
  48565. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48566. */
  48567. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48568. /**
  48569. * Draw a list of unindexed primitives
  48570. * @param fillMode defines the primitive to use
  48571. * @param verticesStart defines the index of first vertex to draw
  48572. * @param verticesCount defines the count of vertices to draw
  48573. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48574. */
  48575. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48576. /** @hidden */
  48577. _createTexture(): WebGLTexture;
  48578. /** @hidden */
  48579. _releaseTexture(texture: InternalTexture): void;
  48580. /**
  48581. * Usually called from Texture.ts.
  48582. * Passed information to create a WebGLTexture
  48583. * @param urlArg defines a value which contains one of the following:
  48584. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48585. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48586. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48587. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48588. * @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)
  48589. * @param scene needed for loading to the correct scene
  48590. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48591. * @param onLoad optional callback to be called upon successful completion
  48592. * @param onError optional callback to be called upon failure
  48593. * @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
  48594. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48595. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48596. * @param forcedExtension defines the extension to use to pick the right loader
  48597. * @param mimeType defines an optional mime type
  48598. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48599. */
  48600. 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>, mimeType?: string): InternalTexture;
  48601. /**
  48602. * Creates a new render target texture
  48603. * @param size defines the size of the texture
  48604. * @param options defines the options used to create the texture
  48605. * @returns a new render target texture stored in an InternalTexture
  48606. */
  48607. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48608. /**
  48609. * Update the sampling mode of a given texture
  48610. * @param samplingMode defines the required sampling mode
  48611. * @param texture defines the texture to update
  48612. */
  48613. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48614. /**
  48615. * Binds the frame buffer to the specified texture.
  48616. * @param texture The texture to render to or null for the default canvas
  48617. * @param faceIndex The face of the texture to render to in case of cube texture
  48618. * @param requiredWidth The width of the target to render to
  48619. * @param requiredHeight The height of the target to render to
  48620. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48621. * @param lodLevel defines le lod level to bind to the frame buffer
  48622. */
  48623. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48624. /**
  48625. * Unbind the current render target texture from the webGL context
  48626. * @param texture defines the render target texture to unbind
  48627. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48628. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48629. */
  48630. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48631. /**
  48632. * Creates a dynamic vertex buffer
  48633. * @param vertices the data for the dynamic vertex buffer
  48634. * @returns the new WebGL dynamic buffer
  48635. */
  48636. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48637. /**
  48638. * Update the content of a dynamic texture
  48639. * @param texture defines the texture to update
  48640. * @param canvas defines the canvas containing the source
  48641. * @param invertY defines if data must be stored with Y axis inverted
  48642. * @param premulAlpha defines if alpha is stored as premultiplied
  48643. * @param format defines the format of the data
  48644. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48645. */
  48646. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48647. /**
  48648. * Gets a boolean indicating if all created effects are ready
  48649. * @returns true if all effects are ready
  48650. */
  48651. areAllEffectsReady(): boolean;
  48652. /**
  48653. * @hidden
  48654. * Get the current error code of the webGL context
  48655. * @returns the error code
  48656. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48657. */
  48658. getError(): number;
  48659. /** @hidden */
  48660. _getUnpackAlignement(): number;
  48661. /** @hidden */
  48662. _unpackFlipY(value: boolean): void;
  48663. /**
  48664. * Update a dynamic index buffer
  48665. * @param indexBuffer defines the target index buffer
  48666. * @param indices defines the data to update
  48667. * @param offset defines the offset in the target index buffer where update should start
  48668. */
  48669. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48670. /**
  48671. * Updates a dynamic vertex buffer.
  48672. * @param vertexBuffer the vertex buffer to update
  48673. * @param vertices the data used to update the vertex buffer
  48674. * @param byteOffset the byte offset of the data (optional)
  48675. * @param byteLength the byte length of the data (optional)
  48676. */
  48677. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48678. /** @hidden */
  48679. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48680. /** @hidden */
  48681. _bindTexture(channel: number, texture: InternalTexture): void;
  48682. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48683. /**
  48684. * 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
  48685. */
  48686. releaseEffects(): void;
  48687. displayLoadingUI(): void;
  48688. hideLoadingUI(): void;
  48689. /** @hidden */
  48690. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48691. /** @hidden */
  48692. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48693. /** @hidden */
  48694. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48695. /** @hidden */
  48696. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48697. }
  48698. }
  48699. declare module "babylonjs/Instrumentation/timeToken" {
  48700. import { Nullable } from "babylonjs/types";
  48701. /**
  48702. * @hidden
  48703. **/
  48704. export class _TimeToken {
  48705. _startTimeQuery: Nullable<WebGLQuery>;
  48706. _endTimeQuery: Nullable<WebGLQuery>;
  48707. _timeElapsedQuery: Nullable<WebGLQuery>;
  48708. _timeElapsedQueryEnded: boolean;
  48709. }
  48710. }
  48711. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48712. import { Nullable, int } from "babylonjs/types";
  48713. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48714. /** @hidden */
  48715. export class _OcclusionDataStorage {
  48716. /** @hidden */
  48717. occlusionInternalRetryCounter: number;
  48718. /** @hidden */
  48719. isOcclusionQueryInProgress: boolean;
  48720. /** @hidden */
  48721. isOccluded: boolean;
  48722. /** @hidden */
  48723. occlusionRetryCount: number;
  48724. /** @hidden */
  48725. occlusionType: number;
  48726. /** @hidden */
  48727. occlusionQueryAlgorithmType: number;
  48728. }
  48729. module "babylonjs/Engines/engine" {
  48730. interface Engine {
  48731. /**
  48732. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48733. * @return the new query
  48734. */
  48735. createQuery(): WebGLQuery;
  48736. /**
  48737. * Delete and release a webGL query
  48738. * @param query defines the query to delete
  48739. * @return the current engine
  48740. */
  48741. deleteQuery(query: WebGLQuery): Engine;
  48742. /**
  48743. * Check if a given query has resolved and got its value
  48744. * @param query defines the query to check
  48745. * @returns true if the query got its value
  48746. */
  48747. isQueryResultAvailable(query: WebGLQuery): boolean;
  48748. /**
  48749. * Gets the value of a given query
  48750. * @param query defines the query to check
  48751. * @returns the value of the query
  48752. */
  48753. getQueryResult(query: WebGLQuery): number;
  48754. /**
  48755. * Initiates an occlusion query
  48756. * @param algorithmType defines the algorithm to use
  48757. * @param query defines the query to use
  48758. * @returns the current engine
  48759. * @see http://doc.babylonjs.com/features/occlusionquery
  48760. */
  48761. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48762. /**
  48763. * Ends an occlusion query
  48764. * @see http://doc.babylonjs.com/features/occlusionquery
  48765. * @param algorithmType defines the algorithm to use
  48766. * @returns the current engine
  48767. */
  48768. endOcclusionQuery(algorithmType: number): Engine;
  48769. /**
  48770. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48771. * Please note that only one query can be issued at a time
  48772. * @returns a time token used to track the time span
  48773. */
  48774. startTimeQuery(): Nullable<_TimeToken>;
  48775. /**
  48776. * Ends a time query
  48777. * @param token defines the token used to measure the time span
  48778. * @returns the time spent (in ns)
  48779. */
  48780. endTimeQuery(token: _TimeToken): int;
  48781. /** @hidden */
  48782. _currentNonTimestampToken: Nullable<_TimeToken>;
  48783. /** @hidden */
  48784. _createTimeQuery(): WebGLQuery;
  48785. /** @hidden */
  48786. _deleteTimeQuery(query: WebGLQuery): void;
  48787. /** @hidden */
  48788. _getGlAlgorithmType(algorithmType: number): number;
  48789. /** @hidden */
  48790. _getTimeQueryResult(query: WebGLQuery): any;
  48791. /** @hidden */
  48792. _getTimeQueryAvailability(query: WebGLQuery): any;
  48793. }
  48794. }
  48795. module "babylonjs/Meshes/abstractMesh" {
  48796. interface AbstractMesh {
  48797. /**
  48798. * Backing filed
  48799. * @hidden
  48800. */
  48801. __occlusionDataStorage: _OcclusionDataStorage;
  48802. /**
  48803. * Access property
  48804. * @hidden
  48805. */
  48806. _occlusionDataStorage: _OcclusionDataStorage;
  48807. /**
  48808. * 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.
  48809. * The default value is -1 which means don't break the query and wait till the result
  48810. * @see http://doc.babylonjs.com/features/occlusionquery
  48811. */
  48812. occlusionRetryCount: number;
  48813. /**
  48814. * 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:
  48815. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48816. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48817. * * 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.
  48818. * @see http://doc.babylonjs.com/features/occlusionquery
  48819. */
  48820. occlusionType: number;
  48821. /**
  48822. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48823. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48824. * * 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.
  48825. * @see http://doc.babylonjs.com/features/occlusionquery
  48826. */
  48827. occlusionQueryAlgorithmType: number;
  48828. /**
  48829. * 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
  48830. * @see http://doc.babylonjs.com/features/occlusionquery
  48831. */
  48832. isOccluded: boolean;
  48833. /**
  48834. * Flag to check the progress status of the query
  48835. * @see http://doc.babylonjs.com/features/occlusionquery
  48836. */
  48837. isOcclusionQueryInProgress: boolean;
  48838. }
  48839. }
  48840. }
  48841. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48842. import { Nullable } from "babylonjs/types";
  48843. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48844. /** @hidden */
  48845. export var _forceTransformFeedbackToBundle: boolean;
  48846. module "babylonjs/Engines/engine" {
  48847. interface Engine {
  48848. /**
  48849. * Creates a webGL transform feedback object
  48850. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48851. * @returns the webGL transform feedback object
  48852. */
  48853. createTransformFeedback(): WebGLTransformFeedback;
  48854. /**
  48855. * Delete a webGL transform feedback object
  48856. * @param value defines the webGL transform feedback object to delete
  48857. */
  48858. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48859. /**
  48860. * Bind a webGL transform feedback object to the webgl context
  48861. * @param value defines the webGL transform feedback object to bind
  48862. */
  48863. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48864. /**
  48865. * Begins a transform feedback operation
  48866. * @param usePoints defines if points or triangles must be used
  48867. */
  48868. beginTransformFeedback(usePoints: boolean): void;
  48869. /**
  48870. * Ends a transform feedback operation
  48871. */
  48872. endTransformFeedback(): void;
  48873. /**
  48874. * Specify the varyings to use with transform feedback
  48875. * @param program defines the associated webGL program
  48876. * @param value defines the list of strings representing the varying names
  48877. */
  48878. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48879. /**
  48880. * Bind a webGL buffer for a transform feedback operation
  48881. * @param value defines the webGL buffer to bind
  48882. */
  48883. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48884. }
  48885. }
  48886. }
  48887. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48888. import { Scene } from "babylonjs/scene";
  48889. import { Engine } from "babylonjs/Engines/engine";
  48890. import { Texture } from "babylonjs/Materials/Textures/texture";
  48891. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48892. import "babylonjs/Engines/Extensions/engine.multiRender";
  48893. /**
  48894. * Creation options of the multi render target texture.
  48895. */
  48896. export interface IMultiRenderTargetOptions {
  48897. /**
  48898. * Define if the texture needs to create mip maps after render.
  48899. */
  48900. generateMipMaps?: boolean;
  48901. /**
  48902. * Define the types of all the draw buffers we want to create
  48903. */
  48904. types?: number[];
  48905. /**
  48906. * Define the sampling modes of all the draw buffers we want to create
  48907. */
  48908. samplingModes?: number[];
  48909. /**
  48910. * Define if a depth buffer is required
  48911. */
  48912. generateDepthBuffer?: boolean;
  48913. /**
  48914. * Define if a stencil buffer is required
  48915. */
  48916. generateStencilBuffer?: boolean;
  48917. /**
  48918. * Define if a depth texture is required instead of a depth buffer
  48919. */
  48920. generateDepthTexture?: boolean;
  48921. /**
  48922. * Define the number of desired draw buffers
  48923. */
  48924. textureCount?: number;
  48925. /**
  48926. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48927. */
  48928. doNotChangeAspectRatio?: boolean;
  48929. /**
  48930. * Define the default type of the buffers we are creating
  48931. */
  48932. defaultType?: number;
  48933. }
  48934. /**
  48935. * A multi render target, like a render target provides the ability to render to a texture.
  48936. * Unlike the render target, it can render to several draw buffers in one draw.
  48937. * This is specially interesting in deferred rendering or for any effects requiring more than
  48938. * just one color from a single pass.
  48939. */
  48940. export class MultiRenderTarget extends RenderTargetTexture {
  48941. private _internalTextures;
  48942. private _textures;
  48943. private _multiRenderTargetOptions;
  48944. /**
  48945. * Get if draw buffers are currently supported by the used hardware and browser.
  48946. */
  48947. get isSupported(): boolean;
  48948. /**
  48949. * Get the list of textures generated by the multi render target.
  48950. */
  48951. get textures(): Texture[];
  48952. /**
  48953. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48954. */
  48955. get depthTexture(): Texture;
  48956. /**
  48957. * Set the wrapping mode on U of all the textures we are rendering to.
  48958. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48959. */
  48960. set wrapU(wrap: number);
  48961. /**
  48962. * Set the wrapping mode on V of all the textures we are rendering to.
  48963. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48964. */
  48965. set wrapV(wrap: number);
  48966. /**
  48967. * Instantiate a new multi render target texture.
  48968. * A multi render target, like a render target provides the ability to render to a texture.
  48969. * Unlike the render target, it can render to several draw buffers in one draw.
  48970. * This is specially interesting in deferred rendering or for any effects requiring more than
  48971. * just one color from a single pass.
  48972. * @param name Define the name of the texture
  48973. * @param size Define the size of the buffers to render to
  48974. * @param count Define the number of target we are rendering into
  48975. * @param scene Define the scene the texture belongs to
  48976. * @param options Define the options used to create the multi render target
  48977. */
  48978. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48979. /** @hidden */
  48980. _rebuild(): void;
  48981. private _createInternalTextures;
  48982. private _createTextures;
  48983. /**
  48984. * Define the number of samples used if MSAA is enabled.
  48985. */
  48986. get samples(): number;
  48987. set samples(value: number);
  48988. /**
  48989. * Resize all the textures in the multi render target.
  48990. * Be carrefull as it will recreate all the data in the new texture.
  48991. * @param size Define the new size
  48992. */
  48993. resize(size: any): void;
  48994. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48995. /**
  48996. * Dispose the render targets and their associated resources
  48997. */
  48998. dispose(): void;
  48999. /**
  49000. * Release all the underlying texture used as draw buffers.
  49001. */
  49002. releaseInternalTextures(): void;
  49003. }
  49004. }
  49005. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49006. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49007. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49008. import { Nullable } from "babylonjs/types";
  49009. module "babylonjs/Engines/thinEngine" {
  49010. interface ThinEngine {
  49011. /**
  49012. * Unbind a list of render target textures from the webGL context
  49013. * This is used only when drawBuffer extension or webGL2 are active
  49014. * @param textures defines the render target textures to unbind
  49015. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49016. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49017. */
  49018. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49019. /**
  49020. * Create a multi render target texture
  49021. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49022. * @param size defines the size of the texture
  49023. * @param options defines the creation options
  49024. * @returns the cube texture as an InternalTexture
  49025. */
  49026. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49027. /**
  49028. * Update the sample count for a given multiple render target texture
  49029. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49030. * @param textures defines the textures to update
  49031. * @param samples defines the sample count to set
  49032. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49033. */
  49034. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49035. }
  49036. }
  49037. }
  49038. declare module "babylonjs/Engines/Extensions/engine.views" {
  49039. import { Camera } from "babylonjs/Cameras/camera";
  49040. import { Nullable } from "babylonjs/types";
  49041. /**
  49042. * Class used to define an additional view for the engine
  49043. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49044. */
  49045. export class EngineView {
  49046. /** Defines the canvas where to render the view */
  49047. target: HTMLCanvasElement;
  49048. /** Defines an optional camera used to render the view (will use active camera else) */
  49049. camera?: Camera;
  49050. }
  49051. module "babylonjs/Engines/engine" {
  49052. interface Engine {
  49053. /**
  49054. * Gets or sets the HTML element to use for attaching events
  49055. */
  49056. inputElement: Nullable<HTMLElement>;
  49057. /**
  49058. * Gets the current engine view
  49059. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49060. */
  49061. activeView: Nullable<EngineView>;
  49062. /** Gets or sets the list of views */
  49063. views: EngineView[];
  49064. /**
  49065. * Register a new child canvas
  49066. * @param canvas defines the canvas to register
  49067. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49068. * @returns the associated view
  49069. */
  49070. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49071. /**
  49072. * Remove a registered child canvas
  49073. * @param canvas defines the canvas to remove
  49074. * @returns the current engine
  49075. */
  49076. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49077. }
  49078. }
  49079. }
  49080. declare module "babylonjs/Engines/Extensions/index" {
  49081. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49082. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49083. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49084. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49085. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49086. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49087. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49088. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49089. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49090. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49091. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49092. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49093. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49094. export * from "babylonjs/Engines/Extensions/engine.views";
  49095. }
  49096. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49097. import { Nullable } from "babylonjs/types";
  49098. /**
  49099. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49100. */
  49101. export interface CubeMapInfo {
  49102. /**
  49103. * The pixel array for the front face.
  49104. * This is stored in format, left to right, up to down format.
  49105. */
  49106. front: Nullable<ArrayBufferView>;
  49107. /**
  49108. * The pixel array for the back face.
  49109. * This is stored in format, left to right, up to down format.
  49110. */
  49111. back: Nullable<ArrayBufferView>;
  49112. /**
  49113. * The pixel array for the left face.
  49114. * This is stored in format, left to right, up to down format.
  49115. */
  49116. left: Nullable<ArrayBufferView>;
  49117. /**
  49118. * The pixel array for the right face.
  49119. * This is stored in format, left to right, up to down format.
  49120. */
  49121. right: Nullable<ArrayBufferView>;
  49122. /**
  49123. * The pixel array for the up face.
  49124. * This is stored in format, left to right, up to down format.
  49125. */
  49126. up: Nullable<ArrayBufferView>;
  49127. /**
  49128. * The pixel array for the down face.
  49129. * This is stored in format, left to right, up to down format.
  49130. */
  49131. down: Nullable<ArrayBufferView>;
  49132. /**
  49133. * The size of the cubemap stored.
  49134. *
  49135. * Each faces will be size * size pixels.
  49136. */
  49137. size: number;
  49138. /**
  49139. * The format of the texture.
  49140. *
  49141. * RGBA, RGB.
  49142. */
  49143. format: number;
  49144. /**
  49145. * The type of the texture data.
  49146. *
  49147. * UNSIGNED_INT, FLOAT.
  49148. */
  49149. type: number;
  49150. /**
  49151. * Specifies whether the texture is in gamma space.
  49152. */
  49153. gammaSpace: boolean;
  49154. }
  49155. /**
  49156. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49157. */
  49158. export class PanoramaToCubeMapTools {
  49159. private static FACE_FRONT;
  49160. private static FACE_BACK;
  49161. private static FACE_RIGHT;
  49162. private static FACE_LEFT;
  49163. private static FACE_DOWN;
  49164. private static FACE_UP;
  49165. /**
  49166. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49167. *
  49168. * @param float32Array The source data.
  49169. * @param inputWidth The width of the input panorama.
  49170. * @param inputHeight The height of the input panorama.
  49171. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49172. * @return The cubemap data
  49173. */
  49174. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49175. private static CreateCubemapTexture;
  49176. private static CalcProjectionSpherical;
  49177. }
  49178. }
  49179. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49180. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49181. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49182. import { Nullable } from "babylonjs/types";
  49183. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49184. /**
  49185. * Helper class dealing with the extraction of spherical polynomial dataArray
  49186. * from a cube map.
  49187. */
  49188. export class CubeMapToSphericalPolynomialTools {
  49189. private static FileFaces;
  49190. /**
  49191. * Converts a texture to the according Spherical Polynomial data.
  49192. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49193. *
  49194. * @param texture The texture to extract the information from.
  49195. * @return The Spherical Polynomial data.
  49196. */
  49197. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49198. /**
  49199. * Converts a cubemap to the according Spherical Polynomial data.
  49200. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49201. *
  49202. * @param cubeInfo The Cube map to extract the information from.
  49203. * @return The Spherical Polynomial data.
  49204. */
  49205. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49206. }
  49207. }
  49208. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49209. import { Nullable } from "babylonjs/types";
  49210. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49211. module "babylonjs/Materials/Textures/baseTexture" {
  49212. interface BaseTexture {
  49213. /**
  49214. * Get the polynomial representation of the texture data.
  49215. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49216. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49217. */
  49218. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49219. }
  49220. }
  49221. }
  49222. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49223. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49224. /** @hidden */
  49225. export var rgbdEncodePixelShader: {
  49226. name: string;
  49227. shader: string;
  49228. };
  49229. }
  49230. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49231. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49232. /** @hidden */
  49233. export var rgbdDecodePixelShader: {
  49234. name: string;
  49235. shader: string;
  49236. };
  49237. }
  49238. declare module "babylonjs/Misc/environmentTextureTools" {
  49239. import { Nullable } from "babylonjs/types";
  49240. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49241. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49242. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49243. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49244. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49245. import "babylonjs/Shaders/rgbdEncode.fragment";
  49246. import "babylonjs/Shaders/rgbdDecode.fragment";
  49247. /**
  49248. * Raw texture data and descriptor sufficient for WebGL texture upload
  49249. */
  49250. export interface EnvironmentTextureInfo {
  49251. /**
  49252. * Version of the environment map
  49253. */
  49254. version: number;
  49255. /**
  49256. * Width of image
  49257. */
  49258. width: number;
  49259. /**
  49260. * Irradiance information stored in the file.
  49261. */
  49262. irradiance: any;
  49263. /**
  49264. * Specular information stored in the file.
  49265. */
  49266. specular: any;
  49267. }
  49268. /**
  49269. * Defines One Image in the file. It requires only the position in the file
  49270. * as well as the length.
  49271. */
  49272. interface BufferImageData {
  49273. /**
  49274. * Length of the image data.
  49275. */
  49276. length: number;
  49277. /**
  49278. * Position of the data from the null terminator delimiting the end of the JSON.
  49279. */
  49280. position: number;
  49281. }
  49282. /**
  49283. * Defines the specular data enclosed in the file.
  49284. * This corresponds to the version 1 of the data.
  49285. */
  49286. export interface EnvironmentTextureSpecularInfoV1 {
  49287. /**
  49288. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49289. */
  49290. specularDataPosition?: number;
  49291. /**
  49292. * This contains all the images data needed to reconstruct the cubemap.
  49293. */
  49294. mipmaps: Array<BufferImageData>;
  49295. /**
  49296. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49297. */
  49298. lodGenerationScale: number;
  49299. }
  49300. /**
  49301. * Sets of helpers addressing the serialization and deserialization of environment texture
  49302. * stored in a BabylonJS env file.
  49303. * Those files are usually stored as .env files.
  49304. */
  49305. export class EnvironmentTextureTools {
  49306. /**
  49307. * Magic number identifying the env file.
  49308. */
  49309. private static _MagicBytes;
  49310. /**
  49311. * Gets the environment info from an env file.
  49312. * @param data The array buffer containing the .env bytes.
  49313. * @returns the environment file info (the json header) if successfully parsed.
  49314. */
  49315. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49316. /**
  49317. * Creates an environment texture from a loaded cube texture.
  49318. * @param texture defines the cube texture to convert in env file
  49319. * @return a promise containing the environment data if succesfull.
  49320. */
  49321. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49322. /**
  49323. * Creates a JSON representation of the spherical data.
  49324. * @param texture defines the texture containing the polynomials
  49325. * @return the JSON representation of the spherical info
  49326. */
  49327. private static _CreateEnvTextureIrradiance;
  49328. /**
  49329. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49330. * @param data the image data
  49331. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49332. * @return the views described by info providing access to the underlying buffer
  49333. */
  49334. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49335. /**
  49336. * Uploads the texture info contained in the env file to the GPU.
  49337. * @param texture defines the internal texture to upload to
  49338. * @param data defines the data to load
  49339. * @param info defines the texture info retrieved through the GetEnvInfo method
  49340. * @returns a promise
  49341. */
  49342. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49343. private static _OnImageReadyAsync;
  49344. /**
  49345. * Uploads the levels of image data to the GPU.
  49346. * @param texture defines the internal texture to upload to
  49347. * @param imageData defines the array buffer views of image data [mipmap][face]
  49348. * @returns a promise
  49349. */
  49350. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49351. /**
  49352. * Uploads spherical polynomials information to the texture.
  49353. * @param texture defines the texture we are trying to upload the information to
  49354. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49355. */
  49356. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49357. /** @hidden */
  49358. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49359. }
  49360. }
  49361. declare module "babylonjs/Maths/math.vertexFormat" {
  49362. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49363. /**
  49364. * Contains position and normal vectors for a vertex
  49365. */
  49366. export class PositionNormalVertex {
  49367. /** the position of the vertex (defaut: 0,0,0) */
  49368. position: Vector3;
  49369. /** the normal of the vertex (defaut: 0,1,0) */
  49370. normal: Vector3;
  49371. /**
  49372. * Creates a PositionNormalVertex
  49373. * @param position the position of the vertex (defaut: 0,0,0)
  49374. * @param normal the normal of the vertex (defaut: 0,1,0)
  49375. */
  49376. constructor(
  49377. /** the position of the vertex (defaut: 0,0,0) */
  49378. position?: Vector3,
  49379. /** the normal of the vertex (defaut: 0,1,0) */
  49380. normal?: Vector3);
  49381. /**
  49382. * Clones the PositionNormalVertex
  49383. * @returns the cloned PositionNormalVertex
  49384. */
  49385. clone(): PositionNormalVertex;
  49386. }
  49387. /**
  49388. * Contains position, normal and uv vectors for a vertex
  49389. */
  49390. export class PositionNormalTextureVertex {
  49391. /** the position of the vertex (defaut: 0,0,0) */
  49392. position: Vector3;
  49393. /** the normal of the vertex (defaut: 0,1,0) */
  49394. normal: Vector3;
  49395. /** the uv of the vertex (default: 0,0) */
  49396. uv: Vector2;
  49397. /**
  49398. * Creates a PositionNormalTextureVertex
  49399. * @param position the position of the vertex (defaut: 0,0,0)
  49400. * @param normal the normal of the vertex (defaut: 0,1,0)
  49401. * @param uv the uv of the vertex (default: 0,0)
  49402. */
  49403. constructor(
  49404. /** the position of the vertex (defaut: 0,0,0) */
  49405. position?: Vector3,
  49406. /** the normal of the vertex (defaut: 0,1,0) */
  49407. normal?: Vector3,
  49408. /** the uv of the vertex (default: 0,0) */
  49409. uv?: Vector2);
  49410. /**
  49411. * Clones the PositionNormalTextureVertex
  49412. * @returns the cloned PositionNormalTextureVertex
  49413. */
  49414. clone(): PositionNormalTextureVertex;
  49415. }
  49416. }
  49417. declare module "babylonjs/Maths/math" {
  49418. export * from "babylonjs/Maths/math.axis";
  49419. export * from "babylonjs/Maths/math.color";
  49420. export * from "babylonjs/Maths/math.constants";
  49421. export * from "babylonjs/Maths/math.frustum";
  49422. export * from "babylonjs/Maths/math.path";
  49423. export * from "babylonjs/Maths/math.plane";
  49424. export * from "babylonjs/Maths/math.size";
  49425. export * from "babylonjs/Maths/math.vector";
  49426. export * from "babylonjs/Maths/math.vertexFormat";
  49427. export * from "babylonjs/Maths/math.viewport";
  49428. }
  49429. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49430. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49431. /** @hidden */
  49432. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49433. private _genericAttributeLocation;
  49434. private _varyingLocationCount;
  49435. private _varyingLocationMap;
  49436. private _replacements;
  49437. private _textureCount;
  49438. private _uniforms;
  49439. lineProcessor(line: string): string;
  49440. attributeProcessor(attribute: string): string;
  49441. varyingProcessor(varying: string, isFragment: boolean): string;
  49442. uniformProcessor(uniform: string): string;
  49443. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49444. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49445. }
  49446. }
  49447. declare module "babylonjs/Engines/nativeEngine" {
  49448. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49449. import { Engine } from "babylonjs/Engines/engine";
  49450. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49451. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49452. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49453. import { Effect } from "babylonjs/Materials/effect";
  49454. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49455. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49456. import { IColor4Like } from "babylonjs/Maths/math.like";
  49457. import { Scene } from "babylonjs/scene";
  49458. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49459. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49460. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49461. /**
  49462. * Container for accessors for natively-stored mesh data buffers.
  49463. */
  49464. class NativeDataBuffer extends DataBuffer {
  49465. /**
  49466. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49467. */
  49468. nativeIndexBuffer?: any;
  49469. /**
  49470. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49471. */
  49472. nativeVertexBuffer?: any;
  49473. }
  49474. /** @hidden */
  49475. class NativeTexture extends InternalTexture {
  49476. getInternalTexture(): InternalTexture;
  49477. getViewCount(): number;
  49478. }
  49479. /** @hidden */
  49480. export class NativeEngine extends Engine {
  49481. private readonly _native;
  49482. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49483. private readonly INVALID_HANDLE;
  49484. getHardwareScalingLevel(): number;
  49485. constructor();
  49486. /**
  49487. * Can be used to override the current requestAnimationFrame requester.
  49488. * @hidden
  49489. */
  49490. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49491. /**
  49492. * Override default engine behavior.
  49493. * @param color
  49494. * @param backBuffer
  49495. * @param depth
  49496. * @param stencil
  49497. */
  49498. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49499. /**
  49500. * Gets host document
  49501. * @returns the host document object
  49502. */
  49503. getHostDocument(): Nullable<Document>;
  49504. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49505. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49506. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49507. recordVertexArrayObject(vertexBuffers: {
  49508. [key: string]: VertexBuffer;
  49509. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49510. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49511. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49512. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49513. /**
  49514. * Draw a list of indexed primitives
  49515. * @param fillMode defines the primitive to use
  49516. * @param indexStart defines the starting index
  49517. * @param indexCount defines the number of index to draw
  49518. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49519. */
  49520. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49521. /**
  49522. * Draw a list of unindexed primitives
  49523. * @param fillMode defines the primitive to use
  49524. * @param verticesStart defines the index of first vertex to draw
  49525. * @param verticesCount defines the count of vertices to draw
  49526. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49527. */
  49528. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49529. createPipelineContext(): IPipelineContext;
  49530. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49531. /** @hidden */
  49532. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49533. /** @hidden */
  49534. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49535. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49536. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49537. protected _setProgram(program: WebGLProgram): void;
  49538. _releaseEffect(effect: Effect): void;
  49539. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49540. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49541. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49542. bindSamplers(effect: Effect): void;
  49543. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49544. getRenderWidth(useScreen?: boolean): number;
  49545. getRenderHeight(useScreen?: boolean): number;
  49546. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49547. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49548. /**
  49549. * Set the z offset to apply to current rendering
  49550. * @param value defines the offset to apply
  49551. */
  49552. setZOffset(value: number): void;
  49553. /**
  49554. * Gets the current value of the zOffset
  49555. * @returns the current zOffset state
  49556. */
  49557. getZOffset(): number;
  49558. /**
  49559. * Enable or disable depth buffering
  49560. * @param enable defines the state to set
  49561. */
  49562. setDepthBuffer(enable: boolean): void;
  49563. /**
  49564. * Gets a boolean indicating if depth writing is enabled
  49565. * @returns the current depth writing state
  49566. */
  49567. getDepthWrite(): boolean;
  49568. /**
  49569. * Enable or disable depth writing
  49570. * @param enable defines the state to set
  49571. */
  49572. setDepthWrite(enable: boolean): void;
  49573. /**
  49574. * Enable or disable color writing
  49575. * @param enable defines the state to set
  49576. */
  49577. setColorWrite(enable: boolean): void;
  49578. /**
  49579. * Gets a boolean indicating if color writing is enabled
  49580. * @returns the current color writing state
  49581. */
  49582. getColorWrite(): boolean;
  49583. /**
  49584. * Sets alpha constants used by some alpha blending modes
  49585. * @param r defines the red component
  49586. * @param g defines the green component
  49587. * @param b defines the blue component
  49588. * @param a defines the alpha component
  49589. */
  49590. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49591. /**
  49592. * Sets the current alpha mode
  49593. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49594. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49595. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49596. */
  49597. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49598. /**
  49599. * Gets the current alpha mode
  49600. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49601. * @returns the current alpha mode
  49602. */
  49603. getAlphaMode(): number;
  49604. setInt(uniform: WebGLUniformLocation, int: number): void;
  49605. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49606. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49607. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49608. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49609. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49610. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49611. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49612. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49613. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49614. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49615. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49616. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49617. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49618. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49619. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49620. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49621. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49622. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49623. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49624. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49625. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49626. wipeCaches(bruteForce?: boolean): void;
  49627. _createTexture(): WebGLTexture;
  49628. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49629. /**
  49630. * Usually called from Texture.ts.
  49631. * Passed information to create a WebGLTexture
  49632. * @param urlArg defines a value which contains one of the following:
  49633. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49634. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49635. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49636. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49637. * @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)
  49638. * @param scene needed for loading to the correct scene
  49639. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49640. * @param onLoad optional callback to be called upon successful completion
  49641. * @param onError optional callback to be called upon failure
  49642. * @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
  49643. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49644. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49645. * @param forcedExtension defines the extension to use to pick the right loader
  49646. * @param mimeType defines an optional mime type
  49647. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49648. */
  49649. 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>, mimeType?: string): InternalTexture;
  49650. /**
  49651. * Creates a cube texture
  49652. * @param rootUrl defines the url where the files to load is located
  49653. * @param scene defines the current scene
  49654. * @param files defines the list of files to load (1 per face)
  49655. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49656. * @param onLoad defines an optional callback raised when the texture is loaded
  49657. * @param onError defines an optional callback raised if there is an issue to load the texture
  49658. * @param format defines the format of the data
  49659. * @param forcedExtension defines the extension to use to pick the right loader
  49660. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49661. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49662. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49663. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49664. * @returns the cube texture as an InternalTexture
  49665. */
  49666. 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;
  49667. private _getSamplingFilter;
  49668. private static _GetNativeTextureFormat;
  49669. createRenderTargetTexture(size: number | {
  49670. width: number;
  49671. height: number;
  49672. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49673. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49674. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49675. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49676. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49677. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49678. /**
  49679. * Updates a dynamic vertex buffer.
  49680. * @param vertexBuffer the vertex buffer to update
  49681. * @param data the data used to update the vertex buffer
  49682. * @param byteOffset the byte offset of the data (optional)
  49683. * @param byteLength the byte length of the data (optional)
  49684. */
  49685. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49686. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49687. private _updateAnisotropicLevel;
  49688. private _getAddressMode;
  49689. /** @hidden */
  49690. _bindTexture(channel: number, texture: InternalTexture): void;
  49691. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49692. releaseEffects(): void;
  49693. /** @hidden */
  49694. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49695. /** @hidden */
  49696. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49697. /** @hidden */
  49698. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49699. /** @hidden */
  49700. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49701. }
  49702. }
  49703. declare module "babylonjs/Engines/index" {
  49704. export * from "babylonjs/Engines/constants";
  49705. export * from "babylonjs/Engines/engineCapabilities";
  49706. export * from "babylonjs/Engines/instancingAttributeInfo";
  49707. export * from "babylonjs/Engines/thinEngine";
  49708. export * from "babylonjs/Engines/engine";
  49709. export * from "babylonjs/Engines/engineStore";
  49710. export * from "babylonjs/Engines/nullEngine";
  49711. export * from "babylonjs/Engines/Extensions/index";
  49712. export * from "babylonjs/Engines/IPipelineContext";
  49713. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49714. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49715. export * from "babylonjs/Engines/nativeEngine";
  49716. }
  49717. declare module "babylonjs/Events/clipboardEvents" {
  49718. /**
  49719. * Gather the list of clipboard event types as constants.
  49720. */
  49721. export class ClipboardEventTypes {
  49722. /**
  49723. * The clipboard event is fired when a copy command is active (pressed).
  49724. */
  49725. static readonly COPY: number;
  49726. /**
  49727. * The clipboard event is fired when a cut command is active (pressed).
  49728. */
  49729. static readonly CUT: number;
  49730. /**
  49731. * The clipboard event is fired when a paste command is active (pressed).
  49732. */
  49733. static readonly PASTE: number;
  49734. }
  49735. /**
  49736. * This class is used to store clipboard related info for the onClipboardObservable event.
  49737. */
  49738. export class ClipboardInfo {
  49739. /**
  49740. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49741. */
  49742. type: number;
  49743. /**
  49744. * Defines the related dom event
  49745. */
  49746. event: ClipboardEvent;
  49747. /**
  49748. *Creates an instance of ClipboardInfo.
  49749. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49750. * @param event Defines the related dom event
  49751. */
  49752. constructor(
  49753. /**
  49754. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49755. */
  49756. type: number,
  49757. /**
  49758. * Defines the related dom event
  49759. */
  49760. event: ClipboardEvent);
  49761. /**
  49762. * Get the clipboard event's type from the keycode.
  49763. * @param keyCode Defines the keyCode for the current keyboard event.
  49764. * @return {number}
  49765. */
  49766. static GetTypeFromCharacter(keyCode: number): number;
  49767. }
  49768. }
  49769. declare module "babylonjs/Events/index" {
  49770. export * from "babylonjs/Events/keyboardEvents";
  49771. export * from "babylonjs/Events/pointerEvents";
  49772. export * from "babylonjs/Events/clipboardEvents";
  49773. }
  49774. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49775. import { Scene } from "babylonjs/scene";
  49776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49777. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49778. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49779. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49780. /**
  49781. * Google Daydream controller
  49782. */
  49783. export class DaydreamController extends WebVRController {
  49784. /**
  49785. * Base Url for the controller model.
  49786. */
  49787. static MODEL_BASE_URL: string;
  49788. /**
  49789. * File name for the controller model.
  49790. */
  49791. static MODEL_FILENAME: string;
  49792. /**
  49793. * Gamepad Id prefix used to identify Daydream Controller.
  49794. */
  49795. static readonly GAMEPAD_ID_PREFIX: string;
  49796. /**
  49797. * Creates a new DaydreamController from a gamepad
  49798. * @param vrGamepad the gamepad that the controller should be created from
  49799. */
  49800. constructor(vrGamepad: any);
  49801. /**
  49802. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49803. * @param scene scene in which to add meshes
  49804. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49805. */
  49806. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49807. /**
  49808. * Called once for each button that changed state since the last frame
  49809. * @param buttonIdx Which button index changed
  49810. * @param state New state of the button
  49811. * @param changes Which properties on the state changed since last frame
  49812. */
  49813. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49814. }
  49815. }
  49816. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49817. import { Scene } from "babylonjs/scene";
  49818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49819. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49820. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49821. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49822. /**
  49823. * Gear VR Controller
  49824. */
  49825. export class GearVRController extends WebVRController {
  49826. /**
  49827. * Base Url for the controller model.
  49828. */
  49829. static MODEL_BASE_URL: string;
  49830. /**
  49831. * File name for the controller model.
  49832. */
  49833. static MODEL_FILENAME: string;
  49834. /**
  49835. * Gamepad Id prefix used to identify this controller.
  49836. */
  49837. static readonly GAMEPAD_ID_PREFIX: string;
  49838. private readonly _buttonIndexToObservableNameMap;
  49839. /**
  49840. * Creates a new GearVRController from a gamepad
  49841. * @param vrGamepad the gamepad that the controller should be created from
  49842. */
  49843. constructor(vrGamepad: any);
  49844. /**
  49845. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49846. * @param scene scene in which to add meshes
  49847. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49848. */
  49849. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49850. /**
  49851. * Called once for each button that changed state since the last frame
  49852. * @param buttonIdx Which button index changed
  49853. * @param state New state of the button
  49854. * @param changes Which properties on the state changed since last frame
  49855. */
  49856. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49857. }
  49858. }
  49859. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49860. import { Scene } from "babylonjs/scene";
  49861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49862. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49863. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49864. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49865. /**
  49866. * Generic Controller
  49867. */
  49868. export class GenericController extends WebVRController {
  49869. /**
  49870. * Base Url for the controller model.
  49871. */
  49872. static readonly MODEL_BASE_URL: string;
  49873. /**
  49874. * File name for the controller model.
  49875. */
  49876. static readonly MODEL_FILENAME: string;
  49877. /**
  49878. * Creates a new GenericController from a gamepad
  49879. * @param vrGamepad the gamepad that the controller should be created from
  49880. */
  49881. constructor(vrGamepad: any);
  49882. /**
  49883. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49884. * @param scene scene in which to add meshes
  49885. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49886. */
  49887. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49888. /**
  49889. * Called once for each button that changed state since the last frame
  49890. * @param buttonIdx Which button index changed
  49891. * @param state New state of the button
  49892. * @param changes Which properties on the state changed since last frame
  49893. */
  49894. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49895. }
  49896. }
  49897. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49898. import { Observable } from "babylonjs/Misc/observable";
  49899. import { Scene } from "babylonjs/scene";
  49900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49901. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49902. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49903. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49904. /**
  49905. * Oculus Touch Controller
  49906. */
  49907. export class OculusTouchController extends WebVRController {
  49908. /**
  49909. * Base Url for the controller model.
  49910. */
  49911. static MODEL_BASE_URL: string;
  49912. /**
  49913. * File name for the left controller model.
  49914. */
  49915. static MODEL_LEFT_FILENAME: string;
  49916. /**
  49917. * File name for the right controller model.
  49918. */
  49919. static MODEL_RIGHT_FILENAME: string;
  49920. /**
  49921. * Base Url for the Quest controller model.
  49922. */
  49923. static QUEST_MODEL_BASE_URL: string;
  49924. /**
  49925. * @hidden
  49926. * If the controllers are running on a device that needs the updated Quest controller models
  49927. */
  49928. static _IsQuest: boolean;
  49929. /**
  49930. * Fired when the secondary trigger on this controller is modified
  49931. */
  49932. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49933. /**
  49934. * Fired when the thumb rest on this controller is modified
  49935. */
  49936. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49937. /**
  49938. * Creates a new OculusTouchController from a gamepad
  49939. * @param vrGamepad the gamepad that the controller should be created from
  49940. */
  49941. constructor(vrGamepad: any);
  49942. /**
  49943. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49944. * @param scene scene in which to add meshes
  49945. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49946. */
  49947. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49948. /**
  49949. * Fired when the A button on this controller is modified
  49950. */
  49951. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49952. /**
  49953. * Fired when the B button on this controller is modified
  49954. */
  49955. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49956. /**
  49957. * Fired when the X button on this controller is modified
  49958. */
  49959. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49960. /**
  49961. * Fired when the Y button on this controller is modified
  49962. */
  49963. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49964. /**
  49965. * Called once for each button that changed state since the last frame
  49966. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49967. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49968. * 2) secondary trigger (same)
  49969. * 3) A (right) X (left), touch, pressed = value
  49970. * 4) B / Y
  49971. * 5) thumb rest
  49972. * @param buttonIdx Which button index changed
  49973. * @param state New state of the button
  49974. * @param changes Which properties on the state changed since last frame
  49975. */
  49976. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49977. }
  49978. }
  49979. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49980. import { Scene } from "babylonjs/scene";
  49981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49982. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49983. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49984. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49985. import { Observable } from "babylonjs/Misc/observable";
  49986. /**
  49987. * Vive Controller
  49988. */
  49989. export class ViveController extends WebVRController {
  49990. /**
  49991. * Base Url for the controller model.
  49992. */
  49993. static MODEL_BASE_URL: string;
  49994. /**
  49995. * File name for the controller model.
  49996. */
  49997. static MODEL_FILENAME: string;
  49998. /**
  49999. * Creates a new ViveController from a gamepad
  50000. * @param vrGamepad the gamepad that the controller should be created from
  50001. */
  50002. constructor(vrGamepad: any);
  50003. /**
  50004. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50005. * @param scene scene in which to add meshes
  50006. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50007. */
  50008. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50009. /**
  50010. * Fired when the left button on this controller is modified
  50011. */
  50012. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50013. /**
  50014. * Fired when the right button on this controller is modified
  50015. */
  50016. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50017. /**
  50018. * Fired when the menu button on this controller is modified
  50019. */
  50020. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50021. /**
  50022. * Called once for each button that changed state since the last frame
  50023. * Vive mapping:
  50024. * 0: touchpad
  50025. * 1: trigger
  50026. * 2: left AND right buttons
  50027. * 3: menu button
  50028. * @param buttonIdx Which button index changed
  50029. * @param state New state of the button
  50030. * @param changes Which properties on the state changed since last frame
  50031. */
  50032. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50033. }
  50034. }
  50035. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50036. import { Observable } from "babylonjs/Misc/observable";
  50037. import { Scene } from "babylonjs/scene";
  50038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50039. import { Ray } from "babylonjs/Culling/ray";
  50040. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50041. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50042. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50043. /**
  50044. * Defines the WindowsMotionController object that the state of the windows motion controller
  50045. */
  50046. export class WindowsMotionController extends WebVRController {
  50047. /**
  50048. * The base url used to load the left and right controller models
  50049. */
  50050. static MODEL_BASE_URL: string;
  50051. /**
  50052. * The name of the left controller model file
  50053. */
  50054. static MODEL_LEFT_FILENAME: string;
  50055. /**
  50056. * The name of the right controller model file
  50057. */
  50058. static MODEL_RIGHT_FILENAME: string;
  50059. /**
  50060. * The controller name prefix for this controller type
  50061. */
  50062. static readonly GAMEPAD_ID_PREFIX: string;
  50063. /**
  50064. * The controller id pattern for this controller type
  50065. */
  50066. private static readonly GAMEPAD_ID_PATTERN;
  50067. private _loadedMeshInfo;
  50068. protected readonly _mapping: {
  50069. buttons: string[];
  50070. buttonMeshNames: {
  50071. 'trigger': string;
  50072. 'menu': string;
  50073. 'grip': string;
  50074. 'thumbstick': string;
  50075. 'trackpad': string;
  50076. };
  50077. buttonObservableNames: {
  50078. 'trigger': string;
  50079. 'menu': string;
  50080. 'grip': string;
  50081. 'thumbstick': string;
  50082. 'trackpad': string;
  50083. };
  50084. axisMeshNames: string[];
  50085. pointingPoseMeshName: string;
  50086. };
  50087. /**
  50088. * Fired when the trackpad on this controller is clicked
  50089. */
  50090. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50091. /**
  50092. * Fired when the trackpad on this controller is modified
  50093. */
  50094. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50095. /**
  50096. * The current x and y values of this controller's trackpad
  50097. */
  50098. trackpad: StickValues;
  50099. /**
  50100. * Creates a new WindowsMotionController from a gamepad
  50101. * @param vrGamepad the gamepad that the controller should be created from
  50102. */
  50103. constructor(vrGamepad: any);
  50104. /**
  50105. * Fired when the trigger on this controller is modified
  50106. */
  50107. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50108. /**
  50109. * Fired when the menu button on this controller is modified
  50110. */
  50111. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50112. /**
  50113. * Fired when the grip button on this controller is modified
  50114. */
  50115. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50116. /**
  50117. * Fired when the thumbstick button on this controller is modified
  50118. */
  50119. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50120. /**
  50121. * Fired when the touchpad button on this controller is modified
  50122. */
  50123. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50124. /**
  50125. * Fired when the touchpad values on this controller are modified
  50126. */
  50127. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50128. protected _updateTrackpad(): void;
  50129. /**
  50130. * Called once per frame by the engine.
  50131. */
  50132. update(): void;
  50133. /**
  50134. * Called once for each button that changed state since the last frame
  50135. * @param buttonIdx Which button index changed
  50136. * @param state New state of the button
  50137. * @param changes Which properties on the state changed since last frame
  50138. */
  50139. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50140. /**
  50141. * Moves the buttons on the controller mesh based on their current state
  50142. * @param buttonName the name of the button to move
  50143. * @param buttonValue the value of the button which determines the buttons new position
  50144. */
  50145. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50146. /**
  50147. * Moves the axis on the controller mesh based on its current state
  50148. * @param axis the index of the axis
  50149. * @param axisValue the value of the axis which determines the meshes new position
  50150. * @hidden
  50151. */
  50152. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50153. /**
  50154. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50155. * @param scene scene in which to add meshes
  50156. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50157. */
  50158. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50159. /**
  50160. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50161. * can be transformed by button presses and axes values, based on this._mapping.
  50162. *
  50163. * @param scene scene in which the meshes exist
  50164. * @param meshes list of meshes that make up the controller model to process
  50165. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50166. */
  50167. private processModel;
  50168. private createMeshInfo;
  50169. /**
  50170. * Gets the ray of the controller in the direction the controller is pointing
  50171. * @param length the length the resulting ray should be
  50172. * @returns a ray in the direction the controller is pointing
  50173. */
  50174. getForwardRay(length?: number): Ray;
  50175. /**
  50176. * Disposes of the controller
  50177. */
  50178. dispose(): void;
  50179. }
  50180. /**
  50181. * This class represents a new windows motion controller in XR.
  50182. */
  50183. export class XRWindowsMotionController extends WindowsMotionController {
  50184. /**
  50185. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50186. */
  50187. protected readonly _mapping: {
  50188. buttons: string[];
  50189. buttonMeshNames: {
  50190. 'trigger': string;
  50191. 'menu': string;
  50192. 'grip': string;
  50193. 'thumbstick': string;
  50194. 'trackpad': string;
  50195. };
  50196. buttonObservableNames: {
  50197. 'trigger': string;
  50198. 'menu': string;
  50199. 'grip': string;
  50200. 'thumbstick': string;
  50201. 'trackpad': string;
  50202. };
  50203. axisMeshNames: string[];
  50204. pointingPoseMeshName: string;
  50205. };
  50206. /**
  50207. * Construct a new XR-Based windows motion controller
  50208. *
  50209. * @param gamepadInfo the gamepad object from the browser
  50210. */
  50211. constructor(gamepadInfo: any);
  50212. /**
  50213. * holds the thumbstick values (X,Y)
  50214. */
  50215. thumbstickValues: StickValues;
  50216. /**
  50217. * Fired when the thumbstick on this controller is clicked
  50218. */
  50219. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50220. /**
  50221. * Fired when the thumbstick on this controller is modified
  50222. */
  50223. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50224. /**
  50225. * Fired when the touchpad button on this controller is modified
  50226. */
  50227. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50228. /**
  50229. * Fired when the touchpad values on this controller are modified
  50230. */
  50231. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50232. /**
  50233. * Fired when the thumbstick button on this controller is modified
  50234. * here to prevent breaking changes
  50235. */
  50236. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50237. /**
  50238. * updating the thumbstick(!) and not the trackpad.
  50239. * This is named this way due to the difference between WebVR and XR and to avoid
  50240. * changing the parent class.
  50241. */
  50242. protected _updateTrackpad(): void;
  50243. /**
  50244. * Disposes the class with joy
  50245. */
  50246. dispose(): void;
  50247. }
  50248. }
  50249. declare module "babylonjs/Gamepads/Controllers/index" {
  50250. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50251. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50252. export * from "babylonjs/Gamepads/Controllers/genericController";
  50253. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50254. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50255. export * from "babylonjs/Gamepads/Controllers/viveController";
  50256. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50257. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50258. }
  50259. declare module "babylonjs/Gamepads/index" {
  50260. export * from "babylonjs/Gamepads/Controllers/index";
  50261. export * from "babylonjs/Gamepads/gamepad";
  50262. export * from "babylonjs/Gamepads/gamepadManager";
  50263. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50264. export * from "babylonjs/Gamepads/xboxGamepad";
  50265. export * from "babylonjs/Gamepads/dualShockGamepad";
  50266. }
  50267. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50268. import { Scene } from "babylonjs/scene";
  50269. import { Vector4 } from "babylonjs/Maths/math.vector";
  50270. import { Color4 } from "babylonjs/Maths/math.color";
  50271. import { Mesh } from "babylonjs/Meshes/mesh";
  50272. import { Nullable } from "babylonjs/types";
  50273. /**
  50274. * Class containing static functions to help procedurally build meshes
  50275. */
  50276. export class PolyhedronBuilder {
  50277. /**
  50278. * Creates a polyhedron mesh
  50279. * * 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
  50280. * * The parameter `size` (positive float, default 1) sets the polygon size
  50281. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50282. * * 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`
  50283. * * 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
  50284. * * 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)`)
  50285. * * 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
  50286. * * 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
  50287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50288. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50290. * @param name defines the name of the mesh
  50291. * @param options defines the options used to create the mesh
  50292. * @param scene defines the hosting scene
  50293. * @returns the polyhedron mesh
  50294. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50295. */
  50296. static CreatePolyhedron(name: string, options: {
  50297. type?: number;
  50298. size?: number;
  50299. sizeX?: number;
  50300. sizeY?: number;
  50301. sizeZ?: number;
  50302. custom?: any;
  50303. faceUV?: Vector4[];
  50304. faceColors?: Color4[];
  50305. flat?: boolean;
  50306. updatable?: boolean;
  50307. sideOrientation?: number;
  50308. frontUVs?: Vector4;
  50309. backUVs?: Vector4;
  50310. }, scene?: Nullable<Scene>): Mesh;
  50311. }
  50312. }
  50313. declare module "babylonjs/Gizmos/scaleGizmo" {
  50314. import { Observable } from "babylonjs/Misc/observable";
  50315. import { Nullable } from "babylonjs/types";
  50316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50317. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50318. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50319. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50320. /**
  50321. * Gizmo that enables scaling a mesh along 3 axis
  50322. */
  50323. export class ScaleGizmo extends Gizmo {
  50324. /**
  50325. * Internal gizmo used for interactions on the x axis
  50326. */
  50327. xGizmo: AxisScaleGizmo;
  50328. /**
  50329. * Internal gizmo used for interactions on the y axis
  50330. */
  50331. yGizmo: AxisScaleGizmo;
  50332. /**
  50333. * Internal gizmo used for interactions on the z axis
  50334. */
  50335. zGizmo: AxisScaleGizmo;
  50336. /**
  50337. * Internal gizmo used to scale all axis equally
  50338. */
  50339. uniformScaleGizmo: AxisScaleGizmo;
  50340. private _meshAttached;
  50341. private _updateGizmoRotationToMatchAttachedMesh;
  50342. private _snapDistance;
  50343. private _scaleRatio;
  50344. private _uniformScalingMesh;
  50345. private _octahedron;
  50346. private _sensitivity;
  50347. /** Fires an event when any of it's sub gizmos are dragged */
  50348. onDragStartObservable: Observable<unknown>;
  50349. /** Fires an event when any of it's sub gizmos are released from dragging */
  50350. onDragEndObservable: Observable<unknown>;
  50351. get attachedMesh(): Nullable<AbstractMesh>;
  50352. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50353. /**
  50354. * Creates a ScaleGizmo
  50355. * @param gizmoLayer The utility layer the gizmo will be added to
  50356. */
  50357. constructor(gizmoLayer?: UtilityLayerRenderer);
  50358. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50359. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50360. /**
  50361. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50362. */
  50363. set snapDistance(value: number);
  50364. get snapDistance(): number;
  50365. /**
  50366. * Ratio for the scale of the gizmo (Default: 1)
  50367. */
  50368. set scaleRatio(value: number);
  50369. get scaleRatio(): number;
  50370. /**
  50371. * Sensitivity factor for dragging (Default: 1)
  50372. */
  50373. set sensitivity(value: number);
  50374. get sensitivity(): number;
  50375. /**
  50376. * Disposes of the gizmo
  50377. */
  50378. dispose(): void;
  50379. }
  50380. }
  50381. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50382. import { Observable } from "babylonjs/Misc/observable";
  50383. import { Nullable } from "babylonjs/types";
  50384. import { Vector3 } from "babylonjs/Maths/math.vector";
  50385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50386. import { Mesh } from "babylonjs/Meshes/mesh";
  50387. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50388. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50389. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50390. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50391. import { Color3 } from "babylonjs/Maths/math.color";
  50392. /**
  50393. * Single axis scale gizmo
  50394. */
  50395. export class AxisScaleGizmo extends Gizmo {
  50396. /**
  50397. * Drag behavior responsible for the gizmos dragging interactions
  50398. */
  50399. dragBehavior: PointerDragBehavior;
  50400. private _pointerObserver;
  50401. /**
  50402. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50403. */
  50404. snapDistance: number;
  50405. /**
  50406. * Event that fires each time the gizmo snaps to a new location.
  50407. * * snapDistance is the the change in distance
  50408. */
  50409. onSnapObservable: Observable<{
  50410. snapDistance: number;
  50411. }>;
  50412. /**
  50413. * If the scaling operation should be done on all axis (default: false)
  50414. */
  50415. uniformScaling: boolean;
  50416. /**
  50417. * Custom sensitivity value for the drag strength
  50418. */
  50419. sensitivity: number;
  50420. private _isEnabled;
  50421. private _parent;
  50422. private _arrow;
  50423. private _coloredMaterial;
  50424. private _hoverMaterial;
  50425. /**
  50426. * Creates an AxisScaleGizmo
  50427. * @param gizmoLayer The utility layer the gizmo will be added to
  50428. * @param dragAxis The axis which the gizmo will be able to scale on
  50429. * @param color The color of the gizmo
  50430. */
  50431. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50432. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50433. /**
  50434. * If the gizmo is enabled
  50435. */
  50436. set isEnabled(value: boolean);
  50437. get isEnabled(): boolean;
  50438. /**
  50439. * Disposes of the gizmo
  50440. */
  50441. dispose(): void;
  50442. /**
  50443. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50444. * @param mesh The mesh to replace the default mesh of the gizmo
  50445. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50446. */
  50447. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50448. }
  50449. }
  50450. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50451. import { Observable } from "babylonjs/Misc/observable";
  50452. import { Nullable } from "babylonjs/types";
  50453. import { Vector3 } from "babylonjs/Maths/math.vector";
  50454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50455. import { Mesh } from "babylonjs/Meshes/mesh";
  50456. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50457. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50458. import { Color3 } from "babylonjs/Maths/math.color";
  50459. import "babylonjs/Meshes/Builders/boxBuilder";
  50460. /**
  50461. * Bounding box gizmo
  50462. */
  50463. export class BoundingBoxGizmo extends Gizmo {
  50464. private _lineBoundingBox;
  50465. private _rotateSpheresParent;
  50466. private _scaleBoxesParent;
  50467. private _boundingDimensions;
  50468. private _renderObserver;
  50469. private _pointerObserver;
  50470. private _scaleDragSpeed;
  50471. private _tmpQuaternion;
  50472. private _tmpVector;
  50473. private _tmpRotationMatrix;
  50474. /**
  50475. * 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)
  50476. */
  50477. ignoreChildren: boolean;
  50478. /**
  50479. * 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)
  50480. */
  50481. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50482. /**
  50483. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50484. */
  50485. rotationSphereSize: number;
  50486. /**
  50487. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50488. */
  50489. scaleBoxSize: number;
  50490. /**
  50491. * 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)
  50492. */
  50493. fixedDragMeshScreenSize: boolean;
  50494. /**
  50495. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50496. */
  50497. fixedDragMeshScreenSizeDistanceFactor: number;
  50498. /**
  50499. * Fired when a rotation sphere or scale box is dragged
  50500. */
  50501. onDragStartObservable: Observable<{}>;
  50502. /**
  50503. * Fired when a scale box is dragged
  50504. */
  50505. onScaleBoxDragObservable: Observable<{}>;
  50506. /**
  50507. * Fired when a scale box drag is ended
  50508. */
  50509. onScaleBoxDragEndObservable: Observable<{}>;
  50510. /**
  50511. * Fired when a rotation sphere is dragged
  50512. */
  50513. onRotationSphereDragObservable: Observable<{}>;
  50514. /**
  50515. * Fired when a rotation sphere drag is ended
  50516. */
  50517. onRotationSphereDragEndObservable: Observable<{}>;
  50518. /**
  50519. * 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)
  50520. */
  50521. scalePivot: Nullable<Vector3>;
  50522. /**
  50523. * Mesh used as a pivot to rotate the attached mesh
  50524. */
  50525. private _anchorMesh;
  50526. private _existingMeshScale;
  50527. private _dragMesh;
  50528. private pointerDragBehavior;
  50529. private coloredMaterial;
  50530. private hoverColoredMaterial;
  50531. /**
  50532. * Sets the color of the bounding box gizmo
  50533. * @param color the color to set
  50534. */
  50535. setColor(color: Color3): void;
  50536. /**
  50537. * Creates an BoundingBoxGizmo
  50538. * @param gizmoLayer The utility layer the gizmo will be added to
  50539. * @param color The color of the gizmo
  50540. */
  50541. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50542. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50543. private _selectNode;
  50544. /**
  50545. * Updates the bounding box information for the Gizmo
  50546. */
  50547. updateBoundingBox(): void;
  50548. private _updateRotationSpheres;
  50549. private _updateScaleBoxes;
  50550. /**
  50551. * Enables rotation on the specified axis and disables rotation on the others
  50552. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50553. */
  50554. setEnabledRotationAxis(axis: string): void;
  50555. /**
  50556. * Enables/disables scaling
  50557. * @param enable if scaling should be enabled
  50558. */
  50559. setEnabledScaling(enable: boolean): void;
  50560. private _updateDummy;
  50561. /**
  50562. * Enables a pointer drag behavior on the bounding box of the gizmo
  50563. */
  50564. enableDragBehavior(): void;
  50565. /**
  50566. * Disposes of the gizmo
  50567. */
  50568. dispose(): void;
  50569. /**
  50570. * 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)
  50571. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50572. * @returns the bounding box mesh with the passed in mesh as a child
  50573. */
  50574. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50575. /**
  50576. * CustomMeshes are not supported by this gizmo
  50577. * @param mesh The mesh to replace the default mesh of the gizmo
  50578. */
  50579. setCustomMesh(mesh: Mesh): void;
  50580. }
  50581. }
  50582. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50583. import { Observable } from "babylonjs/Misc/observable";
  50584. import { Nullable } from "babylonjs/types";
  50585. import { Vector3 } from "babylonjs/Maths/math.vector";
  50586. import { Color3 } from "babylonjs/Maths/math.color";
  50587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50588. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50589. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50590. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50591. import "babylonjs/Meshes/Builders/linesBuilder";
  50592. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50593. /**
  50594. * Single plane rotation gizmo
  50595. */
  50596. export class PlaneRotationGizmo extends Gizmo {
  50597. /**
  50598. * Drag behavior responsible for the gizmos dragging interactions
  50599. */
  50600. dragBehavior: PointerDragBehavior;
  50601. private _pointerObserver;
  50602. /**
  50603. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50604. */
  50605. snapDistance: number;
  50606. /**
  50607. * Event that fires each time the gizmo snaps to a new location.
  50608. * * snapDistance is the the change in distance
  50609. */
  50610. onSnapObservable: Observable<{
  50611. snapDistance: number;
  50612. }>;
  50613. private _isEnabled;
  50614. private _parent;
  50615. /**
  50616. * Creates a PlaneRotationGizmo
  50617. * @param gizmoLayer The utility layer the gizmo will be added to
  50618. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50619. * @param color The color of the gizmo
  50620. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50621. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50622. */
  50623. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50624. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50625. /**
  50626. * If the gizmo is enabled
  50627. */
  50628. set isEnabled(value: boolean);
  50629. get isEnabled(): boolean;
  50630. /**
  50631. * Disposes of the gizmo
  50632. */
  50633. dispose(): void;
  50634. }
  50635. }
  50636. declare module "babylonjs/Gizmos/rotationGizmo" {
  50637. import { Observable } from "babylonjs/Misc/observable";
  50638. import { Nullable } from "babylonjs/types";
  50639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50640. import { Mesh } from "babylonjs/Meshes/mesh";
  50641. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50642. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50643. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50644. /**
  50645. * Gizmo that enables rotating a mesh along 3 axis
  50646. */
  50647. export class RotationGizmo extends Gizmo {
  50648. /**
  50649. * Internal gizmo used for interactions on the x axis
  50650. */
  50651. xGizmo: PlaneRotationGizmo;
  50652. /**
  50653. * Internal gizmo used for interactions on the y axis
  50654. */
  50655. yGizmo: PlaneRotationGizmo;
  50656. /**
  50657. * Internal gizmo used for interactions on the z axis
  50658. */
  50659. zGizmo: PlaneRotationGizmo;
  50660. /** Fires an event when any of it's sub gizmos are dragged */
  50661. onDragStartObservable: Observable<unknown>;
  50662. /** Fires an event when any of it's sub gizmos are released from dragging */
  50663. onDragEndObservable: Observable<unknown>;
  50664. private _meshAttached;
  50665. get attachedMesh(): Nullable<AbstractMesh>;
  50666. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50667. /**
  50668. * Creates a RotationGizmo
  50669. * @param gizmoLayer The utility layer the gizmo will be added to
  50670. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50671. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50672. */
  50673. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50674. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50675. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50676. /**
  50677. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50678. */
  50679. set snapDistance(value: number);
  50680. get snapDistance(): number;
  50681. /**
  50682. * Ratio for the scale of the gizmo (Default: 1)
  50683. */
  50684. set scaleRatio(value: number);
  50685. get scaleRatio(): number;
  50686. /**
  50687. * Disposes of the gizmo
  50688. */
  50689. dispose(): void;
  50690. /**
  50691. * CustomMeshes are not supported by this gizmo
  50692. * @param mesh The mesh to replace the default mesh of the gizmo
  50693. */
  50694. setCustomMesh(mesh: Mesh): void;
  50695. }
  50696. }
  50697. declare module "babylonjs/Gizmos/gizmoManager" {
  50698. import { Observable } from "babylonjs/Misc/observable";
  50699. import { Nullable } from "babylonjs/types";
  50700. import { Scene, IDisposable } from "babylonjs/scene";
  50701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50702. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50703. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50704. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50705. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50706. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50707. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50708. /**
  50709. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50710. */
  50711. export class GizmoManager implements IDisposable {
  50712. private scene;
  50713. /**
  50714. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50715. */
  50716. gizmos: {
  50717. positionGizmo: Nullable<PositionGizmo>;
  50718. rotationGizmo: Nullable<RotationGizmo>;
  50719. scaleGizmo: Nullable<ScaleGizmo>;
  50720. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50721. };
  50722. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50723. clearGizmoOnEmptyPointerEvent: boolean;
  50724. /** Fires an event when the manager is attached to a mesh */
  50725. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50726. private _gizmosEnabled;
  50727. private _pointerObserver;
  50728. private _attachedMesh;
  50729. private _boundingBoxColor;
  50730. private _defaultUtilityLayer;
  50731. private _defaultKeepDepthUtilityLayer;
  50732. /**
  50733. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50734. */
  50735. boundingBoxDragBehavior: SixDofDragBehavior;
  50736. /**
  50737. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50738. */
  50739. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50740. /**
  50741. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50742. */
  50743. usePointerToAttachGizmos: boolean;
  50744. /**
  50745. * Utility layer that the bounding box gizmo belongs to
  50746. */
  50747. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50748. /**
  50749. * Utility layer that all gizmos besides bounding box belong to
  50750. */
  50751. get utilityLayer(): UtilityLayerRenderer;
  50752. /**
  50753. * Instatiates a gizmo manager
  50754. * @param scene the scene to overlay the gizmos on top of
  50755. */
  50756. constructor(scene: Scene);
  50757. /**
  50758. * Attaches a set of gizmos to the specified mesh
  50759. * @param mesh The mesh the gizmo's should be attached to
  50760. */
  50761. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50762. /**
  50763. * If the position gizmo is enabled
  50764. */
  50765. set positionGizmoEnabled(value: boolean);
  50766. get positionGizmoEnabled(): boolean;
  50767. /**
  50768. * If the rotation gizmo is enabled
  50769. */
  50770. set rotationGizmoEnabled(value: boolean);
  50771. get rotationGizmoEnabled(): boolean;
  50772. /**
  50773. * If the scale gizmo is enabled
  50774. */
  50775. set scaleGizmoEnabled(value: boolean);
  50776. get scaleGizmoEnabled(): boolean;
  50777. /**
  50778. * If the boundingBox gizmo is enabled
  50779. */
  50780. set boundingBoxGizmoEnabled(value: boolean);
  50781. get boundingBoxGizmoEnabled(): boolean;
  50782. /**
  50783. * Disposes of the gizmo manager
  50784. */
  50785. dispose(): void;
  50786. }
  50787. }
  50788. declare module "babylonjs/Lights/directionalLight" {
  50789. import { Camera } from "babylonjs/Cameras/camera";
  50790. import { Scene } from "babylonjs/scene";
  50791. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50793. import { Light } from "babylonjs/Lights/light";
  50794. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50795. import { Effect } from "babylonjs/Materials/effect";
  50796. /**
  50797. * A directional light is defined by a direction (what a surprise!).
  50798. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50799. * 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.
  50800. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50801. */
  50802. export class DirectionalLight extends ShadowLight {
  50803. private _shadowFrustumSize;
  50804. /**
  50805. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50806. */
  50807. get shadowFrustumSize(): number;
  50808. /**
  50809. * Specifies a fix frustum size for the shadow generation.
  50810. */
  50811. set shadowFrustumSize(value: number);
  50812. private _shadowOrthoScale;
  50813. /**
  50814. * Gets the shadow projection scale against the optimal computed one.
  50815. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50816. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50817. */
  50818. get shadowOrthoScale(): number;
  50819. /**
  50820. * Sets the shadow projection scale against the optimal computed one.
  50821. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50822. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50823. */
  50824. set shadowOrthoScale(value: number);
  50825. /**
  50826. * Automatically compute the projection matrix to best fit (including all the casters)
  50827. * on each frame.
  50828. */
  50829. autoUpdateExtends: boolean;
  50830. /**
  50831. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50832. * on each frame. autoUpdateExtends must be set to true for this to work
  50833. */
  50834. autoCalcShadowZBounds: boolean;
  50835. private _orthoLeft;
  50836. private _orthoRight;
  50837. private _orthoTop;
  50838. private _orthoBottom;
  50839. /**
  50840. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50841. * The directional light is emitted from everywhere in the given direction.
  50842. * It can cast shadows.
  50843. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50844. * @param name The friendly name of the light
  50845. * @param direction The direction of the light
  50846. * @param scene The scene the light belongs to
  50847. */
  50848. constructor(name: string, direction: Vector3, scene: Scene);
  50849. /**
  50850. * Returns the string "DirectionalLight".
  50851. * @return The class name
  50852. */
  50853. getClassName(): string;
  50854. /**
  50855. * Returns the integer 1.
  50856. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50857. */
  50858. getTypeID(): number;
  50859. /**
  50860. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50861. * Returns the DirectionalLight Shadow projection matrix.
  50862. */
  50863. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50864. /**
  50865. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50866. * Returns the DirectionalLight Shadow projection matrix.
  50867. */
  50868. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50869. /**
  50870. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50871. * Returns the DirectionalLight Shadow projection matrix.
  50872. */
  50873. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50874. protected _buildUniformLayout(): void;
  50875. /**
  50876. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50877. * @param effect The effect to update
  50878. * @param lightIndex The index of the light in the effect to update
  50879. * @returns The directional light
  50880. */
  50881. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50882. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50883. /**
  50884. * Gets the minZ used for shadow according to both the scene and the light.
  50885. *
  50886. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50887. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50888. * @param activeCamera The camera we are returning the min for
  50889. * @returns the depth min z
  50890. */
  50891. getDepthMinZ(activeCamera: Camera): number;
  50892. /**
  50893. * Gets the maxZ used for shadow according to both the scene and the light.
  50894. *
  50895. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50896. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50897. * @param activeCamera The camera we are returning the max for
  50898. * @returns the depth max z
  50899. */
  50900. getDepthMaxZ(activeCamera: Camera): number;
  50901. /**
  50902. * Prepares the list of defines specific to the light type.
  50903. * @param defines the list of defines
  50904. * @param lightIndex defines the index of the light for the effect
  50905. */
  50906. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50907. }
  50908. }
  50909. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50910. import { Mesh } from "babylonjs/Meshes/mesh";
  50911. /**
  50912. * Class containing static functions to help procedurally build meshes
  50913. */
  50914. export class HemisphereBuilder {
  50915. /**
  50916. * Creates a hemisphere mesh
  50917. * @param name defines the name of the mesh
  50918. * @param options defines the options used to create the mesh
  50919. * @param scene defines the hosting scene
  50920. * @returns the hemisphere mesh
  50921. */
  50922. static CreateHemisphere(name: string, options: {
  50923. segments?: number;
  50924. diameter?: number;
  50925. sideOrientation?: number;
  50926. }, scene: any): Mesh;
  50927. }
  50928. }
  50929. declare module "babylonjs/Lights/spotLight" {
  50930. import { Nullable } from "babylonjs/types";
  50931. import { Scene } from "babylonjs/scene";
  50932. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50934. import { Effect } from "babylonjs/Materials/effect";
  50935. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50936. import { Light } from "babylonjs/Lights/light";
  50937. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50938. /**
  50939. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50940. * These values define a cone of light starting from the position, emitting toward the direction.
  50941. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50942. * and the exponent defines the speed of the decay of the light with distance (reach).
  50943. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50944. */
  50945. export class SpotLight extends ShadowLight {
  50946. private _angle;
  50947. private _innerAngle;
  50948. private _cosHalfAngle;
  50949. private _lightAngleScale;
  50950. private _lightAngleOffset;
  50951. /**
  50952. * Gets the cone angle of the spot light in Radians.
  50953. */
  50954. get angle(): number;
  50955. /**
  50956. * Sets the cone angle of the spot light in Radians.
  50957. */
  50958. set angle(value: number);
  50959. /**
  50960. * Only used in gltf falloff mode, this defines the angle where
  50961. * the directional falloff will start before cutting at angle which could be seen
  50962. * as outer angle.
  50963. */
  50964. get innerAngle(): number;
  50965. /**
  50966. * Only used in gltf falloff mode, this defines the angle where
  50967. * the directional falloff will start before cutting at angle which could be seen
  50968. * as outer angle.
  50969. */
  50970. set innerAngle(value: number);
  50971. private _shadowAngleScale;
  50972. /**
  50973. * Allows scaling the angle of the light for shadow generation only.
  50974. */
  50975. get shadowAngleScale(): number;
  50976. /**
  50977. * Allows scaling the angle of the light for shadow generation only.
  50978. */
  50979. set shadowAngleScale(value: number);
  50980. /**
  50981. * The light decay speed with the distance from the emission spot.
  50982. */
  50983. exponent: number;
  50984. private _projectionTextureMatrix;
  50985. /**
  50986. * Allows reading the projecton texture
  50987. */
  50988. get projectionTextureMatrix(): Matrix;
  50989. protected _projectionTextureLightNear: number;
  50990. /**
  50991. * Gets the near clip of the Spotlight for texture projection.
  50992. */
  50993. get projectionTextureLightNear(): number;
  50994. /**
  50995. * Sets the near clip of the Spotlight for texture projection.
  50996. */
  50997. set projectionTextureLightNear(value: number);
  50998. protected _projectionTextureLightFar: number;
  50999. /**
  51000. * Gets the far clip of the Spotlight for texture projection.
  51001. */
  51002. get projectionTextureLightFar(): number;
  51003. /**
  51004. * Sets the far clip of the Spotlight for texture projection.
  51005. */
  51006. set projectionTextureLightFar(value: number);
  51007. protected _projectionTextureUpDirection: Vector3;
  51008. /**
  51009. * Gets the Up vector of the Spotlight for texture projection.
  51010. */
  51011. get projectionTextureUpDirection(): Vector3;
  51012. /**
  51013. * Sets the Up vector of the Spotlight for texture projection.
  51014. */
  51015. set projectionTextureUpDirection(value: Vector3);
  51016. private _projectionTexture;
  51017. /**
  51018. * Gets the projection texture of the light.
  51019. */
  51020. get projectionTexture(): Nullable<BaseTexture>;
  51021. /**
  51022. * Sets the projection texture of the light.
  51023. */
  51024. set projectionTexture(value: Nullable<BaseTexture>);
  51025. private _projectionTextureViewLightDirty;
  51026. private _projectionTextureProjectionLightDirty;
  51027. private _projectionTextureDirty;
  51028. private _projectionTextureViewTargetVector;
  51029. private _projectionTextureViewLightMatrix;
  51030. private _projectionTextureProjectionLightMatrix;
  51031. private _projectionTextureScalingMatrix;
  51032. /**
  51033. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51034. * It can cast shadows.
  51035. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51036. * @param name The light friendly name
  51037. * @param position The position of the spot light in the scene
  51038. * @param direction The direction of the light in the scene
  51039. * @param angle The cone angle of the light in Radians
  51040. * @param exponent The light decay speed with the distance from the emission spot
  51041. * @param scene The scene the lights belongs to
  51042. */
  51043. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51044. /**
  51045. * Returns the string "SpotLight".
  51046. * @returns the class name
  51047. */
  51048. getClassName(): string;
  51049. /**
  51050. * Returns the integer 2.
  51051. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51052. */
  51053. getTypeID(): number;
  51054. /**
  51055. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51056. */
  51057. protected _setDirection(value: Vector3): void;
  51058. /**
  51059. * Overrides the position setter to recompute the projection texture view light Matrix.
  51060. */
  51061. protected _setPosition(value: Vector3): void;
  51062. /**
  51063. * 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.
  51064. * Returns the SpotLight.
  51065. */
  51066. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51067. protected _computeProjectionTextureViewLightMatrix(): void;
  51068. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51069. /**
  51070. * Main function for light texture projection matrix computing.
  51071. */
  51072. protected _computeProjectionTextureMatrix(): void;
  51073. protected _buildUniformLayout(): void;
  51074. private _computeAngleValues;
  51075. /**
  51076. * Sets the passed Effect "effect" with the Light textures.
  51077. * @param effect The effect to update
  51078. * @param lightIndex The index of the light in the effect to update
  51079. * @returns The light
  51080. */
  51081. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51082. /**
  51083. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51084. * @param effect The effect to update
  51085. * @param lightIndex The index of the light in the effect to update
  51086. * @returns The spot light
  51087. */
  51088. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51089. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51090. /**
  51091. * Disposes the light and the associated resources.
  51092. */
  51093. dispose(): void;
  51094. /**
  51095. * Prepares the list of defines specific to the light type.
  51096. * @param defines the list of defines
  51097. * @param lightIndex defines the index of the light for the effect
  51098. */
  51099. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51100. }
  51101. }
  51102. declare module "babylonjs/Gizmos/lightGizmo" {
  51103. import { Nullable } from "babylonjs/types";
  51104. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51105. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51106. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51107. import { Light } from "babylonjs/Lights/light";
  51108. /**
  51109. * Gizmo that enables viewing a light
  51110. */
  51111. export class LightGizmo extends Gizmo {
  51112. private _lightMesh;
  51113. private _material;
  51114. private _cachedPosition;
  51115. private _cachedForward;
  51116. private _attachedMeshParent;
  51117. /**
  51118. * Creates a LightGizmo
  51119. * @param gizmoLayer The utility layer the gizmo will be added to
  51120. */
  51121. constructor(gizmoLayer?: UtilityLayerRenderer);
  51122. private _light;
  51123. /**
  51124. * The light that the gizmo is attached to
  51125. */
  51126. set light(light: Nullable<Light>);
  51127. get light(): Nullable<Light>;
  51128. /**
  51129. * Gets the material used to render the light gizmo
  51130. */
  51131. get material(): StandardMaterial;
  51132. /**
  51133. * @hidden
  51134. * Updates the gizmo to match the attached mesh's position/rotation
  51135. */
  51136. protected _update(): void;
  51137. private static _Scale;
  51138. /**
  51139. * Creates the lines for a light mesh
  51140. */
  51141. private static _CreateLightLines;
  51142. /**
  51143. * Disposes of the light gizmo
  51144. */
  51145. dispose(): void;
  51146. private static _CreateHemisphericLightMesh;
  51147. private static _CreatePointLightMesh;
  51148. private static _CreateSpotLightMesh;
  51149. private static _CreateDirectionalLightMesh;
  51150. }
  51151. }
  51152. declare module "babylonjs/Gizmos/index" {
  51153. export * from "babylonjs/Gizmos/axisDragGizmo";
  51154. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51155. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51156. export * from "babylonjs/Gizmos/gizmo";
  51157. export * from "babylonjs/Gizmos/gizmoManager";
  51158. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51159. export * from "babylonjs/Gizmos/positionGizmo";
  51160. export * from "babylonjs/Gizmos/rotationGizmo";
  51161. export * from "babylonjs/Gizmos/scaleGizmo";
  51162. export * from "babylonjs/Gizmos/lightGizmo";
  51163. export * from "babylonjs/Gizmos/planeDragGizmo";
  51164. }
  51165. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51166. /** @hidden */
  51167. export var backgroundFragmentDeclaration: {
  51168. name: string;
  51169. shader: string;
  51170. };
  51171. }
  51172. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51173. /** @hidden */
  51174. export var backgroundUboDeclaration: {
  51175. name: string;
  51176. shader: string;
  51177. };
  51178. }
  51179. declare module "babylonjs/Shaders/background.fragment" {
  51180. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51181. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51182. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51183. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51184. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51185. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51186. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51187. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51188. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51189. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51190. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51191. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51192. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51193. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51194. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51195. /** @hidden */
  51196. export var backgroundPixelShader: {
  51197. name: string;
  51198. shader: string;
  51199. };
  51200. }
  51201. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51202. /** @hidden */
  51203. export var backgroundVertexDeclaration: {
  51204. name: string;
  51205. shader: string;
  51206. };
  51207. }
  51208. declare module "babylonjs/Shaders/background.vertex" {
  51209. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51210. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51211. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51212. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51213. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51214. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51215. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51216. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51217. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51218. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51219. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51220. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51221. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51222. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51223. /** @hidden */
  51224. export var backgroundVertexShader: {
  51225. name: string;
  51226. shader: string;
  51227. };
  51228. }
  51229. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51230. import { Nullable, int, float } from "babylonjs/types";
  51231. import { Scene } from "babylonjs/scene";
  51232. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51233. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51235. import { Mesh } from "babylonjs/Meshes/mesh";
  51236. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51237. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51238. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51239. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51240. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51241. import { Color3 } from "babylonjs/Maths/math.color";
  51242. import "babylonjs/Shaders/background.fragment";
  51243. import "babylonjs/Shaders/background.vertex";
  51244. /**
  51245. * Background material used to create an efficient environement around your scene.
  51246. */
  51247. export class BackgroundMaterial extends PushMaterial {
  51248. /**
  51249. * Standard reflectance value at parallel view angle.
  51250. */
  51251. static StandardReflectance0: number;
  51252. /**
  51253. * Standard reflectance value at grazing angle.
  51254. */
  51255. static StandardReflectance90: number;
  51256. protected _primaryColor: Color3;
  51257. /**
  51258. * Key light Color (multiply against the environement texture)
  51259. */
  51260. primaryColor: Color3;
  51261. protected __perceptualColor: Nullable<Color3>;
  51262. /**
  51263. * Experimental Internal Use Only.
  51264. *
  51265. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51266. * This acts as a helper to set the primary color to a more "human friendly" value.
  51267. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51268. * output color as close as possible from the chosen value.
  51269. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51270. * part of lighting setup.)
  51271. */
  51272. get _perceptualColor(): Nullable<Color3>;
  51273. set _perceptualColor(value: Nullable<Color3>);
  51274. protected _primaryColorShadowLevel: float;
  51275. /**
  51276. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51277. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51278. */
  51279. get primaryColorShadowLevel(): float;
  51280. set primaryColorShadowLevel(value: float);
  51281. protected _primaryColorHighlightLevel: float;
  51282. /**
  51283. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51284. * The primary color is used at the level chosen to define what the white area would look.
  51285. */
  51286. get primaryColorHighlightLevel(): float;
  51287. set primaryColorHighlightLevel(value: float);
  51288. protected _reflectionTexture: Nullable<BaseTexture>;
  51289. /**
  51290. * Reflection Texture used in the material.
  51291. * Should be author in a specific way for the best result (refer to the documentation).
  51292. */
  51293. reflectionTexture: Nullable<BaseTexture>;
  51294. protected _reflectionBlur: float;
  51295. /**
  51296. * Reflection Texture level of blur.
  51297. *
  51298. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51299. * texture twice.
  51300. */
  51301. reflectionBlur: float;
  51302. protected _diffuseTexture: Nullable<BaseTexture>;
  51303. /**
  51304. * Diffuse Texture used in the material.
  51305. * Should be author in a specific way for the best result (refer to the documentation).
  51306. */
  51307. diffuseTexture: Nullable<BaseTexture>;
  51308. protected _shadowLights: Nullable<IShadowLight[]>;
  51309. /**
  51310. * Specify the list of lights casting shadow on the material.
  51311. * All scene shadow lights will be included if null.
  51312. */
  51313. shadowLights: Nullable<IShadowLight[]>;
  51314. protected _shadowLevel: float;
  51315. /**
  51316. * Helps adjusting the shadow to a softer level if required.
  51317. * 0 means black shadows and 1 means no shadows.
  51318. */
  51319. shadowLevel: float;
  51320. protected _sceneCenter: Vector3;
  51321. /**
  51322. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51323. * It is usually zero but might be interesting to modify according to your setup.
  51324. */
  51325. sceneCenter: Vector3;
  51326. protected _opacityFresnel: boolean;
  51327. /**
  51328. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51329. * This helps ensuring a nice transition when the camera goes under the ground.
  51330. */
  51331. opacityFresnel: boolean;
  51332. protected _reflectionFresnel: boolean;
  51333. /**
  51334. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51335. * This helps adding a mirror texture on the ground.
  51336. */
  51337. reflectionFresnel: boolean;
  51338. protected _reflectionFalloffDistance: number;
  51339. /**
  51340. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51341. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51342. */
  51343. reflectionFalloffDistance: number;
  51344. protected _reflectionAmount: number;
  51345. /**
  51346. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51347. */
  51348. reflectionAmount: number;
  51349. protected _reflectionReflectance0: number;
  51350. /**
  51351. * This specifies the weight of the reflection at grazing angle.
  51352. */
  51353. reflectionReflectance0: number;
  51354. protected _reflectionReflectance90: number;
  51355. /**
  51356. * This specifies the weight of the reflection at a perpendicular point of view.
  51357. */
  51358. reflectionReflectance90: number;
  51359. /**
  51360. * Sets the reflection reflectance fresnel values according to the default standard
  51361. * empirically know to work well :-)
  51362. */
  51363. set reflectionStandardFresnelWeight(value: number);
  51364. protected _useRGBColor: boolean;
  51365. /**
  51366. * Helps to directly use the maps channels instead of their level.
  51367. */
  51368. useRGBColor: boolean;
  51369. protected _enableNoise: boolean;
  51370. /**
  51371. * This helps reducing the banding effect that could occur on the background.
  51372. */
  51373. enableNoise: boolean;
  51374. /**
  51375. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51376. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51377. * Recommended to be keep at 1.0 except for special cases.
  51378. */
  51379. get fovMultiplier(): number;
  51380. set fovMultiplier(value: number);
  51381. private _fovMultiplier;
  51382. /**
  51383. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51384. */
  51385. useEquirectangularFOV: boolean;
  51386. private _maxSimultaneousLights;
  51387. /**
  51388. * Number of Simultaneous lights allowed on the material.
  51389. */
  51390. maxSimultaneousLights: int;
  51391. /**
  51392. * Default configuration related to image processing available in the Background Material.
  51393. */
  51394. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51395. /**
  51396. * Keep track of the image processing observer to allow dispose and replace.
  51397. */
  51398. private _imageProcessingObserver;
  51399. /**
  51400. * Attaches a new image processing configuration to the PBR Material.
  51401. * @param configuration (if null the scene configuration will be use)
  51402. */
  51403. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51404. /**
  51405. * Gets the image processing configuration used either in this material.
  51406. */
  51407. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51408. /**
  51409. * Sets the Default image processing configuration used either in the this material.
  51410. *
  51411. * If sets to null, the scene one is in use.
  51412. */
  51413. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51414. /**
  51415. * Gets wether the color curves effect is enabled.
  51416. */
  51417. get cameraColorCurvesEnabled(): boolean;
  51418. /**
  51419. * Sets wether the color curves effect is enabled.
  51420. */
  51421. set cameraColorCurvesEnabled(value: boolean);
  51422. /**
  51423. * Gets wether the color grading effect is enabled.
  51424. */
  51425. get cameraColorGradingEnabled(): boolean;
  51426. /**
  51427. * Gets wether the color grading effect is enabled.
  51428. */
  51429. set cameraColorGradingEnabled(value: boolean);
  51430. /**
  51431. * Gets wether tonemapping is enabled or not.
  51432. */
  51433. get cameraToneMappingEnabled(): boolean;
  51434. /**
  51435. * Sets wether tonemapping is enabled or not
  51436. */
  51437. set cameraToneMappingEnabled(value: boolean);
  51438. /**
  51439. * The camera exposure used on this material.
  51440. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51441. * This corresponds to a photographic exposure.
  51442. */
  51443. get cameraExposure(): float;
  51444. /**
  51445. * The camera exposure used on this material.
  51446. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51447. * This corresponds to a photographic exposure.
  51448. */
  51449. set cameraExposure(value: float);
  51450. /**
  51451. * Gets The camera contrast used on this material.
  51452. */
  51453. get cameraContrast(): float;
  51454. /**
  51455. * Sets The camera contrast used on this material.
  51456. */
  51457. set cameraContrast(value: float);
  51458. /**
  51459. * Gets the Color Grading 2D Lookup Texture.
  51460. */
  51461. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51462. /**
  51463. * Sets the Color Grading 2D Lookup Texture.
  51464. */
  51465. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51466. /**
  51467. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51468. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51469. * 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;
  51470. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51471. */
  51472. get cameraColorCurves(): Nullable<ColorCurves>;
  51473. /**
  51474. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51475. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51476. * 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;
  51477. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51478. */
  51479. set cameraColorCurves(value: Nullable<ColorCurves>);
  51480. /**
  51481. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51482. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51483. */
  51484. switchToBGR: boolean;
  51485. private _renderTargets;
  51486. private _reflectionControls;
  51487. private _white;
  51488. private _primaryShadowColor;
  51489. private _primaryHighlightColor;
  51490. /**
  51491. * Instantiates a Background Material in the given scene
  51492. * @param name The friendly name of the material
  51493. * @param scene The scene to add the material to
  51494. */
  51495. constructor(name: string, scene: Scene);
  51496. /**
  51497. * Gets a boolean indicating that current material needs to register RTT
  51498. */
  51499. get hasRenderTargetTextures(): boolean;
  51500. /**
  51501. * The entire material has been created in order to prevent overdraw.
  51502. * @returns false
  51503. */
  51504. needAlphaTesting(): boolean;
  51505. /**
  51506. * The entire material has been created in order to prevent overdraw.
  51507. * @returns true if blending is enable
  51508. */
  51509. needAlphaBlending(): boolean;
  51510. /**
  51511. * Checks wether the material is ready to be rendered for a given mesh.
  51512. * @param mesh The mesh to render
  51513. * @param subMesh The submesh to check against
  51514. * @param useInstances Specify wether or not the material is used with instances
  51515. * @returns true if all the dependencies are ready (Textures, Effects...)
  51516. */
  51517. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51518. /**
  51519. * Compute the primary color according to the chosen perceptual color.
  51520. */
  51521. private _computePrimaryColorFromPerceptualColor;
  51522. /**
  51523. * Compute the highlights and shadow colors according to their chosen levels.
  51524. */
  51525. private _computePrimaryColors;
  51526. /**
  51527. * Build the uniform buffer used in the material.
  51528. */
  51529. buildUniformLayout(): void;
  51530. /**
  51531. * Unbind the material.
  51532. */
  51533. unbind(): void;
  51534. /**
  51535. * Bind only the world matrix to the material.
  51536. * @param world The world matrix to bind.
  51537. */
  51538. bindOnlyWorldMatrix(world: Matrix): void;
  51539. /**
  51540. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51541. * @param world The world matrix to bind.
  51542. * @param subMesh The submesh to bind for.
  51543. */
  51544. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51545. /**
  51546. * Checks to see if a texture is used in the material.
  51547. * @param texture - Base texture to use.
  51548. * @returns - Boolean specifying if a texture is used in the material.
  51549. */
  51550. hasTexture(texture: BaseTexture): boolean;
  51551. /**
  51552. * Dispose the material.
  51553. * @param forceDisposeEffect Force disposal of the associated effect.
  51554. * @param forceDisposeTextures Force disposal of the associated textures.
  51555. */
  51556. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51557. /**
  51558. * Clones the material.
  51559. * @param name The cloned name.
  51560. * @returns The cloned material.
  51561. */
  51562. clone(name: string): BackgroundMaterial;
  51563. /**
  51564. * Serializes the current material to its JSON representation.
  51565. * @returns The JSON representation.
  51566. */
  51567. serialize(): any;
  51568. /**
  51569. * Gets the class name of the material
  51570. * @returns "BackgroundMaterial"
  51571. */
  51572. getClassName(): string;
  51573. /**
  51574. * Parse a JSON input to create back a background material.
  51575. * @param source The JSON data to parse
  51576. * @param scene The scene to create the parsed material in
  51577. * @param rootUrl The root url of the assets the material depends upon
  51578. * @returns the instantiated BackgroundMaterial.
  51579. */
  51580. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51581. }
  51582. }
  51583. declare module "babylonjs/Helpers/environmentHelper" {
  51584. import { Observable } from "babylonjs/Misc/observable";
  51585. import { Nullable } from "babylonjs/types";
  51586. import { Scene } from "babylonjs/scene";
  51587. import { Vector3 } from "babylonjs/Maths/math.vector";
  51588. import { Color3 } from "babylonjs/Maths/math.color";
  51589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51590. import { Mesh } from "babylonjs/Meshes/mesh";
  51591. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51592. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51593. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51594. import "babylonjs/Meshes/Builders/planeBuilder";
  51595. import "babylonjs/Meshes/Builders/boxBuilder";
  51596. /**
  51597. * Represents the different options available during the creation of
  51598. * a Environment helper.
  51599. *
  51600. * This can control the default ground, skybox and image processing setup of your scene.
  51601. */
  51602. export interface IEnvironmentHelperOptions {
  51603. /**
  51604. * Specifies whether or not to create a ground.
  51605. * True by default.
  51606. */
  51607. createGround: boolean;
  51608. /**
  51609. * Specifies the ground size.
  51610. * 15 by default.
  51611. */
  51612. groundSize: number;
  51613. /**
  51614. * The texture used on the ground for the main color.
  51615. * Comes from the BabylonJS CDN by default.
  51616. *
  51617. * Remarks: Can be either a texture or a url.
  51618. */
  51619. groundTexture: string | BaseTexture;
  51620. /**
  51621. * The color mixed in the ground texture by default.
  51622. * BabylonJS clearColor by default.
  51623. */
  51624. groundColor: Color3;
  51625. /**
  51626. * Specifies the ground opacity.
  51627. * 1 by default.
  51628. */
  51629. groundOpacity: number;
  51630. /**
  51631. * Enables the ground to receive shadows.
  51632. * True by default.
  51633. */
  51634. enableGroundShadow: boolean;
  51635. /**
  51636. * Helps preventing the shadow to be fully black on the ground.
  51637. * 0.5 by default.
  51638. */
  51639. groundShadowLevel: number;
  51640. /**
  51641. * Creates a mirror texture attach to the ground.
  51642. * false by default.
  51643. */
  51644. enableGroundMirror: boolean;
  51645. /**
  51646. * Specifies the ground mirror size ratio.
  51647. * 0.3 by default as the default kernel is 64.
  51648. */
  51649. groundMirrorSizeRatio: number;
  51650. /**
  51651. * Specifies the ground mirror blur kernel size.
  51652. * 64 by default.
  51653. */
  51654. groundMirrorBlurKernel: number;
  51655. /**
  51656. * Specifies the ground mirror visibility amount.
  51657. * 1 by default
  51658. */
  51659. groundMirrorAmount: number;
  51660. /**
  51661. * Specifies the ground mirror reflectance weight.
  51662. * This uses the standard weight of the background material to setup the fresnel effect
  51663. * of the mirror.
  51664. * 1 by default.
  51665. */
  51666. groundMirrorFresnelWeight: number;
  51667. /**
  51668. * Specifies the ground mirror Falloff distance.
  51669. * This can helps reducing the size of the reflection.
  51670. * 0 by Default.
  51671. */
  51672. groundMirrorFallOffDistance: number;
  51673. /**
  51674. * Specifies the ground mirror texture type.
  51675. * Unsigned Int by Default.
  51676. */
  51677. groundMirrorTextureType: number;
  51678. /**
  51679. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51680. * the shown objects.
  51681. */
  51682. groundYBias: number;
  51683. /**
  51684. * Specifies whether or not to create a skybox.
  51685. * True by default.
  51686. */
  51687. createSkybox: boolean;
  51688. /**
  51689. * Specifies the skybox size.
  51690. * 20 by default.
  51691. */
  51692. skyboxSize: number;
  51693. /**
  51694. * The texture used on the skybox for the main color.
  51695. * Comes from the BabylonJS CDN by default.
  51696. *
  51697. * Remarks: Can be either a texture or a url.
  51698. */
  51699. skyboxTexture: string | BaseTexture;
  51700. /**
  51701. * The color mixed in the skybox texture by default.
  51702. * BabylonJS clearColor by default.
  51703. */
  51704. skyboxColor: Color3;
  51705. /**
  51706. * The background rotation around the Y axis of the scene.
  51707. * This helps aligning the key lights of your scene with the background.
  51708. * 0 by default.
  51709. */
  51710. backgroundYRotation: number;
  51711. /**
  51712. * Compute automatically the size of the elements to best fit with the scene.
  51713. */
  51714. sizeAuto: boolean;
  51715. /**
  51716. * Default position of the rootMesh if autoSize is not true.
  51717. */
  51718. rootPosition: Vector3;
  51719. /**
  51720. * Sets up the image processing in the scene.
  51721. * true by default.
  51722. */
  51723. setupImageProcessing: boolean;
  51724. /**
  51725. * The texture used as your environment texture in the scene.
  51726. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51727. *
  51728. * Remarks: Can be either a texture or a url.
  51729. */
  51730. environmentTexture: string | BaseTexture;
  51731. /**
  51732. * The value of the exposure to apply to the scene.
  51733. * 0.6 by default if setupImageProcessing is true.
  51734. */
  51735. cameraExposure: number;
  51736. /**
  51737. * The value of the contrast to apply to the scene.
  51738. * 1.6 by default if setupImageProcessing is true.
  51739. */
  51740. cameraContrast: number;
  51741. /**
  51742. * Specifies whether or not tonemapping should be enabled in the scene.
  51743. * true by default if setupImageProcessing is true.
  51744. */
  51745. toneMappingEnabled: boolean;
  51746. }
  51747. /**
  51748. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51749. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51750. * It also helps with the default setup of your imageProcessing configuration.
  51751. */
  51752. export class EnvironmentHelper {
  51753. /**
  51754. * Default ground texture URL.
  51755. */
  51756. private static _groundTextureCDNUrl;
  51757. /**
  51758. * Default skybox texture URL.
  51759. */
  51760. private static _skyboxTextureCDNUrl;
  51761. /**
  51762. * Default environment texture URL.
  51763. */
  51764. private static _environmentTextureCDNUrl;
  51765. /**
  51766. * Creates the default options for the helper.
  51767. */
  51768. private static _getDefaultOptions;
  51769. private _rootMesh;
  51770. /**
  51771. * Gets the root mesh created by the helper.
  51772. */
  51773. get rootMesh(): Mesh;
  51774. private _skybox;
  51775. /**
  51776. * Gets the skybox created by the helper.
  51777. */
  51778. get skybox(): Nullable<Mesh>;
  51779. private _skyboxTexture;
  51780. /**
  51781. * Gets the skybox texture created by the helper.
  51782. */
  51783. get skyboxTexture(): Nullable<BaseTexture>;
  51784. private _skyboxMaterial;
  51785. /**
  51786. * Gets the skybox material created by the helper.
  51787. */
  51788. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51789. private _ground;
  51790. /**
  51791. * Gets the ground mesh created by the helper.
  51792. */
  51793. get ground(): Nullable<Mesh>;
  51794. private _groundTexture;
  51795. /**
  51796. * Gets the ground texture created by the helper.
  51797. */
  51798. get groundTexture(): Nullable<BaseTexture>;
  51799. private _groundMirror;
  51800. /**
  51801. * Gets the ground mirror created by the helper.
  51802. */
  51803. get groundMirror(): Nullable<MirrorTexture>;
  51804. /**
  51805. * Gets the ground mirror render list to helps pushing the meshes
  51806. * you wish in the ground reflection.
  51807. */
  51808. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51809. private _groundMaterial;
  51810. /**
  51811. * Gets the ground material created by the helper.
  51812. */
  51813. get groundMaterial(): Nullable<BackgroundMaterial>;
  51814. /**
  51815. * Stores the creation options.
  51816. */
  51817. private readonly _scene;
  51818. private _options;
  51819. /**
  51820. * This observable will be notified with any error during the creation of the environment,
  51821. * mainly texture creation errors.
  51822. */
  51823. onErrorObservable: Observable<{
  51824. message?: string;
  51825. exception?: any;
  51826. }>;
  51827. /**
  51828. * constructor
  51829. * @param options Defines the options we want to customize the helper
  51830. * @param scene The scene to add the material to
  51831. */
  51832. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51833. /**
  51834. * Updates the background according to the new options
  51835. * @param options
  51836. */
  51837. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51838. /**
  51839. * Sets the primary color of all the available elements.
  51840. * @param color the main color to affect to the ground and the background
  51841. */
  51842. setMainColor(color: Color3): void;
  51843. /**
  51844. * Setup the image processing according to the specified options.
  51845. */
  51846. private _setupImageProcessing;
  51847. /**
  51848. * Setup the environment texture according to the specified options.
  51849. */
  51850. private _setupEnvironmentTexture;
  51851. /**
  51852. * Setup the background according to the specified options.
  51853. */
  51854. private _setupBackground;
  51855. /**
  51856. * Get the scene sizes according to the setup.
  51857. */
  51858. private _getSceneSize;
  51859. /**
  51860. * Setup the ground according to the specified options.
  51861. */
  51862. private _setupGround;
  51863. /**
  51864. * Setup the ground material according to the specified options.
  51865. */
  51866. private _setupGroundMaterial;
  51867. /**
  51868. * Setup the ground diffuse texture according to the specified options.
  51869. */
  51870. private _setupGroundDiffuseTexture;
  51871. /**
  51872. * Setup the ground mirror texture according to the specified options.
  51873. */
  51874. private _setupGroundMirrorTexture;
  51875. /**
  51876. * Setup the ground to receive the mirror texture.
  51877. */
  51878. private _setupMirrorInGroundMaterial;
  51879. /**
  51880. * Setup the skybox according to the specified options.
  51881. */
  51882. private _setupSkybox;
  51883. /**
  51884. * Setup the skybox material according to the specified options.
  51885. */
  51886. private _setupSkyboxMaterial;
  51887. /**
  51888. * Setup the skybox reflection texture according to the specified options.
  51889. */
  51890. private _setupSkyboxReflectionTexture;
  51891. private _errorHandler;
  51892. /**
  51893. * Dispose all the elements created by the Helper.
  51894. */
  51895. dispose(): void;
  51896. }
  51897. }
  51898. declare module "babylonjs/Helpers/photoDome" {
  51899. import { Observable } from "babylonjs/Misc/observable";
  51900. import { Nullable } from "babylonjs/types";
  51901. import { Scene } from "babylonjs/scene";
  51902. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51903. import { Mesh } from "babylonjs/Meshes/mesh";
  51904. import { Texture } from "babylonjs/Materials/Textures/texture";
  51905. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51906. import "babylonjs/Meshes/Builders/sphereBuilder";
  51907. /**
  51908. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51909. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51910. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51911. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51912. */
  51913. export class PhotoDome extends TransformNode {
  51914. /**
  51915. * Define the image as a Monoscopic panoramic 360 image.
  51916. */
  51917. static readonly MODE_MONOSCOPIC: number;
  51918. /**
  51919. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51920. */
  51921. static readonly MODE_TOPBOTTOM: number;
  51922. /**
  51923. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51924. */
  51925. static readonly MODE_SIDEBYSIDE: number;
  51926. private _useDirectMapping;
  51927. /**
  51928. * The texture being displayed on the sphere
  51929. */
  51930. protected _photoTexture: Texture;
  51931. /**
  51932. * Gets or sets the texture being displayed on the sphere
  51933. */
  51934. get photoTexture(): Texture;
  51935. set photoTexture(value: Texture);
  51936. /**
  51937. * Observable raised when an error occured while loading the 360 image
  51938. */
  51939. onLoadErrorObservable: Observable<string>;
  51940. /**
  51941. * The skybox material
  51942. */
  51943. protected _material: BackgroundMaterial;
  51944. /**
  51945. * The surface used for the skybox
  51946. */
  51947. protected _mesh: Mesh;
  51948. /**
  51949. * Gets the mesh used for the skybox.
  51950. */
  51951. get mesh(): Mesh;
  51952. /**
  51953. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51954. * Also see the options.resolution property.
  51955. */
  51956. get fovMultiplier(): number;
  51957. set fovMultiplier(value: number);
  51958. private _imageMode;
  51959. /**
  51960. * Gets or set the current video mode for the video. It can be:
  51961. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51962. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51963. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51964. */
  51965. get imageMode(): number;
  51966. set imageMode(value: number);
  51967. /**
  51968. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51969. * @param name Element's name, child elements will append suffixes for their own names.
  51970. * @param urlsOfPhoto defines the url of the photo to display
  51971. * @param options defines an object containing optional or exposed sub element properties
  51972. * @param onError defines a callback called when an error occured while loading the texture
  51973. */
  51974. constructor(name: string, urlOfPhoto: string, options: {
  51975. resolution?: number;
  51976. size?: number;
  51977. useDirectMapping?: boolean;
  51978. faceForward?: boolean;
  51979. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51980. private _onBeforeCameraRenderObserver;
  51981. private _changeImageMode;
  51982. /**
  51983. * Releases resources associated with this node.
  51984. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51985. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51986. */
  51987. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51988. }
  51989. }
  51990. declare module "babylonjs/Misc/rgbdTextureTools" {
  51991. import "babylonjs/Shaders/rgbdDecode.fragment";
  51992. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51993. import { Texture } from "babylonjs/Materials/Textures/texture";
  51994. /**
  51995. * Class used to host RGBD texture specific utilities
  51996. */
  51997. export class RGBDTextureTools {
  51998. /**
  51999. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52000. * @param texture the texture to expand.
  52001. */
  52002. static ExpandRGBDTexture(texture: Texture): void;
  52003. }
  52004. }
  52005. declare module "babylonjs/Misc/brdfTextureTools" {
  52006. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52007. import { Scene } from "babylonjs/scene";
  52008. /**
  52009. * Class used to host texture specific utilities
  52010. */
  52011. export class BRDFTextureTools {
  52012. /**
  52013. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52014. * @param scene defines the hosting scene
  52015. * @returns the environment BRDF texture
  52016. */
  52017. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52018. private static _environmentBRDFBase64Texture;
  52019. }
  52020. }
  52021. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52022. import { Nullable } from "babylonjs/types";
  52023. import { Color3 } from "babylonjs/Maths/math.color";
  52024. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52025. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52026. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52027. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52028. import { Engine } from "babylonjs/Engines/engine";
  52029. import { Scene } from "babylonjs/scene";
  52030. /**
  52031. * @hidden
  52032. */
  52033. export interface IMaterialClearCoatDefines {
  52034. CLEARCOAT: boolean;
  52035. CLEARCOAT_DEFAULTIOR: boolean;
  52036. CLEARCOAT_TEXTURE: boolean;
  52037. CLEARCOAT_TEXTUREDIRECTUV: number;
  52038. CLEARCOAT_BUMP: boolean;
  52039. CLEARCOAT_BUMPDIRECTUV: number;
  52040. CLEARCOAT_TINT: boolean;
  52041. CLEARCOAT_TINT_TEXTURE: boolean;
  52042. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52043. /** @hidden */
  52044. _areTexturesDirty: boolean;
  52045. }
  52046. /**
  52047. * Define the code related to the clear coat parameters of the pbr material.
  52048. */
  52049. export class PBRClearCoatConfiguration {
  52050. /**
  52051. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52052. * The default fits with a polyurethane material.
  52053. */
  52054. private static readonly _DefaultIndexOfRefraction;
  52055. private _isEnabled;
  52056. /**
  52057. * Defines if the clear coat is enabled in the material.
  52058. */
  52059. isEnabled: boolean;
  52060. /**
  52061. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52062. */
  52063. intensity: number;
  52064. /**
  52065. * Defines the clear coat layer roughness.
  52066. */
  52067. roughness: number;
  52068. private _indexOfRefraction;
  52069. /**
  52070. * Defines the index of refraction of the clear coat.
  52071. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52072. * The default fits with a polyurethane material.
  52073. * Changing the default value is more performance intensive.
  52074. */
  52075. indexOfRefraction: number;
  52076. private _texture;
  52077. /**
  52078. * Stores the clear coat values in a texture.
  52079. */
  52080. texture: Nullable<BaseTexture>;
  52081. private _bumpTexture;
  52082. /**
  52083. * Define the clear coat specific bump texture.
  52084. */
  52085. bumpTexture: Nullable<BaseTexture>;
  52086. private _isTintEnabled;
  52087. /**
  52088. * Defines if the clear coat tint is enabled in the material.
  52089. */
  52090. isTintEnabled: boolean;
  52091. /**
  52092. * Defines the clear coat tint of the material.
  52093. * This is only use if tint is enabled
  52094. */
  52095. tintColor: Color3;
  52096. /**
  52097. * Defines the distance at which the tint color should be found in the
  52098. * clear coat media.
  52099. * This is only use if tint is enabled
  52100. */
  52101. tintColorAtDistance: number;
  52102. /**
  52103. * Defines the clear coat layer thickness.
  52104. * This is only use if tint is enabled
  52105. */
  52106. tintThickness: number;
  52107. private _tintTexture;
  52108. /**
  52109. * Stores the clear tint values in a texture.
  52110. * rgb is tint
  52111. * a is a thickness factor
  52112. */
  52113. tintTexture: Nullable<BaseTexture>;
  52114. /** @hidden */
  52115. private _internalMarkAllSubMeshesAsTexturesDirty;
  52116. /** @hidden */
  52117. _markAllSubMeshesAsTexturesDirty(): void;
  52118. /**
  52119. * Instantiate a new istance of clear coat configuration.
  52120. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52121. */
  52122. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52123. /**
  52124. * Gets wehter the submesh is ready to be used or not.
  52125. * @param defines the list of "defines" to update.
  52126. * @param scene defines the scene the material belongs to.
  52127. * @param engine defines the engine the material belongs to.
  52128. * @param disableBumpMap defines wether the material disables bump or not.
  52129. * @returns - boolean indicating that the submesh is ready or not.
  52130. */
  52131. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52132. /**
  52133. * Checks to see if a texture is used in the material.
  52134. * @param defines the list of "defines" to update.
  52135. * @param scene defines the scene to the material belongs to.
  52136. */
  52137. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52138. /**
  52139. * Binds the material data.
  52140. * @param uniformBuffer defines the Uniform buffer to fill in.
  52141. * @param scene defines the scene the material belongs to.
  52142. * @param engine defines the engine the material belongs to.
  52143. * @param disableBumpMap defines wether the material disables bump or not.
  52144. * @param isFrozen defines wether the material is frozen or not.
  52145. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52146. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52147. */
  52148. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52149. /**
  52150. * Checks to see if a texture is used in the material.
  52151. * @param texture - Base texture to use.
  52152. * @returns - Boolean specifying if a texture is used in the material.
  52153. */
  52154. hasTexture(texture: BaseTexture): boolean;
  52155. /**
  52156. * Returns an array of the actively used textures.
  52157. * @param activeTextures Array of BaseTextures
  52158. */
  52159. getActiveTextures(activeTextures: BaseTexture[]): void;
  52160. /**
  52161. * Returns the animatable textures.
  52162. * @param animatables Array of animatable textures.
  52163. */
  52164. getAnimatables(animatables: IAnimatable[]): void;
  52165. /**
  52166. * Disposes the resources of the material.
  52167. * @param forceDisposeTextures - Forces the disposal of all textures.
  52168. */
  52169. dispose(forceDisposeTextures?: boolean): void;
  52170. /**
  52171. * Get the current class name of the texture useful for serialization or dynamic coding.
  52172. * @returns "PBRClearCoatConfiguration"
  52173. */
  52174. getClassName(): string;
  52175. /**
  52176. * Add fallbacks to the effect fallbacks list.
  52177. * @param defines defines the Base texture to use.
  52178. * @param fallbacks defines the current fallback list.
  52179. * @param currentRank defines the current fallback rank.
  52180. * @returns the new fallback rank.
  52181. */
  52182. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52183. /**
  52184. * Add the required uniforms to the current list.
  52185. * @param uniforms defines the current uniform list.
  52186. */
  52187. static AddUniforms(uniforms: string[]): void;
  52188. /**
  52189. * Add the required samplers to the current list.
  52190. * @param samplers defines the current sampler list.
  52191. */
  52192. static AddSamplers(samplers: string[]): void;
  52193. /**
  52194. * Add the required uniforms to the current buffer.
  52195. * @param uniformBuffer defines the current uniform buffer.
  52196. */
  52197. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52198. /**
  52199. * Makes a duplicate of the current configuration into another one.
  52200. * @param clearCoatConfiguration define the config where to copy the info
  52201. */
  52202. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52203. /**
  52204. * Serializes this clear coat configuration.
  52205. * @returns - An object with the serialized config.
  52206. */
  52207. serialize(): any;
  52208. /**
  52209. * Parses a anisotropy Configuration from a serialized object.
  52210. * @param source - Serialized object.
  52211. * @param scene Defines the scene we are parsing for
  52212. * @param rootUrl Defines the rootUrl to load from
  52213. */
  52214. parse(source: any, scene: Scene, rootUrl: string): void;
  52215. }
  52216. }
  52217. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52218. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52220. import { Vector2 } from "babylonjs/Maths/math.vector";
  52221. import { Scene } from "babylonjs/scene";
  52222. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52223. import { Nullable } from "babylonjs/types";
  52224. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52225. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52226. /**
  52227. * @hidden
  52228. */
  52229. export interface IMaterialAnisotropicDefines {
  52230. ANISOTROPIC: boolean;
  52231. ANISOTROPIC_TEXTURE: boolean;
  52232. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52233. MAINUV1: boolean;
  52234. _areTexturesDirty: boolean;
  52235. _needUVs: boolean;
  52236. }
  52237. /**
  52238. * Define the code related to the anisotropic parameters of the pbr material.
  52239. */
  52240. export class PBRAnisotropicConfiguration {
  52241. private _isEnabled;
  52242. /**
  52243. * Defines if the anisotropy is enabled in the material.
  52244. */
  52245. isEnabled: boolean;
  52246. /**
  52247. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52248. */
  52249. intensity: number;
  52250. /**
  52251. * Defines if the effect is along the tangents, bitangents or in between.
  52252. * By default, the effect is "strectching" the highlights along the tangents.
  52253. */
  52254. direction: Vector2;
  52255. private _texture;
  52256. /**
  52257. * Stores the anisotropy values in a texture.
  52258. * rg is direction (like normal from -1 to 1)
  52259. * b is a intensity
  52260. */
  52261. texture: Nullable<BaseTexture>;
  52262. /** @hidden */
  52263. private _internalMarkAllSubMeshesAsTexturesDirty;
  52264. /** @hidden */
  52265. _markAllSubMeshesAsTexturesDirty(): void;
  52266. /**
  52267. * Instantiate a new istance of anisotropy configuration.
  52268. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52269. */
  52270. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52271. /**
  52272. * Specifies that the submesh is ready to be used.
  52273. * @param defines the list of "defines" to update.
  52274. * @param scene defines the scene the material belongs to.
  52275. * @returns - boolean indicating that the submesh is ready or not.
  52276. */
  52277. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52278. /**
  52279. * Checks to see if a texture is used in the material.
  52280. * @param defines the list of "defines" to update.
  52281. * @param mesh the mesh we are preparing the defines for.
  52282. * @param scene defines the scene the material belongs to.
  52283. */
  52284. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52285. /**
  52286. * Binds the material data.
  52287. * @param uniformBuffer defines the Uniform buffer to fill in.
  52288. * @param scene defines the scene the material belongs to.
  52289. * @param isFrozen defines wether the material is frozen or not.
  52290. */
  52291. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52292. /**
  52293. * Checks to see if a texture is used in the material.
  52294. * @param texture - Base texture to use.
  52295. * @returns - Boolean specifying if a texture is used in the material.
  52296. */
  52297. hasTexture(texture: BaseTexture): boolean;
  52298. /**
  52299. * Returns an array of the actively used textures.
  52300. * @param activeTextures Array of BaseTextures
  52301. */
  52302. getActiveTextures(activeTextures: BaseTexture[]): void;
  52303. /**
  52304. * Returns the animatable textures.
  52305. * @param animatables Array of animatable textures.
  52306. */
  52307. getAnimatables(animatables: IAnimatable[]): void;
  52308. /**
  52309. * Disposes the resources of the material.
  52310. * @param forceDisposeTextures - Forces the disposal of all textures.
  52311. */
  52312. dispose(forceDisposeTextures?: boolean): void;
  52313. /**
  52314. * Get the current class name of the texture useful for serialization or dynamic coding.
  52315. * @returns "PBRAnisotropicConfiguration"
  52316. */
  52317. getClassName(): string;
  52318. /**
  52319. * Add fallbacks to the effect fallbacks list.
  52320. * @param defines defines the Base texture to use.
  52321. * @param fallbacks defines the current fallback list.
  52322. * @param currentRank defines the current fallback rank.
  52323. * @returns the new fallback rank.
  52324. */
  52325. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52326. /**
  52327. * Add the required uniforms to the current list.
  52328. * @param uniforms defines the current uniform list.
  52329. */
  52330. static AddUniforms(uniforms: string[]): void;
  52331. /**
  52332. * Add the required uniforms to the current buffer.
  52333. * @param uniformBuffer defines the current uniform buffer.
  52334. */
  52335. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52336. /**
  52337. * Add the required samplers to the current list.
  52338. * @param samplers defines the current sampler list.
  52339. */
  52340. static AddSamplers(samplers: string[]): void;
  52341. /**
  52342. * Makes a duplicate of the current configuration into another one.
  52343. * @param anisotropicConfiguration define the config where to copy the info
  52344. */
  52345. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52346. /**
  52347. * Serializes this anisotropy configuration.
  52348. * @returns - An object with the serialized config.
  52349. */
  52350. serialize(): any;
  52351. /**
  52352. * Parses a anisotropy Configuration from a serialized object.
  52353. * @param source - Serialized object.
  52354. * @param scene Defines the scene we are parsing for
  52355. * @param rootUrl Defines the rootUrl to load from
  52356. */
  52357. parse(source: any, scene: Scene, rootUrl: string): void;
  52358. }
  52359. }
  52360. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52361. import { Scene } from "babylonjs/scene";
  52362. /**
  52363. * @hidden
  52364. */
  52365. export interface IMaterialBRDFDefines {
  52366. BRDF_V_HEIGHT_CORRELATED: boolean;
  52367. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52368. SPHERICAL_HARMONICS: boolean;
  52369. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52370. /** @hidden */
  52371. _areMiscDirty: boolean;
  52372. }
  52373. /**
  52374. * Define the code related to the BRDF parameters of the pbr material.
  52375. */
  52376. export class PBRBRDFConfiguration {
  52377. /**
  52378. * Default value used for the energy conservation.
  52379. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52380. */
  52381. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52382. /**
  52383. * Default value used for the Smith Visibility Height Correlated mode.
  52384. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52385. */
  52386. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52387. /**
  52388. * Default value used for the IBL diffuse part.
  52389. * This can help switching back to the polynomials mode globally which is a tiny bit
  52390. * less GPU intensive at the drawback of a lower quality.
  52391. */
  52392. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52393. /**
  52394. * Default value used for activating energy conservation for the specular workflow.
  52395. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52396. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52397. */
  52398. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52399. private _useEnergyConservation;
  52400. /**
  52401. * Defines if the material uses energy conservation.
  52402. */
  52403. useEnergyConservation: boolean;
  52404. private _useSmithVisibilityHeightCorrelated;
  52405. /**
  52406. * LEGACY Mode set to false
  52407. * Defines if the material uses height smith correlated visibility term.
  52408. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52409. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52410. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52411. * Not relying on height correlated will also disable energy conservation.
  52412. */
  52413. useSmithVisibilityHeightCorrelated: boolean;
  52414. private _useSphericalHarmonics;
  52415. /**
  52416. * LEGACY Mode set to false
  52417. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52418. * diffuse part of the IBL.
  52419. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52420. * to the ground truth.
  52421. */
  52422. useSphericalHarmonics: boolean;
  52423. private _useSpecularGlossinessInputEnergyConservation;
  52424. /**
  52425. * Defines if the material uses energy conservation, when the specular workflow is active.
  52426. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52427. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52428. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52429. */
  52430. useSpecularGlossinessInputEnergyConservation: boolean;
  52431. /** @hidden */
  52432. private _internalMarkAllSubMeshesAsMiscDirty;
  52433. /** @hidden */
  52434. _markAllSubMeshesAsMiscDirty(): void;
  52435. /**
  52436. * Instantiate a new istance of clear coat configuration.
  52437. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52438. */
  52439. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52440. /**
  52441. * Checks to see if a texture is used in the material.
  52442. * @param defines the list of "defines" to update.
  52443. */
  52444. prepareDefines(defines: IMaterialBRDFDefines): void;
  52445. /**
  52446. * Get the current class name of the texture useful for serialization or dynamic coding.
  52447. * @returns "PBRClearCoatConfiguration"
  52448. */
  52449. getClassName(): string;
  52450. /**
  52451. * Makes a duplicate of the current configuration into another one.
  52452. * @param brdfConfiguration define the config where to copy the info
  52453. */
  52454. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52455. /**
  52456. * Serializes this BRDF configuration.
  52457. * @returns - An object with the serialized config.
  52458. */
  52459. serialize(): any;
  52460. /**
  52461. * Parses a anisotropy Configuration from a serialized object.
  52462. * @param source - Serialized object.
  52463. * @param scene Defines the scene we are parsing for
  52464. * @param rootUrl Defines the rootUrl to load from
  52465. */
  52466. parse(source: any, scene: Scene, rootUrl: string): void;
  52467. }
  52468. }
  52469. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52470. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52471. import { Color3 } from "babylonjs/Maths/math.color";
  52472. import { Scene } from "babylonjs/scene";
  52473. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52474. import { Nullable } from "babylonjs/types";
  52475. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52476. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52477. /**
  52478. * @hidden
  52479. */
  52480. export interface IMaterialSheenDefines {
  52481. SHEEN: boolean;
  52482. SHEEN_TEXTURE: boolean;
  52483. SHEEN_TEXTUREDIRECTUV: number;
  52484. SHEEN_LINKWITHALBEDO: boolean;
  52485. SHEEN_ROUGHNESS: boolean;
  52486. SHEEN_ALBEDOSCALING: boolean;
  52487. /** @hidden */
  52488. _areTexturesDirty: boolean;
  52489. }
  52490. /**
  52491. * Define the code related to the Sheen parameters of the pbr material.
  52492. */
  52493. export class PBRSheenConfiguration {
  52494. private _isEnabled;
  52495. /**
  52496. * Defines if the material uses sheen.
  52497. */
  52498. isEnabled: boolean;
  52499. private _linkSheenWithAlbedo;
  52500. /**
  52501. * Defines if the sheen is linked to the sheen color.
  52502. */
  52503. linkSheenWithAlbedo: boolean;
  52504. /**
  52505. * Defines the sheen intensity.
  52506. */
  52507. intensity: number;
  52508. /**
  52509. * Defines the sheen color.
  52510. */
  52511. color: Color3;
  52512. private _texture;
  52513. /**
  52514. * Stores the sheen tint values in a texture.
  52515. * rgb is tint
  52516. * a is a intensity
  52517. */
  52518. texture: Nullable<BaseTexture>;
  52519. private _roughness;
  52520. /**
  52521. * Defines the sheen roughness.
  52522. * It is not taken into account if linkSheenWithAlbedo is true.
  52523. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  52524. */
  52525. roughness: Nullable<number>;
  52526. private _albedoScaling;
  52527. /**
  52528. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  52529. * It allows the strength of the sheen effect to not depend on the base color of the material,
  52530. * making it easier to setup and tweak the effect
  52531. */
  52532. albedoScaling: boolean;
  52533. /** @hidden */
  52534. private _internalMarkAllSubMeshesAsTexturesDirty;
  52535. /** @hidden */
  52536. _markAllSubMeshesAsTexturesDirty(): void;
  52537. /**
  52538. * Instantiate a new istance of clear coat configuration.
  52539. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52540. */
  52541. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52542. /**
  52543. * Specifies that the submesh is ready to be used.
  52544. * @param defines the list of "defines" to update.
  52545. * @param scene defines the scene the material belongs to.
  52546. * @returns - boolean indicating that the submesh is ready or not.
  52547. */
  52548. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52549. /**
  52550. * Checks to see if a texture is used in the material.
  52551. * @param defines the list of "defines" to update.
  52552. * @param scene defines the scene the material belongs to.
  52553. */
  52554. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52555. /**
  52556. * Binds the material data.
  52557. * @param uniformBuffer defines the Uniform buffer to fill in.
  52558. * @param scene defines the scene the material belongs to.
  52559. * @param isFrozen defines wether the material is frozen or not.
  52560. */
  52561. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52562. /**
  52563. * Checks to see if a texture is used in the material.
  52564. * @param texture - Base texture to use.
  52565. * @returns - Boolean specifying if a texture is used in the material.
  52566. */
  52567. hasTexture(texture: BaseTexture): boolean;
  52568. /**
  52569. * Returns an array of the actively used textures.
  52570. * @param activeTextures Array of BaseTextures
  52571. */
  52572. getActiveTextures(activeTextures: BaseTexture[]): void;
  52573. /**
  52574. * Returns the animatable textures.
  52575. * @param animatables Array of animatable textures.
  52576. */
  52577. getAnimatables(animatables: IAnimatable[]): void;
  52578. /**
  52579. * Disposes the resources of the material.
  52580. * @param forceDisposeTextures - Forces the disposal of all textures.
  52581. */
  52582. dispose(forceDisposeTextures?: boolean): void;
  52583. /**
  52584. * Get the current class name of the texture useful for serialization or dynamic coding.
  52585. * @returns "PBRSheenConfiguration"
  52586. */
  52587. getClassName(): string;
  52588. /**
  52589. * Add fallbacks to the effect fallbacks list.
  52590. * @param defines defines the Base texture to use.
  52591. * @param fallbacks defines the current fallback list.
  52592. * @param currentRank defines the current fallback rank.
  52593. * @returns the new fallback rank.
  52594. */
  52595. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52596. /**
  52597. * Add the required uniforms to the current list.
  52598. * @param uniforms defines the current uniform list.
  52599. */
  52600. static AddUniforms(uniforms: string[]): void;
  52601. /**
  52602. * Add the required uniforms to the current buffer.
  52603. * @param uniformBuffer defines the current uniform buffer.
  52604. */
  52605. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52606. /**
  52607. * Add the required samplers to the current list.
  52608. * @param samplers defines the current sampler list.
  52609. */
  52610. static AddSamplers(samplers: string[]): void;
  52611. /**
  52612. * Makes a duplicate of the current configuration into another one.
  52613. * @param sheenConfiguration define the config where to copy the info
  52614. */
  52615. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52616. /**
  52617. * Serializes this BRDF configuration.
  52618. * @returns - An object with the serialized config.
  52619. */
  52620. serialize(): any;
  52621. /**
  52622. * Parses a anisotropy Configuration from a serialized object.
  52623. * @param source - Serialized object.
  52624. * @param scene Defines the scene we are parsing for
  52625. * @param rootUrl Defines the rootUrl to load from
  52626. */
  52627. parse(source: any, scene: Scene, rootUrl: string): void;
  52628. }
  52629. }
  52630. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52631. import { Nullable } from "babylonjs/types";
  52632. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52633. import { Color3 } from "babylonjs/Maths/math.color";
  52634. import { SmartArray } from "babylonjs/Misc/smartArray";
  52635. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52636. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52637. import { Effect } from "babylonjs/Materials/effect";
  52638. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52639. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52640. import { Engine } from "babylonjs/Engines/engine";
  52641. import { Scene } from "babylonjs/scene";
  52642. /**
  52643. * @hidden
  52644. */
  52645. export interface IMaterialSubSurfaceDefines {
  52646. SUBSURFACE: boolean;
  52647. SS_REFRACTION: boolean;
  52648. SS_TRANSLUCENCY: boolean;
  52649. SS_SCATERRING: boolean;
  52650. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52651. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52652. SS_REFRACTIONMAP_3D: boolean;
  52653. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52654. SS_LODINREFRACTIONALPHA: boolean;
  52655. SS_GAMMAREFRACTION: boolean;
  52656. SS_RGBDREFRACTION: boolean;
  52657. SS_LINEARSPECULARREFRACTION: boolean;
  52658. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52659. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52660. /** @hidden */
  52661. _areTexturesDirty: boolean;
  52662. }
  52663. /**
  52664. * Define the code related to the sub surface parameters of the pbr material.
  52665. */
  52666. export class PBRSubSurfaceConfiguration {
  52667. private _isRefractionEnabled;
  52668. /**
  52669. * Defines if the refraction is enabled in the material.
  52670. */
  52671. isRefractionEnabled: boolean;
  52672. private _isTranslucencyEnabled;
  52673. /**
  52674. * Defines if the translucency is enabled in the material.
  52675. */
  52676. isTranslucencyEnabled: boolean;
  52677. private _isScatteringEnabled;
  52678. /**
  52679. * Defines the refraction intensity of the material.
  52680. * The refraction when enabled replaces the Diffuse part of the material.
  52681. * The intensity helps transitionning between diffuse and refraction.
  52682. */
  52683. refractionIntensity: number;
  52684. /**
  52685. * Defines the translucency intensity of the material.
  52686. * When translucency has been enabled, this defines how much of the "translucency"
  52687. * is addded to the diffuse part of the material.
  52688. */
  52689. translucencyIntensity: number;
  52690. /**
  52691. * Defines the scattering intensity of the material.
  52692. * When scattering has been enabled, this defines how much of the "scattered light"
  52693. * is addded to the diffuse part of the material.
  52694. */
  52695. scatteringIntensity: number;
  52696. private _thicknessTexture;
  52697. /**
  52698. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52699. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52700. * 0 would mean minimumThickness
  52701. * 1 would mean maximumThickness
  52702. * The other channels might be use as a mask to vary the different effects intensity.
  52703. */
  52704. thicknessTexture: Nullable<BaseTexture>;
  52705. private _refractionTexture;
  52706. /**
  52707. * Defines the texture to use for refraction.
  52708. */
  52709. refractionTexture: Nullable<BaseTexture>;
  52710. private _indexOfRefraction;
  52711. /**
  52712. * Defines the index of refraction used in the material.
  52713. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52714. */
  52715. indexOfRefraction: number;
  52716. private _invertRefractionY;
  52717. /**
  52718. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52719. */
  52720. invertRefractionY: boolean;
  52721. private _linkRefractionWithTransparency;
  52722. /**
  52723. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52724. * Materials half opaque for instance using refraction could benefit from this control.
  52725. */
  52726. linkRefractionWithTransparency: boolean;
  52727. /**
  52728. * Defines the minimum thickness stored in the thickness map.
  52729. * If no thickness map is defined, this value will be used to simulate thickness.
  52730. */
  52731. minimumThickness: number;
  52732. /**
  52733. * Defines the maximum thickness stored in the thickness map.
  52734. */
  52735. maximumThickness: number;
  52736. /**
  52737. * Defines the volume tint of the material.
  52738. * This is used for both translucency and scattering.
  52739. */
  52740. tintColor: Color3;
  52741. /**
  52742. * Defines the distance at which the tint color should be found in the media.
  52743. * This is used for refraction only.
  52744. */
  52745. tintColorAtDistance: number;
  52746. /**
  52747. * Defines how far each channel transmit through the media.
  52748. * It is defined as a color to simplify it selection.
  52749. */
  52750. diffusionDistance: Color3;
  52751. private _useMaskFromThicknessTexture;
  52752. /**
  52753. * Stores the intensity of the different subsurface effects in the thickness texture.
  52754. * * the green channel is the translucency intensity.
  52755. * * the blue channel is the scattering intensity.
  52756. * * the alpha channel is the refraction intensity.
  52757. */
  52758. useMaskFromThicknessTexture: boolean;
  52759. /** @hidden */
  52760. private _internalMarkAllSubMeshesAsTexturesDirty;
  52761. /** @hidden */
  52762. _markAllSubMeshesAsTexturesDirty(): void;
  52763. /**
  52764. * Instantiate a new istance of sub surface configuration.
  52765. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52766. */
  52767. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52768. /**
  52769. * Gets wehter the submesh is ready to be used or not.
  52770. * @param defines the list of "defines" to update.
  52771. * @param scene defines the scene the material belongs to.
  52772. * @returns - boolean indicating that the submesh is ready or not.
  52773. */
  52774. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52775. /**
  52776. * Checks to see if a texture is used in the material.
  52777. * @param defines the list of "defines" to update.
  52778. * @param scene defines the scene to the material belongs to.
  52779. */
  52780. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52781. /**
  52782. * Binds the material data.
  52783. * @param uniformBuffer defines the Uniform buffer to fill in.
  52784. * @param scene defines the scene the material belongs to.
  52785. * @param engine defines the engine the material belongs to.
  52786. * @param isFrozen defines wether the material is frozen or not.
  52787. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52788. */
  52789. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52790. /**
  52791. * Unbinds the material from the mesh.
  52792. * @param activeEffect defines the effect that should be unbound from.
  52793. * @returns true if unbound, otherwise false
  52794. */
  52795. unbind(activeEffect: Effect): boolean;
  52796. /**
  52797. * Returns the texture used for refraction or null if none is used.
  52798. * @param scene defines the scene the material belongs to.
  52799. * @returns - Refraction texture if present. If no refraction texture and refraction
  52800. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52801. */
  52802. private _getRefractionTexture;
  52803. /**
  52804. * Returns true if alpha blending should be disabled.
  52805. */
  52806. get disableAlphaBlending(): boolean;
  52807. /**
  52808. * Fills the list of render target textures.
  52809. * @param renderTargets the list of render targets to update
  52810. */
  52811. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52812. /**
  52813. * Checks to see if a texture is used in the material.
  52814. * @param texture - Base texture to use.
  52815. * @returns - Boolean specifying if a texture is used in the material.
  52816. */
  52817. hasTexture(texture: BaseTexture): boolean;
  52818. /**
  52819. * Gets a boolean indicating that current material needs to register RTT
  52820. * @returns true if this uses a render target otherwise false.
  52821. */
  52822. hasRenderTargetTextures(): boolean;
  52823. /**
  52824. * Returns an array of the actively used textures.
  52825. * @param activeTextures Array of BaseTextures
  52826. */
  52827. getActiveTextures(activeTextures: BaseTexture[]): void;
  52828. /**
  52829. * Returns the animatable textures.
  52830. * @param animatables Array of animatable textures.
  52831. */
  52832. getAnimatables(animatables: IAnimatable[]): void;
  52833. /**
  52834. * Disposes the resources of the material.
  52835. * @param forceDisposeTextures - Forces the disposal of all textures.
  52836. */
  52837. dispose(forceDisposeTextures?: boolean): void;
  52838. /**
  52839. * Get the current class name of the texture useful for serialization or dynamic coding.
  52840. * @returns "PBRSubSurfaceConfiguration"
  52841. */
  52842. getClassName(): string;
  52843. /**
  52844. * Add fallbacks to the effect fallbacks list.
  52845. * @param defines defines the Base texture to use.
  52846. * @param fallbacks defines the current fallback list.
  52847. * @param currentRank defines the current fallback rank.
  52848. * @returns the new fallback rank.
  52849. */
  52850. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52851. /**
  52852. * Add the required uniforms to the current list.
  52853. * @param uniforms defines the current uniform list.
  52854. */
  52855. static AddUniforms(uniforms: string[]): void;
  52856. /**
  52857. * Add the required samplers to the current list.
  52858. * @param samplers defines the current sampler list.
  52859. */
  52860. static AddSamplers(samplers: string[]): void;
  52861. /**
  52862. * Add the required uniforms to the current buffer.
  52863. * @param uniformBuffer defines the current uniform buffer.
  52864. */
  52865. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52866. /**
  52867. * Makes a duplicate of the current configuration into another one.
  52868. * @param configuration define the config where to copy the info
  52869. */
  52870. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52871. /**
  52872. * Serializes this Sub Surface configuration.
  52873. * @returns - An object with the serialized config.
  52874. */
  52875. serialize(): any;
  52876. /**
  52877. * Parses a anisotropy Configuration from a serialized object.
  52878. * @param source - Serialized object.
  52879. * @param scene Defines the scene we are parsing for
  52880. * @param rootUrl Defines the rootUrl to load from
  52881. */
  52882. parse(source: any, scene: Scene, rootUrl: string): void;
  52883. }
  52884. }
  52885. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52886. /** @hidden */
  52887. export var pbrFragmentDeclaration: {
  52888. name: string;
  52889. shader: string;
  52890. };
  52891. }
  52892. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52893. /** @hidden */
  52894. export var pbrUboDeclaration: {
  52895. name: string;
  52896. shader: string;
  52897. };
  52898. }
  52899. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52900. /** @hidden */
  52901. export var pbrFragmentExtraDeclaration: {
  52902. name: string;
  52903. shader: string;
  52904. };
  52905. }
  52906. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52907. /** @hidden */
  52908. export var pbrFragmentSamplersDeclaration: {
  52909. name: string;
  52910. shader: string;
  52911. };
  52912. }
  52913. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52914. /** @hidden */
  52915. export var pbrHelperFunctions: {
  52916. name: string;
  52917. shader: string;
  52918. };
  52919. }
  52920. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52921. /** @hidden */
  52922. export var harmonicsFunctions: {
  52923. name: string;
  52924. shader: string;
  52925. };
  52926. }
  52927. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52928. /** @hidden */
  52929. export var pbrDirectLightingSetupFunctions: {
  52930. name: string;
  52931. shader: string;
  52932. };
  52933. }
  52934. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52935. /** @hidden */
  52936. export var pbrDirectLightingFalloffFunctions: {
  52937. name: string;
  52938. shader: string;
  52939. };
  52940. }
  52941. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52942. /** @hidden */
  52943. export var pbrBRDFFunctions: {
  52944. name: string;
  52945. shader: string;
  52946. };
  52947. }
  52948. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52949. /** @hidden */
  52950. export var pbrDirectLightingFunctions: {
  52951. name: string;
  52952. shader: string;
  52953. };
  52954. }
  52955. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52956. /** @hidden */
  52957. export var pbrIBLFunctions: {
  52958. name: string;
  52959. shader: string;
  52960. };
  52961. }
  52962. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52963. /** @hidden */
  52964. export var pbrDebug: {
  52965. name: string;
  52966. shader: string;
  52967. };
  52968. }
  52969. declare module "babylonjs/Shaders/pbr.fragment" {
  52970. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52971. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52972. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52973. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52974. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52975. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52976. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52977. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52978. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52979. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52980. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52981. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52982. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52983. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52984. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52985. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52986. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52987. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52988. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52989. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52990. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52991. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52992. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52993. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52994. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52995. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52996. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52997. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52998. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52999. /** @hidden */
  53000. export var pbrPixelShader: {
  53001. name: string;
  53002. shader: string;
  53003. };
  53004. }
  53005. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53006. /** @hidden */
  53007. export var pbrVertexDeclaration: {
  53008. name: string;
  53009. shader: string;
  53010. };
  53011. }
  53012. declare module "babylonjs/Shaders/pbr.vertex" {
  53013. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53014. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53015. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53016. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53017. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53018. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53019. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53020. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53021. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53022. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53023. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53024. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53025. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53026. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53027. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53028. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53029. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53030. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53031. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53032. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53033. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53034. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53035. /** @hidden */
  53036. export var pbrVertexShader: {
  53037. name: string;
  53038. shader: string;
  53039. };
  53040. }
  53041. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53042. import { Nullable } from "babylonjs/types";
  53043. import { Scene } from "babylonjs/scene";
  53044. import { Matrix } from "babylonjs/Maths/math.vector";
  53045. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53047. import { Mesh } from "babylonjs/Meshes/mesh";
  53048. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53049. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53050. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53051. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53052. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53053. import { Color3 } from "babylonjs/Maths/math.color";
  53054. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53055. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53056. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53057. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53058. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53059. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53060. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53061. import "babylonjs/Shaders/pbr.fragment";
  53062. import "babylonjs/Shaders/pbr.vertex";
  53063. /**
  53064. * Manages the defines for the PBR Material.
  53065. * @hidden
  53066. */
  53067. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53068. PBR: boolean;
  53069. MAINUV1: boolean;
  53070. MAINUV2: boolean;
  53071. UV1: boolean;
  53072. UV2: boolean;
  53073. ALBEDO: boolean;
  53074. GAMMAALBEDO: boolean;
  53075. ALBEDODIRECTUV: number;
  53076. VERTEXCOLOR: boolean;
  53077. AMBIENT: boolean;
  53078. AMBIENTDIRECTUV: number;
  53079. AMBIENTINGRAYSCALE: boolean;
  53080. OPACITY: boolean;
  53081. VERTEXALPHA: boolean;
  53082. OPACITYDIRECTUV: number;
  53083. OPACITYRGB: boolean;
  53084. ALPHATEST: boolean;
  53085. DEPTHPREPASS: boolean;
  53086. ALPHABLEND: boolean;
  53087. ALPHAFROMALBEDO: boolean;
  53088. ALPHATESTVALUE: string;
  53089. SPECULAROVERALPHA: boolean;
  53090. RADIANCEOVERALPHA: boolean;
  53091. ALPHAFRESNEL: boolean;
  53092. LINEARALPHAFRESNEL: boolean;
  53093. PREMULTIPLYALPHA: boolean;
  53094. EMISSIVE: boolean;
  53095. EMISSIVEDIRECTUV: number;
  53096. REFLECTIVITY: boolean;
  53097. REFLECTIVITYDIRECTUV: number;
  53098. SPECULARTERM: boolean;
  53099. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53100. MICROSURFACEAUTOMATIC: boolean;
  53101. LODBASEDMICROSFURACE: boolean;
  53102. MICROSURFACEMAP: boolean;
  53103. MICROSURFACEMAPDIRECTUV: number;
  53104. METALLICWORKFLOW: boolean;
  53105. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53106. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53107. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53108. AOSTOREINMETALMAPRED: boolean;
  53109. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53110. ENVIRONMENTBRDF: boolean;
  53111. ENVIRONMENTBRDF_RGBD: boolean;
  53112. NORMAL: boolean;
  53113. TANGENT: boolean;
  53114. BUMP: boolean;
  53115. BUMPDIRECTUV: number;
  53116. OBJECTSPACE_NORMALMAP: boolean;
  53117. PARALLAX: boolean;
  53118. PARALLAXOCCLUSION: boolean;
  53119. NORMALXYSCALE: boolean;
  53120. LIGHTMAP: boolean;
  53121. LIGHTMAPDIRECTUV: number;
  53122. USELIGHTMAPASSHADOWMAP: boolean;
  53123. GAMMALIGHTMAP: boolean;
  53124. RGBDLIGHTMAP: boolean;
  53125. REFLECTION: boolean;
  53126. REFLECTIONMAP_3D: boolean;
  53127. REFLECTIONMAP_SPHERICAL: boolean;
  53128. REFLECTIONMAP_PLANAR: boolean;
  53129. REFLECTIONMAP_CUBIC: boolean;
  53130. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53131. REFLECTIONMAP_PROJECTION: boolean;
  53132. REFLECTIONMAP_SKYBOX: boolean;
  53133. REFLECTIONMAP_EXPLICIT: boolean;
  53134. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53135. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53136. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53137. INVERTCUBICMAP: boolean;
  53138. USESPHERICALFROMREFLECTIONMAP: boolean;
  53139. USEIRRADIANCEMAP: boolean;
  53140. SPHERICAL_HARMONICS: boolean;
  53141. USESPHERICALINVERTEX: boolean;
  53142. REFLECTIONMAP_OPPOSITEZ: boolean;
  53143. LODINREFLECTIONALPHA: boolean;
  53144. GAMMAREFLECTION: boolean;
  53145. RGBDREFLECTION: boolean;
  53146. LINEARSPECULARREFLECTION: boolean;
  53147. RADIANCEOCCLUSION: boolean;
  53148. HORIZONOCCLUSION: boolean;
  53149. INSTANCES: boolean;
  53150. NUM_BONE_INFLUENCERS: number;
  53151. BonesPerMesh: number;
  53152. BONETEXTURE: boolean;
  53153. NONUNIFORMSCALING: boolean;
  53154. MORPHTARGETS: boolean;
  53155. MORPHTARGETS_NORMAL: boolean;
  53156. MORPHTARGETS_TANGENT: boolean;
  53157. MORPHTARGETS_UV: boolean;
  53158. NUM_MORPH_INFLUENCERS: number;
  53159. IMAGEPROCESSING: boolean;
  53160. VIGNETTE: boolean;
  53161. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53162. VIGNETTEBLENDMODEOPAQUE: boolean;
  53163. TONEMAPPING: boolean;
  53164. TONEMAPPING_ACES: boolean;
  53165. CONTRAST: boolean;
  53166. COLORCURVES: boolean;
  53167. COLORGRADING: boolean;
  53168. COLORGRADING3D: boolean;
  53169. SAMPLER3DGREENDEPTH: boolean;
  53170. SAMPLER3DBGRMAP: boolean;
  53171. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53172. EXPOSURE: boolean;
  53173. MULTIVIEW: boolean;
  53174. USEPHYSICALLIGHTFALLOFF: boolean;
  53175. USEGLTFLIGHTFALLOFF: boolean;
  53176. TWOSIDEDLIGHTING: boolean;
  53177. SHADOWFLOAT: boolean;
  53178. CLIPPLANE: boolean;
  53179. CLIPPLANE2: boolean;
  53180. CLIPPLANE3: boolean;
  53181. CLIPPLANE4: boolean;
  53182. CLIPPLANE5: boolean;
  53183. CLIPPLANE6: boolean;
  53184. POINTSIZE: boolean;
  53185. FOG: boolean;
  53186. LOGARITHMICDEPTH: boolean;
  53187. FORCENORMALFORWARD: boolean;
  53188. SPECULARAA: boolean;
  53189. CLEARCOAT: boolean;
  53190. CLEARCOAT_DEFAULTIOR: boolean;
  53191. CLEARCOAT_TEXTURE: boolean;
  53192. CLEARCOAT_TEXTUREDIRECTUV: number;
  53193. CLEARCOAT_BUMP: boolean;
  53194. CLEARCOAT_BUMPDIRECTUV: number;
  53195. CLEARCOAT_TINT: boolean;
  53196. CLEARCOAT_TINT_TEXTURE: boolean;
  53197. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53198. ANISOTROPIC: boolean;
  53199. ANISOTROPIC_TEXTURE: boolean;
  53200. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53201. BRDF_V_HEIGHT_CORRELATED: boolean;
  53202. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53203. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53204. SHEEN: boolean;
  53205. SHEEN_TEXTURE: boolean;
  53206. SHEEN_TEXTUREDIRECTUV: number;
  53207. SHEEN_LINKWITHALBEDO: boolean;
  53208. SHEEN_ROUGHNESS: boolean;
  53209. SHEEN_ALBEDOSCALING: boolean;
  53210. SUBSURFACE: boolean;
  53211. SS_REFRACTION: boolean;
  53212. SS_TRANSLUCENCY: boolean;
  53213. SS_SCATERRING: boolean;
  53214. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53215. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53216. SS_REFRACTIONMAP_3D: boolean;
  53217. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53218. SS_LODINREFRACTIONALPHA: boolean;
  53219. SS_GAMMAREFRACTION: boolean;
  53220. SS_RGBDREFRACTION: boolean;
  53221. SS_LINEARSPECULARREFRACTION: boolean;
  53222. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53223. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53224. UNLIT: boolean;
  53225. DEBUGMODE: number;
  53226. /**
  53227. * Initializes the PBR Material defines.
  53228. */
  53229. constructor();
  53230. /**
  53231. * Resets the PBR Material defines.
  53232. */
  53233. reset(): void;
  53234. }
  53235. /**
  53236. * The Physically based material base class of BJS.
  53237. *
  53238. * This offers the main features of a standard PBR material.
  53239. * For more information, please refer to the documentation :
  53240. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53241. */
  53242. export abstract class PBRBaseMaterial extends PushMaterial {
  53243. /**
  53244. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53245. */
  53246. static readonly PBRMATERIAL_OPAQUE: number;
  53247. /**
  53248. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53249. */
  53250. static readonly PBRMATERIAL_ALPHATEST: number;
  53251. /**
  53252. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53253. */
  53254. static readonly PBRMATERIAL_ALPHABLEND: number;
  53255. /**
  53256. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53257. * They are also discarded below the alpha cutoff threshold to improve performances.
  53258. */
  53259. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53260. /**
  53261. * Defines the default value of how much AO map is occluding the analytical lights
  53262. * (point spot...).
  53263. */
  53264. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53265. /**
  53266. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53267. */
  53268. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53269. /**
  53270. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53271. * to enhance interoperability with other engines.
  53272. */
  53273. static readonly LIGHTFALLOFF_GLTF: number;
  53274. /**
  53275. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53276. * to enhance interoperability with other materials.
  53277. */
  53278. static readonly LIGHTFALLOFF_STANDARD: number;
  53279. /**
  53280. * Intensity of the direct lights e.g. the four lights available in your scene.
  53281. * This impacts both the direct diffuse and specular highlights.
  53282. */
  53283. protected _directIntensity: number;
  53284. /**
  53285. * Intensity of the emissive part of the material.
  53286. * This helps controlling the emissive effect without modifying the emissive color.
  53287. */
  53288. protected _emissiveIntensity: number;
  53289. /**
  53290. * Intensity of the environment e.g. how much the environment will light the object
  53291. * either through harmonics for rough material or through the refelction for shiny ones.
  53292. */
  53293. protected _environmentIntensity: number;
  53294. /**
  53295. * This is a special control allowing the reduction of the specular highlights coming from the
  53296. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53297. */
  53298. protected _specularIntensity: number;
  53299. /**
  53300. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53301. */
  53302. private _lightingInfos;
  53303. /**
  53304. * Debug Control allowing disabling the bump map on this material.
  53305. */
  53306. protected _disableBumpMap: boolean;
  53307. /**
  53308. * AKA Diffuse Texture in standard nomenclature.
  53309. */
  53310. protected _albedoTexture: Nullable<BaseTexture>;
  53311. /**
  53312. * AKA Occlusion Texture in other nomenclature.
  53313. */
  53314. protected _ambientTexture: Nullable<BaseTexture>;
  53315. /**
  53316. * AKA Occlusion Texture Intensity in other nomenclature.
  53317. */
  53318. protected _ambientTextureStrength: number;
  53319. /**
  53320. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53321. * 1 means it completely occludes it
  53322. * 0 mean it has no impact
  53323. */
  53324. protected _ambientTextureImpactOnAnalyticalLights: number;
  53325. /**
  53326. * Stores the alpha values in a texture.
  53327. */
  53328. protected _opacityTexture: Nullable<BaseTexture>;
  53329. /**
  53330. * Stores the reflection values in a texture.
  53331. */
  53332. protected _reflectionTexture: Nullable<BaseTexture>;
  53333. /**
  53334. * Stores the emissive values in a texture.
  53335. */
  53336. protected _emissiveTexture: Nullable<BaseTexture>;
  53337. /**
  53338. * AKA Specular texture in other nomenclature.
  53339. */
  53340. protected _reflectivityTexture: Nullable<BaseTexture>;
  53341. /**
  53342. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53343. */
  53344. protected _metallicTexture: Nullable<BaseTexture>;
  53345. /**
  53346. * Specifies the metallic scalar of the metallic/roughness workflow.
  53347. * Can also be used to scale the metalness values of the metallic texture.
  53348. */
  53349. protected _metallic: Nullable<number>;
  53350. /**
  53351. * Specifies the roughness scalar of the metallic/roughness workflow.
  53352. * Can also be used to scale the roughness values of the metallic texture.
  53353. */
  53354. protected _roughness: Nullable<number>;
  53355. /**
  53356. * Specifies the an F0 factor to help configuring the material F0.
  53357. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53358. * to 0.5 the previously hard coded value stays the same.
  53359. * Can also be used to scale the F0 values of the metallic texture.
  53360. */
  53361. protected _metallicF0Factor: number;
  53362. /**
  53363. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53364. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53365. * your expectation as it multiplies with the texture data.
  53366. */
  53367. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53368. /**
  53369. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53370. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53371. */
  53372. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53373. /**
  53374. * Stores surface normal data used to displace a mesh in a texture.
  53375. */
  53376. protected _bumpTexture: Nullable<BaseTexture>;
  53377. /**
  53378. * Stores the pre-calculated light information of a mesh in a texture.
  53379. */
  53380. protected _lightmapTexture: Nullable<BaseTexture>;
  53381. /**
  53382. * The color of a material in ambient lighting.
  53383. */
  53384. protected _ambientColor: Color3;
  53385. /**
  53386. * AKA Diffuse Color in other nomenclature.
  53387. */
  53388. protected _albedoColor: Color3;
  53389. /**
  53390. * AKA Specular Color in other nomenclature.
  53391. */
  53392. protected _reflectivityColor: Color3;
  53393. /**
  53394. * The color applied when light is reflected from a material.
  53395. */
  53396. protected _reflectionColor: Color3;
  53397. /**
  53398. * The color applied when light is emitted from a material.
  53399. */
  53400. protected _emissiveColor: Color3;
  53401. /**
  53402. * AKA Glossiness in other nomenclature.
  53403. */
  53404. protected _microSurface: number;
  53405. /**
  53406. * Specifies that the material will use the light map as a show map.
  53407. */
  53408. protected _useLightmapAsShadowmap: boolean;
  53409. /**
  53410. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53411. * makes the reflect vector face the model (under horizon).
  53412. */
  53413. protected _useHorizonOcclusion: boolean;
  53414. /**
  53415. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53416. * too much the area relying on ambient texture to define their ambient occlusion.
  53417. */
  53418. protected _useRadianceOcclusion: boolean;
  53419. /**
  53420. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53421. */
  53422. protected _useAlphaFromAlbedoTexture: boolean;
  53423. /**
  53424. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53425. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53426. */
  53427. protected _useSpecularOverAlpha: boolean;
  53428. /**
  53429. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53430. */
  53431. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53432. /**
  53433. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53434. */
  53435. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53436. /**
  53437. * Specifies if the metallic texture contains the roughness information in its green channel.
  53438. */
  53439. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53440. /**
  53441. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53442. */
  53443. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53444. /**
  53445. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53446. */
  53447. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53448. /**
  53449. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53450. */
  53451. protected _useAmbientInGrayScale: boolean;
  53452. /**
  53453. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53454. * The material will try to infer what glossiness each pixel should be.
  53455. */
  53456. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53457. /**
  53458. * Defines the falloff type used in this material.
  53459. * It by default is Physical.
  53460. */
  53461. protected _lightFalloff: number;
  53462. /**
  53463. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53464. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53465. */
  53466. protected _useRadianceOverAlpha: boolean;
  53467. /**
  53468. * Allows using an object space normal map (instead of tangent space).
  53469. */
  53470. protected _useObjectSpaceNormalMap: boolean;
  53471. /**
  53472. * Allows using the bump map in parallax mode.
  53473. */
  53474. protected _useParallax: boolean;
  53475. /**
  53476. * Allows using the bump map in parallax occlusion mode.
  53477. */
  53478. protected _useParallaxOcclusion: boolean;
  53479. /**
  53480. * Controls the scale bias of the parallax mode.
  53481. */
  53482. protected _parallaxScaleBias: number;
  53483. /**
  53484. * If sets to true, disables all the lights affecting the material.
  53485. */
  53486. protected _disableLighting: boolean;
  53487. /**
  53488. * Number of Simultaneous lights allowed on the material.
  53489. */
  53490. protected _maxSimultaneousLights: number;
  53491. /**
  53492. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53493. */
  53494. protected _invertNormalMapX: boolean;
  53495. /**
  53496. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53497. */
  53498. protected _invertNormalMapY: boolean;
  53499. /**
  53500. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53501. */
  53502. protected _twoSidedLighting: boolean;
  53503. /**
  53504. * Defines the alpha limits in alpha test mode.
  53505. */
  53506. protected _alphaCutOff: number;
  53507. /**
  53508. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53509. */
  53510. protected _forceAlphaTest: boolean;
  53511. /**
  53512. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53513. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53514. */
  53515. protected _useAlphaFresnel: boolean;
  53516. /**
  53517. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53518. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53519. */
  53520. protected _useLinearAlphaFresnel: boolean;
  53521. /**
  53522. * The transparency mode of the material.
  53523. */
  53524. protected _transparencyMode: Nullable<number>;
  53525. /**
  53526. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53527. * from cos thetav and roughness:
  53528. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53529. */
  53530. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53531. /**
  53532. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53533. */
  53534. protected _forceIrradianceInFragment: boolean;
  53535. /**
  53536. * Force normal to face away from face.
  53537. */
  53538. protected _forceNormalForward: boolean;
  53539. /**
  53540. * Enables specular anti aliasing in the PBR shader.
  53541. * It will both interacts on the Geometry for analytical and IBL lighting.
  53542. * It also prefilter the roughness map based on the bump values.
  53543. */
  53544. protected _enableSpecularAntiAliasing: boolean;
  53545. /**
  53546. * Default configuration related to image processing available in the PBR Material.
  53547. */
  53548. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53549. /**
  53550. * Keep track of the image processing observer to allow dispose and replace.
  53551. */
  53552. private _imageProcessingObserver;
  53553. /**
  53554. * Attaches a new image processing configuration to the PBR Material.
  53555. * @param configuration
  53556. */
  53557. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53558. /**
  53559. * Stores the available render targets.
  53560. */
  53561. private _renderTargets;
  53562. /**
  53563. * Sets the global ambient color for the material used in lighting calculations.
  53564. */
  53565. private _globalAmbientColor;
  53566. /**
  53567. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53568. */
  53569. private _useLogarithmicDepth;
  53570. /**
  53571. * If set to true, no lighting calculations will be applied.
  53572. */
  53573. private _unlit;
  53574. private _debugMode;
  53575. /**
  53576. * @hidden
  53577. * This is reserved for the inspector.
  53578. * Defines the material debug mode.
  53579. * It helps seeing only some components of the material while troubleshooting.
  53580. */
  53581. debugMode: number;
  53582. /**
  53583. * @hidden
  53584. * This is reserved for the inspector.
  53585. * Specify from where on screen the debug mode should start.
  53586. * The value goes from -1 (full screen) to 1 (not visible)
  53587. * It helps with side by side comparison against the final render
  53588. * This defaults to -1
  53589. */
  53590. private debugLimit;
  53591. /**
  53592. * @hidden
  53593. * This is reserved for the inspector.
  53594. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53595. * You can use the factor to better multiply the final value.
  53596. */
  53597. private debugFactor;
  53598. /**
  53599. * Defines the clear coat layer parameters for the material.
  53600. */
  53601. readonly clearCoat: PBRClearCoatConfiguration;
  53602. /**
  53603. * Defines the anisotropic parameters for the material.
  53604. */
  53605. readonly anisotropy: PBRAnisotropicConfiguration;
  53606. /**
  53607. * Defines the BRDF parameters for the material.
  53608. */
  53609. readonly brdf: PBRBRDFConfiguration;
  53610. /**
  53611. * Defines the Sheen parameters for the material.
  53612. */
  53613. readonly sheen: PBRSheenConfiguration;
  53614. /**
  53615. * Defines the SubSurface parameters for the material.
  53616. */
  53617. readonly subSurface: PBRSubSurfaceConfiguration;
  53618. /**
  53619. * Custom callback helping to override the default shader used in the material.
  53620. */
  53621. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53622. protected _rebuildInParallel: boolean;
  53623. /**
  53624. * Instantiates a new PBRMaterial instance.
  53625. *
  53626. * @param name The material name
  53627. * @param scene The scene the material will be use in.
  53628. */
  53629. constructor(name: string, scene: Scene);
  53630. /**
  53631. * Gets a boolean indicating that current material needs to register RTT
  53632. */
  53633. get hasRenderTargetTextures(): boolean;
  53634. /**
  53635. * Gets the name of the material class.
  53636. */
  53637. getClassName(): string;
  53638. /**
  53639. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53640. */
  53641. get useLogarithmicDepth(): boolean;
  53642. /**
  53643. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53644. */
  53645. set useLogarithmicDepth(value: boolean);
  53646. /**
  53647. * Gets the current transparency mode.
  53648. */
  53649. get transparencyMode(): Nullable<number>;
  53650. /**
  53651. * Sets the transparency mode of the material.
  53652. *
  53653. * | Value | Type | Description |
  53654. * | ----- | ----------------------------------- | ----------- |
  53655. * | 0 | OPAQUE | |
  53656. * | 1 | ALPHATEST | |
  53657. * | 2 | ALPHABLEND | |
  53658. * | 3 | ALPHATESTANDBLEND | |
  53659. *
  53660. */
  53661. set transparencyMode(value: Nullable<number>);
  53662. /**
  53663. * Returns true if alpha blending should be disabled.
  53664. */
  53665. private get _disableAlphaBlending();
  53666. /**
  53667. * Specifies whether or not this material should be rendered in alpha blend mode.
  53668. */
  53669. needAlphaBlending(): boolean;
  53670. /**
  53671. * Specifies if the mesh will require alpha blending.
  53672. * @param mesh - BJS mesh.
  53673. */
  53674. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53675. /**
  53676. * Specifies whether or not this material should be rendered in alpha test mode.
  53677. */
  53678. needAlphaTesting(): boolean;
  53679. /**
  53680. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53681. */
  53682. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53683. /**
  53684. * Gets the texture used for the alpha test.
  53685. */
  53686. getAlphaTestTexture(): Nullable<BaseTexture>;
  53687. /**
  53688. * Specifies that the submesh is ready to be used.
  53689. * @param mesh - BJS mesh.
  53690. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53691. * @param useInstances - Specifies that instances should be used.
  53692. * @returns - boolean indicating that the submesh is ready or not.
  53693. */
  53694. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53695. /**
  53696. * Specifies if the material uses metallic roughness workflow.
  53697. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53698. */
  53699. isMetallicWorkflow(): boolean;
  53700. private _prepareEffect;
  53701. private _prepareDefines;
  53702. /**
  53703. * Force shader compilation
  53704. */
  53705. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53706. /**
  53707. * Initializes the uniform buffer layout for the shader.
  53708. */
  53709. buildUniformLayout(): void;
  53710. /**
  53711. * Unbinds the material from the mesh
  53712. */
  53713. unbind(): void;
  53714. /**
  53715. * Binds the submesh data.
  53716. * @param world - The world matrix.
  53717. * @param mesh - The BJS mesh.
  53718. * @param subMesh - A submesh of the BJS mesh.
  53719. */
  53720. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53721. /**
  53722. * Returns the animatable textures.
  53723. * @returns - Array of animatable textures.
  53724. */
  53725. getAnimatables(): IAnimatable[];
  53726. /**
  53727. * Returns the texture used for reflections.
  53728. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53729. */
  53730. private _getReflectionTexture;
  53731. /**
  53732. * Returns an array of the actively used textures.
  53733. * @returns - Array of BaseTextures
  53734. */
  53735. getActiveTextures(): BaseTexture[];
  53736. /**
  53737. * Checks to see if a texture is used in the material.
  53738. * @param texture - Base texture to use.
  53739. * @returns - Boolean specifying if a texture is used in the material.
  53740. */
  53741. hasTexture(texture: BaseTexture): boolean;
  53742. /**
  53743. * Disposes the resources of the material.
  53744. * @param forceDisposeEffect - Forces the disposal of effects.
  53745. * @param forceDisposeTextures - Forces the disposal of all textures.
  53746. */
  53747. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53748. }
  53749. }
  53750. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53751. import { Nullable } from "babylonjs/types";
  53752. import { Scene } from "babylonjs/scene";
  53753. import { Color3 } from "babylonjs/Maths/math.color";
  53754. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53755. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53756. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53757. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53758. /**
  53759. * The Physically based material of BJS.
  53760. *
  53761. * This offers the main features of a standard PBR material.
  53762. * For more information, please refer to the documentation :
  53763. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53764. */
  53765. export class PBRMaterial extends PBRBaseMaterial {
  53766. /**
  53767. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53768. */
  53769. static readonly PBRMATERIAL_OPAQUE: number;
  53770. /**
  53771. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53772. */
  53773. static readonly PBRMATERIAL_ALPHATEST: number;
  53774. /**
  53775. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53776. */
  53777. static readonly PBRMATERIAL_ALPHABLEND: number;
  53778. /**
  53779. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53780. * They are also discarded below the alpha cutoff threshold to improve performances.
  53781. */
  53782. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53783. /**
  53784. * Defines the default value of how much AO map is occluding the analytical lights
  53785. * (point spot...).
  53786. */
  53787. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53788. /**
  53789. * Intensity of the direct lights e.g. the four lights available in your scene.
  53790. * This impacts both the direct diffuse and specular highlights.
  53791. */
  53792. directIntensity: number;
  53793. /**
  53794. * Intensity of the emissive part of the material.
  53795. * This helps controlling the emissive effect without modifying the emissive color.
  53796. */
  53797. emissiveIntensity: number;
  53798. /**
  53799. * Intensity of the environment e.g. how much the environment will light the object
  53800. * either through harmonics for rough material or through the refelction for shiny ones.
  53801. */
  53802. environmentIntensity: number;
  53803. /**
  53804. * This is a special control allowing the reduction of the specular highlights coming from the
  53805. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53806. */
  53807. specularIntensity: number;
  53808. /**
  53809. * Debug Control allowing disabling the bump map on this material.
  53810. */
  53811. disableBumpMap: boolean;
  53812. /**
  53813. * AKA Diffuse Texture in standard nomenclature.
  53814. */
  53815. albedoTexture: BaseTexture;
  53816. /**
  53817. * AKA Occlusion Texture in other nomenclature.
  53818. */
  53819. ambientTexture: BaseTexture;
  53820. /**
  53821. * AKA Occlusion Texture Intensity in other nomenclature.
  53822. */
  53823. ambientTextureStrength: number;
  53824. /**
  53825. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53826. * 1 means it completely occludes it
  53827. * 0 mean it has no impact
  53828. */
  53829. ambientTextureImpactOnAnalyticalLights: number;
  53830. /**
  53831. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53832. */
  53833. opacityTexture: BaseTexture;
  53834. /**
  53835. * Stores the reflection values in a texture.
  53836. */
  53837. reflectionTexture: Nullable<BaseTexture>;
  53838. /**
  53839. * Stores the emissive values in a texture.
  53840. */
  53841. emissiveTexture: BaseTexture;
  53842. /**
  53843. * AKA Specular texture in other nomenclature.
  53844. */
  53845. reflectivityTexture: BaseTexture;
  53846. /**
  53847. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53848. */
  53849. metallicTexture: BaseTexture;
  53850. /**
  53851. * Specifies the metallic scalar of the metallic/roughness workflow.
  53852. * Can also be used to scale the metalness values of the metallic texture.
  53853. */
  53854. metallic: Nullable<number>;
  53855. /**
  53856. * Specifies the roughness scalar of the metallic/roughness workflow.
  53857. * Can also be used to scale the roughness values of the metallic texture.
  53858. */
  53859. roughness: Nullable<number>;
  53860. /**
  53861. * Specifies the an F0 factor to help configuring the material F0.
  53862. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53863. * to 0.5 the previously hard coded value stays the same.
  53864. * Can also be used to scale the F0 values of the metallic texture.
  53865. */
  53866. metallicF0Factor: number;
  53867. /**
  53868. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53869. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53870. * your expectation as it multiplies with the texture data.
  53871. */
  53872. useMetallicF0FactorFromMetallicTexture: boolean;
  53873. /**
  53874. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53875. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53876. */
  53877. microSurfaceTexture: BaseTexture;
  53878. /**
  53879. * Stores surface normal data used to displace a mesh in a texture.
  53880. */
  53881. bumpTexture: BaseTexture;
  53882. /**
  53883. * Stores the pre-calculated light information of a mesh in a texture.
  53884. */
  53885. lightmapTexture: BaseTexture;
  53886. /**
  53887. * Stores the refracted light information in a texture.
  53888. */
  53889. get refractionTexture(): Nullable<BaseTexture>;
  53890. set refractionTexture(value: Nullable<BaseTexture>);
  53891. /**
  53892. * The color of a material in ambient lighting.
  53893. */
  53894. ambientColor: Color3;
  53895. /**
  53896. * AKA Diffuse Color in other nomenclature.
  53897. */
  53898. albedoColor: Color3;
  53899. /**
  53900. * AKA Specular Color in other nomenclature.
  53901. */
  53902. reflectivityColor: Color3;
  53903. /**
  53904. * The color reflected from the material.
  53905. */
  53906. reflectionColor: Color3;
  53907. /**
  53908. * The color emitted from the material.
  53909. */
  53910. emissiveColor: Color3;
  53911. /**
  53912. * AKA Glossiness in other nomenclature.
  53913. */
  53914. microSurface: number;
  53915. /**
  53916. * source material index of refraction (IOR)' / 'destination material IOR.
  53917. */
  53918. get indexOfRefraction(): number;
  53919. set indexOfRefraction(value: number);
  53920. /**
  53921. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53922. */
  53923. get invertRefractionY(): boolean;
  53924. set invertRefractionY(value: boolean);
  53925. /**
  53926. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53927. * Materials half opaque for instance using refraction could benefit from this control.
  53928. */
  53929. get linkRefractionWithTransparency(): boolean;
  53930. set linkRefractionWithTransparency(value: boolean);
  53931. /**
  53932. * If true, the light map contains occlusion information instead of lighting info.
  53933. */
  53934. useLightmapAsShadowmap: boolean;
  53935. /**
  53936. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53937. */
  53938. useAlphaFromAlbedoTexture: boolean;
  53939. /**
  53940. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53941. */
  53942. forceAlphaTest: boolean;
  53943. /**
  53944. * Defines the alpha limits in alpha test mode.
  53945. */
  53946. alphaCutOff: number;
  53947. /**
  53948. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53949. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53950. */
  53951. useSpecularOverAlpha: boolean;
  53952. /**
  53953. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53954. */
  53955. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53956. /**
  53957. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53958. */
  53959. useRoughnessFromMetallicTextureAlpha: boolean;
  53960. /**
  53961. * Specifies if the metallic texture contains the roughness information in its green channel.
  53962. */
  53963. useRoughnessFromMetallicTextureGreen: boolean;
  53964. /**
  53965. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53966. */
  53967. useMetallnessFromMetallicTextureBlue: boolean;
  53968. /**
  53969. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53970. */
  53971. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53972. /**
  53973. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53974. */
  53975. useAmbientInGrayScale: boolean;
  53976. /**
  53977. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53978. * The material will try to infer what glossiness each pixel should be.
  53979. */
  53980. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53981. /**
  53982. * BJS is using an harcoded light falloff based on a manually sets up range.
  53983. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53984. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53985. */
  53986. get usePhysicalLightFalloff(): boolean;
  53987. /**
  53988. * BJS is using an harcoded light falloff based on a manually sets up range.
  53989. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53990. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53991. */
  53992. set usePhysicalLightFalloff(value: boolean);
  53993. /**
  53994. * In order to support the falloff compatibility with gltf, a special mode has been added
  53995. * to reproduce the gltf light falloff.
  53996. */
  53997. get useGLTFLightFalloff(): boolean;
  53998. /**
  53999. * In order to support the falloff compatibility with gltf, a special mode has been added
  54000. * to reproduce the gltf light falloff.
  54001. */
  54002. set useGLTFLightFalloff(value: boolean);
  54003. /**
  54004. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54005. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54006. */
  54007. useRadianceOverAlpha: boolean;
  54008. /**
  54009. * Allows using an object space normal map (instead of tangent space).
  54010. */
  54011. useObjectSpaceNormalMap: boolean;
  54012. /**
  54013. * Allows using the bump map in parallax mode.
  54014. */
  54015. useParallax: boolean;
  54016. /**
  54017. * Allows using the bump map in parallax occlusion mode.
  54018. */
  54019. useParallaxOcclusion: boolean;
  54020. /**
  54021. * Controls the scale bias of the parallax mode.
  54022. */
  54023. parallaxScaleBias: number;
  54024. /**
  54025. * If sets to true, disables all the lights affecting the material.
  54026. */
  54027. disableLighting: boolean;
  54028. /**
  54029. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54030. */
  54031. forceIrradianceInFragment: boolean;
  54032. /**
  54033. * Number of Simultaneous lights allowed on the material.
  54034. */
  54035. maxSimultaneousLights: number;
  54036. /**
  54037. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54038. */
  54039. invertNormalMapX: boolean;
  54040. /**
  54041. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54042. */
  54043. invertNormalMapY: boolean;
  54044. /**
  54045. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54046. */
  54047. twoSidedLighting: boolean;
  54048. /**
  54049. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54050. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54051. */
  54052. useAlphaFresnel: boolean;
  54053. /**
  54054. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54055. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54056. */
  54057. useLinearAlphaFresnel: boolean;
  54058. /**
  54059. * Let user defines the brdf lookup texture used for IBL.
  54060. * A default 8bit version is embedded but you could point at :
  54061. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54062. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54063. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54064. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54065. */
  54066. environmentBRDFTexture: Nullable<BaseTexture>;
  54067. /**
  54068. * Force normal to face away from face.
  54069. */
  54070. forceNormalForward: boolean;
  54071. /**
  54072. * Enables specular anti aliasing in the PBR shader.
  54073. * It will both interacts on the Geometry for analytical and IBL lighting.
  54074. * It also prefilter the roughness map based on the bump values.
  54075. */
  54076. enableSpecularAntiAliasing: boolean;
  54077. /**
  54078. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54079. * makes the reflect vector face the model (under horizon).
  54080. */
  54081. useHorizonOcclusion: boolean;
  54082. /**
  54083. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54084. * too much the area relying on ambient texture to define their ambient occlusion.
  54085. */
  54086. useRadianceOcclusion: boolean;
  54087. /**
  54088. * If set to true, no lighting calculations will be applied.
  54089. */
  54090. unlit: boolean;
  54091. /**
  54092. * Gets the image processing configuration used either in this material.
  54093. */
  54094. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54095. /**
  54096. * Sets the Default image processing configuration used either in the this material.
  54097. *
  54098. * If sets to null, the scene one is in use.
  54099. */
  54100. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54101. /**
  54102. * Gets wether the color curves effect is enabled.
  54103. */
  54104. get cameraColorCurvesEnabled(): boolean;
  54105. /**
  54106. * Sets wether the color curves effect is enabled.
  54107. */
  54108. set cameraColorCurvesEnabled(value: boolean);
  54109. /**
  54110. * Gets wether the color grading effect is enabled.
  54111. */
  54112. get cameraColorGradingEnabled(): boolean;
  54113. /**
  54114. * Gets wether the color grading effect is enabled.
  54115. */
  54116. set cameraColorGradingEnabled(value: boolean);
  54117. /**
  54118. * Gets wether tonemapping is enabled or not.
  54119. */
  54120. get cameraToneMappingEnabled(): boolean;
  54121. /**
  54122. * Sets wether tonemapping is enabled or not
  54123. */
  54124. set cameraToneMappingEnabled(value: boolean);
  54125. /**
  54126. * The camera exposure used on this material.
  54127. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54128. * This corresponds to a photographic exposure.
  54129. */
  54130. get cameraExposure(): number;
  54131. /**
  54132. * The camera exposure used on this material.
  54133. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54134. * This corresponds to a photographic exposure.
  54135. */
  54136. set cameraExposure(value: number);
  54137. /**
  54138. * Gets The camera contrast used on this material.
  54139. */
  54140. get cameraContrast(): number;
  54141. /**
  54142. * Sets The camera contrast used on this material.
  54143. */
  54144. set cameraContrast(value: number);
  54145. /**
  54146. * Gets the Color Grading 2D Lookup Texture.
  54147. */
  54148. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54149. /**
  54150. * Sets the Color Grading 2D Lookup Texture.
  54151. */
  54152. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54153. /**
  54154. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54155. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54156. * 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;
  54157. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54158. */
  54159. get cameraColorCurves(): Nullable<ColorCurves>;
  54160. /**
  54161. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54162. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54163. * 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;
  54164. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54165. */
  54166. set cameraColorCurves(value: Nullable<ColorCurves>);
  54167. /**
  54168. * Instantiates a new PBRMaterial instance.
  54169. *
  54170. * @param name The material name
  54171. * @param scene The scene the material will be use in.
  54172. */
  54173. constructor(name: string, scene: Scene);
  54174. /**
  54175. * Returns the name of this material class.
  54176. */
  54177. getClassName(): string;
  54178. /**
  54179. * Makes a duplicate of the current material.
  54180. * @param name - name to use for the new material.
  54181. */
  54182. clone(name: string): PBRMaterial;
  54183. /**
  54184. * Serializes this PBR Material.
  54185. * @returns - An object with the serialized material.
  54186. */
  54187. serialize(): any;
  54188. /**
  54189. * Parses a PBR Material from a serialized object.
  54190. * @param source - Serialized object.
  54191. * @param scene - BJS scene instance.
  54192. * @param rootUrl - url for the scene object
  54193. * @returns - PBRMaterial
  54194. */
  54195. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54196. }
  54197. }
  54198. declare module "babylonjs/Misc/dds" {
  54199. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54200. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54201. import { Nullable } from "babylonjs/types";
  54202. import { Scene } from "babylonjs/scene";
  54203. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54204. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54205. /**
  54206. * Direct draw surface info
  54207. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54208. */
  54209. export interface DDSInfo {
  54210. /**
  54211. * Width of the texture
  54212. */
  54213. width: number;
  54214. /**
  54215. * Width of the texture
  54216. */
  54217. height: number;
  54218. /**
  54219. * Number of Mipmaps for the texture
  54220. * @see https://en.wikipedia.org/wiki/Mipmap
  54221. */
  54222. mipmapCount: number;
  54223. /**
  54224. * If the textures format is a known fourCC format
  54225. * @see https://www.fourcc.org/
  54226. */
  54227. isFourCC: boolean;
  54228. /**
  54229. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54230. */
  54231. isRGB: boolean;
  54232. /**
  54233. * If the texture is a lumincance format
  54234. */
  54235. isLuminance: boolean;
  54236. /**
  54237. * If this is a cube texture
  54238. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54239. */
  54240. isCube: boolean;
  54241. /**
  54242. * If the texture is a compressed format eg. FOURCC_DXT1
  54243. */
  54244. isCompressed: boolean;
  54245. /**
  54246. * The dxgiFormat of the texture
  54247. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54248. */
  54249. dxgiFormat: number;
  54250. /**
  54251. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54252. */
  54253. textureType: number;
  54254. /**
  54255. * Sphericle polynomial created for the dds texture
  54256. */
  54257. sphericalPolynomial?: SphericalPolynomial;
  54258. }
  54259. /**
  54260. * Class used to provide DDS decompression tools
  54261. */
  54262. export class DDSTools {
  54263. /**
  54264. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54265. */
  54266. static StoreLODInAlphaChannel: boolean;
  54267. /**
  54268. * Gets DDS information from an array buffer
  54269. * @param data defines the array buffer view to read data from
  54270. * @returns the DDS information
  54271. */
  54272. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54273. private static _FloatView;
  54274. private static _Int32View;
  54275. private static _ToHalfFloat;
  54276. private static _FromHalfFloat;
  54277. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54278. private static _GetHalfFloatRGBAArrayBuffer;
  54279. private static _GetFloatRGBAArrayBuffer;
  54280. private static _GetFloatAsUIntRGBAArrayBuffer;
  54281. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54282. private static _GetRGBAArrayBuffer;
  54283. private static _ExtractLongWordOrder;
  54284. private static _GetRGBArrayBuffer;
  54285. private static _GetLuminanceArrayBuffer;
  54286. /**
  54287. * Uploads DDS Levels to a Babylon Texture
  54288. * @hidden
  54289. */
  54290. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54291. }
  54292. module "babylonjs/Engines/thinEngine" {
  54293. interface ThinEngine {
  54294. /**
  54295. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54296. * @param rootUrl defines the url where the file to load is located
  54297. * @param scene defines the current scene
  54298. * @param lodScale defines scale to apply to the mip map selection
  54299. * @param lodOffset defines offset to apply to the mip map selection
  54300. * @param onLoad defines an optional callback raised when the texture is loaded
  54301. * @param onError defines an optional callback raised if there is an issue to load the texture
  54302. * @param format defines the format of the data
  54303. * @param forcedExtension defines the extension to use to pick the right loader
  54304. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54305. * @returns the cube texture as an InternalTexture
  54306. */
  54307. 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;
  54308. }
  54309. }
  54310. }
  54311. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54312. import { Nullable } from "babylonjs/types";
  54313. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54314. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54315. /**
  54316. * Implementation of the DDS Texture Loader.
  54317. * @hidden
  54318. */
  54319. export class _DDSTextureLoader implements IInternalTextureLoader {
  54320. /**
  54321. * Defines wether the loader supports cascade loading the different faces.
  54322. */
  54323. readonly supportCascades: boolean;
  54324. /**
  54325. * This returns if the loader support the current file information.
  54326. * @param extension defines the file extension of the file being loaded
  54327. * @returns true if the loader can load the specified file
  54328. */
  54329. canLoad(extension: string): boolean;
  54330. /**
  54331. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54332. * @param data contains the texture data
  54333. * @param texture defines the BabylonJS internal texture
  54334. * @param createPolynomials will be true if polynomials have been requested
  54335. * @param onLoad defines the callback to trigger once the texture is ready
  54336. * @param onError defines the callback to trigger in case of error
  54337. */
  54338. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54339. /**
  54340. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54341. * @param data contains the texture data
  54342. * @param texture defines the BabylonJS internal texture
  54343. * @param callback defines the method to call once ready to upload
  54344. */
  54345. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54346. }
  54347. }
  54348. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54349. import { Nullable } from "babylonjs/types";
  54350. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54351. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54352. /**
  54353. * Implementation of the ENV Texture Loader.
  54354. * @hidden
  54355. */
  54356. export class _ENVTextureLoader implements IInternalTextureLoader {
  54357. /**
  54358. * Defines wether the loader supports cascade loading the different faces.
  54359. */
  54360. readonly supportCascades: boolean;
  54361. /**
  54362. * This returns if the loader support the current file information.
  54363. * @param extension defines the file extension of the file being loaded
  54364. * @returns true if the loader can load the specified file
  54365. */
  54366. canLoad(extension: string): boolean;
  54367. /**
  54368. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54369. * @param data contains the texture data
  54370. * @param texture defines the BabylonJS internal texture
  54371. * @param createPolynomials will be true if polynomials have been requested
  54372. * @param onLoad defines the callback to trigger once the texture is ready
  54373. * @param onError defines the callback to trigger in case of error
  54374. */
  54375. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54376. /**
  54377. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54378. * @param data contains the texture data
  54379. * @param texture defines the BabylonJS internal texture
  54380. * @param callback defines the method to call once ready to upload
  54381. */
  54382. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54383. }
  54384. }
  54385. declare module "babylonjs/Misc/khronosTextureContainer" {
  54386. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54387. /**
  54388. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54389. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54390. */
  54391. export class KhronosTextureContainer {
  54392. /** contents of the KTX container file */
  54393. data: ArrayBufferView;
  54394. private static HEADER_LEN;
  54395. private static COMPRESSED_2D;
  54396. private static COMPRESSED_3D;
  54397. private static TEX_2D;
  54398. private static TEX_3D;
  54399. /**
  54400. * Gets the openGL type
  54401. */
  54402. glType: number;
  54403. /**
  54404. * Gets the openGL type size
  54405. */
  54406. glTypeSize: number;
  54407. /**
  54408. * Gets the openGL format
  54409. */
  54410. glFormat: number;
  54411. /**
  54412. * Gets the openGL internal format
  54413. */
  54414. glInternalFormat: number;
  54415. /**
  54416. * Gets the base internal format
  54417. */
  54418. glBaseInternalFormat: number;
  54419. /**
  54420. * Gets image width in pixel
  54421. */
  54422. pixelWidth: number;
  54423. /**
  54424. * Gets image height in pixel
  54425. */
  54426. pixelHeight: number;
  54427. /**
  54428. * Gets image depth in pixels
  54429. */
  54430. pixelDepth: number;
  54431. /**
  54432. * Gets the number of array elements
  54433. */
  54434. numberOfArrayElements: number;
  54435. /**
  54436. * Gets the number of faces
  54437. */
  54438. numberOfFaces: number;
  54439. /**
  54440. * Gets the number of mipmap levels
  54441. */
  54442. numberOfMipmapLevels: number;
  54443. /**
  54444. * Gets the bytes of key value data
  54445. */
  54446. bytesOfKeyValueData: number;
  54447. /**
  54448. * Gets the load type
  54449. */
  54450. loadType: number;
  54451. /**
  54452. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54453. */
  54454. isInvalid: boolean;
  54455. /**
  54456. * Creates a new KhronosTextureContainer
  54457. * @param data contents of the KTX container file
  54458. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54459. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54460. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54461. */
  54462. constructor(
  54463. /** contents of the KTX container file */
  54464. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54465. /**
  54466. * Uploads KTX content to a Babylon Texture.
  54467. * It is assumed that the texture has already been created & is currently bound
  54468. * @hidden
  54469. */
  54470. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54471. private _upload2DCompressedLevels;
  54472. /**
  54473. * Checks if the given data starts with a KTX file identifier.
  54474. * @param data the data to check
  54475. * @returns true if the data is a KTX file or false otherwise
  54476. */
  54477. static IsValid(data: ArrayBufferView): boolean;
  54478. }
  54479. }
  54480. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54481. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54482. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54483. /**
  54484. * Class for loading KTX2 files
  54485. * !!! Experimental Extension Subject to Changes !!!
  54486. * @hidden
  54487. */
  54488. export class KhronosTextureContainer2 {
  54489. private static _ModulePromise;
  54490. private static _TranscodeFormat;
  54491. constructor(engine: ThinEngine);
  54492. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  54493. private _determineTranscodeFormat;
  54494. /**
  54495. * Checks if the given data starts with a KTX2 file identifier.
  54496. * @param data the data to check
  54497. * @returns true if the data is a KTX2 file or false otherwise
  54498. */
  54499. static IsValid(data: ArrayBufferView): boolean;
  54500. }
  54501. }
  54502. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54503. import { Nullable } from "babylonjs/types";
  54504. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54505. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54506. /**
  54507. * Implementation of the KTX Texture Loader.
  54508. * @hidden
  54509. */
  54510. export class _KTXTextureLoader implements IInternalTextureLoader {
  54511. /**
  54512. * Defines wether the loader supports cascade loading the different faces.
  54513. */
  54514. readonly supportCascades: boolean;
  54515. /**
  54516. * This returns if the loader support the current file information.
  54517. * @param extension defines the file extension of the file being loaded
  54518. * @returns true if the loader can load the specified file
  54519. */
  54520. canLoad(extension: string): boolean;
  54521. /**
  54522. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54523. * @param data contains the texture data
  54524. * @param texture defines the BabylonJS internal texture
  54525. * @param createPolynomials will be true if polynomials have been requested
  54526. * @param onLoad defines the callback to trigger once the texture is ready
  54527. * @param onError defines the callback to trigger in case of error
  54528. */
  54529. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54530. /**
  54531. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54532. * @param data contains the texture data
  54533. * @param texture defines the BabylonJS internal texture
  54534. * @param callback defines the method to call once ready to upload
  54535. */
  54536. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54537. }
  54538. }
  54539. declare module "babylonjs/Helpers/sceneHelpers" {
  54540. import { Nullable } from "babylonjs/types";
  54541. import { Mesh } from "babylonjs/Meshes/mesh";
  54542. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54543. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54544. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54545. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54546. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54547. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54548. import "babylonjs/Meshes/Builders/boxBuilder";
  54549. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54550. /** @hidden */
  54551. export var _forceSceneHelpersToBundle: boolean;
  54552. module "babylonjs/scene" {
  54553. interface Scene {
  54554. /**
  54555. * Creates a default light for the scene.
  54556. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54557. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54558. */
  54559. createDefaultLight(replace?: boolean): void;
  54560. /**
  54561. * Creates a default camera for the scene.
  54562. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54563. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54564. * @param replace has default false, when true replaces the active camera in the scene
  54565. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54566. */
  54567. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54568. /**
  54569. * Creates a default camera and a default light.
  54570. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54571. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54572. * @param replace has the default false, when true replaces the active camera/light in the scene
  54573. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54574. */
  54575. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54576. /**
  54577. * Creates a new sky box
  54578. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54579. * @param environmentTexture defines the texture to use as environment texture
  54580. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54581. * @param scale defines the overall scale of the skybox
  54582. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54583. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54584. * @returns a new mesh holding the sky box
  54585. */
  54586. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54587. /**
  54588. * Creates a new environment
  54589. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54590. * @param options defines the options you can use to configure the environment
  54591. * @returns the new EnvironmentHelper
  54592. */
  54593. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54594. /**
  54595. * Creates a new VREXperienceHelper
  54596. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54597. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54598. * @returns a new VREXperienceHelper
  54599. */
  54600. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54601. /**
  54602. * Creates a new WebXRDefaultExperience
  54603. * @see http://doc.babylonjs.com/how_to/webxr
  54604. * @param options experience options
  54605. * @returns a promise for a new WebXRDefaultExperience
  54606. */
  54607. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54608. }
  54609. }
  54610. }
  54611. declare module "babylonjs/Helpers/videoDome" {
  54612. import { Scene } from "babylonjs/scene";
  54613. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54614. import { Mesh } from "babylonjs/Meshes/mesh";
  54615. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54616. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54617. import "babylonjs/Meshes/Builders/sphereBuilder";
  54618. /**
  54619. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54620. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54621. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54622. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54623. */
  54624. export class VideoDome extends TransformNode {
  54625. /**
  54626. * Define the video source as a Monoscopic panoramic 360 video.
  54627. */
  54628. static readonly MODE_MONOSCOPIC: number;
  54629. /**
  54630. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54631. */
  54632. static readonly MODE_TOPBOTTOM: number;
  54633. /**
  54634. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54635. */
  54636. static readonly MODE_SIDEBYSIDE: number;
  54637. private _halfDome;
  54638. private _useDirectMapping;
  54639. /**
  54640. * The video texture being displayed on the sphere
  54641. */
  54642. protected _videoTexture: VideoTexture;
  54643. /**
  54644. * Gets the video texture being displayed on the sphere
  54645. */
  54646. get videoTexture(): VideoTexture;
  54647. /**
  54648. * The skybox material
  54649. */
  54650. protected _material: BackgroundMaterial;
  54651. /**
  54652. * The surface used for the skybox
  54653. */
  54654. protected _mesh: Mesh;
  54655. /**
  54656. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54657. */
  54658. private _halfDomeMask;
  54659. /**
  54660. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54661. * Also see the options.resolution property.
  54662. */
  54663. get fovMultiplier(): number;
  54664. set fovMultiplier(value: number);
  54665. private _videoMode;
  54666. /**
  54667. * Gets or set the current video mode for the video. It can be:
  54668. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54669. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54670. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54671. */
  54672. get videoMode(): number;
  54673. set videoMode(value: number);
  54674. /**
  54675. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54676. *
  54677. */
  54678. get halfDome(): boolean;
  54679. /**
  54680. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54681. */
  54682. set halfDome(enabled: boolean);
  54683. /**
  54684. * Oberserver used in Stereoscopic VR Mode.
  54685. */
  54686. private _onBeforeCameraRenderObserver;
  54687. /**
  54688. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54689. * @param name Element's name, child elements will append suffixes for their own names.
  54690. * @param urlsOrVideo defines the url(s) or the video element to use
  54691. * @param options An object containing optional or exposed sub element properties
  54692. */
  54693. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54694. resolution?: number;
  54695. clickToPlay?: boolean;
  54696. autoPlay?: boolean;
  54697. loop?: boolean;
  54698. size?: number;
  54699. poster?: string;
  54700. faceForward?: boolean;
  54701. useDirectMapping?: boolean;
  54702. halfDomeMode?: boolean;
  54703. }, scene: Scene);
  54704. private _changeVideoMode;
  54705. /**
  54706. * Releases resources associated with this node.
  54707. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54708. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54709. */
  54710. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54711. }
  54712. }
  54713. declare module "babylonjs/Helpers/index" {
  54714. export * from "babylonjs/Helpers/environmentHelper";
  54715. export * from "babylonjs/Helpers/photoDome";
  54716. export * from "babylonjs/Helpers/sceneHelpers";
  54717. export * from "babylonjs/Helpers/videoDome";
  54718. }
  54719. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54720. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54721. import { IDisposable } from "babylonjs/scene";
  54722. import { Engine } from "babylonjs/Engines/engine";
  54723. /**
  54724. * This class can be used to get instrumentation data from a Babylon engine
  54725. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54726. */
  54727. export class EngineInstrumentation implements IDisposable {
  54728. /**
  54729. * Define the instrumented engine.
  54730. */
  54731. engine: Engine;
  54732. private _captureGPUFrameTime;
  54733. private _gpuFrameTimeToken;
  54734. private _gpuFrameTime;
  54735. private _captureShaderCompilationTime;
  54736. private _shaderCompilationTime;
  54737. private _onBeginFrameObserver;
  54738. private _onEndFrameObserver;
  54739. private _onBeforeShaderCompilationObserver;
  54740. private _onAfterShaderCompilationObserver;
  54741. /**
  54742. * Gets the perf counter used for GPU frame time
  54743. */
  54744. get gpuFrameTimeCounter(): PerfCounter;
  54745. /**
  54746. * Gets the GPU frame time capture status
  54747. */
  54748. get captureGPUFrameTime(): boolean;
  54749. /**
  54750. * Enable or disable the GPU frame time capture
  54751. */
  54752. set captureGPUFrameTime(value: boolean);
  54753. /**
  54754. * Gets the perf counter used for shader compilation time
  54755. */
  54756. get shaderCompilationTimeCounter(): PerfCounter;
  54757. /**
  54758. * Gets the shader compilation time capture status
  54759. */
  54760. get captureShaderCompilationTime(): boolean;
  54761. /**
  54762. * Enable or disable the shader compilation time capture
  54763. */
  54764. set captureShaderCompilationTime(value: boolean);
  54765. /**
  54766. * Instantiates a new engine instrumentation.
  54767. * This class can be used to get instrumentation data from a Babylon engine
  54768. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54769. * @param engine Defines the engine to instrument
  54770. */
  54771. constructor(
  54772. /**
  54773. * Define the instrumented engine.
  54774. */
  54775. engine: Engine);
  54776. /**
  54777. * Dispose and release associated resources.
  54778. */
  54779. dispose(): void;
  54780. }
  54781. }
  54782. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54783. import { Scene, IDisposable } from "babylonjs/scene";
  54784. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54785. /**
  54786. * This class can be used to get instrumentation data from a Babylon engine
  54787. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54788. */
  54789. export class SceneInstrumentation implements IDisposable {
  54790. /**
  54791. * Defines the scene to instrument
  54792. */
  54793. scene: Scene;
  54794. private _captureActiveMeshesEvaluationTime;
  54795. private _activeMeshesEvaluationTime;
  54796. private _captureRenderTargetsRenderTime;
  54797. private _renderTargetsRenderTime;
  54798. private _captureFrameTime;
  54799. private _frameTime;
  54800. private _captureRenderTime;
  54801. private _renderTime;
  54802. private _captureInterFrameTime;
  54803. private _interFrameTime;
  54804. private _captureParticlesRenderTime;
  54805. private _particlesRenderTime;
  54806. private _captureSpritesRenderTime;
  54807. private _spritesRenderTime;
  54808. private _capturePhysicsTime;
  54809. private _physicsTime;
  54810. private _captureAnimationsTime;
  54811. private _animationsTime;
  54812. private _captureCameraRenderTime;
  54813. private _cameraRenderTime;
  54814. private _onBeforeActiveMeshesEvaluationObserver;
  54815. private _onAfterActiveMeshesEvaluationObserver;
  54816. private _onBeforeRenderTargetsRenderObserver;
  54817. private _onAfterRenderTargetsRenderObserver;
  54818. private _onAfterRenderObserver;
  54819. private _onBeforeDrawPhaseObserver;
  54820. private _onAfterDrawPhaseObserver;
  54821. private _onBeforeAnimationsObserver;
  54822. private _onBeforeParticlesRenderingObserver;
  54823. private _onAfterParticlesRenderingObserver;
  54824. private _onBeforeSpritesRenderingObserver;
  54825. private _onAfterSpritesRenderingObserver;
  54826. private _onBeforePhysicsObserver;
  54827. private _onAfterPhysicsObserver;
  54828. private _onAfterAnimationsObserver;
  54829. private _onBeforeCameraRenderObserver;
  54830. private _onAfterCameraRenderObserver;
  54831. /**
  54832. * Gets the perf counter used for active meshes evaluation time
  54833. */
  54834. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54835. /**
  54836. * Gets the active meshes evaluation time capture status
  54837. */
  54838. get captureActiveMeshesEvaluationTime(): boolean;
  54839. /**
  54840. * Enable or disable the active meshes evaluation time capture
  54841. */
  54842. set captureActiveMeshesEvaluationTime(value: boolean);
  54843. /**
  54844. * Gets the perf counter used for render targets render time
  54845. */
  54846. get renderTargetsRenderTimeCounter(): PerfCounter;
  54847. /**
  54848. * Gets the render targets render time capture status
  54849. */
  54850. get captureRenderTargetsRenderTime(): boolean;
  54851. /**
  54852. * Enable or disable the render targets render time capture
  54853. */
  54854. set captureRenderTargetsRenderTime(value: boolean);
  54855. /**
  54856. * Gets the perf counter used for particles render time
  54857. */
  54858. get particlesRenderTimeCounter(): PerfCounter;
  54859. /**
  54860. * Gets the particles render time capture status
  54861. */
  54862. get captureParticlesRenderTime(): boolean;
  54863. /**
  54864. * Enable or disable the particles render time capture
  54865. */
  54866. set captureParticlesRenderTime(value: boolean);
  54867. /**
  54868. * Gets the perf counter used for sprites render time
  54869. */
  54870. get spritesRenderTimeCounter(): PerfCounter;
  54871. /**
  54872. * Gets the sprites render time capture status
  54873. */
  54874. get captureSpritesRenderTime(): boolean;
  54875. /**
  54876. * Enable or disable the sprites render time capture
  54877. */
  54878. set captureSpritesRenderTime(value: boolean);
  54879. /**
  54880. * Gets the perf counter used for physics time
  54881. */
  54882. get physicsTimeCounter(): PerfCounter;
  54883. /**
  54884. * Gets the physics time capture status
  54885. */
  54886. get capturePhysicsTime(): boolean;
  54887. /**
  54888. * Enable or disable the physics time capture
  54889. */
  54890. set capturePhysicsTime(value: boolean);
  54891. /**
  54892. * Gets the perf counter used for animations time
  54893. */
  54894. get animationsTimeCounter(): PerfCounter;
  54895. /**
  54896. * Gets the animations time capture status
  54897. */
  54898. get captureAnimationsTime(): boolean;
  54899. /**
  54900. * Enable or disable the animations time capture
  54901. */
  54902. set captureAnimationsTime(value: boolean);
  54903. /**
  54904. * Gets the perf counter used for frame time capture
  54905. */
  54906. get frameTimeCounter(): PerfCounter;
  54907. /**
  54908. * Gets the frame time capture status
  54909. */
  54910. get captureFrameTime(): boolean;
  54911. /**
  54912. * Enable or disable the frame time capture
  54913. */
  54914. set captureFrameTime(value: boolean);
  54915. /**
  54916. * Gets the perf counter used for inter-frames time capture
  54917. */
  54918. get interFrameTimeCounter(): PerfCounter;
  54919. /**
  54920. * Gets the inter-frames time capture status
  54921. */
  54922. get captureInterFrameTime(): boolean;
  54923. /**
  54924. * Enable or disable the inter-frames time capture
  54925. */
  54926. set captureInterFrameTime(value: boolean);
  54927. /**
  54928. * Gets the perf counter used for render time capture
  54929. */
  54930. get renderTimeCounter(): PerfCounter;
  54931. /**
  54932. * Gets the render time capture status
  54933. */
  54934. get captureRenderTime(): boolean;
  54935. /**
  54936. * Enable or disable the render time capture
  54937. */
  54938. set captureRenderTime(value: boolean);
  54939. /**
  54940. * Gets the perf counter used for camera render time capture
  54941. */
  54942. get cameraRenderTimeCounter(): PerfCounter;
  54943. /**
  54944. * Gets the camera render time capture status
  54945. */
  54946. get captureCameraRenderTime(): boolean;
  54947. /**
  54948. * Enable or disable the camera render time capture
  54949. */
  54950. set captureCameraRenderTime(value: boolean);
  54951. /**
  54952. * Gets the perf counter used for draw calls
  54953. */
  54954. get drawCallsCounter(): PerfCounter;
  54955. /**
  54956. * Instantiates a new scene instrumentation.
  54957. * This class can be used to get instrumentation data from a Babylon engine
  54958. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54959. * @param scene Defines the scene to instrument
  54960. */
  54961. constructor(
  54962. /**
  54963. * Defines the scene to instrument
  54964. */
  54965. scene: Scene);
  54966. /**
  54967. * Dispose and release associated resources.
  54968. */
  54969. dispose(): void;
  54970. }
  54971. }
  54972. declare module "babylonjs/Instrumentation/index" {
  54973. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54974. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54975. export * from "babylonjs/Instrumentation/timeToken";
  54976. }
  54977. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54978. /** @hidden */
  54979. export var glowMapGenerationPixelShader: {
  54980. name: string;
  54981. shader: string;
  54982. };
  54983. }
  54984. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54985. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54986. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54987. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54988. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54989. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54990. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54991. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54992. /** @hidden */
  54993. export var glowMapGenerationVertexShader: {
  54994. name: string;
  54995. shader: string;
  54996. };
  54997. }
  54998. declare module "babylonjs/Layers/effectLayer" {
  54999. import { Observable } from "babylonjs/Misc/observable";
  55000. import { Nullable } from "babylonjs/types";
  55001. import { Camera } from "babylonjs/Cameras/camera";
  55002. import { Scene } from "babylonjs/scene";
  55003. import { ISize } from "babylonjs/Maths/math.size";
  55004. import { Color4 } from "babylonjs/Maths/math.color";
  55005. import { Engine } from "babylonjs/Engines/engine";
  55006. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55008. import { Mesh } from "babylonjs/Meshes/mesh";
  55009. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55010. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55011. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55012. import { Effect } from "babylonjs/Materials/effect";
  55013. import { Material } from "babylonjs/Materials/material";
  55014. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55015. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55016. /**
  55017. * Effect layer options. This helps customizing the behaviour
  55018. * of the effect layer.
  55019. */
  55020. export interface IEffectLayerOptions {
  55021. /**
  55022. * Multiplication factor apply to the canvas size to compute the render target size
  55023. * used to generated the objects (the smaller the faster).
  55024. */
  55025. mainTextureRatio: number;
  55026. /**
  55027. * Enforces a fixed size texture to ensure effect stability across devices.
  55028. */
  55029. mainTextureFixedSize?: number;
  55030. /**
  55031. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55032. */
  55033. alphaBlendingMode: number;
  55034. /**
  55035. * The camera attached to the layer.
  55036. */
  55037. camera: Nullable<Camera>;
  55038. /**
  55039. * The rendering group to draw the layer in.
  55040. */
  55041. renderingGroupId: number;
  55042. }
  55043. /**
  55044. * The effect layer Helps adding post process effect blended with the main pass.
  55045. *
  55046. * This can be for instance use to generate glow or higlight effects on the scene.
  55047. *
  55048. * The effect layer class can not be used directly and is intented to inherited from to be
  55049. * customized per effects.
  55050. */
  55051. export abstract class EffectLayer {
  55052. private _vertexBuffers;
  55053. private _indexBuffer;
  55054. private _cachedDefines;
  55055. private _effectLayerMapGenerationEffect;
  55056. private _effectLayerOptions;
  55057. private _mergeEffect;
  55058. protected _scene: Scene;
  55059. protected _engine: Engine;
  55060. protected _maxSize: number;
  55061. protected _mainTextureDesiredSize: ISize;
  55062. protected _mainTexture: RenderTargetTexture;
  55063. protected _shouldRender: boolean;
  55064. protected _postProcesses: PostProcess[];
  55065. protected _textures: BaseTexture[];
  55066. protected _emissiveTextureAndColor: {
  55067. texture: Nullable<BaseTexture>;
  55068. color: Color4;
  55069. };
  55070. /**
  55071. * The name of the layer
  55072. */
  55073. name: string;
  55074. /**
  55075. * The clear color of the texture used to generate the glow map.
  55076. */
  55077. neutralColor: Color4;
  55078. /**
  55079. * Specifies whether the highlight layer is enabled or not.
  55080. */
  55081. isEnabled: boolean;
  55082. /**
  55083. * Gets the camera attached to the layer.
  55084. */
  55085. get camera(): Nullable<Camera>;
  55086. /**
  55087. * Gets the rendering group id the layer should render in.
  55088. */
  55089. get renderingGroupId(): number;
  55090. set renderingGroupId(renderingGroupId: number);
  55091. /**
  55092. * An event triggered when the effect layer has been disposed.
  55093. */
  55094. onDisposeObservable: Observable<EffectLayer>;
  55095. /**
  55096. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55097. */
  55098. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55099. /**
  55100. * An event triggered when the generated texture is being merged in the scene.
  55101. */
  55102. onBeforeComposeObservable: Observable<EffectLayer>;
  55103. /**
  55104. * An event triggered when the mesh is rendered into the effect render target.
  55105. */
  55106. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55107. /**
  55108. * An event triggered after the mesh has been rendered into the effect render target.
  55109. */
  55110. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55111. /**
  55112. * An event triggered when the generated texture has been merged in the scene.
  55113. */
  55114. onAfterComposeObservable: Observable<EffectLayer>;
  55115. /**
  55116. * An event triggered when the efffect layer changes its size.
  55117. */
  55118. onSizeChangedObservable: Observable<EffectLayer>;
  55119. /** @hidden */
  55120. static _SceneComponentInitialization: (scene: Scene) => void;
  55121. /**
  55122. * Instantiates a new effect Layer and references it in the scene.
  55123. * @param name The name of the layer
  55124. * @param scene The scene to use the layer in
  55125. */
  55126. constructor(
  55127. /** The Friendly of the effect in the scene */
  55128. name: string, scene: Scene);
  55129. /**
  55130. * Get the effect name of the layer.
  55131. * @return The effect name
  55132. */
  55133. abstract getEffectName(): string;
  55134. /**
  55135. * Checks for the readiness of the element composing the layer.
  55136. * @param subMesh the mesh to check for
  55137. * @param useInstances specify whether or not to use instances to render the mesh
  55138. * @return true if ready otherwise, false
  55139. */
  55140. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55141. /**
  55142. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55143. * @returns true if the effect requires stencil during the main canvas render pass.
  55144. */
  55145. abstract needStencil(): boolean;
  55146. /**
  55147. * Create the merge effect. This is the shader use to blit the information back
  55148. * to the main canvas at the end of the scene rendering.
  55149. * @returns The effect containing the shader used to merge the effect on the main canvas
  55150. */
  55151. protected abstract _createMergeEffect(): Effect;
  55152. /**
  55153. * Creates the render target textures and post processes used in the effect layer.
  55154. */
  55155. protected abstract _createTextureAndPostProcesses(): void;
  55156. /**
  55157. * Implementation specific of rendering the generating effect on the main canvas.
  55158. * @param effect The effect used to render through
  55159. */
  55160. protected abstract _internalRender(effect: Effect): void;
  55161. /**
  55162. * Sets the required values for both the emissive texture and and the main color.
  55163. */
  55164. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55165. /**
  55166. * Free any resources and references associated to a mesh.
  55167. * Internal use
  55168. * @param mesh The mesh to free.
  55169. */
  55170. abstract _disposeMesh(mesh: Mesh): void;
  55171. /**
  55172. * Serializes this layer (Glow or Highlight for example)
  55173. * @returns a serialized layer object
  55174. */
  55175. abstract serialize?(): any;
  55176. /**
  55177. * Initializes the effect layer with the required options.
  55178. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55179. */
  55180. protected _init(options: Partial<IEffectLayerOptions>): void;
  55181. /**
  55182. * Generates the index buffer of the full screen quad blending to the main canvas.
  55183. */
  55184. private _generateIndexBuffer;
  55185. /**
  55186. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55187. */
  55188. private _generateVertexBuffer;
  55189. /**
  55190. * Sets the main texture desired size which is the closest power of two
  55191. * of the engine canvas size.
  55192. */
  55193. private _setMainTextureSize;
  55194. /**
  55195. * Creates the main texture for the effect layer.
  55196. */
  55197. protected _createMainTexture(): void;
  55198. /**
  55199. * Adds specific effects defines.
  55200. * @param defines The defines to add specifics to.
  55201. */
  55202. protected _addCustomEffectDefines(defines: string[]): void;
  55203. /**
  55204. * Checks for the readiness of the element composing the layer.
  55205. * @param subMesh the mesh to check for
  55206. * @param useInstances specify whether or not to use instances to render the mesh
  55207. * @param emissiveTexture the associated emissive texture used to generate the glow
  55208. * @return true if ready otherwise, false
  55209. */
  55210. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55211. /**
  55212. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55213. */
  55214. render(): void;
  55215. /**
  55216. * Determine if a given mesh will be used in the current effect.
  55217. * @param mesh mesh to test
  55218. * @returns true if the mesh will be used
  55219. */
  55220. hasMesh(mesh: AbstractMesh): boolean;
  55221. /**
  55222. * Returns true if the layer contains information to display, otherwise false.
  55223. * @returns true if the glow layer should be rendered
  55224. */
  55225. shouldRender(): boolean;
  55226. /**
  55227. * Returns true if the mesh should render, otherwise false.
  55228. * @param mesh The mesh to render
  55229. * @returns true if it should render otherwise false
  55230. */
  55231. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55232. /**
  55233. * Returns true if the mesh can be rendered, otherwise false.
  55234. * @param mesh The mesh to render
  55235. * @param material The material used on the mesh
  55236. * @returns true if it can be rendered otherwise false
  55237. */
  55238. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55239. /**
  55240. * Returns true if the mesh should render, otherwise false.
  55241. * @param mesh The mesh to render
  55242. * @returns true if it should render otherwise false
  55243. */
  55244. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55245. /**
  55246. * Renders the submesh passed in parameter to the generation map.
  55247. */
  55248. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55249. /**
  55250. * Defines whether the current material of the mesh should be use to render the effect.
  55251. * @param mesh defines the current mesh to render
  55252. */
  55253. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55254. /**
  55255. * Rebuild the required buffers.
  55256. * @hidden Internal use only.
  55257. */
  55258. _rebuild(): void;
  55259. /**
  55260. * Dispose only the render target textures and post process.
  55261. */
  55262. private _disposeTextureAndPostProcesses;
  55263. /**
  55264. * Dispose the highlight layer and free resources.
  55265. */
  55266. dispose(): void;
  55267. /**
  55268. * Gets the class name of the effect layer
  55269. * @returns the string with the class name of the effect layer
  55270. */
  55271. getClassName(): string;
  55272. /**
  55273. * Creates an effect layer from parsed effect layer data
  55274. * @param parsedEffectLayer defines effect layer data
  55275. * @param scene defines the current scene
  55276. * @param rootUrl defines the root URL containing the effect layer information
  55277. * @returns a parsed effect Layer
  55278. */
  55279. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55280. }
  55281. }
  55282. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55283. import { Scene } from "babylonjs/scene";
  55284. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55285. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55286. import { AbstractScene } from "babylonjs/abstractScene";
  55287. module "babylonjs/abstractScene" {
  55288. interface AbstractScene {
  55289. /**
  55290. * The list of effect layers (highlights/glow) added to the scene
  55291. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55292. * @see http://doc.babylonjs.com/how_to/glow_layer
  55293. */
  55294. effectLayers: Array<EffectLayer>;
  55295. /**
  55296. * Removes the given effect layer from this scene.
  55297. * @param toRemove defines the effect layer to remove
  55298. * @returns the index of the removed effect layer
  55299. */
  55300. removeEffectLayer(toRemove: EffectLayer): number;
  55301. /**
  55302. * Adds the given effect layer to this scene
  55303. * @param newEffectLayer defines the effect layer to add
  55304. */
  55305. addEffectLayer(newEffectLayer: EffectLayer): void;
  55306. }
  55307. }
  55308. /**
  55309. * Defines the layer scene component responsible to manage any effect layers
  55310. * in a given scene.
  55311. */
  55312. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55313. /**
  55314. * The component name helpfull to identify the component in the list of scene components.
  55315. */
  55316. readonly name: string;
  55317. /**
  55318. * The scene the component belongs to.
  55319. */
  55320. scene: Scene;
  55321. private _engine;
  55322. private _renderEffects;
  55323. private _needStencil;
  55324. private _previousStencilState;
  55325. /**
  55326. * Creates a new instance of the component for the given scene
  55327. * @param scene Defines the scene to register the component in
  55328. */
  55329. constructor(scene: Scene);
  55330. /**
  55331. * Registers the component in a given scene
  55332. */
  55333. register(): void;
  55334. /**
  55335. * Rebuilds the elements related to this component in case of
  55336. * context lost for instance.
  55337. */
  55338. rebuild(): void;
  55339. /**
  55340. * Serializes the component data to the specified json object
  55341. * @param serializationObject The object to serialize to
  55342. */
  55343. serialize(serializationObject: any): void;
  55344. /**
  55345. * Adds all the elements from the container to the scene
  55346. * @param container the container holding the elements
  55347. */
  55348. addFromContainer(container: AbstractScene): void;
  55349. /**
  55350. * Removes all the elements in the container from the scene
  55351. * @param container contains the elements to remove
  55352. * @param dispose if the removed element should be disposed (default: false)
  55353. */
  55354. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55355. /**
  55356. * Disposes the component and the associated ressources.
  55357. */
  55358. dispose(): void;
  55359. private _isReadyForMesh;
  55360. private _renderMainTexture;
  55361. private _setStencil;
  55362. private _setStencilBack;
  55363. private _draw;
  55364. private _drawCamera;
  55365. private _drawRenderingGroup;
  55366. }
  55367. }
  55368. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55369. /** @hidden */
  55370. export var glowMapMergePixelShader: {
  55371. name: string;
  55372. shader: string;
  55373. };
  55374. }
  55375. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55376. /** @hidden */
  55377. export var glowMapMergeVertexShader: {
  55378. name: string;
  55379. shader: string;
  55380. };
  55381. }
  55382. declare module "babylonjs/Layers/glowLayer" {
  55383. import { Nullable } from "babylonjs/types";
  55384. import { Camera } from "babylonjs/Cameras/camera";
  55385. import { Scene } from "babylonjs/scene";
  55386. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55388. import { Mesh } from "babylonjs/Meshes/mesh";
  55389. import { Texture } from "babylonjs/Materials/Textures/texture";
  55390. import { Effect } from "babylonjs/Materials/effect";
  55391. import { Material } from "babylonjs/Materials/material";
  55392. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55393. import { Color4 } from "babylonjs/Maths/math.color";
  55394. import "babylonjs/Shaders/glowMapMerge.fragment";
  55395. import "babylonjs/Shaders/glowMapMerge.vertex";
  55396. import "babylonjs/Layers/effectLayerSceneComponent";
  55397. module "babylonjs/abstractScene" {
  55398. interface AbstractScene {
  55399. /**
  55400. * Return a the first highlight layer of the scene with a given name.
  55401. * @param name The name of the highlight layer to look for.
  55402. * @return The highlight layer if found otherwise null.
  55403. */
  55404. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55405. }
  55406. }
  55407. /**
  55408. * Glow layer options. This helps customizing the behaviour
  55409. * of the glow layer.
  55410. */
  55411. export interface IGlowLayerOptions {
  55412. /**
  55413. * Multiplication factor apply to the canvas size to compute the render target size
  55414. * used to generated the glowing objects (the smaller the faster).
  55415. */
  55416. mainTextureRatio: number;
  55417. /**
  55418. * Enforces a fixed size texture to ensure resize independant blur.
  55419. */
  55420. mainTextureFixedSize?: number;
  55421. /**
  55422. * How big is the kernel of the blur texture.
  55423. */
  55424. blurKernelSize: number;
  55425. /**
  55426. * The camera attached to the layer.
  55427. */
  55428. camera: Nullable<Camera>;
  55429. /**
  55430. * Enable MSAA by chosing the number of samples.
  55431. */
  55432. mainTextureSamples?: number;
  55433. /**
  55434. * The rendering group to draw the layer in.
  55435. */
  55436. renderingGroupId: number;
  55437. }
  55438. /**
  55439. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55440. *
  55441. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55442. *
  55443. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55444. */
  55445. export class GlowLayer extends EffectLayer {
  55446. /**
  55447. * Effect Name of the layer.
  55448. */
  55449. static readonly EffectName: string;
  55450. /**
  55451. * The default blur kernel size used for the glow.
  55452. */
  55453. static DefaultBlurKernelSize: number;
  55454. /**
  55455. * The default texture size ratio used for the glow.
  55456. */
  55457. static DefaultTextureRatio: number;
  55458. /**
  55459. * Sets the kernel size of the blur.
  55460. */
  55461. set blurKernelSize(value: number);
  55462. /**
  55463. * Gets the kernel size of the blur.
  55464. */
  55465. get blurKernelSize(): number;
  55466. /**
  55467. * Sets the glow intensity.
  55468. */
  55469. set intensity(value: number);
  55470. /**
  55471. * Gets the glow intensity.
  55472. */
  55473. get intensity(): number;
  55474. private _options;
  55475. private _intensity;
  55476. private _horizontalBlurPostprocess1;
  55477. private _verticalBlurPostprocess1;
  55478. private _horizontalBlurPostprocess2;
  55479. private _verticalBlurPostprocess2;
  55480. private _blurTexture1;
  55481. private _blurTexture2;
  55482. private _postProcesses1;
  55483. private _postProcesses2;
  55484. private _includedOnlyMeshes;
  55485. private _excludedMeshes;
  55486. private _meshesUsingTheirOwnMaterials;
  55487. /**
  55488. * Callback used to let the user override the color selection on a per mesh basis
  55489. */
  55490. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55491. /**
  55492. * Callback used to let the user override the texture selection on a per mesh basis
  55493. */
  55494. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55495. /**
  55496. * Instantiates a new glow Layer and references it to the scene.
  55497. * @param name The name of the layer
  55498. * @param scene The scene to use the layer in
  55499. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55500. */
  55501. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55502. /**
  55503. * Get the effect name of the layer.
  55504. * @return The effect name
  55505. */
  55506. getEffectName(): string;
  55507. /**
  55508. * Create the merge effect. This is the shader use to blit the information back
  55509. * to the main canvas at the end of the scene rendering.
  55510. */
  55511. protected _createMergeEffect(): Effect;
  55512. /**
  55513. * Creates the render target textures and post processes used in the glow layer.
  55514. */
  55515. protected _createTextureAndPostProcesses(): void;
  55516. /**
  55517. * Checks for the readiness of the element composing the layer.
  55518. * @param subMesh the mesh to check for
  55519. * @param useInstances specify wether or not to use instances to render the mesh
  55520. * @param emissiveTexture the associated emissive texture used to generate the glow
  55521. * @return true if ready otherwise, false
  55522. */
  55523. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55524. /**
  55525. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55526. */
  55527. needStencil(): boolean;
  55528. /**
  55529. * Returns true if the mesh can be rendered, otherwise false.
  55530. * @param mesh The mesh to render
  55531. * @param material The material used on the mesh
  55532. * @returns true if it can be rendered otherwise false
  55533. */
  55534. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55535. /**
  55536. * Implementation specific of rendering the generating effect on the main canvas.
  55537. * @param effect The effect used to render through
  55538. */
  55539. protected _internalRender(effect: Effect): void;
  55540. /**
  55541. * Sets the required values for both the emissive texture and and the main color.
  55542. */
  55543. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55544. /**
  55545. * Returns true if the mesh should render, otherwise false.
  55546. * @param mesh The mesh to render
  55547. * @returns true if it should render otherwise false
  55548. */
  55549. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55550. /**
  55551. * Adds specific effects defines.
  55552. * @param defines The defines to add specifics to.
  55553. */
  55554. protected _addCustomEffectDefines(defines: string[]): void;
  55555. /**
  55556. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55557. * @param mesh The mesh to exclude from the glow layer
  55558. */
  55559. addExcludedMesh(mesh: Mesh): void;
  55560. /**
  55561. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55562. * @param mesh The mesh to remove
  55563. */
  55564. removeExcludedMesh(mesh: Mesh): void;
  55565. /**
  55566. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55567. * @param mesh The mesh to include in the glow layer
  55568. */
  55569. addIncludedOnlyMesh(mesh: Mesh): void;
  55570. /**
  55571. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55572. * @param mesh The mesh to remove
  55573. */
  55574. removeIncludedOnlyMesh(mesh: Mesh): void;
  55575. /**
  55576. * Determine if a given mesh will be used in the glow layer
  55577. * @param mesh The mesh to test
  55578. * @returns true if the mesh will be highlighted by the current glow layer
  55579. */
  55580. hasMesh(mesh: AbstractMesh): boolean;
  55581. /**
  55582. * Defines whether the current material of the mesh should be use to render the effect.
  55583. * @param mesh defines the current mesh to render
  55584. */
  55585. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55586. /**
  55587. * Add a mesh to be rendered through its own material and not with emissive only.
  55588. * @param mesh The mesh for which we need to use its material
  55589. */
  55590. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55591. /**
  55592. * Remove a mesh from being rendered through its own material and not with emissive only.
  55593. * @param mesh The mesh for which we need to not use its material
  55594. */
  55595. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55596. /**
  55597. * Free any resources and references associated to a mesh.
  55598. * Internal use
  55599. * @param mesh The mesh to free.
  55600. * @hidden
  55601. */
  55602. _disposeMesh(mesh: Mesh): void;
  55603. /**
  55604. * Gets the class name of the effect layer
  55605. * @returns the string with the class name of the effect layer
  55606. */
  55607. getClassName(): string;
  55608. /**
  55609. * Serializes this glow layer
  55610. * @returns a serialized glow layer object
  55611. */
  55612. serialize(): any;
  55613. /**
  55614. * Creates a Glow Layer from parsed glow layer data
  55615. * @param parsedGlowLayer defines glow layer data
  55616. * @param scene defines the current scene
  55617. * @param rootUrl defines the root URL containing the glow layer information
  55618. * @returns a parsed Glow Layer
  55619. */
  55620. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55621. }
  55622. }
  55623. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55624. /** @hidden */
  55625. export var glowBlurPostProcessPixelShader: {
  55626. name: string;
  55627. shader: string;
  55628. };
  55629. }
  55630. declare module "babylonjs/Layers/highlightLayer" {
  55631. import { Observable } from "babylonjs/Misc/observable";
  55632. import { Nullable } from "babylonjs/types";
  55633. import { Camera } from "babylonjs/Cameras/camera";
  55634. import { Scene } from "babylonjs/scene";
  55635. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55637. import { Mesh } from "babylonjs/Meshes/mesh";
  55638. import { Effect } from "babylonjs/Materials/effect";
  55639. import { Material } from "babylonjs/Materials/material";
  55640. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55641. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55642. import "babylonjs/Shaders/glowMapMerge.fragment";
  55643. import "babylonjs/Shaders/glowMapMerge.vertex";
  55644. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55645. module "babylonjs/abstractScene" {
  55646. interface AbstractScene {
  55647. /**
  55648. * Return a the first highlight layer of the scene with a given name.
  55649. * @param name The name of the highlight layer to look for.
  55650. * @return The highlight layer if found otherwise null.
  55651. */
  55652. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55653. }
  55654. }
  55655. /**
  55656. * Highlight layer options. This helps customizing the behaviour
  55657. * of the highlight layer.
  55658. */
  55659. export interface IHighlightLayerOptions {
  55660. /**
  55661. * Multiplication factor apply to the canvas size to compute the render target size
  55662. * used to generated the glowing objects (the smaller the faster).
  55663. */
  55664. mainTextureRatio: number;
  55665. /**
  55666. * Enforces a fixed size texture to ensure resize independant blur.
  55667. */
  55668. mainTextureFixedSize?: number;
  55669. /**
  55670. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55671. * of the picture to blur (the smaller the faster).
  55672. */
  55673. blurTextureSizeRatio: number;
  55674. /**
  55675. * How big in texel of the blur texture is the vertical blur.
  55676. */
  55677. blurVerticalSize: number;
  55678. /**
  55679. * How big in texel of the blur texture is the horizontal blur.
  55680. */
  55681. blurHorizontalSize: number;
  55682. /**
  55683. * Alpha blending mode used to apply the blur. Default is combine.
  55684. */
  55685. alphaBlendingMode: number;
  55686. /**
  55687. * The camera attached to the layer.
  55688. */
  55689. camera: Nullable<Camera>;
  55690. /**
  55691. * Should we display highlight as a solid stroke?
  55692. */
  55693. isStroke?: boolean;
  55694. /**
  55695. * The rendering group to draw the layer in.
  55696. */
  55697. renderingGroupId: number;
  55698. }
  55699. /**
  55700. * The highlight layer Helps adding a glow effect around a mesh.
  55701. *
  55702. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55703. * glowy meshes to your scene.
  55704. *
  55705. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55706. */
  55707. export class HighlightLayer extends EffectLayer {
  55708. name: string;
  55709. /**
  55710. * Effect Name of the highlight layer.
  55711. */
  55712. static readonly EffectName: string;
  55713. /**
  55714. * The neutral color used during the preparation of the glow effect.
  55715. * This is black by default as the blend operation is a blend operation.
  55716. */
  55717. static NeutralColor: Color4;
  55718. /**
  55719. * Stencil value used for glowing meshes.
  55720. */
  55721. static GlowingMeshStencilReference: number;
  55722. /**
  55723. * Stencil value used for the other meshes in the scene.
  55724. */
  55725. static NormalMeshStencilReference: number;
  55726. /**
  55727. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55728. */
  55729. innerGlow: boolean;
  55730. /**
  55731. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55732. */
  55733. outerGlow: boolean;
  55734. /**
  55735. * Specifies the horizontal size of the blur.
  55736. */
  55737. set blurHorizontalSize(value: number);
  55738. /**
  55739. * Specifies the vertical size of the blur.
  55740. */
  55741. set blurVerticalSize(value: number);
  55742. /**
  55743. * Gets the horizontal size of the blur.
  55744. */
  55745. get blurHorizontalSize(): number;
  55746. /**
  55747. * Gets the vertical size of the blur.
  55748. */
  55749. get blurVerticalSize(): number;
  55750. /**
  55751. * An event triggered when the highlight layer is being blurred.
  55752. */
  55753. onBeforeBlurObservable: Observable<HighlightLayer>;
  55754. /**
  55755. * An event triggered when the highlight layer has been blurred.
  55756. */
  55757. onAfterBlurObservable: Observable<HighlightLayer>;
  55758. private _instanceGlowingMeshStencilReference;
  55759. private _options;
  55760. private _downSamplePostprocess;
  55761. private _horizontalBlurPostprocess;
  55762. private _verticalBlurPostprocess;
  55763. private _blurTexture;
  55764. private _meshes;
  55765. private _excludedMeshes;
  55766. /**
  55767. * Instantiates a new highlight Layer and references it to the scene..
  55768. * @param name The name of the layer
  55769. * @param scene The scene to use the layer in
  55770. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55771. */
  55772. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55773. /**
  55774. * Get the effect name of the layer.
  55775. * @return The effect name
  55776. */
  55777. getEffectName(): string;
  55778. /**
  55779. * Create the merge effect. This is the shader use to blit the information back
  55780. * to the main canvas at the end of the scene rendering.
  55781. */
  55782. protected _createMergeEffect(): Effect;
  55783. /**
  55784. * Creates the render target textures and post processes used in the highlight layer.
  55785. */
  55786. protected _createTextureAndPostProcesses(): void;
  55787. /**
  55788. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55789. */
  55790. needStencil(): boolean;
  55791. /**
  55792. * Checks for the readiness of the element composing the layer.
  55793. * @param subMesh the mesh to check for
  55794. * @param useInstances specify wether or not to use instances to render the mesh
  55795. * @param emissiveTexture the associated emissive texture used to generate the glow
  55796. * @return true if ready otherwise, false
  55797. */
  55798. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55799. /**
  55800. * Implementation specific of rendering the generating effect on the main canvas.
  55801. * @param effect The effect used to render through
  55802. */
  55803. protected _internalRender(effect: Effect): void;
  55804. /**
  55805. * Returns true if the layer contains information to display, otherwise false.
  55806. */
  55807. shouldRender(): boolean;
  55808. /**
  55809. * Returns true if the mesh should render, otherwise false.
  55810. * @param mesh The mesh to render
  55811. * @returns true if it should render otherwise false
  55812. */
  55813. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55814. /**
  55815. * Sets the required values for both the emissive texture and and the main color.
  55816. */
  55817. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55818. /**
  55819. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55820. * @param mesh The mesh to exclude from the highlight layer
  55821. */
  55822. addExcludedMesh(mesh: Mesh): void;
  55823. /**
  55824. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55825. * @param mesh The mesh to highlight
  55826. */
  55827. removeExcludedMesh(mesh: Mesh): void;
  55828. /**
  55829. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55830. * @param mesh mesh to test
  55831. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55832. */
  55833. hasMesh(mesh: AbstractMesh): boolean;
  55834. /**
  55835. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55836. * @param mesh The mesh to highlight
  55837. * @param color The color of the highlight
  55838. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55839. */
  55840. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55841. /**
  55842. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55843. * @param mesh The mesh to highlight
  55844. */
  55845. removeMesh(mesh: Mesh): void;
  55846. /**
  55847. * Remove all the meshes currently referenced in the highlight layer
  55848. */
  55849. removeAllMeshes(): void;
  55850. /**
  55851. * Force the stencil to the normal expected value for none glowing parts
  55852. */
  55853. private _defaultStencilReference;
  55854. /**
  55855. * Free any resources and references associated to a mesh.
  55856. * Internal use
  55857. * @param mesh The mesh to free.
  55858. * @hidden
  55859. */
  55860. _disposeMesh(mesh: Mesh): void;
  55861. /**
  55862. * Dispose the highlight layer and free resources.
  55863. */
  55864. dispose(): void;
  55865. /**
  55866. * Gets the class name of the effect layer
  55867. * @returns the string with the class name of the effect layer
  55868. */
  55869. getClassName(): string;
  55870. /**
  55871. * Serializes this Highlight layer
  55872. * @returns a serialized Highlight layer object
  55873. */
  55874. serialize(): any;
  55875. /**
  55876. * Creates a Highlight layer from parsed Highlight layer data
  55877. * @param parsedHightlightLayer defines the Highlight layer data
  55878. * @param scene defines the current scene
  55879. * @param rootUrl defines the root URL containing the Highlight layer information
  55880. * @returns a parsed Highlight layer
  55881. */
  55882. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55883. }
  55884. }
  55885. declare module "babylonjs/Layers/layerSceneComponent" {
  55886. import { Scene } from "babylonjs/scene";
  55887. import { ISceneComponent } from "babylonjs/sceneComponent";
  55888. import { Layer } from "babylonjs/Layers/layer";
  55889. import { AbstractScene } from "babylonjs/abstractScene";
  55890. module "babylonjs/abstractScene" {
  55891. interface AbstractScene {
  55892. /**
  55893. * The list of layers (background and foreground) of the scene
  55894. */
  55895. layers: Array<Layer>;
  55896. }
  55897. }
  55898. /**
  55899. * Defines the layer scene component responsible to manage any layers
  55900. * in a given scene.
  55901. */
  55902. export class LayerSceneComponent implements ISceneComponent {
  55903. /**
  55904. * The component name helpfull to identify the component in the list of scene components.
  55905. */
  55906. readonly name: string;
  55907. /**
  55908. * The scene the component belongs to.
  55909. */
  55910. scene: Scene;
  55911. private _engine;
  55912. /**
  55913. * Creates a new instance of the component for the given scene
  55914. * @param scene Defines the scene to register the component in
  55915. */
  55916. constructor(scene: Scene);
  55917. /**
  55918. * Registers the component in a given scene
  55919. */
  55920. register(): void;
  55921. /**
  55922. * Rebuilds the elements related to this component in case of
  55923. * context lost for instance.
  55924. */
  55925. rebuild(): void;
  55926. /**
  55927. * Disposes the component and the associated ressources.
  55928. */
  55929. dispose(): void;
  55930. private _draw;
  55931. private _drawCameraPredicate;
  55932. private _drawCameraBackground;
  55933. private _drawCameraForeground;
  55934. private _drawRenderTargetPredicate;
  55935. private _drawRenderTargetBackground;
  55936. private _drawRenderTargetForeground;
  55937. /**
  55938. * Adds all the elements from the container to the scene
  55939. * @param container the container holding the elements
  55940. */
  55941. addFromContainer(container: AbstractScene): void;
  55942. /**
  55943. * Removes all the elements in the container from the scene
  55944. * @param container contains the elements to remove
  55945. * @param dispose if the removed element should be disposed (default: false)
  55946. */
  55947. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55948. }
  55949. }
  55950. declare module "babylonjs/Shaders/layer.fragment" {
  55951. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55952. /** @hidden */
  55953. export var layerPixelShader: {
  55954. name: string;
  55955. shader: string;
  55956. };
  55957. }
  55958. declare module "babylonjs/Shaders/layer.vertex" {
  55959. /** @hidden */
  55960. export var layerVertexShader: {
  55961. name: string;
  55962. shader: string;
  55963. };
  55964. }
  55965. declare module "babylonjs/Layers/layer" {
  55966. import { Observable } from "babylonjs/Misc/observable";
  55967. import { Nullable } from "babylonjs/types";
  55968. import { Scene } from "babylonjs/scene";
  55969. import { Vector2 } from "babylonjs/Maths/math.vector";
  55970. import { Color4 } from "babylonjs/Maths/math.color";
  55971. import { Texture } from "babylonjs/Materials/Textures/texture";
  55972. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55973. import "babylonjs/Shaders/layer.fragment";
  55974. import "babylonjs/Shaders/layer.vertex";
  55975. /**
  55976. * This represents a full screen 2d layer.
  55977. * This can be useful to display a picture in the background of your scene for instance.
  55978. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55979. */
  55980. export class Layer {
  55981. /**
  55982. * Define the name of the layer.
  55983. */
  55984. name: string;
  55985. /**
  55986. * Define the texture the layer should display.
  55987. */
  55988. texture: Nullable<Texture>;
  55989. /**
  55990. * Is the layer in background or foreground.
  55991. */
  55992. isBackground: boolean;
  55993. /**
  55994. * Define the color of the layer (instead of texture).
  55995. */
  55996. color: Color4;
  55997. /**
  55998. * Define the scale of the layer in order to zoom in out of the texture.
  55999. */
  56000. scale: Vector2;
  56001. /**
  56002. * Define an offset for the layer in order to shift the texture.
  56003. */
  56004. offset: Vector2;
  56005. /**
  56006. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56007. */
  56008. alphaBlendingMode: number;
  56009. /**
  56010. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56011. * Alpha test will not mix with the background color in case of transparency.
  56012. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56013. */
  56014. alphaTest: boolean;
  56015. /**
  56016. * Define a mask to restrict the layer to only some of the scene cameras.
  56017. */
  56018. layerMask: number;
  56019. /**
  56020. * Define the list of render target the layer is visible into.
  56021. */
  56022. renderTargetTextures: RenderTargetTexture[];
  56023. /**
  56024. * Define if the layer is only used in renderTarget or if it also
  56025. * renders in the main frame buffer of the canvas.
  56026. */
  56027. renderOnlyInRenderTargetTextures: boolean;
  56028. private _scene;
  56029. private _vertexBuffers;
  56030. private _indexBuffer;
  56031. private _effect;
  56032. private _previousDefines;
  56033. /**
  56034. * An event triggered when the layer is disposed.
  56035. */
  56036. onDisposeObservable: Observable<Layer>;
  56037. private _onDisposeObserver;
  56038. /**
  56039. * Back compatibility with callback before the onDisposeObservable existed.
  56040. * The set callback will be triggered when the layer has been disposed.
  56041. */
  56042. set onDispose(callback: () => void);
  56043. /**
  56044. * An event triggered before rendering the scene
  56045. */
  56046. onBeforeRenderObservable: Observable<Layer>;
  56047. private _onBeforeRenderObserver;
  56048. /**
  56049. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56050. * The set callback will be triggered just before rendering the layer.
  56051. */
  56052. set onBeforeRender(callback: () => void);
  56053. /**
  56054. * An event triggered after rendering the scene
  56055. */
  56056. onAfterRenderObservable: Observable<Layer>;
  56057. private _onAfterRenderObserver;
  56058. /**
  56059. * Back compatibility with callback before the onAfterRenderObservable existed.
  56060. * The set callback will be triggered just after rendering the layer.
  56061. */
  56062. set onAfterRender(callback: () => void);
  56063. /**
  56064. * Instantiates a new layer.
  56065. * This represents a full screen 2d layer.
  56066. * This can be useful to display a picture in the background of your scene for instance.
  56067. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56068. * @param name Define the name of the layer in the scene
  56069. * @param imgUrl Define the url of the texture to display in the layer
  56070. * @param scene Define the scene the layer belongs to
  56071. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56072. * @param color Defines a color for the layer
  56073. */
  56074. constructor(
  56075. /**
  56076. * Define the name of the layer.
  56077. */
  56078. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56079. private _createIndexBuffer;
  56080. /** @hidden */
  56081. _rebuild(): void;
  56082. /**
  56083. * Renders the layer in the scene.
  56084. */
  56085. render(): void;
  56086. /**
  56087. * Disposes and releases the associated ressources.
  56088. */
  56089. dispose(): void;
  56090. }
  56091. }
  56092. declare module "babylonjs/Layers/index" {
  56093. export * from "babylonjs/Layers/effectLayer";
  56094. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56095. export * from "babylonjs/Layers/glowLayer";
  56096. export * from "babylonjs/Layers/highlightLayer";
  56097. export * from "babylonjs/Layers/layer";
  56098. export * from "babylonjs/Layers/layerSceneComponent";
  56099. }
  56100. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56101. /** @hidden */
  56102. export var lensFlarePixelShader: {
  56103. name: string;
  56104. shader: string;
  56105. };
  56106. }
  56107. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56108. /** @hidden */
  56109. export var lensFlareVertexShader: {
  56110. name: string;
  56111. shader: string;
  56112. };
  56113. }
  56114. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56115. import { Scene } from "babylonjs/scene";
  56116. import { Vector3 } from "babylonjs/Maths/math.vector";
  56117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56118. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56119. import "babylonjs/Shaders/lensFlare.fragment";
  56120. import "babylonjs/Shaders/lensFlare.vertex";
  56121. import { Viewport } from "babylonjs/Maths/math.viewport";
  56122. /**
  56123. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56124. * It is usually composed of several `lensFlare`.
  56125. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56126. */
  56127. export class LensFlareSystem {
  56128. /**
  56129. * Define the name of the lens flare system
  56130. */
  56131. name: string;
  56132. /**
  56133. * List of lens flares used in this system.
  56134. */
  56135. lensFlares: LensFlare[];
  56136. /**
  56137. * Define a limit from the border the lens flare can be visible.
  56138. */
  56139. borderLimit: number;
  56140. /**
  56141. * Define a viewport border we do not want to see the lens flare in.
  56142. */
  56143. viewportBorder: number;
  56144. /**
  56145. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56146. */
  56147. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56148. /**
  56149. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56150. */
  56151. layerMask: number;
  56152. /**
  56153. * Define the id of the lens flare system in the scene.
  56154. * (equal to name by default)
  56155. */
  56156. id: string;
  56157. private _scene;
  56158. private _emitter;
  56159. private _vertexBuffers;
  56160. private _indexBuffer;
  56161. private _effect;
  56162. private _positionX;
  56163. private _positionY;
  56164. private _isEnabled;
  56165. /** @hidden */
  56166. static _SceneComponentInitialization: (scene: Scene) => void;
  56167. /**
  56168. * Instantiates a lens flare system.
  56169. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56170. * It is usually composed of several `lensFlare`.
  56171. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56172. * @param name Define the name of the lens flare system in the scene
  56173. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56174. * @param scene Define the scene the lens flare system belongs to
  56175. */
  56176. constructor(
  56177. /**
  56178. * Define the name of the lens flare system
  56179. */
  56180. name: string, emitter: any, scene: Scene);
  56181. /**
  56182. * Define if the lens flare system is enabled.
  56183. */
  56184. get isEnabled(): boolean;
  56185. set isEnabled(value: boolean);
  56186. /**
  56187. * Get the scene the effects belongs to.
  56188. * @returns the scene holding the lens flare system
  56189. */
  56190. getScene(): Scene;
  56191. /**
  56192. * Get the emitter of the lens flare system.
  56193. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56194. * @returns the emitter of the lens flare system
  56195. */
  56196. getEmitter(): any;
  56197. /**
  56198. * Set the emitter of the lens flare system.
  56199. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56200. * @param newEmitter Define the new emitter of the system
  56201. */
  56202. setEmitter(newEmitter: any): void;
  56203. /**
  56204. * Get the lens flare system emitter position.
  56205. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56206. * @returns the position
  56207. */
  56208. getEmitterPosition(): Vector3;
  56209. /**
  56210. * @hidden
  56211. */
  56212. computeEffectivePosition(globalViewport: Viewport): boolean;
  56213. /** @hidden */
  56214. _isVisible(): boolean;
  56215. /**
  56216. * @hidden
  56217. */
  56218. render(): boolean;
  56219. /**
  56220. * Dispose and release the lens flare with its associated resources.
  56221. */
  56222. dispose(): void;
  56223. /**
  56224. * Parse a lens flare system from a JSON repressentation
  56225. * @param parsedLensFlareSystem Define the JSON to parse
  56226. * @param scene Define the scene the parsed system should be instantiated in
  56227. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56228. * @returns the parsed system
  56229. */
  56230. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56231. /**
  56232. * Serialize the current Lens Flare System into a JSON representation.
  56233. * @returns the serialized JSON
  56234. */
  56235. serialize(): any;
  56236. }
  56237. }
  56238. declare module "babylonjs/LensFlares/lensFlare" {
  56239. import { Nullable } from "babylonjs/types";
  56240. import { Color3 } from "babylonjs/Maths/math.color";
  56241. import { Texture } from "babylonjs/Materials/Textures/texture";
  56242. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56243. /**
  56244. * This represents one of the lens effect in a `lensFlareSystem`.
  56245. * It controls one of the indiviual texture used in the effect.
  56246. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56247. */
  56248. export class LensFlare {
  56249. /**
  56250. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56251. */
  56252. size: number;
  56253. /**
  56254. * 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.
  56255. */
  56256. position: number;
  56257. /**
  56258. * Define the lens color.
  56259. */
  56260. color: Color3;
  56261. /**
  56262. * Define the lens texture.
  56263. */
  56264. texture: Nullable<Texture>;
  56265. /**
  56266. * Define the alpha mode to render this particular lens.
  56267. */
  56268. alphaMode: number;
  56269. private _system;
  56270. /**
  56271. * Creates a new Lens Flare.
  56272. * This represents one of the lens effect in a `lensFlareSystem`.
  56273. * It controls one of the indiviual texture used in the effect.
  56274. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56275. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56276. * @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.
  56277. * @param color Define the lens color
  56278. * @param imgUrl Define the lens texture url
  56279. * @param system Define the `lensFlareSystem` this flare is part of
  56280. * @returns The newly created Lens Flare
  56281. */
  56282. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56283. /**
  56284. * Instantiates a new Lens Flare.
  56285. * This represents one of the lens effect in a `lensFlareSystem`.
  56286. * It controls one of the indiviual texture used in the effect.
  56287. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56288. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56289. * @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.
  56290. * @param color Define the lens color
  56291. * @param imgUrl Define the lens texture url
  56292. * @param system Define the `lensFlareSystem` this flare is part of
  56293. */
  56294. constructor(
  56295. /**
  56296. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56297. */
  56298. size: number,
  56299. /**
  56300. * 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.
  56301. */
  56302. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56303. /**
  56304. * Dispose and release the lens flare with its associated resources.
  56305. */
  56306. dispose(): void;
  56307. }
  56308. }
  56309. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56310. import { Nullable } from "babylonjs/types";
  56311. import { Scene } from "babylonjs/scene";
  56312. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56313. import { AbstractScene } from "babylonjs/abstractScene";
  56314. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56315. module "babylonjs/abstractScene" {
  56316. interface AbstractScene {
  56317. /**
  56318. * The list of lens flare system added to the scene
  56319. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56320. */
  56321. lensFlareSystems: Array<LensFlareSystem>;
  56322. /**
  56323. * Removes the given lens flare system from this scene.
  56324. * @param toRemove The lens flare system to remove
  56325. * @returns The index of the removed lens flare system
  56326. */
  56327. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56328. /**
  56329. * Adds the given lens flare system to this scene
  56330. * @param newLensFlareSystem The lens flare system to add
  56331. */
  56332. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56333. /**
  56334. * Gets a lens flare system using its name
  56335. * @param name defines the name to look for
  56336. * @returns the lens flare system or null if not found
  56337. */
  56338. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56339. /**
  56340. * Gets a lens flare system using its id
  56341. * @param id defines the id to look for
  56342. * @returns the lens flare system or null if not found
  56343. */
  56344. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56345. }
  56346. }
  56347. /**
  56348. * Defines the lens flare scene component responsible to manage any lens flares
  56349. * in a given scene.
  56350. */
  56351. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56352. /**
  56353. * The component name helpfull to identify the component in the list of scene components.
  56354. */
  56355. readonly name: string;
  56356. /**
  56357. * The scene the component belongs to.
  56358. */
  56359. scene: Scene;
  56360. /**
  56361. * Creates a new instance of the component for the given scene
  56362. * @param scene Defines the scene to register the component in
  56363. */
  56364. constructor(scene: Scene);
  56365. /**
  56366. * Registers the component in a given scene
  56367. */
  56368. register(): void;
  56369. /**
  56370. * Rebuilds the elements related to this component in case of
  56371. * context lost for instance.
  56372. */
  56373. rebuild(): void;
  56374. /**
  56375. * Adds all the elements from the container to the scene
  56376. * @param container the container holding the elements
  56377. */
  56378. addFromContainer(container: AbstractScene): void;
  56379. /**
  56380. * Removes all the elements in the container from the scene
  56381. * @param container contains the elements to remove
  56382. * @param dispose if the removed element should be disposed (default: false)
  56383. */
  56384. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56385. /**
  56386. * Serializes the component data to the specified json object
  56387. * @param serializationObject The object to serialize to
  56388. */
  56389. serialize(serializationObject: any): void;
  56390. /**
  56391. * Disposes the component and the associated ressources.
  56392. */
  56393. dispose(): void;
  56394. private _draw;
  56395. }
  56396. }
  56397. declare module "babylonjs/LensFlares/index" {
  56398. export * from "babylonjs/LensFlares/lensFlare";
  56399. export * from "babylonjs/LensFlares/lensFlareSystem";
  56400. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56401. }
  56402. declare module "babylonjs/Shaders/depth.fragment" {
  56403. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56404. /** @hidden */
  56405. export var depthPixelShader: {
  56406. name: string;
  56407. shader: string;
  56408. };
  56409. }
  56410. declare module "babylonjs/Shaders/depth.vertex" {
  56411. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56412. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56413. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56414. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56415. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56416. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56417. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56418. /** @hidden */
  56419. export var depthVertexShader: {
  56420. name: string;
  56421. shader: string;
  56422. };
  56423. }
  56424. declare module "babylonjs/Rendering/depthRenderer" {
  56425. import { Nullable } from "babylonjs/types";
  56426. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56427. import { Scene } from "babylonjs/scene";
  56428. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56429. import { Camera } from "babylonjs/Cameras/camera";
  56430. import "babylonjs/Shaders/depth.fragment";
  56431. import "babylonjs/Shaders/depth.vertex";
  56432. /**
  56433. * This represents a depth renderer in Babylon.
  56434. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56435. */
  56436. export class DepthRenderer {
  56437. private _scene;
  56438. private _depthMap;
  56439. private _effect;
  56440. private readonly _storeNonLinearDepth;
  56441. private readonly _clearColor;
  56442. /** Get if the depth renderer is using packed depth or not */
  56443. readonly isPacked: boolean;
  56444. private _cachedDefines;
  56445. private _camera;
  56446. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56447. enabled: boolean;
  56448. /**
  56449. * Specifiess that the depth renderer will only be used within
  56450. * the camera it is created for.
  56451. * This can help forcing its rendering during the camera processing.
  56452. */
  56453. useOnlyInActiveCamera: boolean;
  56454. /** @hidden */
  56455. static _SceneComponentInitialization: (scene: Scene) => void;
  56456. /**
  56457. * Instantiates a depth renderer
  56458. * @param scene The scene the renderer belongs to
  56459. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56460. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56461. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56462. */
  56463. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56464. /**
  56465. * Creates the depth rendering effect and checks if the effect is ready.
  56466. * @param subMesh The submesh to be used to render the depth map of
  56467. * @param useInstances If multiple world instances should be used
  56468. * @returns if the depth renderer is ready to render the depth map
  56469. */
  56470. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56471. /**
  56472. * Gets the texture which the depth map will be written to.
  56473. * @returns The depth map texture
  56474. */
  56475. getDepthMap(): RenderTargetTexture;
  56476. /**
  56477. * Disposes of the depth renderer.
  56478. */
  56479. dispose(): void;
  56480. }
  56481. }
  56482. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56483. /** @hidden */
  56484. export var minmaxReduxPixelShader: {
  56485. name: string;
  56486. shader: string;
  56487. };
  56488. }
  56489. declare module "babylonjs/Misc/minMaxReducer" {
  56490. import { Nullable } from "babylonjs/types";
  56491. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56492. import { Camera } from "babylonjs/Cameras/camera";
  56493. import { Observer } from "babylonjs/Misc/observable";
  56494. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56495. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56496. import { Observable } from "babylonjs/Misc/observable";
  56497. import "babylonjs/Shaders/minmaxRedux.fragment";
  56498. /**
  56499. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56500. * and maximum values from all values of the texture.
  56501. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56502. * The source values are read from the red channel of the texture.
  56503. */
  56504. export class MinMaxReducer {
  56505. /**
  56506. * Observable triggered when the computation has been performed
  56507. */
  56508. onAfterReductionPerformed: Observable<{
  56509. min: number;
  56510. max: number;
  56511. }>;
  56512. protected _camera: Camera;
  56513. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56514. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56515. protected _postProcessManager: PostProcessManager;
  56516. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56517. protected _forceFullscreenViewport: boolean;
  56518. /**
  56519. * Creates a min/max reducer
  56520. * @param camera The camera to use for the post processes
  56521. */
  56522. constructor(camera: Camera);
  56523. /**
  56524. * Gets the texture used to read the values from.
  56525. */
  56526. get sourceTexture(): Nullable<RenderTargetTexture>;
  56527. /**
  56528. * Sets the source texture to read the values from.
  56529. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56530. * because in such textures '1' value must not be taken into account to compute the maximum
  56531. * as this value is used to clear the texture.
  56532. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56533. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56534. * @param depthRedux Indicates if the texture is a depth texture or not
  56535. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56536. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56537. */
  56538. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56539. /**
  56540. * Defines the refresh rate of the computation.
  56541. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56542. */
  56543. get refreshRate(): number;
  56544. set refreshRate(value: number);
  56545. protected _activated: boolean;
  56546. /**
  56547. * Gets the activation status of the reducer
  56548. */
  56549. get activated(): boolean;
  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 min/max 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/Misc/depthReducer" {
  56568. import { Nullable } from "babylonjs/types";
  56569. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56570. import { Camera } from "babylonjs/Cameras/camera";
  56571. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56572. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56573. /**
  56574. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56575. */
  56576. export class DepthReducer extends MinMaxReducer {
  56577. private _depthRenderer;
  56578. private _depthRendererId;
  56579. /**
  56580. * Gets the depth renderer used for the computation.
  56581. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56582. */
  56583. get depthRenderer(): Nullable<DepthRenderer>;
  56584. /**
  56585. * Creates a depth reducer
  56586. * @param camera The camera used to render the depth texture
  56587. */
  56588. constructor(camera: Camera);
  56589. /**
  56590. * Sets the depth renderer to use to generate the depth map
  56591. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56592. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56593. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56594. */
  56595. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56596. /** @hidden */
  56597. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56598. /**
  56599. * Activates the reduction computation.
  56600. * When activated, the observers registered in onAfterReductionPerformed are
  56601. * called after the compuation is performed
  56602. */
  56603. activate(): void;
  56604. /**
  56605. * Deactivates the reduction computation.
  56606. */
  56607. deactivate(): void;
  56608. /**
  56609. * Disposes the depth reducer
  56610. * @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.
  56611. */
  56612. dispose(disposeAll?: boolean): void;
  56613. }
  56614. }
  56615. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56616. import { Nullable } from "babylonjs/types";
  56617. import { Scene } from "babylonjs/scene";
  56618. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56619. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56620. import { Effect } from "babylonjs/Materials/effect";
  56621. import "babylonjs/Shaders/shadowMap.fragment";
  56622. import "babylonjs/Shaders/shadowMap.vertex";
  56623. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56624. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56625. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56626. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56627. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56628. /**
  56629. * A CSM implementation allowing casting shadows on large scenes.
  56630. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56631. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56632. */
  56633. export class CascadedShadowGenerator extends ShadowGenerator {
  56634. private static readonly frustumCornersNDCSpace;
  56635. /**
  56636. * Name of the CSM class
  56637. */
  56638. static CLASSNAME: string;
  56639. /**
  56640. * Defines the default number of cascades used by the CSM.
  56641. */
  56642. static readonly DEFAULT_CASCADES_COUNT: number;
  56643. /**
  56644. * Defines the minimum number of cascades used by the CSM.
  56645. */
  56646. static readonly MIN_CASCADES_COUNT: number;
  56647. /**
  56648. * Defines the maximum number of cascades used by the CSM.
  56649. */
  56650. static readonly MAX_CASCADES_COUNT: number;
  56651. protected _validateFilter(filter: number): number;
  56652. /**
  56653. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56654. */
  56655. penumbraDarkness: number;
  56656. private _numCascades;
  56657. /**
  56658. * Gets or set the number of cascades used by the CSM.
  56659. */
  56660. get numCascades(): number;
  56661. set numCascades(value: number);
  56662. /**
  56663. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56664. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56665. */
  56666. stabilizeCascades: boolean;
  56667. private _freezeShadowCastersBoundingInfo;
  56668. private _freezeShadowCastersBoundingInfoObservable;
  56669. /**
  56670. * Enables or disables the shadow casters bounding info computation.
  56671. * If your shadow casters don't move, you can disable this feature.
  56672. * If it is enabled, the bounding box computation is done every frame.
  56673. */
  56674. get freezeShadowCastersBoundingInfo(): boolean;
  56675. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56676. private _scbiMin;
  56677. private _scbiMax;
  56678. protected _computeShadowCastersBoundingInfo(): void;
  56679. protected _shadowCastersBoundingInfo: BoundingInfo;
  56680. /**
  56681. * Gets or sets the shadow casters bounding info.
  56682. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56683. * so that the system won't overwrite the bounds you provide
  56684. */
  56685. get shadowCastersBoundingInfo(): BoundingInfo;
  56686. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56687. protected _breaksAreDirty: boolean;
  56688. protected _minDistance: number;
  56689. protected _maxDistance: number;
  56690. /**
  56691. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56692. *
  56693. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56694. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56695. * @param min minimal distance for the breaks (default to 0.)
  56696. * @param max maximal distance for the breaks (default to 1.)
  56697. */
  56698. setMinMaxDistance(min: number, max: number): void;
  56699. /** Gets the minimal distance used in the cascade break computation */
  56700. get minDistance(): number;
  56701. /** Gets the maximal distance used in the cascade break computation */
  56702. get maxDistance(): number;
  56703. /**
  56704. * Gets the class name of that object
  56705. * @returns "CascadedShadowGenerator"
  56706. */
  56707. getClassName(): string;
  56708. private _cascadeMinExtents;
  56709. private _cascadeMaxExtents;
  56710. /**
  56711. * Gets a cascade minimum extents
  56712. * @param cascadeIndex index of the cascade
  56713. * @returns the minimum cascade extents
  56714. */
  56715. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56716. /**
  56717. * Gets a cascade maximum extents
  56718. * @param cascadeIndex index of the cascade
  56719. * @returns the maximum cascade extents
  56720. */
  56721. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56722. private _cascades;
  56723. private _currentLayer;
  56724. private _viewSpaceFrustumsZ;
  56725. private _viewMatrices;
  56726. private _projectionMatrices;
  56727. private _transformMatrices;
  56728. private _transformMatricesAsArray;
  56729. private _frustumLengths;
  56730. private _lightSizeUVCorrection;
  56731. private _depthCorrection;
  56732. private _frustumCornersWorldSpace;
  56733. private _frustumCenter;
  56734. private _shadowCameraPos;
  56735. private _shadowMaxZ;
  56736. /**
  56737. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56738. * It defaults to camera.maxZ
  56739. */
  56740. get shadowMaxZ(): number;
  56741. /**
  56742. * Sets the shadow max z distance.
  56743. */
  56744. set shadowMaxZ(value: number);
  56745. protected _debug: boolean;
  56746. /**
  56747. * Gets or sets the debug flag.
  56748. * When enabled, the cascades are materialized by different colors on the screen.
  56749. */
  56750. get debug(): boolean;
  56751. set debug(dbg: boolean);
  56752. private _depthClamp;
  56753. /**
  56754. * Gets or sets the depth clamping value.
  56755. *
  56756. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56757. * to account for the shadow casters far away.
  56758. *
  56759. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56760. */
  56761. get depthClamp(): boolean;
  56762. set depthClamp(value: boolean);
  56763. private _cascadeBlendPercentage;
  56764. /**
  56765. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56766. * It defaults to 0.1 (10% blending).
  56767. */
  56768. get cascadeBlendPercentage(): number;
  56769. set cascadeBlendPercentage(value: number);
  56770. private _lambda;
  56771. /**
  56772. * Gets or set the lambda parameter.
  56773. * This parameter is used to split the camera frustum and create the cascades.
  56774. * 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.
  56775. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56776. */
  56777. get lambda(): number;
  56778. set lambda(value: number);
  56779. /**
  56780. * Gets the view matrix corresponding to a given cascade
  56781. * @param cascadeNum cascade to retrieve the view matrix from
  56782. * @returns the cascade view matrix
  56783. */
  56784. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56785. /**
  56786. * Gets the projection matrix corresponding to a given cascade
  56787. * @param cascadeNum cascade to retrieve the projection matrix from
  56788. * @returns the cascade projection matrix
  56789. */
  56790. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56791. /**
  56792. * Gets the transformation matrix corresponding to a given cascade
  56793. * @param cascadeNum cascade to retrieve the transformation matrix from
  56794. * @returns the cascade transformation matrix
  56795. */
  56796. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56797. private _depthRenderer;
  56798. /**
  56799. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56800. *
  56801. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56802. *
  56803. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56804. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56805. * @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
  56806. */
  56807. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56808. private _depthReducer;
  56809. private _autoCalcDepthBounds;
  56810. /**
  56811. * Gets or sets the autoCalcDepthBounds property.
  56812. *
  56813. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56814. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56815. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56816. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56817. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56818. */
  56819. get autoCalcDepthBounds(): boolean;
  56820. set autoCalcDepthBounds(value: boolean);
  56821. /**
  56822. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56823. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56824. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56825. * for setting the refresh rate on the renderer yourself!
  56826. */
  56827. get autoCalcDepthBoundsRefreshRate(): number;
  56828. set autoCalcDepthBoundsRefreshRate(value: number);
  56829. /**
  56830. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56831. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56832. * you change the camera near/far planes!
  56833. */
  56834. splitFrustum(): void;
  56835. private _splitFrustum;
  56836. private _computeMatrices;
  56837. private _computeFrustumInWorldSpace;
  56838. private _computeCascadeFrustum;
  56839. /** @hidden */
  56840. static _SceneComponentInitialization: (scene: Scene) => void;
  56841. /**
  56842. * Creates a Cascaded Shadow Generator object.
  56843. * A ShadowGenerator is the required tool to use the shadows.
  56844. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56845. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56846. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56847. * @param light The directional light object generating the shadows.
  56848. * @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.
  56849. */
  56850. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56851. protected _initializeGenerator(): void;
  56852. protected _createTargetRenderTexture(): void;
  56853. protected _initializeShadowMap(): void;
  56854. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56855. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56856. /**
  56857. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56858. * @param defines Defines of the material we want to update
  56859. * @param lightIndex Index of the light in the enabled light list of the material
  56860. */
  56861. prepareDefines(defines: any, lightIndex: number): void;
  56862. /**
  56863. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56864. * defined in the generator but impacting the effect).
  56865. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56866. * @param effect The effect we are binfing the information for
  56867. */
  56868. bindShadowLight(lightIndex: string, effect: Effect): void;
  56869. /**
  56870. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56871. * (eq to view projection * shadow projection matrices)
  56872. * @returns The transform matrix used to create the shadow map
  56873. */
  56874. getTransformMatrix(): Matrix;
  56875. /**
  56876. * Disposes the ShadowGenerator.
  56877. * Returns nothing.
  56878. */
  56879. dispose(): void;
  56880. /**
  56881. * Serializes the shadow generator setup to a json object.
  56882. * @returns The serialized JSON object
  56883. */
  56884. serialize(): any;
  56885. /**
  56886. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56887. * @param parsedShadowGenerator The JSON object to parse
  56888. * @param scene The scene to create the shadow map for
  56889. * @returns The parsed shadow generator
  56890. */
  56891. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56892. }
  56893. }
  56894. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56895. import { Scene } from "babylonjs/scene";
  56896. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56897. import { AbstractScene } from "babylonjs/abstractScene";
  56898. /**
  56899. * Defines the shadow generator component responsible to manage any shadow generators
  56900. * in a given scene.
  56901. */
  56902. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56903. /**
  56904. * The component name helpfull to identify the component in the list of scene components.
  56905. */
  56906. readonly name: string;
  56907. /**
  56908. * The scene the component belongs to.
  56909. */
  56910. scene: Scene;
  56911. /**
  56912. * Creates a new instance of the component for the given scene
  56913. * @param scene Defines the scene to register the component in
  56914. */
  56915. constructor(scene: Scene);
  56916. /**
  56917. * Registers the component in a given scene
  56918. */
  56919. register(): void;
  56920. /**
  56921. * Rebuilds the elements related to this component in case of
  56922. * context lost for instance.
  56923. */
  56924. rebuild(): void;
  56925. /**
  56926. * Serializes the component data to the specified json object
  56927. * @param serializationObject The object to serialize to
  56928. */
  56929. serialize(serializationObject: any): void;
  56930. /**
  56931. * Adds all the elements from the container to the scene
  56932. * @param container the container holding the elements
  56933. */
  56934. addFromContainer(container: AbstractScene): void;
  56935. /**
  56936. * Removes all the elements in the container from the scene
  56937. * @param container contains the elements to remove
  56938. * @param dispose if the removed element should be disposed (default: false)
  56939. */
  56940. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56941. /**
  56942. * Rebuilds the elements related to this component in case of
  56943. * context lost for instance.
  56944. */
  56945. dispose(): void;
  56946. private _gatherRenderTargets;
  56947. }
  56948. }
  56949. declare module "babylonjs/Lights/Shadows/index" {
  56950. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56951. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56952. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56953. }
  56954. declare module "babylonjs/Lights/pointLight" {
  56955. import { Scene } from "babylonjs/scene";
  56956. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56958. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56959. import { Effect } from "babylonjs/Materials/effect";
  56960. /**
  56961. * A point light is a light defined by an unique point in world space.
  56962. * The light is emitted in every direction from this point.
  56963. * A good example of a point light is a standard light bulb.
  56964. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56965. */
  56966. export class PointLight extends ShadowLight {
  56967. private _shadowAngle;
  56968. /**
  56969. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56970. * This specifies what angle the shadow will use to be created.
  56971. *
  56972. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56973. */
  56974. get shadowAngle(): number;
  56975. /**
  56976. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56977. * This specifies what angle the shadow will use to be created.
  56978. *
  56979. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56980. */
  56981. set shadowAngle(value: number);
  56982. /**
  56983. * Gets the direction if it has been set.
  56984. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56985. */
  56986. get direction(): Vector3;
  56987. /**
  56988. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56989. */
  56990. set direction(value: Vector3);
  56991. /**
  56992. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56993. * A PointLight emits the light in every direction.
  56994. * It can cast shadows.
  56995. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56996. * ```javascript
  56997. * var pointLight = new PointLight("pl", camera.position, scene);
  56998. * ```
  56999. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57000. * @param name The light friendly name
  57001. * @param position The position of the point light in the scene
  57002. * @param scene The scene the lights belongs to
  57003. */
  57004. constructor(name: string, position: Vector3, scene: Scene);
  57005. /**
  57006. * Returns the string "PointLight"
  57007. * @returns the class name
  57008. */
  57009. getClassName(): string;
  57010. /**
  57011. * Returns the integer 0.
  57012. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57013. */
  57014. getTypeID(): number;
  57015. /**
  57016. * Specifies wether or not the shadowmap should be a cube texture.
  57017. * @returns true if the shadowmap needs to be a cube texture.
  57018. */
  57019. needCube(): boolean;
  57020. /**
  57021. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57022. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57023. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57024. */
  57025. getShadowDirection(faceIndex?: number): Vector3;
  57026. /**
  57027. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57028. * - fov = PI / 2
  57029. * - aspect ratio : 1.0
  57030. * - z-near and far equal to the active camera minZ and maxZ.
  57031. * Returns the PointLight.
  57032. */
  57033. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57034. protected _buildUniformLayout(): void;
  57035. /**
  57036. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57037. * @param effect The effect to update
  57038. * @param lightIndex The index of the light in the effect to update
  57039. * @returns The point light
  57040. */
  57041. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57042. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57043. /**
  57044. * Prepares the list of defines specific to the light type.
  57045. * @param defines the list of defines
  57046. * @param lightIndex defines the index of the light for the effect
  57047. */
  57048. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57049. }
  57050. }
  57051. declare module "babylonjs/Lights/index" {
  57052. export * from "babylonjs/Lights/light";
  57053. export * from "babylonjs/Lights/shadowLight";
  57054. export * from "babylonjs/Lights/Shadows/index";
  57055. export * from "babylonjs/Lights/directionalLight";
  57056. export * from "babylonjs/Lights/hemisphericLight";
  57057. export * from "babylonjs/Lights/pointLight";
  57058. export * from "babylonjs/Lights/spotLight";
  57059. }
  57060. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57061. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57062. /**
  57063. * Header information of HDR texture files.
  57064. */
  57065. export interface HDRInfo {
  57066. /**
  57067. * The height of the texture in pixels.
  57068. */
  57069. height: number;
  57070. /**
  57071. * The width of the texture in pixels.
  57072. */
  57073. width: number;
  57074. /**
  57075. * The index of the beginning of the data in the binary file.
  57076. */
  57077. dataPosition: number;
  57078. }
  57079. /**
  57080. * This groups tools to convert HDR texture to native colors array.
  57081. */
  57082. export class HDRTools {
  57083. private static Ldexp;
  57084. private static Rgbe2float;
  57085. private static readStringLine;
  57086. /**
  57087. * Reads header information from an RGBE texture stored in a native array.
  57088. * More information on this format are available here:
  57089. * https://en.wikipedia.org/wiki/RGBE_image_format
  57090. *
  57091. * @param uint8array The binary file stored in native array.
  57092. * @return The header information.
  57093. */
  57094. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57095. /**
  57096. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57097. * This RGBE texture needs to store the information as a panorama.
  57098. *
  57099. * More information on this format are available here:
  57100. * https://en.wikipedia.org/wiki/RGBE_image_format
  57101. *
  57102. * @param buffer The binary file stored in an array buffer.
  57103. * @param size The expected size of the extracted cubemap.
  57104. * @return The Cube Map information.
  57105. */
  57106. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57107. /**
  57108. * Returns the pixels data extracted from an RGBE texture.
  57109. * This pixels will be stored left to right up to down in the R G B order in one array.
  57110. *
  57111. * More information on this format are available here:
  57112. * https://en.wikipedia.org/wiki/RGBE_image_format
  57113. *
  57114. * @param uint8array The binary file stored in an array buffer.
  57115. * @param hdrInfo The header information of the file.
  57116. * @return The pixels data in RGB right to left up to down order.
  57117. */
  57118. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57119. private static RGBE_ReadPixels_RLE;
  57120. }
  57121. }
  57122. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57123. import { Nullable } from "babylonjs/types";
  57124. import { Scene } from "babylonjs/scene";
  57125. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57126. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57127. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57128. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57129. /**
  57130. * This represents a texture coming from an HDR input.
  57131. *
  57132. * The only supported format is currently panorama picture stored in RGBE format.
  57133. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57134. */
  57135. export class HDRCubeTexture extends BaseTexture {
  57136. private static _facesMapping;
  57137. private _generateHarmonics;
  57138. private _noMipmap;
  57139. private _textureMatrix;
  57140. private _size;
  57141. private _onLoad;
  57142. private _onError;
  57143. /**
  57144. * The texture URL.
  57145. */
  57146. url: string;
  57147. /**
  57148. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57149. */
  57150. coordinatesMode: number;
  57151. protected _isBlocking: boolean;
  57152. /**
  57153. * Sets wether or not the texture is blocking during loading.
  57154. */
  57155. set isBlocking(value: boolean);
  57156. /**
  57157. * Gets wether or not the texture is blocking during loading.
  57158. */
  57159. get isBlocking(): boolean;
  57160. protected _rotationY: number;
  57161. /**
  57162. * Sets texture matrix rotation angle around Y axis in radians.
  57163. */
  57164. set rotationY(value: number);
  57165. /**
  57166. * Gets texture matrix rotation angle around Y axis radians.
  57167. */
  57168. get rotationY(): number;
  57169. /**
  57170. * Gets or sets the center of the bounding box associated with the cube texture
  57171. * It must define where the camera used to render the texture was set
  57172. */
  57173. boundingBoxPosition: Vector3;
  57174. private _boundingBoxSize;
  57175. /**
  57176. * Gets or sets the size of the bounding box associated with the cube texture
  57177. * When defined, the cubemap will switch to local mode
  57178. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57179. * @example https://www.babylonjs-playground.com/#RNASML
  57180. */
  57181. set boundingBoxSize(value: Vector3);
  57182. get boundingBoxSize(): Vector3;
  57183. /**
  57184. * Instantiates an HDRTexture from the following parameters.
  57185. *
  57186. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57187. * @param scene The scene the texture will be used in
  57188. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57189. * @param noMipmap Forces to not generate the mipmap if true
  57190. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57191. * @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)
  57192. * @param reserved Reserved flag for internal use.
  57193. */
  57194. 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>);
  57195. /**
  57196. * Get the current class name of the texture useful for serialization or dynamic coding.
  57197. * @returns "HDRCubeTexture"
  57198. */
  57199. getClassName(): string;
  57200. /**
  57201. * Occurs when the file is raw .hdr file.
  57202. */
  57203. private loadTexture;
  57204. clone(): HDRCubeTexture;
  57205. delayLoad(): void;
  57206. /**
  57207. * Get the texture reflection matrix used to rotate/transform the reflection.
  57208. * @returns the reflection matrix
  57209. */
  57210. getReflectionTextureMatrix(): Matrix;
  57211. /**
  57212. * Set the texture reflection matrix used to rotate/transform the reflection.
  57213. * @param value Define the reflection matrix to set
  57214. */
  57215. setReflectionTextureMatrix(value: Matrix): void;
  57216. /**
  57217. * Parses a JSON representation of an HDR Texture in order to create the texture
  57218. * @param parsedTexture Define the JSON representation
  57219. * @param scene Define the scene the texture should be created in
  57220. * @param rootUrl Define the root url in case we need to load relative dependencies
  57221. * @returns the newly created texture after parsing
  57222. */
  57223. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57224. serialize(): any;
  57225. }
  57226. }
  57227. declare module "babylonjs/Physics/physicsEngine" {
  57228. import { Nullable } from "babylonjs/types";
  57229. import { Vector3 } from "babylonjs/Maths/math.vector";
  57230. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57231. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57232. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57233. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57234. /**
  57235. * Class used to control physics engine
  57236. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57237. */
  57238. export class PhysicsEngine implements IPhysicsEngine {
  57239. private _physicsPlugin;
  57240. /**
  57241. * Global value used to control the smallest number supported by the simulation
  57242. */
  57243. static Epsilon: number;
  57244. private _impostors;
  57245. private _joints;
  57246. private _subTimeStep;
  57247. /**
  57248. * Gets the gravity vector used by the simulation
  57249. */
  57250. gravity: Vector3;
  57251. /**
  57252. * Factory used to create the default physics plugin.
  57253. * @returns The default physics plugin
  57254. */
  57255. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57256. /**
  57257. * Creates a new Physics Engine
  57258. * @param gravity defines the gravity vector used by the simulation
  57259. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57260. */
  57261. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57262. /**
  57263. * Sets the gravity vector used by the simulation
  57264. * @param gravity defines the gravity vector to use
  57265. */
  57266. setGravity(gravity: Vector3): void;
  57267. /**
  57268. * Set the time step of the physics engine.
  57269. * Default is 1/60.
  57270. * To slow it down, enter 1/600 for example.
  57271. * To speed it up, 1/30
  57272. * @param newTimeStep defines the new timestep to apply to this world.
  57273. */
  57274. setTimeStep(newTimeStep?: number): void;
  57275. /**
  57276. * Get the time step of the physics engine.
  57277. * @returns the current time step
  57278. */
  57279. getTimeStep(): number;
  57280. /**
  57281. * Set the sub time step of the physics engine.
  57282. * Default is 0 meaning there is no sub steps
  57283. * To increase physics resolution precision, set a small value (like 1 ms)
  57284. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57285. */
  57286. setSubTimeStep(subTimeStep?: number): void;
  57287. /**
  57288. * Get the sub time step of the physics engine.
  57289. * @returns the current sub time step
  57290. */
  57291. getSubTimeStep(): number;
  57292. /**
  57293. * Release all resources
  57294. */
  57295. dispose(): void;
  57296. /**
  57297. * Gets the name of the current physics plugin
  57298. * @returns the name of the plugin
  57299. */
  57300. getPhysicsPluginName(): string;
  57301. /**
  57302. * Adding a new impostor for the impostor tracking.
  57303. * This will be done by the impostor itself.
  57304. * @param impostor the impostor to add
  57305. */
  57306. addImpostor(impostor: PhysicsImpostor): void;
  57307. /**
  57308. * Remove an impostor from the engine.
  57309. * This impostor and its mesh will not longer be updated by the physics engine.
  57310. * @param impostor the impostor to remove
  57311. */
  57312. removeImpostor(impostor: PhysicsImpostor): void;
  57313. /**
  57314. * Add a joint to the physics engine
  57315. * @param mainImpostor defines the main impostor to which the joint is added.
  57316. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57317. * @param joint defines the joint that will connect both impostors.
  57318. */
  57319. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57320. /**
  57321. * Removes a joint from the simulation
  57322. * @param mainImpostor defines the impostor used with the joint
  57323. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57324. * @param joint defines the joint to remove
  57325. */
  57326. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57327. /**
  57328. * Called by the scene. No need to call it.
  57329. * @param delta defines the timespam between frames
  57330. */
  57331. _step(delta: number): void;
  57332. /**
  57333. * Gets the current plugin used to run the simulation
  57334. * @returns current plugin
  57335. */
  57336. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57337. /**
  57338. * Gets the list of physic impostors
  57339. * @returns an array of PhysicsImpostor
  57340. */
  57341. getImpostors(): Array<PhysicsImpostor>;
  57342. /**
  57343. * Gets the impostor for a physics enabled object
  57344. * @param object defines the object impersonated by the impostor
  57345. * @returns the PhysicsImpostor or null if not found
  57346. */
  57347. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57348. /**
  57349. * Gets the impostor for a physics body object
  57350. * @param body defines physics body used by the impostor
  57351. * @returns the PhysicsImpostor or null if not found
  57352. */
  57353. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57354. /**
  57355. * Does a raycast in the physics world
  57356. * @param from when should the ray start?
  57357. * @param to when should the ray end?
  57358. * @returns PhysicsRaycastResult
  57359. */
  57360. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57361. }
  57362. }
  57363. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57364. import { Nullable } from "babylonjs/types";
  57365. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57367. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57368. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57369. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57370. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57371. /** @hidden */
  57372. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57373. private _useDeltaForWorldStep;
  57374. world: any;
  57375. name: string;
  57376. private _physicsMaterials;
  57377. private _fixedTimeStep;
  57378. private _cannonRaycastResult;
  57379. private _raycastResult;
  57380. private _physicsBodysToRemoveAfterStep;
  57381. BJSCANNON: any;
  57382. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57383. setGravity(gravity: Vector3): void;
  57384. setTimeStep(timeStep: number): void;
  57385. getTimeStep(): number;
  57386. executeStep(delta: number): void;
  57387. private _removeMarkedPhysicsBodiesFromWorld;
  57388. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57389. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57390. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57391. private _processChildMeshes;
  57392. removePhysicsBody(impostor: PhysicsImpostor): void;
  57393. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57394. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57395. private _addMaterial;
  57396. private _checkWithEpsilon;
  57397. private _createShape;
  57398. private _createHeightmap;
  57399. private _minus90X;
  57400. private _plus90X;
  57401. private _tmpPosition;
  57402. private _tmpDeltaPosition;
  57403. private _tmpUnityRotation;
  57404. private _updatePhysicsBodyTransformation;
  57405. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57406. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57407. isSupported(): boolean;
  57408. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57409. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57410. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57411. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57412. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57413. getBodyMass(impostor: PhysicsImpostor): number;
  57414. getBodyFriction(impostor: PhysicsImpostor): number;
  57415. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57416. getBodyRestitution(impostor: PhysicsImpostor): number;
  57417. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57418. sleepBody(impostor: PhysicsImpostor): void;
  57419. wakeUpBody(impostor: PhysicsImpostor): void;
  57420. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57421. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57422. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57423. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57424. getRadius(impostor: PhysicsImpostor): number;
  57425. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57426. dispose(): void;
  57427. private _extendNamespace;
  57428. /**
  57429. * Does a raycast in the physics world
  57430. * @param from when should the ray start?
  57431. * @param to when should the ray end?
  57432. * @returns PhysicsRaycastResult
  57433. */
  57434. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57435. }
  57436. }
  57437. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57438. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57439. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57440. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57442. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57443. import { Nullable } from "babylonjs/types";
  57444. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57445. /** @hidden */
  57446. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57447. world: any;
  57448. name: string;
  57449. BJSOIMO: any;
  57450. private _raycastResult;
  57451. constructor(iterations?: number, oimoInjection?: any);
  57452. setGravity(gravity: Vector3): void;
  57453. setTimeStep(timeStep: number): void;
  57454. getTimeStep(): number;
  57455. private _tmpImpostorsArray;
  57456. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57457. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57458. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57459. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57460. private _tmpPositionVector;
  57461. removePhysicsBody(impostor: PhysicsImpostor): void;
  57462. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57463. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57464. isSupported(): boolean;
  57465. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57466. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57467. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57468. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57469. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57470. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57471. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57472. getBodyMass(impostor: PhysicsImpostor): number;
  57473. getBodyFriction(impostor: PhysicsImpostor): number;
  57474. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57475. getBodyRestitution(impostor: PhysicsImpostor): number;
  57476. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57477. sleepBody(impostor: PhysicsImpostor): void;
  57478. wakeUpBody(impostor: PhysicsImpostor): void;
  57479. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57480. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57481. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57482. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57483. getRadius(impostor: PhysicsImpostor): number;
  57484. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57485. dispose(): void;
  57486. /**
  57487. * Does a raycast in the physics world
  57488. * @param from when should the ray start?
  57489. * @param to when should the ray end?
  57490. * @returns PhysicsRaycastResult
  57491. */
  57492. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57493. }
  57494. }
  57495. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57496. import { Nullable } from "babylonjs/types";
  57497. import { Scene } from "babylonjs/scene";
  57498. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57499. import { Color4 } from "babylonjs/Maths/math.color";
  57500. import { Mesh } from "babylonjs/Meshes/mesh";
  57501. /**
  57502. * Class containing static functions to help procedurally build meshes
  57503. */
  57504. export class RibbonBuilder {
  57505. /**
  57506. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57507. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57508. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57509. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57510. * * 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
  57511. * * 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
  57512. * * 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
  57513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57515. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57516. * * 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
  57517. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57518. * * 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
  57519. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57521. * @param name defines the name of the mesh
  57522. * @param options defines the options used to create the mesh
  57523. * @param scene defines the hosting scene
  57524. * @returns the ribbon mesh
  57525. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57526. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57527. */
  57528. static CreateRibbon(name: string, options: {
  57529. pathArray: Vector3[][];
  57530. closeArray?: boolean;
  57531. closePath?: boolean;
  57532. offset?: number;
  57533. updatable?: boolean;
  57534. sideOrientation?: number;
  57535. frontUVs?: Vector4;
  57536. backUVs?: Vector4;
  57537. instance?: Mesh;
  57538. invertUV?: boolean;
  57539. uvs?: Vector2[];
  57540. colors?: Color4[];
  57541. }, scene?: Nullable<Scene>): Mesh;
  57542. }
  57543. }
  57544. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57545. import { Nullable } from "babylonjs/types";
  57546. import { Scene } from "babylonjs/scene";
  57547. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57548. import { Mesh } from "babylonjs/Meshes/mesh";
  57549. /**
  57550. * Class containing static functions to help procedurally build meshes
  57551. */
  57552. export class ShapeBuilder {
  57553. /**
  57554. * 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.
  57555. * * 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.
  57556. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57557. * * 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.
  57558. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57559. * * 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
  57560. * * 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
  57561. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57564. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57566. * @param name defines the name of the mesh
  57567. * @param options defines the options used to create the mesh
  57568. * @param scene defines the hosting scene
  57569. * @returns the extruded shape mesh
  57570. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57571. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57572. */
  57573. static ExtrudeShape(name: string, options: {
  57574. shape: Vector3[];
  57575. path: Vector3[];
  57576. scale?: number;
  57577. rotation?: number;
  57578. cap?: number;
  57579. updatable?: boolean;
  57580. sideOrientation?: number;
  57581. frontUVs?: Vector4;
  57582. backUVs?: Vector4;
  57583. instance?: Mesh;
  57584. invertUV?: boolean;
  57585. }, scene?: Nullable<Scene>): Mesh;
  57586. /**
  57587. * Creates an custom extruded shape mesh.
  57588. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57589. * * 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.
  57590. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57591. * * 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
  57592. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57593. * * 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
  57594. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57595. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57596. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57597. * * 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
  57598. * * 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
  57599. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57604. * @param name defines the name of the mesh
  57605. * @param options defines the options used to create the mesh
  57606. * @param scene defines the hosting scene
  57607. * @returns the custom extruded shape mesh
  57608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57609. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57611. */
  57612. static ExtrudeShapeCustom(name: string, options: {
  57613. shape: Vector3[];
  57614. path: Vector3[];
  57615. scaleFunction?: any;
  57616. rotationFunction?: any;
  57617. ribbonCloseArray?: boolean;
  57618. ribbonClosePath?: boolean;
  57619. cap?: number;
  57620. updatable?: boolean;
  57621. sideOrientation?: number;
  57622. frontUVs?: Vector4;
  57623. backUVs?: Vector4;
  57624. instance?: Mesh;
  57625. invertUV?: boolean;
  57626. }, scene?: Nullable<Scene>): Mesh;
  57627. private static _ExtrudeShapeGeneric;
  57628. }
  57629. }
  57630. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57631. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57632. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57633. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57634. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57635. import { Nullable } from "babylonjs/types";
  57636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57637. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57638. /**
  57639. * AmmoJS Physics plugin
  57640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57641. * @see https://github.com/kripken/ammo.js/
  57642. */
  57643. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57644. private _useDeltaForWorldStep;
  57645. /**
  57646. * Reference to the Ammo library
  57647. */
  57648. bjsAMMO: any;
  57649. /**
  57650. * Created ammoJS world which physics bodies are added to
  57651. */
  57652. world: any;
  57653. /**
  57654. * Name of the plugin
  57655. */
  57656. name: string;
  57657. private _timeStep;
  57658. private _fixedTimeStep;
  57659. private _maxSteps;
  57660. private _tmpQuaternion;
  57661. private _tmpAmmoTransform;
  57662. private _tmpAmmoQuaternion;
  57663. private _tmpAmmoConcreteContactResultCallback;
  57664. private _collisionConfiguration;
  57665. private _dispatcher;
  57666. private _overlappingPairCache;
  57667. private _solver;
  57668. private _softBodySolver;
  57669. private _tmpAmmoVectorA;
  57670. private _tmpAmmoVectorB;
  57671. private _tmpAmmoVectorC;
  57672. private _tmpAmmoVectorD;
  57673. private _tmpContactCallbackResult;
  57674. private _tmpAmmoVectorRCA;
  57675. private _tmpAmmoVectorRCB;
  57676. private _raycastResult;
  57677. private static readonly DISABLE_COLLISION_FLAG;
  57678. private static readonly KINEMATIC_FLAG;
  57679. private static readonly DISABLE_DEACTIVATION_FLAG;
  57680. /**
  57681. * Initializes the ammoJS plugin
  57682. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57683. * @param ammoInjection can be used to inject your own ammo reference
  57684. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57685. */
  57686. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57687. /**
  57688. * Sets the gravity of the physics world (m/(s^2))
  57689. * @param gravity Gravity to set
  57690. */
  57691. setGravity(gravity: Vector3): void;
  57692. /**
  57693. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57694. * @param timeStep timestep to use in seconds
  57695. */
  57696. setTimeStep(timeStep: number): void;
  57697. /**
  57698. * 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)
  57699. * @param fixedTimeStep fixedTimeStep to use in seconds
  57700. */
  57701. setFixedTimeStep(fixedTimeStep: number): void;
  57702. /**
  57703. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57704. * @param maxSteps the maximum number of steps by the physics engine per frame
  57705. */
  57706. setMaxSteps(maxSteps: number): void;
  57707. /**
  57708. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57709. * @returns the current timestep in seconds
  57710. */
  57711. getTimeStep(): number;
  57712. /**
  57713. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57714. */
  57715. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57716. private _isImpostorInContact;
  57717. private _isImpostorPairInContact;
  57718. private _stepSimulation;
  57719. /**
  57720. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57721. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57722. * After the step the babylon meshes are set to the position of the physics imposters
  57723. * @param delta amount of time to step forward
  57724. * @param impostors array of imposters to update before/after the step
  57725. */
  57726. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57727. /**
  57728. * Update babylon mesh to match physics world object
  57729. * @param impostor imposter to match
  57730. */
  57731. private _afterSoftStep;
  57732. /**
  57733. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57734. * @param impostor imposter to match
  57735. */
  57736. private _ropeStep;
  57737. /**
  57738. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57739. * @param impostor imposter to match
  57740. */
  57741. private _softbodyOrClothStep;
  57742. private _tmpVector;
  57743. private _tmpMatrix;
  57744. /**
  57745. * Applies an impulse on the imposter
  57746. * @param impostor imposter to apply impulse to
  57747. * @param force amount of force to be applied to the imposter
  57748. * @param contactPoint the location to apply the impulse on the imposter
  57749. */
  57750. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57751. /**
  57752. * Applies a force on the imposter
  57753. * @param impostor imposter to apply force
  57754. * @param force amount of force to be applied to the imposter
  57755. * @param contactPoint the location to apply the force on the imposter
  57756. */
  57757. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57758. /**
  57759. * Creates a physics body using the plugin
  57760. * @param impostor the imposter to create the physics body on
  57761. */
  57762. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57763. /**
  57764. * Removes the physics body from the imposter and disposes of the body's memory
  57765. * @param impostor imposter to remove the physics body from
  57766. */
  57767. removePhysicsBody(impostor: PhysicsImpostor): void;
  57768. /**
  57769. * Generates a joint
  57770. * @param impostorJoint the imposter joint to create the joint with
  57771. */
  57772. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57773. /**
  57774. * Removes a joint
  57775. * @param impostorJoint the imposter joint to remove the joint from
  57776. */
  57777. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57778. private _addMeshVerts;
  57779. /**
  57780. * Initialise the soft body vertices to match its object's (mesh) vertices
  57781. * Softbody vertices (nodes) are in world space and to match this
  57782. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57783. * @param impostor to create the softbody for
  57784. */
  57785. private _softVertexData;
  57786. /**
  57787. * Create an impostor's soft body
  57788. * @param impostor to create the softbody for
  57789. */
  57790. private _createSoftbody;
  57791. /**
  57792. * Create cloth for an impostor
  57793. * @param impostor to create the softbody for
  57794. */
  57795. private _createCloth;
  57796. /**
  57797. * Create rope for an impostor
  57798. * @param impostor to create the softbody for
  57799. */
  57800. private _createRope;
  57801. /**
  57802. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57803. * @param impostor to create the custom physics shape for
  57804. */
  57805. private _createCustom;
  57806. private _addHullVerts;
  57807. private _createShape;
  57808. /**
  57809. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57810. * @param impostor imposter containing the physics body and babylon object
  57811. */
  57812. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57813. /**
  57814. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57815. * @param impostor imposter containing the physics body and babylon object
  57816. * @param newPosition new position
  57817. * @param newRotation new rotation
  57818. */
  57819. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57820. /**
  57821. * If this plugin is supported
  57822. * @returns true if its supported
  57823. */
  57824. isSupported(): boolean;
  57825. /**
  57826. * Sets the linear velocity of the physics body
  57827. * @param impostor imposter to set the velocity on
  57828. * @param velocity velocity to set
  57829. */
  57830. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57831. /**
  57832. * Sets the angular velocity of the physics body
  57833. * @param impostor imposter to set the velocity on
  57834. * @param velocity velocity to set
  57835. */
  57836. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57837. /**
  57838. * gets the linear velocity
  57839. * @param impostor imposter to get linear velocity from
  57840. * @returns linear velocity
  57841. */
  57842. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57843. /**
  57844. * gets the angular velocity
  57845. * @param impostor imposter to get angular velocity from
  57846. * @returns angular velocity
  57847. */
  57848. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57849. /**
  57850. * Sets the mass of physics body
  57851. * @param impostor imposter to set the mass on
  57852. * @param mass mass to set
  57853. */
  57854. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57855. /**
  57856. * Gets the mass of the physics body
  57857. * @param impostor imposter to get the mass from
  57858. * @returns mass
  57859. */
  57860. getBodyMass(impostor: PhysicsImpostor): number;
  57861. /**
  57862. * Gets friction of the impostor
  57863. * @param impostor impostor to get friction from
  57864. * @returns friction value
  57865. */
  57866. getBodyFriction(impostor: PhysicsImpostor): number;
  57867. /**
  57868. * Sets friction of the impostor
  57869. * @param impostor impostor to set friction on
  57870. * @param friction friction value
  57871. */
  57872. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57873. /**
  57874. * Gets restitution of the impostor
  57875. * @param impostor impostor to get restitution from
  57876. * @returns restitution value
  57877. */
  57878. getBodyRestitution(impostor: PhysicsImpostor): number;
  57879. /**
  57880. * Sets resitution of the impostor
  57881. * @param impostor impostor to set resitution on
  57882. * @param restitution resitution value
  57883. */
  57884. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57885. /**
  57886. * Gets pressure inside the impostor
  57887. * @param impostor impostor to get pressure from
  57888. * @returns pressure value
  57889. */
  57890. getBodyPressure(impostor: PhysicsImpostor): number;
  57891. /**
  57892. * Sets pressure inside a soft body impostor
  57893. * Cloth and rope must remain 0 pressure
  57894. * @param impostor impostor to set pressure on
  57895. * @param pressure pressure value
  57896. */
  57897. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57898. /**
  57899. * Gets stiffness of the impostor
  57900. * @param impostor impostor to get stiffness from
  57901. * @returns pressure value
  57902. */
  57903. getBodyStiffness(impostor: PhysicsImpostor): number;
  57904. /**
  57905. * Sets stiffness of the impostor
  57906. * @param impostor impostor to set stiffness on
  57907. * @param stiffness stiffness value from 0 to 1
  57908. */
  57909. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57910. /**
  57911. * Gets velocityIterations of the impostor
  57912. * @param impostor impostor to get velocity iterations from
  57913. * @returns velocityIterations value
  57914. */
  57915. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57916. /**
  57917. * Sets velocityIterations of the impostor
  57918. * @param impostor impostor to set velocity iterations on
  57919. * @param velocityIterations velocityIterations value
  57920. */
  57921. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57922. /**
  57923. * Gets positionIterations of the impostor
  57924. * @param impostor impostor to get position iterations from
  57925. * @returns positionIterations value
  57926. */
  57927. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57928. /**
  57929. * Sets positionIterations of the impostor
  57930. * @param impostor impostor to set position on
  57931. * @param positionIterations positionIterations value
  57932. */
  57933. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57934. /**
  57935. * Append an anchor to a cloth object
  57936. * @param impostor is the cloth impostor to add anchor to
  57937. * @param otherImpostor is the rigid impostor to anchor to
  57938. * @param width ratio across width from 0 to 1
  57939. * @param height ratio up height from 0 to 1
  57940. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57941. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57942. */
  57943. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57944. /**
  57945. * Append an hook to a rope object
  57946. * @param impostor is the rope impostor to add hook to
  57947. * @param otherImpostor is the rigid impostor to hook to
  57948. * @param length ratio along the rope from 0 to 1
  57949. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57950. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57951. */
  57952. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57953. /**
  57954. * Sleeps the physics body and stops it from being active
  57955. * @param impostor impostor to sleep
  57956. */
  57957. sleepBody(impostor: PhysicsImpostor): void;
  57958. /**
  57959. * Activates the physics body
  57960. * @param impostor impostor to activate
  57961. */
  57962. wakeUpBody(impostor: PhysicsImpostor): void;
  57963. /**
  57964. * Updates the distance parameters of the joint
  57965. * @param joint joint to update
  57966. * @param maxDistance maximum distance of the joint
  57967. * @param minDistance minimum distance of the joint
  57968. */
  57969. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57970. /**
  57971. * Sets a motor on the joint
  57972. * @param joint joint to set motor on
  57973. * @param speed speed of the motor
  57974. * @param maxForce maximum force of the motor
  57975. * @param motorIndex index of the motor
  57976. */
  57977. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57978. /**
  57979. * Sets the motors limit
  57980. * @param joint joint to set limit on
  57981. * @param upperLimit upper limit
  57982. * @param lowerLimit lower limit
  57983. */
  57984. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57985. /**
  57986. * Syncs the position and rotation of a mesh with the impostor
  57987. * @param mesh mesh to sync
  57988. * @param impostor impostor to update the mesh with
  57989. */
  57990. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57991. /**
  57992. * Gets the radius of the impostor
  57993. * @param impostor impostor to get radius from
  57994. * @returns the radius
  57995. */
  57996. getRadius(impostor: PhysicsImpostor): number;
  57997. /**
  57998. * Gets the box size of the impostor
  57999. * @param impostor impostor to get box size from
  58000. * @param result the resulting box size
  58001. */
  58002. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58003. /**
  58004. * Disposes of the impostor
  58005. */
  58006. dispose(): void;
  58007. /**
  58008. * Does a raycast in the physics world
  58009. * @param from when should the ray start?
  58010. * @param to when should the ray end?
  58011. * @returns PhysicsRaycastResult
  58012. */
  58013. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58014. }
  58015. }
  58016. declare module "babylonjs/Probes/reflectionProbe" {
  58017. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58018. import { Vector3 } from "babylonjs/Maths/math.vector";
  58019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58020. import { Nullable } from "babylonjs/types";
  58021. import { Scene } from "babylonjs/scene";
  58022. module "babylonjs/abstractScene" {
  58023. interface AbstractScene {
  58024. /**
  58025. * The list of reflection probes added to the scene
  58026. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58027. */
  58028. reflectionProbes: Array<ReflectionProbe>;
  58029. /**
  58030. * Removes the given reflection probe from this scene.
  58031. * @param toRemove The reflection probe to remove
  58032. * @returns The index of the removed reflection probe
  58033. */
  58034. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58035. /**
  58036. * Adds the given reflection probe to this scene.
  58037. * @param newReflectionProbe The reflection probe to add
  58038. */
  58039. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58040. }
  58041. }
  58042. /**
  58043. * Class used to generate realtime reflection / refraction cube textures
  58044. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58045. */
  58046. export class ReflectionProbe {
  58047. /** defines the name of the probe */
  58048. name: string;
  58049. private _scene;
  58050. private _renderTargetTexture;
  58051. private _projectionMatrix;
  58052. private _viewMatrix;
  58053. private _target;
  58054. private _add;
  58055. private _attachedMesh;
  58056. private _invertYAxis;
  58057. /** Gets or sets probe position (center of the cube map) */
  58058. position: Vector3;
  58059. /**
  58060. * Creates a new reflection probe
  58061. * @param name defines the name of the probe
  58062. * @param size defines the texture resolution (for each face)
  58063. * @param scene defines the hosting scene
  58064. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58065. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58066. */
  58067. constructor(
  58068. /** defines the name of the probe */
  58069. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58070. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58071. get samples(): number;
  58072. set samples(value: number);
  58073. /** Gets or sets the refresh rate to use (on every frame by default) */
  58074. get refreshRate(): number;
  58075. set refreshRate(value: number);
  58076. /**
  58077. * Gets the hosting scene
  58078. * @returns a Scene
  58079. */
  58080. getScene(): Scene;
  58081. /** Gets the internal CubeTexture used to render to */
  58082. get cubeTexture(): RenderTargetTexture;
  58083. /** Gets the list of meshes to render */
  58084. get renderList(): Nullable<AbstractMesh[]>;
  58085. /**
  58086. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58087. * @param mesh defines the mesh to attach to
  58088. */
  58089. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58090. /**
  58091. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58092. * @param renderingGroupId The rendering group id corresponding to its index
  58093. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58094. */
  58095. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58096. /**
  58097. * Clean all associated resources
  58098. */
  58099. dispose(): void;
  58100. /**
  58101. * Converts the reflection probe information to a readable string for debug purpose.
  58102. * @param fullDetails Supports for multiple levels of logging within scene loading
  58103. * @returns the human readable reflection probe info
  58104. */
  58105. toString(fullDetails?: boolean): string;
  58106. /**
  58107. * Get the class name of the relfection probe.
  58108. * @returns "ReflectionProbe"
  58109. */
  58110. getClassName(): string;
  58111. /**
  58112. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58113. * @returns The JSON representation of the texture
  58114. */
  58115. serialize(): any;
  58116. /**
  58117. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58118. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58119. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58120. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58121. * @returns The parsed reflection probe if successful
  58122. */
  58123. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58124. }
  58125. }
  58126. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58127. /** @hidden */
  58128. export var _BabylonLoaderRegistered: boolean;
  58129. /**
  58130. * Helps setting up some configuration for the babylon file loader.
  58131. */
  58132. export class BabylonFileLoaderConfiguration {
  58133. /**
  58134. * The loader does not allow injecting custom physix engine into the plugins.
  58135. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58136. * So you could set this variable to your engine import to make it work.
  58137. */
  58138. static LoaderInjectedPhysicsEngine: any;
  58139. }
  58140. }
  58141. declare module "babylonjs/Loading/Plugins/index" {
  58142. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58143. }
  58144. declare module "babylonjs/Loading/index" {
  58145. export * from "babylonjs/Loading/loadingScreen";
  58146. export * from "babylonjs/Loading/Plugins/index";
  58147. export * from "babylonjs/Loading/sceneLoader";
  58148. export * from "babylonjs/Loading/sceneLoaderFlags";
  58149. }
  58150. declare module "babylonjs/Materials/Background/index" {
  58151. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58152. }
  58153. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58154. import { Scene } from "babylonjs/scene";
  58155. import { Color3 } from "babylonjs/Maths/math.color";
  58156. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58157. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58158. /**
  58159. * The Physically based simple base material of BJS.
  58160. *
  58161. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58162. * It is used as the base class for both the specGloss and metalRough conventions.
  58163. */
  58164. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58165. /**
  58166. * Number of Simultaneous lights allowed on the material.
  58167. */
  58168. maxSimultaneousLights: number;
  58169. /**
  58170. * If sets to true, disables all the lights affecting the material.
  58171. */
  58172. disableLighting: boolean;
  58173. /**
  58174. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58175. */
  58176. environmentTexture: BaseTexture;
  58177. /**
  58178. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58179. */
  58180. invertNormalMapX: boolean;
  58181. /**
  58182. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58183. */
  58184. invertNormalMapY: boolean;
  58185. /**
  58186. * Normal map used in the model.
  58187. */
  58188. normalTexture: BaseTexture;
  58189. /**
  58190. * Emissivie color used to self-illuminate the model.
  58191. */
  58192. emissiveColor: Color3;
  58193. /**
  58194. * Emissivie texture used to self-illuminate the model.
  58195. */
  58196. emissiveTexture: BaseTexture;
  58197. /**
  58198. * Occlusion Channel Strenght.
  58199. */
  58200. occlusionStrength: number;
  58201. /**
  58202. * Occlusion Texture of the material (adding extra occlusion effects).
  58203. */
  58204. occlusionTexture: BaseTexture;
  58205. /**
  58206. * Defines the alpha limits in alpha test mode.
  58207. */
  58208. alphaCutOff: number;
  58209. /**
  58210. * Gets the current double sided mode.
  58211. */
  58212. get doubleSided(): boolean;
  58213. /**
  58214. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58215. */
  58216. set doubleSided(value: boolean);
  58217. /**
  58218. * Stores the pre-calculated light information of a mesh in a texture.
  58219. */
  58220. lightmapTexture: BaseTexture;
  58221. /**
  58222. * If true, the light map contains occlusion information instead of lighting info.
  58223. */
  58224. useLightmapAsShadowmap: boolean;
  58225. /**
  58226. * Instantiates a new PBRMaterial instance.
  58227. *
  58228. * @param name The material name
  58229. * @param scene The scene the material will be use in.
  58230. */
  58231. constructor(name: string, scene: Scene);
  58232. getClassName(): string;
  58233. }
  58234. }
  58235. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58236. import { Scene } from "babylonjs/scene";
  58237. import { Color3 } from "babylonjs/Maths/math.color";
  58238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58239. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58240. /**
  58241. * The PBR material of BJS following the metal roughness convention.
  58242. *
  58243. * This fits to the PBR convention in the GLTF definition:
  58244. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58245. */
  58246. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58247. /**
  58248. * The base color has two different interpretations depending on the value of metalness.
  58249. * When the material is a metal, the base color is the specific measured reflectance value
  58250. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58251. * of the material.
  58252. */
  58253. baseColor: Color3;
  58254. /**
  58255. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58256. * well as opacity information in the alpha channel.
  58257. */
  58258. baseTexture: BaseTexture;
  58259. /**
  58260. * Specifies the metallic scalar value of the material.
  58261. * Can also be used to scale the metalness values of the metallic texture.
  58262. */
  58263. metallic: number;
  58264. /**
  58265. * Specifies the roughness scalar value of the material.
  58266. * Can also be used to scale the roughness values of the metallic texture.
  58267. */
  58268. roughness: number;
  58269. /**
  58270. * Texture containing both the metallic value in the B channel and the
  58271. * roughness value in the G channel to keep better precision.
  58272. */
  58273. metallicRoughnessTexture: BaseTexture;
  58274. /**
  58275. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58276. *
  58277. * @param name The material name
  58278. * @param scene The scene the material will be use in.
  58279. */
  58280. constructor(name: string, scene: Scene);
  58281. /**
  58282. * Return the currrent class name of the material.
  58283. */
  58284. getClassName(): string;
  58285. /**
  58286. * Makes a duplicate of the current material.
  58287. * @param name - name to use for the new material.
  58288. */
  58289. clone(name: string): PBRMetallicRoughnessMaterial;
  58290. /**
  58291. * Serialize the material to a parsable JSON object.
  58292. */
  58293. serialize(): any;
  58294. /**
  58295. * Parses a JSON object correponding to the serialize function.
  58296. */
  58297. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58298. }
  58299. }
  58300. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58301. import { Scene } from "babylonjs/scene";
  58302. import { Color3 } from "babylonjs/Maths/math.color";
  58303. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58304. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58305. /**
  58306. * The PBR material of BJS following the specular glossiness convention.
  58307. *
  58308. * This fits to the PBR convention in the GLTF definition:
  58309. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58310. */
  58311. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58312. /**
  58313. * Specifies the diffuse color of the material.
  58314. */
  58315. diffuseColor: Color3;
  58316. /**
  58317. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58318. * channel.
  58319. */
  58320. diffuseTexture: BaseTexture;
  58321. /**
  58322. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58323. */
  58324. specularColor: Color3;
  58325. /**
  58326. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58327. */
  58328. glossiness: number;
  58329. /**
  58330. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58331. */
  58332. specularGlossinessTexture: BaseTexture;
  58333. /**
  58334. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58335. *
  58336. * @param name The material name
  58337. * @param scene The scene the material will be use in.
  58338. */
  58339. constructor(name: string, scene: Scene);
  58340. /**
  58341. * Return the currrent class name of the material.
  58342. */
  58343. getClassName(): string;
  58344. /**
  58345. * Makes a duplicate of the current material.
  58346. * @param name - name to use for the new material.
  58347. */
  58348. clone(name: string): PBRSpecularGlossinessMaterial;
  58349. /**
  58350. * Serialize the material to a parsable JSON object.
  58351. */
  58352. serialize(): any;
  58353. /**
  58354. * Parses a JSON object correponding to the serialize function.
  58355. */
  58356. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58357. }
  58358. }
  58359. declare module "babylonjs/Materials/PBR/index" {
  58360. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58361. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58362. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58363. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58364. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58365. }
  58366. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58367. import { Nullable } from "babylonjs/types";
  58368. import { Scene } from "babylonjs/scene";
  58369. import { Matrix } from "babylonjs/Maths/math.vector";
  58370. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58371. /**
  58372. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58373. * It can help converting any input color in a desired output one. This can then be used to create effects
  58374. * from sepia, black and white to sixties or futuristic rendering...
  58375. *
  58376. * The only supported format is currently 3dl.
  58377. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58378. */
  58379. export class ColorGradingTexture extends BaseTexture {
  58380. /**
  58381. * The current texture matrix. (will always be identity in color grading texture)
  58382. */
  58383. private _textureMatrix;
  58384. /**
  58385. * The texture URL.
  58386. */
  58387. url: string;
  58388. /**
  58389. * Empty line regex stored for GC.
  58390. */
  58391. private static _noneEmptyLineRegex;
  58392. private _engine;
  58393. /**
  58394. * Instantiates a ColorGradingTexture from the following parameters.
  58395. *
  58396. * @param url The location of the color gradind data (currently only supporting 3dl)
  58397. * @param scene The scene the texture will be used in
  58398. */
  58399. constructor(url: string, scene: Scene);
  58400. /**
  58401. * Returns the texture matrix used in most of the material.
  58402. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58403. */
  58404. getTextureMatrix(): Matrix;
  58405. /**
  58406. * Occurs when the file being loaded is a .3dl LUT file.
  58407. */
  58408. private load3dlTexture;
  58409. /**
  58410. * Starts the loading process of the texture.
  58411. */
  58412. private loadTexture;
  58413. /**
  58414. * Clones the color gradind texture.
  58415. */
  58416. clone(): ColorGradingTexture;
  58417. /**
  58418. * Called during delayed load for textures.
  58419. */
  58420. delayLoad(): void;
  58421. /**
  58422. * Parses a color grading texture serialized by Babylon.
  58423. * @param parsedTexture The texture information being parsedTexture
  58424. * @param scene The scene to load the texture in
  58425. * @param rootUrl The root url of the data assets to load
  58426. * @return A color gradind texture
  58427. */
  58428. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58429. /**
  58430. * Serializes the LUT texture to json format.
  58431. */
  58432. serialize(): any;
  58433. }
  58434. }
  58435. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58436. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58437. import { Scene } from "babylonjs/scene";
  58438. import { Nullable } from "babylonjs/types";
  58439. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58440. /**
  58441. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58442. */
  58443. export class EquiRectangularCubeTexture extends BaseTexture {
  58444. /** The six faces of the cube. */
  58445. private static _FacesMapping;
  58446. private _noMipmap;
  58447. private _onLoad;
  58448. private _onError;
  58449. /** The size of the cubemap. */
  58450. private _size;
  58451. /** The buffer of the image. */
  58452. private _buffer;
  58453. /** The width of the input image. */
  58454. private _width;
  58455. /** The height of the input image. */
  58456. private _height;
  58457. /** The URL to the image. */
  58458. url: string;
  58459. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58460. coordinatesMode: number;
  58461. /**
  58462. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58463. * @param url The location of the image
  58464. * @param scene The scene the texture will be used in
  58465. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58466. * @param noMipmap Forces to not generate the mipmap if true
  58467. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58468. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58469. * @param onLoad — defines a callback called when texture is loaded
  58470. * @param onError — defines a callback called if there is an error
  58471. */
  58472. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58473. /**
  58474. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58475. */
  58476. private loadImage;
  58477. /**
  58478. * Convert the image buffer into a cubemap and create a CubeTexture.
  58479. */
  58480. private loadTexture;
  58481. /**
  58482. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58483. * @param buffer The ArrayBuffer that should be converted.
  58484. * @returns The buffer as Float32Array.
  58485. */
  58486. private getFloat32ArrayFromArrayBuffer;
  58487. /**
  58488. * Get the current class name of the texture useful for serialization or dynamic coding.
  58489. * @returns "EquiRectangularCubeTexture"
  58490. */
  58491. getClassName(): string;
  58492. /**
  58493. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58494. * @returns A clone of the current EquiRectangularCubeTexture.
  58495. */
  58496. clone(): EquiRectangularCubeTexture;
  58497. }
  58498. }
  58499. declare module "babylonjs/Misc/tga" {
  58500. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58501. /**
  58502. * Based on jsTGALoader - Javascript loader for TGA file
  58503. * By Vincent Thibault
  58504. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58505. */
  58506. export class TGATools {
  58507. private static _TYPE_INDEXED;
  58508. private static _TYPE_RGB;
  58509. private static _TYPE_GREY;
  58510. private static _TYPE_RLE_INDEXED;
  58511. private static _TYPE_RLE_RGB;
  58512. private static _TYPE_RLE_GREY;
  58513. private static _ORIGIN_MASK;
  58514. private static _ORIGIN_SHIFT;
  58515. private static _ORIGIN_BL;
  58516. private static _ORIGIN_BR;
  58517. private static _ORIGIN_UL;
  58518. private static _ORIGIN_UR;
  58519. /**
  58520. * Gets the header of a TGA file
  58521. * @param data defines the TGA data
  58522. * @returns the header
  58523. */
  58524. static GetTGAHeader(data: Uint8Array): any;
  58525. /**
  58526. * Uploads TGA content to a Babylon Texture
  58527. * @hidden
  58528. */
  58529. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58530. /** @hidden */
  58531. 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;
  58532. /** @hidden */
  58533. 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;
  58534. /** @hidden */
  58535. 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;
  58536. /** @hidden */
  58537. 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;
  58538. /** @hidden */
  58539. 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;
  58540. /** @hidden */
  58541. 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;
  58542. }
  58543. }
  58544. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58545. import { Nullable } from "babylonjs/types";
  58546. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58547. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58548. /**
  58549. * Implementation of the TGA Texture Loader.
  58550. * @hidden
  58551. */
  58552. export class _TGATextureLoader implements IInternalTextureLoader {
  58553. /**
  58554. * Defines wether the loader supports cascade loading the different faces.
  58555. */
  58556. readonly supportCascades: boolean;
  58557. /**
  58558. * This returns if the loader support the current file information.
  58559. * @param extension defines the file extension of the file being loaded
  58560. * @returns true if the loader can load the specified file
  58561. */
  58562. canLoad(extension: string): boolean;
  58563. /**
  58564. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58565. * @param data contains the texture data
  58566. * @param texture defines the BabylonJS internal texture
  58567. * @param createPolynomials will be true if polynomials have been requested
  58568. * @param onLoad defines the callback to trigger once the texture is ready
  58569. * @param onError defines the callback to trigger in case of error
  58570. */
  58571. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58572. /**
  58573. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58574. * @param data contains the texture data
  58575. * @param texture defines the BabylonJS internal texture
  58576. * @param callback defines the method to call once ready to upload
  58577. */
  58578. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58579. }
  58580. }
  58581. declare module "babylonjs/Misc/basis" {
  58582. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58583. /**
  58584. * Info about the .basis files
  58585. */
  58586. class BasisFileInfo {
  58587. /**
  58588. * If the file has alpha
  58589. */
  58590. hasAlpha: boolean;
  58591. /**
  58592. * Info about each image of the basis file
  58593. */
  58594. images: Array<{
  58595. levels: Array<{
  58596. width: number;
  58597. height: number;
  58598. transcodedPixels: ArrayBufferView;
  58599. }>;
  58600. }>;
  58601. }
  58602. /**
  58603. * Result of transcoding a basis file
  58604. */
  58605. class TranscodeResult {
  58606. /**
  58607. * Info about the .basis file
  58608. */
  58609. fileInfo: BasisFileInfo;
  58610. /**
  58611. * Format to use when loading the file
  58612. */
  58613. format: number;
  58614. }
  58615. /**
  58616. * Configuration options for the Basis transcoder
  58617. */
  58618. export class BasisTranscodeConfiguration {
  58619. /**
  58620. * Supported compression formats used to determine the supported output format of the transcoder
  58621. */
  58622. supportedCompressionFormats?: {
  58623. /**
  58624. * etc1 compression format
  58625. */
  58626. etc1?: boolean;
  58627. /**
  58628. * s3tc compression format
  58629. */
  58630. s3tc?: boolean;
  58631. /**
  58632. * pvrtc compression format
  58633. */
  58634. pvrtc?: boolean;
  58635. /**
  58636. * etc2 compression format
  58637. */
  58638. etc2?: boolean;
  58639. };
  58640. /**
  58641. * If mipmap levels should be loaded for transcoded images (Default: true)
  58642. */
  58643. loadMipmapLevels?: boolean;
  58644. /**
  58645. * Index of a single image to load (Default: all images)
  58646. */
  58647. loadSingleImage?: number;
  58648. }
  58649. /**
  58650. * Used to load .Basis files
  58651. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58652. */
  58653. export class BasisTools {
  58654. private static _IgnoreSupportedFormats;
  58655. /**
  58656. * URL to use when loading the basis transcoder
  58657. */
  58658. static JSModuleURL: string;
  58659. /**
  58660. * URL to use when loading the wasm module for the transcoder
  58661. */
  58662. static WasmModuleURL: string;
  58663. /**
  58664. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58665. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58666. * @returns internal format corresponding to the Basis format
  58667. */
  58668. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58669. private static _WorkerPromise;
  58670. private static _Worker;
  58671. private static _actionId;
  58672. private static _CreateWorkerAsync;
  58673. /**
  58674. * Transcodes a loaded image file to compressed pixel data
  58675. * @param data image data to transcode
  58676. * @param config configuration options for the transcoding
  58677. * @returns a promise resulting in the transcoded image
  58678. */
  58679. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58680. /**
  58681. * Loads a texture from the transcode result
  58682. * @param texture texture load to
  58683. * @param transcodeResult the result of transcoding the basis file to load from
  58684. */
  58685. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58686. }
  58687. }
  58688. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58689. import { Nullable } from "babylonjs/types";
  58690. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58691. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58692. /**
  58693. * Loader for .basis file format
  58694. */
  58695. export class _BasisTextureLoader implements IInternalTextureLoader {
  58696. /**
  58697. * Defines whether the loader supports cascade loading the different faces.
  58698. */
  58699. readonly supportCascades: boolean;
  58700. /**
  58701. * This returns if the loader support the current file information.
  58702. * @param extension defines the file extension of the file being loaded
  58703. * @returns true if the loader can load the specified file
  58704. */
  58705. canLoad(extension: string): boolean;
  58706. /**
  58707. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58708. * @param data contains the texture data
  58709. * @param texture defines the BabylonJS internal texture
  58710. * @param createPolynomials will be true if polynomials have been requested
  58711. * @param onLoad defines the callback to trigger once the texture is ready
  58712. * @param onError defines the callback to trigger in case of error
  58713. */
  58714. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58715. /**
  58716. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58717. * @param data contains the texture data
  58718. * @param texture defines the BabylonJS internal texture
  58719. * @param callback defines the method to call once ready to upload
  58720. */
  58721. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58722. }
  58723. }
  58724. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58725. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58726. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58727. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58728. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58729. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58730. }
  58731. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58732. import { Scene } from "babylonjs/scene";
  58733. import { Texture } from "babylonjs/Materials/Textures/texture";
  58734. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58735. /**
  58736. * 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.
  58737. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58738. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58739. */
  58740. export class CustomProceduralTexture extends ProceduralTexture {
  58741. private _animate;
  58742. private _time;
  58743. private _config;
  58744. private _texturePath;
  58745. /**
  58746. * Instantiates a new Custom Procedural Texture.
  58747. * 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.
  58748. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58749. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58750. * @param name Define the name of the texture
  58751. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58752. * @param size Define the size of the texture to create
  58753. * @param scene Define the scene the texture belongs to
  58754. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58755. * @param generateMipMaps Define if the texture should creates mip maps or not
  58756. */
  58757. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58758. private _loadJson;
  58759. /**
  58760. * Is the texture ready to be used ? (rendered at least once)
  58761. * @returns true if ready, otherwise, false.
  58762. */
  58763. isReady(): boolean;
  58764. /**
  58765. * Render the texture to its associated render target.
  58766. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58767. */
  58768. render(useCameraPostProcess?: boolean): void;
  58769. /**
  58770. * Update the list of dependant textures samplers in the shader.
  58771. */
  58772. updateTextures(): void;
  58773. /**
  58774. * Update the uniform values of the procedural texture in the shader.
  58775. */
  58776. updateShaderUniforms(): void;
  58777. /**
  58778. * Define if the texture animates or not.
  58779. */
  58780. get animate(): boolean;
  58781. set animate(value: boolean);
  58782. }
  58783. }
  58784. declare module "babylonjs/Shaders/noise.fragment" {
  58785. /** @hidden */
  58786. export var noisePixelShader: {
  58787. name: string;
  58788. shader: string;
  58789. };
  58790. }
  58791. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58792. import { Nullable } from "babylonjs/types";
  58793. import { Scene } from "babylonjs/scene";
  58794. import { Texture } from "babylonjs/Materials/Textures/texture";
  58795. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58796. import "babylonjs/Shaders/noise.fragment";
  58797. /**
  58798. * Class used to generate noise procedural textures
  58799. */
  58800. export class NoiseProceduralTexture extends ProceduralTexture {
  58801. private _time;
  58802. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58803. brightness: number;
  58804. /** Defines the number of octaves to process */
  58805. octaves: number;
  58806. /** Defines the level of persistence (0.8 by default) */
  58807. persistence: number;
  58808. /** Gets or sets animation speed factor (default is 1) */
  58809. animationSpeedFactor: number;
  58810. /**
  58811. * Creates a new NoiseProceduralTexture
  58812. * @param name defines the name fo the texture
  58813. * @param size defines the size of the texture (default is 256)
  58814. * @param scene defines the hosting scene
  58815. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58816. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58817. */
  58818. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58819. private _updateShaderUniforms;
  58820. protected _getDefines(): string;
  58821. /** Generate the current state of the procedural texture */
  58822. render(useCameraPostProcess?: boolean): void;
  58823. /**
  58824. * Serializes this noise procedural texture
  58825. * @returns a serialized noise procedural texture object
  58826. */
  58827. serialize(): any;
  58828. /**
  58829. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58830. * @param parsedTexture defines parsed texture data
  58831. * @param scene defines the current scene
  58832. * @param rootUrl defines the root URL containing noise procedural texture information
  58833. * @returns a parsed NoiseProceduralTexture
  58834. */
  58835. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58836. }
  58837. }
  58838. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58839. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58840. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58841. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58842. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58843. }
  58844. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58845. import { Nullable } from "babylonjs/types";
  58846. import { Scene } from "babylonjs/scene";
  58847. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58848. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58849. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58850. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58851. /**
  58852. * Raw cube texture where the raw buffers are passed in
  58853. */
  58854. export class RawCubeTexture extends CubeTexture {
  58855. /**
  58856. * Creates a cube texture where the raw buffers are passed in.
  58857. * @param scene defines the scene the texture is attached to
  58858. * @param data defines the array of data to use to create each face
  58859. * @param size defines the size of the textures
  58860. * @param format defines the format of the data
  58861. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58862. * @param generateMipMaps defines if the engine should generate the mip levels
  58863. * @param invertY defines if data must be stored with Y axis inverted
  58864. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58865. * @param compression defines the compression used (null by default)
  58866. */
  58867. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58868. /**
  58869. * Updates the raw cube texture.
  58870. * @param data defines the data to store
  58871. * @param format defines the data format
  58872. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58873. * @param invertY defines if data must be stored with Y axis inverted
  58874. * @param compression defines the compression used (null by default)
  58875. * @param level defines which level of the texture to update
  58876. */
  58877. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58878. /**
  58879. * Updates a raw cube texture with RGBD encoded data.
  58880. * @param data defines the array of data [mipmap][face] to use to create each face
  58881. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58882. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58883. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58884. * @returns a promsie that resolves when the operation is complete
  58885. */
  58886. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58887. /**
  58888. * Clones the raw cube texture.
  58889. * @return a new cube texture
  58890. */
  58891. clone(): CubeTexture;
  58892. /** @hidden */
  58893. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58894. }
  58895. }
  58896. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58897. import { Scene } from "babylonjs/scene";
  58898. import { Texture } from "babylonjs/Materials/Textures/texture";
  58899. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58900. /**
  58901. * Class used to store 3D textures containing user data
  58902. */
  58903. export class RawTexture3D extends Texture {
  58904. /** Gets or sets the texture format to use */
  58905. format: number;
  58906. private _engine;
  58907. /**
  58908. * Create a new RawTexture3D
  58909. * @param data defines the data of the texture
  58910. * @param width defines the width of the texture
  58911. * @param height defines the height of the texture
  58912. * @param depth defines the depth of the texture
  58913. * @param format defines the texture format to use
  58914. * @param scene defines the hosting scene
  58915. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58916. * @param invertY defines if texture must be stored with Y axis inverted
  58917. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58918. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58919. */
  58920. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58921. /** Gets or sets the texture format to use */
  58922. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58923. /**
  58924. * Update the texture with new data
  58925. * @param data defines the data to store in the texture
  58926. */
  58927. update(data: ArrayBufferView): void;
  58928. }
  58929. }
  58930. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58931. import { Scene } from "babylonjs/scene";
  58932. import { Texture } from "babylonjs/Materials/Textures/texture";
  58933. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58934. /**
  58935. * Class used to store 2D array textures containing user data
  58936. */
  58937. export class RawTexture2DArray extends Texture {
  58938. /** Gets or sets the texture format to use */
  58939. format: number;
  58940. private _engine;
  58941. /**
  58942. * Create a new RawTexture2DArray
  58943. * @param data defines the data of the texture
  58944. * @param width defines the width of the texture
  58945. * @param height defines the height of the texture
  58946. * @param depth defines the number of layers of the texture
  58947. * @param format defines the texture format to use
  58948. * @param scene defines the hosting scene
  58949. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58950. * @param invertY defines if texture must be stored with Y axis inverted
  58951. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58952. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58953. */
  58954. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58955. /** Gets or sets the texture format to use */
  58956. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58957. /**
  58958. * Update the texture with new data
  58959. * @param data defines the data to store in the texture
  58960. */
  58961. update(data: ArrayBufferView): void;
  58962. }
  58963. }
  58964. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58965. import { Scene } from "babylonjs/scene";
  58966. import { Plane } from "babylonjs/Maths/math.plane";
  58967. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58968. /**
  58969. * Creates a refraction texture used by refraction channel of the standard material.
  58970. * It is like a mirror but to see through a material.
  58971. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58972. */
  58973. export class RefractionTexture extends RenderTargetTexture {
  58974. /**
  58975. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58976. * 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.
  58977. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58978. */
  58979. refractionPlane: Plane;
  58980. /**
  58981. * Define how deep under the surface we should see.
  58982. */
  58983. depth: number;
  58984. /**
  58985. * Creates a refraction texture used by refraction channel of the standard material.
  58986. * It is like a mirror but to see through a material.
  58987. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58988. * @param name Define the texture name
  58989. * @param size Define the size of the underlying texture
  58990. * @param scene Define the scene the refraction belongs to
  58991. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58992. */
  58993. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58994. /**
  58995. * Clone the refraction texture.
  58996. * @returns the cloned texture
  58997. */
  58998. clone(): RefractionTexture;
  58999. /**
  59000. * Serialize the texture to a JSON representation you could use in Parse later on
  59001. * @returns the serialized JSON representation
  59002. */
  59003. serialize(): any;
  59004. }
  59005. }
  59006. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59007. import { Nullable } from "babylonjs/types";
  59008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59009. import { Matrix } from "babylonjs/Maths/math.vector";
  59010. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59011. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59012. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59013. import { Scene } from "babylonjs/scene";
  59014. /**
  59015. * Defines the options related to the creation of an HtmlElementTexture
  59016. */
  59017. export interface IHtmlElementTextureOptions {
  59018. /**
  59019. * Defines wether mip maps should be created or not.
  59020. */
  59021. generateMipMaps?: boolean;
  59022. /**
  59023. * Defines the sampling mode of the texture.
  59024. */
  59025. samplingMode?: number;
  59026. /**
  59027. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59028. */
  59029. engine: Nullable<ThinEngine>;
  59030. /**
  59031. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59032. */
  59033. scene: Nullable<Scene>;
  59034. }
  59035. /**
  59036. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59037. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59038. * is automatically managed.
  59039. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59040. * in your application.
  59041. *
  59042. * As the update is not automatic, you need to call them manually.
  59043. */
  59044. export class HtmlElementTexture extends BaseTexture {
  59045. /**
  59046. * The texture URL.
  59047. */
  59048. element: HTMLVideoElement | HTMLCanvasElement;
  59049. private static readonly DefaultOptions;
  59050. private _textureMatrix;
  59051. private _engine;
  59052. private _isVideo;
  59053. private _generateMipMaps;
  59054. private _samplingMode;
  59055. /**
  59056. * Instantiates a HtmlElementTexture from the following parameters.
  59057. *
  59058. * @param name Defines the name of the texture
  59059. * @param element Defines the video or canvas the texture is filled with
  59060. * @param options Defines the other none mandatory texture creation options
  59061. */
  59062. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59063. private _createInternalTexture;
  59064. /**
  59065. * Returns the texture matrix used in most of the material.
  59066. */
  59067. getTextureMatrix(): Matrix;
  59068. /**
  59069. * Updates the content of the texture.
  59070. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59071. */
  59072. update(invertY?: Nullable<boolean>): void;
  59073. }
  59074. }
  59075. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59076. import { Vector2 } from "babylonjs/Maths/math.vector";
  59077. /**
  59078. * Defines the basic options interface of a TexturePacker Frame
  59079. */
  59080. export interface ITexturePackerFrame {
  59081. /**
  59082. * The frame ID
  59083. */
  59084. id: number;
  59085. /**
  59086. * The frames Scale
  59087. */
  59088. scale: Vector2;
  59089. /**
  59090. * The Frames offset
  59091. */
  59092. offset: Vector2;
  59093. }
  59094. /**
  59095. * This is a support class for frame Data on texture packer sets.
  59096. */
  59097. export class TexturePackerFrame implements ITexturePackerFrame {
  59098. /**
  59099. * The frame ID
  59100. */
  59101. id: number;
  59102. /**
  59103. * The frames Scale
  59104. */
  59105. scale: Vector2;
  59106. /**
  59107. * The Frames offset
  59108. */
  59109. offset: Vector2;
  59110. /**
  59111. * Initializes a texture package frame.
  59112. * @param id The numerical frame identifier
  59113. * @param scale Scalar Vector2 for UV frame
  59114. * @param offset Vector2 for the frame position in UV units.
  59115. * @returns TexturePackerFrame
  59116. */
  59117. constructor(id: number, scale: Vector2, offset: Vector2);
  59118. }
  59119. }
  59120. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59122. import { Scene } from "babylonjs/scene";
  59123. import { Nullable } from "babylonjs/types";
  59124. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59125. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59126. /**
  59127. * Defines the basic options interface of a TexturePacker
  59128. */
  59129. export interface ITexturePackerOptions {
  59130. /**
  59131. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59132. */
  59133. map?: string[];
  59134. /**
  59135. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59136. */
  59137. uvsIn?: string;
  59138. /**
  59139. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59140. */
  59141. uvsOut?: string;
  59142. /**
  59143. * number representing the layout style. Defaults to LAYOUT_STRIP
  59144. */
  59145. layout?: number;
  59146. /**
  59147. * number of columns if using custom column count layout(2). This defaults to 4.
  59148. */
  59149. colnum?: number;
  59150. /**
  59151. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59152. */
  59153. updateInputMeshes?: boolean;
  59154. /**
  59155. * boolean flag to dispose all the source textures. Defaults to true.
  59156. */
  59157. disposeSources?: boolean;
  59158. /**
  59159. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59160. */
  59161. fillBlanks?: boolean;
  59162. /**
  59163. * string value representing the context fill style color. Defaults to 'black'.
  59164. */
  59165. customFillColor?: string;
  59166. /**
  59167. * Width and Height Value of each Frame in the TexturePacker Sets
  59168. */
  59169. frameSize?: number;
  59170. /**
  59171. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59172. */
  59173. paddingRatio?: number;
  59174. /**
  59175. * Number that declares the fill method for the padding gutter.
  59176. */
  59177. paddingMode?: number;
  59178. /**
  59179. * If in SUBUV_COLOR padding mode what color to use.
  59180. */
  59181. paddingColor?: Color3 | Color4;
  59182. }
  59183. /**
  59184. * Defines the basic interface of a TexturePacker JSON File
  59185. */
  59186. export interface ITexturePackerJSON {
  59187. /**
  59188. * The frame ID
  59189. */
  59190. name: string;
  59191. /**
  59192. * The base64 channel data
  59193. */
  59194. sets: any;
  59195. /**
  59196. * The options of the Packer
  59197. */
  59198. options: ITexturePackerOptions;
  59199. /**
  59200. * The frame data of the Packer
  59201. */
  59202. frames: Array<number>;
  59203. }
  59204. /**
  59205. * This is a support class that generates a series of packed texture sets.
  59206. * @see https://doc.babylonjs.com/babylon101/materials
  59207. */
  59208. export class TexturePacker {
  59209. /** Packer Layout Constant 0 */
  59210. static readonly LAYOUT_STRIP: number;
  59211. /** Packer Layout Constant 1 */
  59212. static readonly LAYOUT_POWER2: number;
  59213. /** Packer Layout Constant 2 */
  59214. static readonly LAYOUT_COLNUM: number;
  59215. /** Packer Layout Constant 0 */
  59216. static readonly SUBUV_WRAP: number;
  59217. /** Packer Layout Constant 1 */
  59218. static readonly SUBUV_EXTEND: number;
  59219. /** Packer Layout Constant 2 */
  59220. static readonly SUBUV_COLOR: number;
  59221. /** The Name of the Texture Package */
  59222. name: string;
  59223. /** The scene scope of the TexturePacker */
  59224. scene: Scene;
  59225. /** The Meshes to target */
  59226. meshes: AbstractMesh[];
  59227. /** Arguments passed with the Constructor */
  59228. options: ITexturePackerOptions;
  59229. /** The promise that is started upon initialization */
  59230. promise: Nullable<Promise<TexturePacker | string>>;
  59231. /** The Container object for the channel sets that are generated */
  59232. sets: object;
  59233. /** The Container array for the frames that are generated */
  59234. frames: TexturePackerFrame[];
  59235. /** The expected number of textures the system is parsing. */
  59236. private _expecting;
  59237. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59238. private _paddingValue;
  59239. /**
  59240. * Initializes a texture package series from an array of meshes or a single mesh.
  59241. * @param name The name of the package
  59242. * @param meshes The target meshes to compose the package from
  59243. * @param options The arguments that texture packer should follow while building.
  59244. * @param scene The scene which the textures are scoped to.
  59245. * @returns TexturePacker
  59246. */
  59247. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59248. /**
  59249. * Starts the package process
  59250. * @param resolve The promises resolution function
  59251. * @returns TexturePacker
  59252. */
  59253. private _createFrames;
  59254. /**
  59255. * Calculates the Size of the Channel Sets
  59256. * @returns Vector2
  59257. */
  59258. private _calculateSize;
  59259. /**
  59260. * Calculates the UV data for the frames.
  59261. * @param baseSize the base frameSize
  59262. * @param padding the base frame padding
  59263. * @param dtSize size of the Dynamic Texture for that channel
  59264. * @param dtUnits is 1/dtSize
  59265. * @param update flag to update the input meshes
  59266. */
  59267. private _calculateMeshUVFrames;
  59268. /**
  59269. * Calculates the frames Offset.
  59270. * @param index of the frame
  59271. * @returns Vector2
  59272. */
  59273. private _getFrameOffset;
  59274. /**
  59275. * Updates a Mesh to the frame data
  59276. * @param mesh that is the target
  59277. * @param frameID or the frame index
  59278. */
  59279. private _updateMeshUV;
  59280. /**
  59281. * Updates a Meshes materials to use the texture packer channels
  59282. * @param m is the mesh to target
  59283. * @param force all channels on the packer to be set.
  59284. */
  59285. private _updateTextureReferences;
  59286. /**
  59287. * Public method to set a Mesh to a frame
  59288. * @param m that is the target
  59289. * @param frameID or the frame index
  59290. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59291. */
  59292. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59293. /**
  59294. * Starts the async promise to compile the texture packer.
  59295. * @returns Promise<void>
  59296. */
  59297. processAsync(): Promise<void>;
  59298. /**
  59299. * Disposes all textures associated with this packer
  59300. */
  59301. dispose(): void;
  59302. /**
  59303. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59304. * @param imageType is the image type to use.
  59305. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59306. */
  59307. download(imageType?: string, quality?: number): void;
  59308. /**
  59309. * Public method to load a texturePacker JSON file.
  59310. * @param data of the JSON file in string format.
  59311. */
  59312. updateFromJSON(data: string): void;
  59313. }
  59314. }
  59315. declare module "babylonjs/Materials/Textures/Packer/index" {
  59316. export * from "babylonjs/Materials/Textures/Packer/packer";
  59317. export * from "babylonjs/Materials/Textures/Packer/frame";
  59318. }
  59319. declare module "babylonjs/Materials/Textures/index" {
  59320. export * from "babylonjs/Materials/Textures/baseTexture";
  59321. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59322. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59323. export * from "babylonjs/Materials/Textures/cubeTexture";
  59324. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59325. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59326. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59327. export * from "babylonjs/Materials/Textures/internalTexture";
  59328. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59329. export * from "babylonjs/Materials/Textures/Loaders/index";
  59330. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59331. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59332. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59333. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59334. export * from "babylonjs/Materials/Textures/rawTexture";
  59335. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59336. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59337. export * from "babylonjs/Materials/Textures/refractionTexture";
  59338. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59339. export * from "babylonjs/Materials/Textures/texture";
  59340. export * from "babylonjs/Materials/Textures/videoTexture";
  59341. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59342. export * from "babylonjs/Materials/Textures/Packer/index";
  59343. }
  59344. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59345. /**
  59346. * Enum used to define the target of a block
  59347. */
  59348. export enum NodeMaterialBlockTargets {
  59349. /** Vertex shader */
  59350. Vertex = 1,
  59351. /** Fragment shader */
  59352. Fragment = 2,
  59353. /** Neutral */
  59354. Neutral = 4,
  59355. /** Vertex and Fragment */
  59356. VertexAndFragment = 3
  59357. }
  59358. }
  59359. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59360. /**
  59361. * Defines the kind of connection point for node based material
  59362. */
  59363. export enum NodeMaterialBlockConnectionPointTypes {
  59364. /** Float */
  59365. Float = 1,
  59366. /** Int */
  59367. Int = 2,
  59368. /** Vector2 */
  59369. Vector2 = 4,
  59370. /** Vector3 */
  59371. Vector3 = 8,
  59372. /** Vector4 */
  59373. Vector4 = 16,
  59374. /** Color3 */
  59375. Color3 = 32,
  59376. /** Color4 */
  59377. Color4 = 64,
  59378. /** Matrix */
  59379. Matrix = 128,
  59380. /** Detect type based on connection */
  59381. AutoDetect = 1024,
  59382. /** Output type that will be defined by input type */
  59383. BasedOnInput = 2048
  59384. }
  59385. }
  59386. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59387. /**
  59388. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59389. */
  59390. export enum NodeMaterialBlockConnectionPointMode {
  59391. /** Value is an uniform */
  59392. Uniform = 0,
  59393. /** Value is a mesh attribute */
  59394. Attribute = 1,
  59395. /** Value is a varying between vertex and fragment shaders */
  59396. Varying = 2,
  59397. /** Mode is undefined */
  59398. Undefined = 3
  59399. }
  59400. }
  59401. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59402. /**
  59403. * Enum used to define system values e.g. values automatically provided by the system
  59404. */
  59405. export enum NodeMaterialSystemValues {
  59406. /** World */
  59407. World = 1,
  59408. /** View */
  59409. View = 2,
  59410. /** Projection */
  59411. Projection = 3,
  59412. /** ViewProjection */
  59413. ViewProjection = 4,
  59414. /** WorldView */
  59415. WorldView = 5,
  59416. /** WorldViewProjection */
  59417. WorldViewProjection = 6,
  59418. /** CameraPosition */
  59419. CameraPosition = 7,
  59420. /** Fog Color */
  59421. FogColor = 8,
  59422. /** Delta time */
  59423. DeltaTime = 9
  59424. }
  59425. }
  59426. declare module "babylonjs/Materials/Node/Enums/index" {
  59427. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59428. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59429. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59430. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59431. }
  59432. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59434. /**
  59435. * Root class for all node material optimizers
  59436. */
  59437. export class NodeMaterialOptimizer {
  59438. /**
  59439. * Function used to optimize a NodeMaterial graph
  59440. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59441. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59442. */
  59443. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59444. }
  59445. }
  59446. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59447. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59448. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59449. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59450. import { Scene } from "babylonjs/scene";
  59451. /**
  59452. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59453. */
  59454. export class TransformBlock extends NodeMaterialBlock {
  59455. /**
  59456. * Defines the value to use to complement W value to transform it to a Vector4
  59457. */
  59458. complementW: number;
  59459. /**
  59460. * Defines the value to use to complement z value to transform it to a Vector4
  59461. */
  59462. complementZ: number;
  59463. /**
  59464. * Creates a new TransformBlock
  59465. * @param name defines the block name
  59466. */
  59467. constructor(name: string);
  59468. /**
  59469. * Gets the current class name
  59470. * @returns the class name
  59471. */
  59472. getClassName(): string;
  59473. /**
  59474. * Gets the vector input
  59475. */
  59476. get vector(): NodeMaterialConnectionPoint;
  59477. /**
  59478. * Gets the output component
  59479. */
  59480. get output(): NodeMaterialConnectionPoint;
  59481. /**
  59482. * Gets the xyz output component
  59483. */
  59484. get xyz(): NodeMaterialConnectionPoint;
  59485. /**
  59486. * Gets the matrix transform input
  59487. */
  59488. get transform(): NodeMaterialConnectionPoint;
  59489. protected _buildBlock(state: NodeMaterialBuildState): this;
  59490. serialize(): any;
  59491. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59492. protected _dumpPropertiesCode(): string;
  59493. }
  59494. }
  59495. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59496. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59497. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59499. /**
  59500. * Block used to output the vertex position
  59501. */
  59502. export class VertexOutputBlock extends NodeMaterialBlock {
  59503. /**
  59504. * Creates a new VertexOutputBlock
  59505. * @param name defines the block name
  59506. */
  59507. constructor(name: string);
  59508. /**
  59509. * Gets the current class name
  59510. * @returns the class name
  59511. */
  59512. getClassName(): string;
  59513. /**
  59514. * Gets the vector input component
  59515. */
  59516. get vector(): NodeMaterialConnectionPoint;
  59517. protected _buildBlock(state: NodeMaterialBuildState): this;
  59518. }
  59519. }
  59520. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59521. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59522. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59524. /**
  59525. * Block used to output the final color
  59526. */
  59527. export class FragmentOutputBlock extends NodeMaterialBlock {
  59528. /**
  59529. * Create a new FragmentOutputBlock
  59530. * @param name defines the block name
  59531. */
  59532. constructor(name: string);
  59533. /**
  59534. * Gets the current class name
  59535. * @returns the class name
  59536. */
  59537. getClassName(): string;
  59538. /**
  59539. * Gets the rgba input component
  59540. */
  59541. get rgba(): NodeMaterialConnectionPoint;
  59542. /**
  59543. * Gets the rgb input component
  59544. */
  59545. get rgb(): NodeMaterialConnectionPoint;
  59546. /**
  59547. * Gets the a input component
  59548. */
  59549. get a(): NodeMaterialConnectionPoint;
  59550. protected _buildBlock(state: NodeMaterialBuildState): this;
  59551. }
  59552. }
  59553. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59557. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59559. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59560. import { Effect } from "babylonjs/Materials/effect";
  59561. import { Mesh } from "babylonjs/Meshes/mesh";
  59562. import { Nullable } from "babylonjs/types";
  59563. import { Scene } from "babylonjs/scene";
  59564. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59565. /**
  59566. * Block used to read a reflection texture from a sampler
  59567. */
  59568. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59569. private _define3DName;
  59570. private _defineCubicName;
  59571. private _defineExplicitName;
  59572. private _defineProjectionName;
  59573. private _defineLocalCubicName;
  59574. private _defineSphericalName;
  59575. private _definePlanarName;
  59576. private _defineEquirectangularName;
  59577. private _defineMirroredEquirectangularFixedName;
  59578. private _defineEquirectangularFixedName;
  59579. private _defineSkyboxName;
  59580. private _cubeSamplerName;
  59581. private _2DSamplerName;
  59582. private _positionUVWName;
  59583. private _directionWName;
  59584. private _reflectionCoordsName;
  59585. private _reflection2DCoordsName;
  59586. private _reflectionColorName;
  59587. private _reflectionMatrixName;
  59588. /**
  59589. * Gets or sets the texture associated with the node
  59590. */
  59591. texture: Nullable<BaseTexture>;
  59592. /**
  59593. * Create a new TextureBlock
  59594. * @param name defines the block name
  59595. */
  59596. constructor(name: string);
  59597. /**
  59598. * Gets the current class name
  59599. * @returns the class name
  59600. */
  59601. getClassName(): string;
  59602. /**
  59603. * Gets the world position input component
  59604. */
  59605. get position(): NodeMaterialConnectionPoint;
  59606. /**
  59607. * Gets the world position input component
  59608. */
  59609. get worldPosition(): NodeMaterialConnectionPoint;
  59610. /**
  59611. * Gets the world normal input component
  59612. */
  59613. get worldNormal(): NodeMaterialConnectionPoint;
  59614. /**
  59615. * Gets the world input component
  59616. */
  59617. get world(): NodeMaterialConnectionPoint;
  59618. /**
  59619. * Gets the camera (or eye) position component
  59620. */
  59621. get cameraPosition(): NodeMaterialConnectionPoint;
  59622. /**
  59623. * Gets the view input component
  59624. */
  59625. get view(): NodeMaterialConnectionPoint;
  59626. /**
  59627. * Gets the rgb output component
  59628. */
  59629. get rgb(): NodeMaterialConnectionPoint;
  59630. /**
  59631. * Gets the r output component
  59632. */
  59633. get r(): NodeMaterialConnectionPoint;
  59634. /**
  59635. * Gets the g output component
  59636. */
  59637. get g(): NodeMaterialConnectionPoint;
  59638. /**
  59639. * Gets the b output component
  59640. */
  59641. get b(): NodeMaterialConnectionPoint;
  59642. autoConfigure(material: NodeMaterial): void;
  59643. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59644. isReady(): boolean;
  59645. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59646. private _injectVertexCode;
  59647. private _writeOutput;
  59648. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59649. protected _dumpPropertiesCode(): string;
  59650. serialize(): any;
  59651. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59652. }
  59653. }
  59654. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59655. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59656. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59657. import { Scene } from "babylonjs/scene";
  59658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59659. import { Matrix } from "babylonjs/Maths/math.vector";
  59660. import { Mesh } from "babylonjs/Meshes/mesh";
  59661. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59662. import { Observable } from "babylonjs/Misc/observable";
  59663. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59664. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59665. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59666. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59667. import { Nullable } from "babylonjs/types";
  59668. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59669. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59670. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59671. /**
  59672. * Interface used to configure the node material editor
  59673. */
  59674. export interface INodeMaterialEditorOptions {
  59675. /** Define the URl to load node editor script */
  59676. editorURL?: string;
  59677. }
  59678. /** @hidden */
  59679. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59680. NORMAL: boolean;
  59681. TANGENT: boolean;
  59682. UV1: boolean;
  59683. /** BONES */
  59684. NUM_BONE_INFLUENCERS: number;
  59685. BonesPerMesh: number;
  59686. BONETEXTURE: boolean;
  59687. /** MORPH TARGETS */
  59688. MORPHTARGETS: boolean;
  59689. MORPHTARGETS_NORMAL: boolean;
  59690. MORPHTARGETS_TANGENT: boolean;
  59691. MORPHTARGETS_UV: boolean;
  59692. NUM_MORPH_INFLUENCERS: number;
  59693. /** IMAGE PROCESSING */
  59694. IMAGEPROCESSING: boolean;
  59695. VIGNETTE: boolean;
  59696. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59697. VIGNETTEBLENDMODEOPAQUE: boolean;
  59698. TONEMAPPING: boolean;
  59699. TONEMAPPING_ACES: boolean;
  59700. CONTRAST: boolean;
  59701. EXPOSURE: boolean;
  59702. COLORCURVES: boolean;
  59703. COLORGRADING: boolean;
  59704. COLORGRADING3D: boolean;
  59705. SAMPLER3DGREENDEPTH: boolean;
  59706. SAMPLER3DBGRMAP: boolean;
  59707. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59708. /** MISC. */
  59709. BUMPDIRECTUV: number;
  59710. constructor();
  59711. setValue(name: string, value: boolean): void;
  59712. }
  59713. /**
  59714. * Class used to configure NodeMaterial
  59715. */
  59716. export interface INodeMaterialOptions {
  59717. /**
  59718. * Defines if blocks should emit comments
  59719. */
  59720. emitComments: boolean;
  59721. }
  59722. /**
  59723. * Class used to create a node based material built by assembling shader blocks
  59724. */
  59725. export class NodeMaterial extends PushMaterial {
  59726. private static _BuildIdGenerator;
  59727. private _options;
  59728. private _vertexCompilationState;
  59729. private _fragmentCompilationState;
  59730. private _sharedData;
  59731. private _buildId;
  59732. private _buildWasSuccessful;
  59733. private _cachedWorldViewMatrix;
  59734. private _cachedWorldViewProjectionMatrix;
  59735. private _optimizers;
  59736. private _animationFrame;
  59737. /** Define the Url to load node editor script */
  59738. static EditorURL: string;
  59739. /** Define the Url to load snippets */
  59740. static SnippetUrl: string;
  59741. private BJSNODEMATERIALEDITOR;
  59742. /** Get the inspector from bundle or global */
  59743. private _getGlobalNodeMaterialEditor;
  59744. /**
  59745. * Gets or sets data used by visual editor
  59746. * @see https://nme.babylonjs.com
  59747. */
  59748. editorData: any;
  59749. /**
  59750. * 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)
  59751. */
  59752. ignoreAlpha: boolean;
  59753. /**
  59754. * Defines the maximum number of lights that can be used in the material
  59755. */
  59756. maxSimultaneousLights: number;
  59757. /**
  59758. * Observable raised when the material is built
  59759. */
  59760. onBuildObservable: Observable<NodeMaterial>;
  59761. /**
  59762. * Gets or sets the root nodes of the material vertex shader
  59763. */
  59764. _vertexOutputNodes: NodeMaterialBlock[];
  59765. /**
  59766. * Gets or sets the root nodes of the material fragment (pixel) shader
  59767. */
  59768. _fragmentOutputNodes: NodeMaterialBlock[];
  59769. /** Gets or sets options to control the node material overall behavior */
  59770. get options(): INodeMaterialOptions;
  59771. set options(options: INodeMaterialOptions);
  59772. /**
  59773. * Default configuration related to image processing available in the standard Material.
  59774. */
  59775. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59776. /**
  59777. * Gets the image processing configuration used either in this material.
  59778. */
  59779. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59780. /**
  59781. * Sets the Default image processing configuration used either in the this material.
  59782. *
  59783. * If sets to null, the scene one is in use.
  59784. */
  59785. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59786. /**
  59787. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59788. */
  59789. attachedBlocks: NodeMaterialBlock[];
  59790. /**
  59791. * Create a new node based material
  59792. * @param name defines the material name
  59793. * @param scene defines the hosting scene
  59794. * @param options defines creation option
  59795. */
  59796. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59797. /**
  59798. * Gets the current class name of the material e.g. "NodeMaterial"
  59799. * @returns the class name
  59800. */
  59801. getClassName(): string;
  59802. /**
  59803. * Keep track of the image processing observer to allow dispose and replace.
  59804. */
  59805. private _imageProcessingObserver;
  59806. /**
  59807. * Attaches a new image processing configuration to the Standard Material.
  59808. * @param configuration
  59809. */
  59810. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59811. /**
  59812. * Get a block by its name
  59813. * @param name defines the name of the block to retrieve
  59814. * @returns the required block or null if not found
  59815. */
  59816. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59817. /**
  59818. * Get a block by its name
  59819. * @param predicate defines the predicate used to find the good candidate
  59820. * @returns the required block or null if not found
  59821. */
  59822. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59823. /**
  59824. * Get an input block by its name
  59825. * @param predicate defines the predicate used to find the good candidate
  59826. * @returns the required input block or null if not found
  59827. */
  59828. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59829. /**
  59830. * Gets the list of input blocks attached to this material
  59831. * @returns an array of InputBlocks
  59832. */
  59833. getInputBlocks(): InputBlock[];
  59834. /**
  59835. * Adds a new optimizer to the list of optimizers
  59836. * @param optimizer defines the optimizers to add
  59837. * @returns the current material
  59838. */
  59839. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59840. /**
  59841. * Remove an optimizer from the list of optimizers
  59842. * @param optimizer defines the optimizers to remove
  59843. * @returns the current material
  59844. */
  59845. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59846. /**
  59847. * Add a new block to the list of output nodes
  59848. * @param node defines the node to add
  59849. * @returns the current material
  59850. */
  59851. addOutputNode(node: NodeMaterialBlock): this;
  59852. /**
  59853. * Remove a block from the list of root nodes
  59854. * @param node defines the node to remove
  59855. * @returns the current material
  59856. */
  59857. removeOutputNode(node: NodeMaterialBlock): this;
  59858. private _addVertexOutputNode;
  59859. private _removeVertexOutputNode;
  59860. private _addFragmentOutputNode;
  59861. private _removeFragmentOutputNode;
  59862. /**
  59863. * Specifies if the material will require alpha blending
  59864. * @returns a boolean specifying if alpha blending is needed
  59865. */
  59866. needAlphaBlending(): boolean;
  59867. /**
  59868. * Specifies if this material should be rendered in alpha test mode
  59869. * @returns a boolean specifying if an alpha test is needed.
  59870. */
  59871. needAlphaTesting(): boolean;
  59872. private _initializeBlock;
  59873. private _resetDualBlocks;
  59874. /**
  59875. * Remove a block from the current node material
  59876. * @param block defines the block to remove
  59877. */
  59878. removeBlock(block: NodeMaterialBlock): void;
  59879. /**
  59880. * Build the material and generates the inner effect
  59881. * @param verbose defines if the build should log activity
  59882. */
  59883. build(verbose?: boolean): void;
  59884. /**
  59885. * Runs an otpimization phase to try to improve the shader code
  59886. */
  59887. optimize(): void;
  59888. private _prepareDefinesForAttributes;
  59889. /**
  59890. * Get if the submesh is ready to be used and all its information available.
  59891. * Child classes can use it to update shaders
  59892. * @param mesh defines the mesh to check
  59893. * @param subMesh defines which submesh to check
  59894. * @param useInstances specifies that instances should be used
  59895. * @returns a boolean indicating that the submesh is ready or not
  59896. */
  59897. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59898. /**
  59899. * Get a string representing the shaders built by the current node graph
  59900. */
  59901. get compiledShaders(): string;
  59902. /**
  59903. * Binds the world matrix to the material
  59904. * @param world defines the world transformation matrix
  59905. */
  59906. bindOnlyWorldMatrix(world: Matrix): void;
  59907. /**
  59908. * Binds the submesh to this material by preparing the effect and shader to draw
  59909. * @param world defines the world transformation matrix
  59910. * @param mesh defines the mesh containing the submesh
  59911. * @param subMesh defines the submesh to bind the material to
  59912. */
  59913. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59914. /**
  59915. * Gets the active textures from the material
  59916. * @returns an array of textures
  59917. */
  59918. getActiveTextures(): BaseTexture[];
  59919. /**
  59920. * Gets the list of texture blocks
  59921. * @returns an array of texture blocks
  59922. */
  59923. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59924. /**
  59925. * Specifies if the material uses a texture
  59926. * @param texture defines the texture to check against the material
  59927. * @returns a boolean specifying if the material uses the texture
  59928. */
  59929. hasTexture(texture: BaseTexture): boolean;
  59930. /**
  59931. * Disposes the material
  59932. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59933. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59934. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59935. */
  59936. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59937. /** Creates the node editor window. */
  59938. private _createNodeEditor;
  59939. /**
  59940. * Launch the node material editor
  59941. * @param config Define the configuration of the editor
  59942. * @return a promise fulfilled when the node editor is visible
  59943. */
  59944. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59945. /**
  59946. * Clear the current material
  59947. */
  59948. clear(): void;
  59949. /**
  59950. * Clear the current material and set it to a default state
  59951. */
  59952. setToDefault(): void;
  59953. /**
  59954. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59955. * @param url defines the url to load from
  59956. * @returns a promise that will fullfil when the material is fully loaded
  59957. */
  59958. loadAsync(url: string): Promise<void>;
  59959. private _gatherBlocks;
  59960. /**
  59961. * Generate a string containing the code declaration required to create an equivalent of this material
  59962. * @returns a string
  59963. */
  59964. generateCode(): string;
  59965. /**
  59966. * Serializes this material in a JSON representation
  59967. * @returns the serialized material object
  59968. */
  59969. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59970. private _restoreConnections;
  59971. /**
  59972. * Clear the current graph and load a new one from a serialization object
  59973. * @param source defines the JSON representation of the material
  59974. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59975. */
  59976. loadFromSerialization(source: any, rootUrl?: string): void;
  59977. /**
  59978. * Creates a node material from parsed material data
  59979. * @param source defines the JSON representation of the material
  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 new node material
  59983. */
  59984. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59985. /**
  59986. * Creates a node material from a snippet saved in a remote file
  59987. * @param name defines the name of the material to create
  59988. * @param url defines the url to load from
  59989. * @param scene defines the hosting scene
  59990. * @returns a promise that will resolve to the new node material
  59991. */
  59992. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59993. /**
  59994. * Creates a node material from a snippet saved by the node material editor
  59995. * @param snippetId defines the snippet to load
  59996. * @param scene defines the hosting scene
  59997. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59998. * @returns a promise that will resolve to the new node material
  59999. */
  60000. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  60001. /**
  60002. * Creates a new node material set to default basic configuration
  60003. * @param name defines the name of the material
  60004. * @param scene defines the hosting scene
  60005. * @returns a new NodeMaterial
  60006. */
  60007. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  60008. }
  60009. }
  60010. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60011. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60012. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60013. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60016. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60017. import { Effect } from "babylonjs/Materials/effect";
  60018. import { Mesh } from "babylonjs/Meshes/mesh";
  60019. import { Nullable } from "babylonjs/types";
  60020. import { Texture } from "babylonjs/Materials/Textures/texture";
  60021. import { Scene } from "babylonjs/scene";
  60022. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60023. /**
  60024. * Block used to read a texture from a sampler
  60025. */
  60026. export class TextureBlock extends NodeMaterialBlock {
  60027. private _defineName;
  60028. private _linearDefineName;
  60029. private _tempTextureRead;
  60030. private _samplerName;
  60031. private _transformedUVName;
  60032. private _textureTransformName;
  60033. private _textureInfoName;
  60034. private _mainUVName;
  60035. private _mainUVDefineName;
  60036. /**
  60037. * Gets or sets the texture associated with the node
  60038. */
  60039. texture: Nullable<Texture>;
  60040. /**
  60041. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60042. */
  60043. convertToGammaSpace: boolean;
  60044. /**
  60045. * Create a new TextureBlock
  60046. * @param name defines the block name
  60047. */
  60048. constructor(name: string);
  60049. /**
  60050. * Gets the current class name
  60051. * @returns the class name
  60052. */
  60053. getClassName(): string;
  60054. /**
  60055. * Gets the uv input component
  60056. */
  60057. get uv(): NodeMaterialConnectionPoint;
  60058. /**
  60059. * Gets the rgba output component
  60060. */
  60061. get rgba(): NodeMaterialConnectionPoint;
  60062. /**
  60063. * Gets the rgb output component
  60064. */
  60065. get rgb(): NodeMaterialConnectionPoint;
  60066. /**
  60067. * Gets the r output component
  60068. */
  60069. get r(): NodeMaterialConnectionPoint;
  60070. /**
  60071. * Gets the g output component
  60072. */
  60073. get g(): NodeMaterialConnectionPoint;
  60074. /**
  60075. * Gets the b output component
  60076. */
  60077. get b(): NodeMaterialConnectionPoint;
  60078. /**
  60079. * Gets the a output component
  60080. */
  60081. get a(): NodeMaterialConnectionPoint;
  60082. get target(): NodeMaterialBlockTargets;
  60083. autoConfigure(material: NodeMaterial): void;
  60084. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60085. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60086. isReady(): boolean;
  60087. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60088. private get _isMixed();
  60089. private _injectVertexCode;
  60090. private _writeTextureRead;
  60091. private _writeOutput;
  60092. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60093. protected _dumpPropertiesCode(): string;
  60094. serialize(): any;
  60095. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60096. }
  60097. }
  60098. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60099. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60100. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60101. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60102. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60103. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60104. import { Scene } from "babylonjs/scene";
  60105. /**
  60106. * Class used to store shared data between 2 NodeMaterialBuildState
  60107. */
  60108. export class NodeMaterialBuildStateSharedData {
  60109. /**
  60110. * Gets the list of emitted varyings
  60111. */
  60112. temps: string[];
  60113. /**
  60114. * Gets the list of emitted varyings
  60115. */
  60116. varyings: string[];
  60117. /**
  60118. * Gets the varying declaration string
  60119. */
  60120. varyingDeclaration: string;
  60121. /**
  60122. * Input blocks
  60123. */
  60124. inputBlocks: InputBlock[];
  60125. /**
  60126. * Input blocks
  60127. */
  60128. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60129. /**
  60130. * Bindable blocks (Blocks that need to set data to the effect)
  60131. */
  60132. bindableBlocks: NodeMaterialBlock[];
  60133. /**
  60134. * List of blocks that can provide a compilation fallback
  60135. */
  60136. blocksWithFallbacks: NodeMaterialBlock[];
  60137. /**
  60138. * List of blocks that can provide a define update
  60139. */
  60140. blocksWithDefines: NodeMaterialBlock[];
  60141. /**
  60142. * List of blocks that can provide a repeatable content
  60143. */
  60144. repeatableContentBlocks: NodeMaterialBlock[];
  60145. /**
  60146. * List of blocks that can provide a dynamic list of uniforms
  60147. */
  60148. dynamicUniformBlocks: NodeMaterialBlock[];
  60149. /**
  60150. * List of blocks that can block the isReady function for the material
  60151. */
  60152. blockingBlocks: NodeMaterialBlock[];
  60153. /**
  60154. * Gets the list of animated inputs
  60155. */
  60156. animatedInputs: InputBlock[];
  60157. /**
  60158. * Build Id used to avoid multiple recompilations
  60159. */
  60160. buildId: number;
  60161. /** List of emitted variables */
  60162. variableNames: {
  60163. [key: string]: number;
  60164. };
  60165. /** List of emitted defines */
  60166. defineNames: {
  60167. [key: string]: number;
  60168. };
  60169. /** Should emit comments? */
  60170. emitComments: boolean;
  60171. /** Emit build activity */
  60172. verbose: boolean;
  60173. /** Gets or sets the hosting scene */
  60174. scene: Scene;
  60175. /**
  60176. * Gets the compilation hints emitted at compilation time
  60177. */
  60178. hints: {
  60179. needWorldViewMatrix: boolean;
  60180. needWorldViewProjectionMatrix: boolean;
  60181. needAlphaBlending: boolean;
  60182. needAlphaTesting: boolean;
  60183. };
  60184. /**
  60185. * List of compilation checks
  60186. */
  60187. checks: {
  60188. emitVertex: boolean;
  60189. emitFragment: boolean;
  60190. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60191. };
  60192. /** Creates a new shared data */
  60193. constructor();
  60194. /**
  60195. * Emits console errors and exceptions if there is a failing check
  60196. */
  60197. emitErrors(): void;
  60198. }
  60199. }
  60200. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60201. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60202. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60203. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60204. /**
  60205. * Class used to store node based material build state
  60206. */
  60207. export class NodeMaterialBuildState {
  60208. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60209. supportUniformBuffers: boolean;
  60210. /**
  60211. * Gets the list of emitted attributes
  60212. */
  60213. attributes: string[];
  60214. /**
  60215. * Gets the list of emitted uniforms
  60216. */
  60217. uniforms: string[];
  60218. /**
  60219. * Gets the list of emitted constants
  60220. */
  60221. constants: string[];
  60222. /**
  60223. * Gets the list of emitted samplers
  60224. */
  60225. samplers: string[];
  60226. /**
  60227. * Gets the list of emitted functions
  60228. */
  60229. functions: {
  60230. [key: string]: string;
  60231. };
  60232. /**
  60233. * Gets the list of emitted extensions
  60234. */
  60235. extensions: {
  60236. [key: string]: string;
  60237. };
  60238. /**
  60239. * Gets the target of the compilation state
  60240. */
  60241. target: NodeMaterialBlockTargets;
  60242. /**
  60243. * Gets the list of emitted counters
  60244. */
  60245. counters: {
  60246. [key: string]: number;
  60247. };
  60248. /**
  60249. * Shared data between multiple NodeMaterialBuildState instances
  60250. */
  60251. sharedData: NodeMaterialBuildStateSharedData;
  60252. /** @hidden */
  60253. _vertexState: NodeMaterialBuildState;
  60254. /** @hidden */
  60255. _attributeDeclaration: string;
  60256. /** @hidden */
  60257. _uniformDeclaration: string;
  60258. /** @hidden */
  60259. _constantDeclaration: string;
  60260. /** @hidden */
  60261. _samplerDeclaration: string;
  60262. /** @hidden */
  60263. _varyingTransfer: string;
  60264. private _repeatableContentAnchorIndex;
  60265. /** @hidden */
  60266. _builtCompilationString: string;
  60267. /**
  60268. * Gets the emitted compilation strings
  60269. */
  60270. compilationString: string;
  60271. /**
  60272. * Finalize the compilation strings
  60273. * @param state defines the current compilation state
  60274. */
  60275. finalize(state: NodeMaterialBuildState): void;
  60276. /** @hidden */
  60277. get _repeatableContentAnchor(): string;
  60278. /** @hidden */
  60279. _getFreeVariableName(prefix: string): string;
  60280. /** @hidden */
  60281. _getFreeDefineName(prefix: string): string;
  60282. /** @hidden */
  60283. _excludeVariableName(name: string): void;
  60284. /** @hidden */
  60285. _emit2DSampler(name: string): void;
  60286. /** @hidden */
  60287. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60288. /** @hidden */
  60289. _emitExtension(name: string, extension: string): void;
  60290. /** @hidden */
  60291. _emitFunction(name: string, code: string, comments: string): void;
  60292. /** @hidden */
  60293. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60294. replaceStrings?: {
  60295. search: RegExp;
  60296. replace: string;
  60297. }[];
  60298. repeatKey?: string;
  60299. }): string;
  60300. /** @hidden */
  60301. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60302. repeatKey?: string;
  60303. removeAttributes?: boolean;
  60304. removeUniforms?: boolean;
  60305. removeVaryings?: boolean;
  60306. removeIfDef?: boolean;
  60307. replaceStrings?: {
  60308. search: RegExp;
  60309. replace: string;
  60310. }[];
  60311. }, storeKey?: string): void;
  60312. /** @hidden */
  60313. _registerTempVariable(name: string): boolean;
  60314. /** @hidden */
  60315. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60316. /** @hidden */
  60317. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60318. /** @hidden */
  60319. _emitFloat(value: number): string;
  60320. }
  60321. }
  60322. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60323. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60324. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60325. import { Nullable } from "babylonjs/types";
  60326. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60327. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60328. import { Effect } from "babylonjs/Materials/effect";
  60329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60330. import { Mesh } from "babylonjs/Meshes/mesh";
  60331. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60332. import { Scene } from "babylonjs/scene";
  60333. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60334. /**
  60335. * Defines a block that can be used inside a node based material
  60336. */
  60337. export class NodeMaterialBlock {
  60338. private _buildId;
  60339. private _buildTarget;
  60340. private _target;
  60341. private _isFinalMerger;
  60342. private _isInput;
  60343. protected _isUnique: boolean;
  60344. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60345. inputsAreExclusive: boolean;
  60346. /** @hidden */
  60347. _codeVariableName: string;
  60348. /** @hidden */
  60349. _inputs: NodeMaterialConnectionPoint[];
  60350. /** @hidden */
  60351. _outputs: NodeMaterialConnectionPoint[];
  60352. /** @hidden */
  60353. _preparationId: number;
  60354. /**
  60355. * Gets or sets the name of the block
  60356. */
  60357. name: string;
  60358. /**
  60359. * Gets or sets the unique id of the node
  60360. */
  60361. uniqueId: number;
  60362. /**
  60363. * Gets or sets the comments associated with this block
  60364. */
  60365. comments: string;
  60366. /**
  60367. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60368. */
  60369. get isUnique(): boolean;
  60370. /**
  60371. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60372. */
  60373. get isFinalMerger(): boolean;
  60374. /**
  60375. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60376. */
  60377. get isInput(): boolean;
  60378. /**
  60379. * Gets or sets the build Id
  60380. */
  60381. get buildId(): number;
  60382. set buildId(value: number);
  60383. /**
  60384. * Gets or sets the target of the block
  60385. */
  60386. get target(): NodeMaterialBlockTargets;
  60387. set target(value: NodeMaterialBlockTargets);
  60388. /**
  60389. * Gets the list of input points
  60390. */
  60391. get inputs(): NodeMaterialConnectionPoint[];
  60392. /** Gets the list of output points */
  60393. get outputs(): NodeMaterialConnectionPoint[];
  60394. /**
  60395. * Find an input by its name
  60396. * @param name defines the name of the input to look for
  60397. * @returns the input or null if not found
  60398. */
  60399. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60400. /**
  60401. * Find an output by its name
  60402. * @param name defines the name of the outputto look for
  60403. * @returns the output or null if not found
  60404. */
  60405. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60406. /**
  60407. * Creates a new NodeMaterialBlock
  60408. * @param name defines the block name
  60409. * @param target defines the target of that block (Vertex by default)
  60410. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60411. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60412. */
  60413. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60414. /**
  60415. * Initialize the block and prepare the context for build
  60416. * @param state defines the state that will be used for the build
  60417. */
  60418. initialize(state: NodeMaterialBuildState): void;
  60419. /**
  60420. * Bind data to effect. Will only be called for blocks with isBindable === true
  60421. * @param effect defines the effect to bind data to
  60422. * @param nodeMaterial defines the hosting NodeMaterial
  60423. * @param mesh defines the mesh that will be rendered
  60424. */
  60425. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60426. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60427. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60428. protected _writeFloat(value: number): string;
  60429. /**
  60430. * Gets the current class name e.g. "NodeMaterialBlock"
  60431. * @returns the class name
  60432. */
  60433. getClassName(): string;
  60434. /**
  60435. * Register a new input. Must be called inside a block constructor
  60436. * @param name defines the connection point name
  60437. * @param type defines the connection point type
  60438. * @param isOptional defines a boolean indicating that this input can be omitted
  60439. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60440. * @returns the current block
  60441. */
  60442. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60443. /**
  60444. * Register a new output. Must be called inside a block constructor
  60445. * @param name defines the connection point name
  60446. * @param type defines the connection point type
  60447. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60448. * @returns the current block
  60449. */
  60450. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60451. /**
  60452. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60453. * @param forOutput defines an optional connection point to check compatibility with
  60454. * @returns the first available input or null
  60455. */
  60456. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60457. /**
  60458. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60459. * @param forBlock defines an optional block to check compatibility with
  60460. * @returns the first available input or null
  60461. */
  60462. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60463. /**
  60464. * Gets the sibling of the given output
  60465. * @param current defines the current output
  60466. * @returns the next output in the list or null
  60467. */
  60468. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60469. /**
  60470. * Connect current block with another block
  60471. * @param other defines the block to connect with
  60472. * @param options define the various options to help pick the right connections
  60473. * @returns the current block
  60474. */
  60475. connectTo(other: NodeMaterialBlock, options?: {
  60476. input?: string;
  60477. output?: string;
  60478. outputSwizzle?: string;
  60479. }): this | undefined;
  60480. protected _buildBlock(state: NodeMaterialBuildState): void;
  60481. /**
  60482. * Add uniforms, samplers and uniform buffers at compilation time
  60483. * @param state defines the state to update
  60484. * @param nodeMaterial defines the node material requesting the update
  60485. * @param defines defines the material defines to update
  60486. * @param uniformBuffers defines the list of uniform buffer names
  60487. */
  60488. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60489. /**
  60490. * Add potential fallbacks if shader compilation fails
  60491. * @param mesh defines the mesh to be rendered
  60492. * @param fallbacks defines the current prioritized list of fallbacks
  60493. */
  60494. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60495. /**
  60496. * Initialize defines for shader compilation
  60497. * @param mesh defines the mesh to be rendered
  60498. * @param nodeMaterial defines the node material requesting the update
  60499. * @param defines defines the material defines to update
  60500. * @param useInstances specifies that instances should be used
  60501. */
  60502. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60503. /**
  60504. * Update defines for shader compilation
  60505. * @param mesh defines the mesh to be rendered
  60506. * @param nodeMaterial defines the node material requesting the update
  60507. * @param defines defines the material defines to update
  60508. * @param useInstances specifies that instances should be used
  60509. */
  60510. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60511. /**
  60512. * Lets the block try to connect some inputs automatically
  60513. * @param material defines the hosting NodeMaterial
  60514. */
  60515. autoConfigure(material: NodeMaterial): void;
  60516. /**
  60517. * Function called when a block is declared as repeatable content generator
  60518. * @param vertexShaderState defines the current compilation state for the vertex shader
  60519. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60520. * @param mesh defines the mesh to be rendered
  60521. * @param defines defines the material defines to update
  60522. */
  60523. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60524. /**
  60525. * Checks if the block is ready
  60526. * @param mesh defines the mesh to be rendered
  60527. * @param nodeMaterial defines the node material requesting the update
  60528. * @param defines defines the material defines to update
  60529. * @param useInstances specifies that instances should be used
  60530. * @returns true if the block is ready
  60531. */
  60532. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60533. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60534. private _processBuild;
  60535. /**
  60536. * Compile the current node and generate the shader code
  60537. * @param state defines the current compilation state (uniforms, samplers, current string)
  60538. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60539. * @returns true if already built
  60540. */
  60541. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60542. protected _inputRename(name: string): string;
  60543. protected _outputRename(name: string): string;
  60544. protected _dumpPropertiesCode(): string;
  60545. /** @hidden */
  60546. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60547. /** @hidden */
  60548. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60549. /**
  60550. * Clone the current block to a new identical block
  60551. * @param scene defines the hosting scene
  60552. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60553. * @returns a copy of the current block
  60554. */
  60555. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60556. /**
  60557. * Serializes this block in a JSON representation
  60558. * @returns the serialized block object
  60559. */
  60560. serialize(): any;
  60561. /** @hidden */
  60562. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60563. /**
  60564. * Release resources
  60565. */
  60566. dispose(): void;
  60567. }
  60568. }
  60569. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60570. /**
  60571. * Enum defining the type of animations supported by InputBlock
  60572. */
  60573. export enum AnimatedInputBlockTypes {
  60574. /** No animation */
  60575. None = 0,
  60576. /** Time based animation. Will only work for floats */
  60577. Time = 1
  60578. }
  60579. }
  60580. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60581. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60582. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60583. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60584. import { Nullable } from "babylonjs/types";
  60585. import { Effect } from "babylonjs/Materials/effect";
  60586. import { Matrix } from "babylonjs/Maths/math.vector";
  60587. import { Scene } from "babylonjs/scene";
  60588. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60589. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60590. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60591. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60592. import { Observable } from "babylonjs/Misc/observable";
  60593. /**
  60594. * Block used to expose an input value
  60595. */
  60596. export class InputBlock extends NodeMaterialBlock {
  60597. private _mode;
  60598. private _associatedVariableName;
  60599. private _storedValue;
  60600. private _valueCallback;
  60601. private _type;
  60602. private _animationType;
  60603. /** Gets or set a value used to limit the range of float values */
  60604. min: number;
  60605. /** Gets or set a value used to limit the range of float values */
  60606. max: number;
  60607. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60608. isBoolean: boolean;
  60609. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60610. matrixMode: number;
  60611. /** @hidden */
  60612. _systemValue: Nullable<NodeMaterialSystemValues>;
  60613. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60614. visibleInInspector: boolean;
  60615. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60616. isConstant: boolean;
  60617. /** Gets or sets the group to use to display this block in the Inspector */
  60618. groupInInspector: string;
  60619. /** Gets an observable raised when the value is changed */
  60620. onValueChangedObservable: Observable<InputBlock>;
  60621. /**
  60622. * Gets or sets the connection point type (default is float)
  60623. */
  60624. get type(): NodeMaterialBlockConnectionPointTypes;
  60625. /**
  60626. * Creates a new InputBlock
  60627. * @param name defines the block name
  60628. * @param target defines the target of that block (Vertex by default)
  60629. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60630. */
  60631. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60632. /**
  60633. * Gets the output component
  60634. */
  60635. get output(): NodeMaterialConnectionPoint;
  60636. /**
  60637. * Set the source of this connection point to a vertex attribute
  60638. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60639. * @returns the current connection point
  60640. */
  60641. setAsAttribute(attributeName?: string): InputBlock;
  60642. /**
  60643. * Set the source of this connection point to a system value
  60644. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60645. * @returns the current connection point
  60646. */
  60647. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60648. /**
  60649. * Gets or sets the value of that point.
  60650. * Please note that this value will be ignored if valueCallback is defined
  60651. */
  60652. get value(): any;
  60653. set value(value: any);
  60654. /**
  60655. * Gets or sets a callback used to get the value of that point.
  60656. * Please note that setting this value will force the connection point to ignore the value property
  60657. */
  60658. get valueCallback(): () => any;
  60659. set valueCallback(value: () => any);
  60660. /**
  60661. * Gets or sets the associated variable name in the shader
  60662. */
  60663. get associatedVariableName(): string;
  60664. set associatedVariableName(value: string);
  60665. /** Gets or sets the type of animation applied to the input */
  60666. get animationType(): AnimatedInputBlockTypes;
  60667. set animationType(value: AnimatedInputBlockTypes);
  60668. /**
  60669. * Gets a boolean indicating that this connection point not defined yet
  60670. */
  60671. get isUndefined(): boolean;
  60672. /**
  60673. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60674. * In this case the connection point name must be the name of the uniform to use.
  60675. * Can only be set on inputs
  60676. */
  60677. get isUniform(): boolean;
  60678. set isUniform(value: boolean);
  60679. /**
  60680. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60681. * In this case the connection point name must be the name of the attribute to use
  60682. * Can only be set on inputs
  60683. */
  60684. get isAttribute(): boolean;
  60685. set isAttribute(value: boolean);
  60686. /**
  60687. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60688. * Can only be set on exit points
  60689. */
  60690. get isVarying(): boolean;
  60691. set isVarying(value: boolean);
  60692. /**
  60693. * Gets a boolean indicating that the current connection point is a system value
  60694. */
  60695. get isSystemValue(): boolean;
  60696. /**
  60697. * Gets or sets the current well known value or null if not defined as a system value
  60698. */
  60699. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60700. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60701. /**
  60702. * Gets the current class name
  60703. * @returns the class name
  60704. */
  60705. getClassName(): string;
  60706. /**
  60707. * Animate the input if animationType !== None
  60708. * @param scene defines the rendering scene
  60709. */
  60710. animate(scene: Scene): void;
  60711. private _emitDefine;
  60712. initialize(state: NodeMaterialBuildState): void;
  60713. /**
  60714. * Set the input block to its default value (based on its type)
  60715. */
  60716. setDefaultValue(): void;
  60717. private _emitConstant;
  60718. private _emit;
  60719. /** @hidden */
  60720. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60721. /** @hidden */
  60722. _transmit(effect: Effect, scene: Scene): void;
  60723. protected _buildBlock(state: NodeMaterialBuildState): void;
  60724. protected _dumpPropertiesCode(): string;
  60725. dispose(): void;
  60726. serialize(): any;
  60727. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60728. }
  60729. }
  60730. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60731. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60732. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60733. import { Nullable } from "babylonjs/types";
  60734. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60735. import { Observable } from "babylonjs/Misc/observable";
  60736. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60737. /**
  60738. * Enum used to define the compatibility state between two connection points
  60739. */
  60740. export enum NodeMaterialConnectionPointCompatibilityStates {
  60741. /** Points are compatibles */
  60742. Compatible = 0,
  60743. /** Points are incompatible because of their types */
  60744. TypeIncompatible = 1,
  60745. /** Points are incompatible because of their targets (vertex vs fragment) */
  60746. TargetIncompatible = 2
  60747. }
  60748. /**
  60749. * Defines the direction of a connection point
  60750. */
  60751. export enum NodeMaterialConnectionPointDirection {
  60752. /** Input */
  60753. Input = 0,
  60754. /** Output */
  60755. Output = 1
  60756. }
  60757. /**
  60758. * Defines a connection point for a block
  60759. */
  60760. export class NodeMaterialConnectionPoint {
  60761. /** @hidden */
  60762. _ownerBlock: NodeMaterialBlock;
  60763. /** @hidden */
  60764. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60765. private _endpoints;
  60766. private _associatedVariableName;
  60767. private _direction;
  60768. /** @hidden */
  60769. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60770. /** @hidden */
  60771. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60772. private _type;
  60773. /** @hidden */
  60774. _enforceAssociatedVariableName: boolean;
  60775. /** Gets the direction of the point */
  60776. get direction(): NodeMaterialConnectionPointDirection;
  60777. /**
  60778. * Gets or sets the additional types supported by this connection point
  60779. */
  60780. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60781. /**
  60782. * Gets or sets the additional types excluded by this connection point
  60783. */
  60784. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60785. /**
  60786. * Observable triggered when this point is connected
  60787. */
  60788. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60789. /**
  60790. * Gets or sets the associated variable name in the shader
  60791. */
  60792. get associatedVariableName(): string;
  60793. set associatedVariableName(value: string);
  60794. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  60795. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60796. /**
  60797. * Gets or sets the connection point type (default is float)
  60798. */
  60799. get type(): NodeMaterialBlockConnectionPointTypes;
  60800. set type(value: NodeMaterialBlockConnectionPointTypes);
  60801. /**
  60802. * Gets or sets the connection point name
  60803. */
  60804. name: string;
  60805. /**
  60806. * Gets or sets a boolean indicating that this connection point can be omitted
  60807. */
  60808. isOptional: boolean;
  60809. /**
  60810. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60811. */
  60812. define: string;
  60813. /** @hidden */
  60814. _prioritizeVertex: boolean;
  60815. private _target;
  60816. /** Gets or sets the target of that connection point */
  60817. get target(): NodeMaterialBlockTargets;
  60818. set target(value: NodeMaterialBlockTargets);
  60819. /**
  60820. * Gets a boolean indicating that the current point is connected
  60821. */
  60822. get isConnected(): boolean;
  60823. /**
  60824. * Gets a boolean indicating that the current point is connected to an input block
  60825. */
  60826. get isConnectedToInputBlock(): boolean;
  60827. /**
  60828. * Gets a the connected input block (if any)
  60829. */
  60830. get connectInputBlock(): Nullable<InputBlock>;
  60831. /** Get the other side of the connection (if any) */
  60832. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60833. /** Get the block that owns this connection point */
  60834. get ownerBlock(): NodeMaterialBlock;
  60835. /** Get the block connected on the other side of this connection (if any) */
  60836. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60837. /** Get the block connected on the endpoints of this connection (if any) */
  60838. get connectedBlocks(): Array<NodeMaterialBlock>;
  60839. /** Gets the list of connected endpoints */
  60840. get endpoints(): NodeMaterialConnectionPoint[];
  60841. /** Gets a boolean indicating if that output point is connected to at least one input */
  60842. get hasEndpoints(): boolean;
  60843. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60844. get isConnectedInVertexShader(): boolean;
  60845. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60846. get isConnectedInFragmentShader(): boolean;
  60847. /**
  60848. * Creates a new connection point
  60849. * @param name defines the connection point name
  60850. * @param ownerBlock defines the block hosting this connection point
  60851. * @param direction defines the direction of the connection point
  60852. */
  60853. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60854. /**
  60855. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60856. * @returns the class name
  60857. */
  60858. getClassName(): string;
  60859. /**
  60860. * Gets a boolean indicating if the current point can be connected to another point
  60861. * @param connectionPoint defines the other connection point
  60862. * @returns a boolean
  60863. */
  60864. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60865. /**
  60866. * Gets a number indicating if the current point can be connected to another point
  60867. * @param connectionPoint defines the other connection point
  60868. * @returns a number defining the compatibility state
  60869. */
  60870. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60871. /**
  60872. * Connect this point to another connection point
  60873. * @param connectionPoint defines the other connection point
  60874. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60875. * @returns the current connection point
  60876. */
  60877. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60878. /**
  60879. * Disconnect this point from one of his endpoint
  60880. * @param endpoint defines the other connection point
  60881. * @returns the current connection point
  60882. */
  60883. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60884. /**
  60885. * Serializes this point in a JSON representation
  60886. * @returns the serialized point object
  60887. */
  60888. serialize(): any;
  60889. /**
  60890. * Release resources
  60891. */
  60892. dispose(): void;
  60893. }
  60894. }
  60895. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60896. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60897. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60899. import { Mesh } from "babylonjs/Meshes/mesh";
  60900. import { Effect } from "babylonjs/Materials/effect";
  60901. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60902. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60903. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60904. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60905. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60906. /**
  60907. * Block used to add support for vertex skinning (bones)
  60908. */
  60909. export class BonesBlock extends NodeMaterialBlock {
  60910. /**
  60911. * Creates a new BonesBlock
  60912. * @param name defines the block name
  60913. */
  60914. constructor(name: string);
  60915. /**
  60916. * Initialize the block and prepare the context for build
  60917. * @param state defines the state that will be used for the build
  60918. */
  60919. initialize(state: NodeMaterialBuildState): void;
  60920. /**
  60921. * Gets the current class name
  60922. * @returns the class name
  60923. */
  60924. getClassName(): string;
  60925. /**
  60926. * Gets the matrix indices input component
  60927. */
  60928. get matricesIndices(): NodeMaterialConnectionPoint;
  60929. /**
  60930. * Gets the matrix weights input component
  60931. */
  60932. get matricesWeights(): NodeMaterialConnectionPoint;
  60933. /**
  60934. * Gets the extra matrix indices input component
  60935. */
  60936. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60937. /**
  60938. * Gets the extra matrix weights input component
  60939. */
  60940. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60941. /**
  60942. * Gets the world input component
  60943. */
  60944. get world(): NodeMaterialConnectionPoint;
  60945. /**
  60946. * Gets the output component
  60947. */
  60948. get output(): NodeMaterialConnectionPoint;
  60949. autoConfigure(material: NodeMaterial): void;
  60950. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60951. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60952. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60953. protected _buildBlock(state: NodeMaterialBuildState): this;
  60954. }
  60955. }
  60956. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60958. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60959. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60961. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60962. /**
  60963. * Block used to add support for instances
  60964. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60965. */
  60966. export class InstancesBlock extends NodeMaterialBlock {
  60967. /**
  60968. * Creates a new InstancesBlock
  60969. * @param name defines the block name
  60970. */
  60971. constructor(name: string);
  60972. /**
  60973. * Gets the current class name
  60974. * @returns the class name
  60975. */
  60976. getClassName(): string;
  60977. /**
  60978. * Gets the first world row input component
  60979. */
  60980. get world0(): NodeMaterialConnectionPoint;
  60981. /**
  60982. * Gets the second world row input component
  60983. */
  60984. get world1(): NodeMaterialConnectionPoint;
  60985. /**
  60986. * Gets the third world row input component
  60987. */
  60988. get world2(): NodeMaterialConnectionPoint;
  60989. /**
  60990. * Gets the forth world row input component
  60991. */
  60992. get world3(): NodeMaterialConnectionPoint;
  60993. /**
  60994. * Gets the world input component
  60995. */
  60996. get world(): NodeMaterialConnectionPoint;
  60997. /**
  60998. * Gets the output component
  60999. */
  61000. get output(): NodeMaterialConnectionPoint;
  61001. /**
  61002. * Gets the isntanceID component
  61003. */
  61004. get instanceID(): NodeMaterialConnectionPoint;
  61005. autoConfigure(material: NodeMaterial): void;
  61006. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61007. protected _buildBlock(state: NodeMaterialBuildState): this;
  61008. }
  61009. }
  61010. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  61011. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61012. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61013. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61015. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61016. import { Effect } from "babylonjs/Materials/effect";
  61017. import { Mesh } from "babylonjs/Meshes/mesh";
  61018. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61019. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61020. /**
  61021. * Block used to add morph targets support to vertex shader
  61022. */
  61023. export class MorphTargetsBlock extends NodeMaterialBlock {
  61024. private _repeatableContentAnchor;
  61025. /**
  61026. * Create a new MorphTargetsBlock
  61027. * @param name defines the block name
  61028. */
  61029. constructor(name: string);
  61030. /**
  61031. * Gets the current class name
  61032. * @returns the class name
  61033. */
  61034. getClassName(): string;
  61035. /**
  61036. * Gets the position input component
  61037. */
  61038. get position(): NodeMaterialConnectionPoint;
  61039. /**
  61040. * Gets the normal input component
  61041. */
  61042. get normal(): NodeMaterialConnectionPoint;
  61043. /**
  61044. * Gets the tangent input component
  61045. */
  61046. get tangent(): NodeMaterialConnectionPoint;
  61047. /**
  61048. * Gets the tangent input component
  61049. */
  61050. get uv(): NodeMaterialConnectionPoint;
  61051. /**
  61052. * Gets the position output component
  61053. */
  61054. get positionOutput(): NodeMaterialConnectionPoint;
  61055. /**
  61056. * Gets the normal output component
  61057. */
  61058. get normalOutput(): NodeMaterialConnectionPoint;
  61059. /**
  61060. * Gets the tangent output component
  61061. */
  61062. get tangentOutput(): NodeMaterialConnectionPoint;
  61063. /**
  61064. * Gets the tangent output component
  61065. */
  61066. get uvOutput(): NodeMaterialConnectionPoint;
  61067. initialize(state: NodeMaterialBuildState): void;
  61068. autoConfigure(material: NodeMaterial): void;
  61069. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61070. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61071. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61072. protected _buildBlock(state: NodeMaterialBuildState): this;
  61073. }
  61074. }
  61075. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61076. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61077. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61079. import { Nullable } from "babylonjs/types";
  61080. import { Scene } from "babylonjs/scene";
  61081. import { Effect } from "babylonjs/Materials/effect";
  61082. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61083. import { Mesh } from "babylonjs/Meshes/mesh";
  61084. import { Light } from "babylonjs/Lights/light";
  61085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61086. /**
  61087. * Block used to get data information from a light
  61088. */
  61089. export class LightInformationBlock extends NodeMaterialBlock {
  61090. private _lightDataUniformName;
  61091. private _lightColorUniformName;
  61092. private _lightTypeDefineName;
  61093. /**
  61094. * Gets or sets the light associated with this block
  61095. */
  61096. light: Nullable<Light>;
  61097. /**
  61098. * Creates a new LightInformationBlock
  61099. * @param name defines the block name
  61100. */
  61101. constructor(name: string);
  61102. /**
  61103. * Gets the current class name
  61104. * @returns the class name
  61105. */
  61106. getClassName(): string;
  61107. /**
  61108. * Gets the world position input component
  61109. */
  61110. get worldPosition(): NodeMaterialConnectionPoint;
  61111. /**
  61112. * Gets the direction output component
  61113. */
  61114. get direction(): NodeMaterialConnectionPoint;
  61115. /**
  61116. * Gets the direction output component
  61117. */
  61118. get color(): NodeMaterialConnectionPoint;
  61119. /**
  61120. * Gets the direction output component
  61121. */
  61122. get intensity(): NodeMaterialConnectionPoint;
  61123. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61124. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61125. protected _buildBlock(state: NodeMaterialBuildState): this;
  61126. serialize(): any;
  61127. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61128. }
  61129. }
  61130. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61131. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61132. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61133. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61134. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61135. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61136. }
  61137. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61138. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61139. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61140. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61142. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61143. import { Effect } from "babylonjs/Materials/effect";
  61144. import { Mesh } from "babylonjs/Meshes/mesh";
  61145. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61146. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61147. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61148. /**
  61149. * Block used to add image processing support to fragment shader
  61150. */
  61151. export class ImageProcessingBlock extends NodeMaterialBlock {
  61152. /**
  61153. * Create a new ImageProcessingBlock
  61154. * @param name defines the block name
  61155. */
  61156. constructor(name: string);
  61157. /**
  61158. * Gets the current class name
  61159. * @returns the class name
  61160. */
  61161. getClassName(): string;
  61162. /**
  61163. * Gets the color input component
  61164. */
  61165. get color(): NodeMaterialConnectionPoint;
  61166. /**
  61167. * Gets the output component
  61168. */
  61169. get output(): NodeMaterialConnectionPoint;
  61170. /**
  61171. * Initialize the block and prepare the context for build
  61172. * @param state defines the state that will be used for the build
  61173. */
  61174. initialize(state: NodeMaterialBuildState): void;
  61175. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61176. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61177. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61178. protected _buildBlock(state: NodeMaterialBuildState): this;
  61179. }
  61180. }
  61181. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61182. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61183. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61184. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61185. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61187. import { Effect } from "babylonjs/Materials/effect";
  61188. import { Mesh } from "babylonjs/Meshes/mesh";
  61189. import { Scene } from "babylonjs/scene";
  61190. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61191. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61192. /**
  61193. * Block used to pertub normals based on a normal map
  61194. */
  61195. export class PerturbNormalBlock extends NodeMaterialBlock {
  61196. private _tangentSpaceParameterName;
  61197. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61198. invertX: boolean;
  61199. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61200. invertY: boolean;
  61201. /**
  61202. * Create a new PerturbNormalBlock
  61203. * @param name defines the block name
  61204. */
  61205. constructor(name: string);
  61206. /**
  61207. * Gets the current class name
  61208. * @returns the class name
  61209. */
  61210. getClassName(): string;
  61211. /**
  61212. * Gets the world position input component
  61213. */
  61214. get worldPosition(): NodeMaterialConnectionPoint;
  61215. /**
  61216. * Gets the world normal input component
  61217. */
  61218. get worldNormal(): NodeMaterialConnectionPoint;
  61219. /**
  61220. * Gets the world tangent input component
  61221. */
  61222. get worldTangent(): NodeMaterialConnectionPoint;
  61223. /**
  61224. * Gets the uv input component
  61225. */
  61226. get uv(): NodeMaterialConnectionPoint;
  61227. /**
  61228. * Gets the normal map color input component
  61229. */
  61230. get normalMapColor(): NodeMaterialConnectionPoint;
  61231. /**
  61232. * Gets the strength input component
  61233. */
  61234. get strength(): NodeMaterialConnectionPoint;
  61235. /**
  61236. * Gets the output component
  61237. */
  61238. get output(): NodeMaterialConnectionPoint;
  61239. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61240. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61241. autoConfigure(material: NodeMaterial): void;
  61242. protected _buildBlock(state: NodeMaterialBuildState): this;
  61243. protected _dumpPropertiesCode(): string;
  61244. serialize(): any;
  61245. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61246. }
  61247. }
  61248. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61249. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61250. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61251. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61252. /**
  61253. * Block used to discard a pixel if a value is smaller than a cutoff
  61254. */
  61255. export class DiscardBlock extends NodeMaterialBlock {
  61256. /**
  61257. * Create a new DiscardBlock
  61258. * @param name defines the block name
  61259. */
  61260. constructor(name: string);
  61261. /**
  61262. * Gets the current class name
  61263. * @returns the class name
  61264. */
  61265. getClassName(): string;
  61266. /**
  61267. * Gets the color input component
  61268. */
  61269. get value(): NodeMaterialConnectionPoint;
  61270. /**
  61271. * Gets the cutoff input component
  61272. */
  61273. get cutoff(): NodeMaterialConnectionPoint;
  61274. protected _buildBlock(state: NodeMaterialBuildState): this;
  61275. }
  61276. }
  61277. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61278. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61279. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61280. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61281. /**
  61282. * Block used to test if the fragment shader is front facing
  61283. */
  61284. export class FrontFacingBlock extends NodeMaterialBlock {
  61285. /**
  61286. * Creates a new FrontFacingBlock
  61287. * @param name defines the block name
  61288. */
  61289. constructor(name: string);
  61290. /**
  61291. * Gets the current class name
  61292. * @returns the class name
  61293. */
  61294. getClassName(): string;
  61295. /**
  61296. * Gets the output component
  61297. */
  61298. get output(): NodeMaterialConnectionPoint;
  61299. protected _buildBlock(state: NodeMaterialBuildState): this;
  61300. }
  61301. }
  61302. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61303. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61304. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61305. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61306. /**
  61307. * Block used to get the derivative value on x and y of a given input
  61308. */
  61309. export class DerivativeBlock extends NodeMaterialBlock {
  61310. /**
  61311. * Create a new DerivativeBlock
  61312. * @param name defines the block name
  61313. */
  61314. constructor(name: string);
  61315. /**
  61316. * Gets the current class name
  61317. * @returns the class name
  61318. */
  61319. getClassName(): string;
  61320. /**
  61321. * Gets the input component
  61322. */
  61323. get input(): NodeMaterialConnectionPoint;
  61324. /**
  61325. * Gets the derivative output on x
  61326. */
  61327. get dx(): NodeMaterialConnectionPoint;
  61328. /**
  61329. * Gets the derivative output on y
  61330. */
  61331. get dy(): NodeMaterialConnectionPoint;
  61332. protected _buildBlock(state: NodeMaterialBuildState): this;
  61333. }
  61334. }
  61335. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61336. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61337. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61338. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61339. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61340. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61341. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61342. }
  61343. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61344. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61345. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61346. import { Mesh } from "babylonjs/Meshes/mesh";
  61347. import { Effect } from "babylonjs/Materials/effect";
  61348. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61350. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61351. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61352. /**
  61353. * Block used to add support for scene fog
  61354. */
  61355. export class FogBlock extends NodeMaterialBlock {
  61356. private _fogDistanceName;
  61357. private _fogParameters;
  61358. /**
  61359. * Create a new FogBlock
  61360. * @param name defines the block name
  61361. */
  61362. constructor(name: string);
  61363. /**
  61364. * Gets the current class name
  61365. * @returns the class name
  61366. */
  61367. getClassName(): string;
  61368. /**
  61369. * Gets the world position input component
  61370. */
  61371. get worldPosition(): NodeMaterialConnectionPoint;
  61372. /**
  61373. * Gets the view input component
  61374. */
  61375. get view(): NodeMaterialConnectionPoint;
  61376. /**
  61377. * Gets the color input component
  61378. */
  61379. get input(): NodeMaterialConnectionPoint;
  61380. /**
  61381. * Gets the fog color input component
  61382. */
  61383. get fogColor(): NodeMaterialConnectionPoint;
  61384. /**
  61385. * Gets the output component
  61386. */
  61387. get output(): NodeMaterialConnectionPoint;
  61388. autoConfigure(material: NodeMaterial): void;
  61389. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61390. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61391. protected _buildBlock(state: NodeMaterialBuildState): this;
  61392. }
  61393. }
  61394. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61395. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61396. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61397. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61399. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61400. import { Effect } from "babylonjs/Materials/effect";
  61401. import { Mesh } from "babylonjs/Meshes/mesh";
  61402. import { Light } from "babylonjs/Lights/light";
  61403. import { Nullable } from "babylonjs/types";
  61404. import { Scene } from "babylonjs/scene";
  61405. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61406. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61407. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61408. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61409. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61410. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61411. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61412. /**
  61413. * Block used to add light in the fragment shader
  61414. */
  61415. export class LightBlock extends NodeMaterialBlock {
  61416. private _lightId;
  61417. /**
  61418. * Gets or sets the light associated with this block
  61419. */
  61420. light: Nullable<Light>;
  61421. /**
  61422. * Create a new LightBlock
  61423. * @param name defines the block name
  61424. */
  61425. constructor(name: string);
  61426. /**
  61427. * Gets the current class name
  61428. * @returns the class name
  61429. */
  61430. getClassName(): string;
  61431. /**
  61432. * Gets the world position input component
  61433. */
  61434. get worldPosition(): NodeMaterialConnectionPoint;
  61435. /**
  61436. * Gets the world normal input component
  61437. */
  61438. get worldNormal(): NodeMaterialConnectionPoint;
  61439. /**
  61440. * Gets the camera (or eye) position component
  61441. */
  61442. get cameraPosition(): NodeMaterialConnectionPoint;
  61443. /**
  61444. * Gets the glossiness component
  61445. */
  61446. get glossiness(): NodeMaterialConnectionPoint;
  61447. /**
  61448. * Gets the glossinness power component
  61449. */
  61450. get glossPower(): NodeMaterialConnectionPoint;
  61451. /**
  61452. * Gets the diffuse color component
  61453. */
  61454. get diffuseColor(): NodeMaterialConnectionPoint;
  61455. /**
  61456. * Gets the specular color component
  61457. */
  61458. get specularColor(): NodeMaterialConnectionPoint;
  61459. /**
  61460. * Gets the diffuse output component
  61461. */
  61462. get diffuseOutput(): NodeMaterialConnectionPoint;
  61463. /**
  61464. * Gets the specular output component
  61465. */
  61466. get specularOutput(): NodeMaterialConnectionPoint;
  61467. /**
  61468. * Gets the shadow output component
  61469. */
  61470. get shadow(): NodeMaterialConnectionPoint;
  61471. autoConfigure(material: NodeMaterial): void;
  61472. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61473. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61474. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61475. private _injectVertexCode;
  61476. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61477. serialize(): any;
  61478. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61479. }
  61480. }
  61481. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61482. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61483. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61484. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61485. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61486. }
  61487. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61488. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61489. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61490. }
  61491. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61492. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61493. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61494. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61495. /**
  61496. * Block used to multiply 2 values
  61497. */
  61498. export class MultiplyBlock extends NodeMaterialBlock {
  61499. /**
  61500. * Creates a new MultiplyBlock
  61501. * @param name defines the block name
  61502. */
  61503. constructor(name: string);
  61504. /**
  61505. * Gets the current class name
  61506. * @returns the class name
  61507. */
  61508. getClassName(): string;
  61509. /**
  61510. * Gets the left operand input component
  61511. */
  61512. get left(): NodeMaterialConnectionPoint;
  61513. /**
  61514. * Gets the right operand input component
  61515. */
  61516. get right(): NodeMaterialConnectionPoint;
  61517. /**
  61518. * Gets the output component
  61519. */
  61520. get output(): NodeMaterialConnectionPoint;
  61521. protected _buildBlock(state: NodeMaterialBuildState): this;
  61522. }
  61523. }
  61524. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61525. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61526. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61527. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61528. /**
  61529. * Block used to add 2 vectors
  61530. */
  61531. export class AddBlock extends NodeMaterialBlock {
  61532. /**
  61533. * Creates a new AddBlock
  61534. * @param name defines the block name
  61535. */
  61536. constructor(name: string);
  61537. /**
  61538. * Gets the current class name
  61539. * @returns the class name
  61540. */
  61541. getClassName(): string;
  61542. /**
  61543. * Gets the left operand input component
  61544. */
  61545. get left(): NodeMaterialConnectionPoint;
  61546. /**
  61547. * Gets the right operand input component
  61548. */
  61549. get right(): NodeMaterialConnectionPoint;
  61550. /**
  61551. * Gets the output component
  61552. */
  61553. get output(): NodeMaterialConnectionPoint;
  61554. protected _buildBlock(state: NodeMaterialBuildState): this;
  61555. }
  61556. }
  61557. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61558. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61559. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61560. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61561. /**
  61562. * Block used to scale a vector by a float
  61563. */
  61564. export class ScaleBlock extends NodeMaterialBlock {
  61565. /**
  61566. * Creates a new ScaleBlock
  61567. * @param name defines the block name
  61568. */
  61569. constructor(name: string);
  61570. /**
  61571. * Gets the current class name
  61572. * @returns the class name
  61573. */
  61574. getClassName(): string;
  61575. /**
  61576. * Gets the input component
  61577. */
  61578. get input(): NodeMaterialConnectionPoint;
  61579. /**
  61580. * Gets the factor input component
  61581. */
  61582. get factor(): NodeMaterialConnectionPoint;
  61583. /**
  61584. * Gets the output component
  61585. */
  61586. get output(): NodeMaterialConnectionPoint;
  61587. protected _buildBlock(state: NodeMaterialBuildState): this;
  61588. }
  61589. }
  61590. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61594. import { Scene } from "babylonjs/scene";
  61595. /**
  61596. * Block used to clamp a float
  61597. */
  61598. export class ClampBlock extends NodeMaterialBlock {
  61599. /** Gets or sets the minimum range */
  61600. minimum: number;
  61601. /** Gets or sets the maximum range */
  61602. maximum: number;
  61603. /**
  61604. * Creates a new ClampBlock
  61605. * @param name defines the block name
  61606. */
  61607. constructor(name: string);
  61608. /**
  61609. * Gets the current class name
  61610. * @returns the class name
  61611. */
  61612. getClassName(): string;
  61613. /**
  61614. * Gets the value input component
  61615. */
  61616. get value(): NodeMaterialConnectionPoint;
  61617. /**
  61618. * Gets the output component
  61619. */
  61620. get output(): NodeMaterialConnectionPoint;
  61621. protected _buildBlock(state: NodeMaterialBuildState): this;
  61622. protected _dumpPropertiesCode(): string;
  61623. serialize(): any;
  61624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61625. }
  61626. }
  61627. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61631. /**
  61632. * Block used to apply a cross product between 2 vectors
  61633. */
  61634. export class CrossBlock extends NodeMaterialBlock {
  61635. /**
  61636. * Creates a new CrossBlock
  61637. * @param name defines the block name
  61638. */
  61639. constructor(name: string);
  61640. /**
  61641. * Gets the current class name
  61642. * @returns the class name
  61643. */
  61644. getClassName(): string;
  61645. /**
  61646. * Gets the left operand input component
  61647. */
  61648. get left(): NodeMaterialConnectionPoint;
  61649. /**
  61650. * Gets the right operand input component
  61651. */
  61652. get right(): NodeMaterialConnectionPoint;
  61653. /**
  61654. * Gets the output component
  61655. */
  61656. get output(): NodeMaterialConnectionPoint;
  61657. protected _buildBlock(state: NodeMaterialBuildState): this;
  61658. }
  61659. }
  61660. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61661. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61662. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61663. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61664. /**
  61665. * Block used to apply a dot product between 2 vectors
  61666. */
  61667. export class DotBlock extends NodeMaterialBlock {
  61668. /**
  61669. * Creates a new DotBlock
  61670. * @param name defines the block name
  61671. */
  61672. constructor(name: string);
  61673. /**
  61674. * Gets the current class name
  61675. * @returns the class name
  61676. */
  61677. getClassName(): string;
  61678. /**
  61679. * Gets the left operand input component
  61680. */
  61681. get left(): NodeMaterialConnectionPoint;
  61682. /**
  61683. * Gets the right operand input component
  61684. */
  61685. get right(): NodeMaterialConnectionPoint;
  61686. /**
  61687. * Gets the output component
  61688. */
  61689. get output(): NodeMaterialConnectionPoint;
  61690. protected _buildBlock(state: NodeMaterialBuildState): this;
  61691. }
  61692. }
  61693. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61694. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61695. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61696. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61697. import { Vector2 } from "babylonjs/Maths/math.vector";
  61698. import { Scene } from "babylonjs/scene";
  61699. /**
  61700. * Block used to remap a float from a range to a new one
  61701. */
  61702. export class RemapBlock extends NodeMaterialBlock {
  61703. /**
  61704. * Gets or sets the source range
  61705. */
  61706. sourceRange: Vector2;
  61707. /**
  61708. * Gets or sets the target range
  61709. */
  61710. targetRange: Vector2;
  61711. /**
  61712. * Creates a new RemapBlock
  61713. * @param name defines the block name
  61714. */
  61715. constructor(name: string);
  61716. /**
  61717. * Gets the current class name
  61718. * @returns the class name
  61719. */
  61720. getClassName(): string;
  61721. /**
  61722. * Gets the input component
  61723. */
  61724. get input(): NodeMaterialConnectionPoint;
  61725. /**
  61726. * Gets the source min input component
  61727. */
  61728. get sourceMin(): NodeMaterialConnectionPoint;
  61729. /**
  61730. * Gets the source max input component
  61731. */
  61732. get sourceMax(): NodeMaterialConnectionPoint;
  61733. /**
  61734. * Gets the target min input component
  61735. */
  61736. get targetMin(): NodeMaterialConnectionPoint;
  61737. /**
  61738. * Gets the target max input component
  61739. */
  61740. get targetMax(): NodeMaterialConnectionPoint;
  61741. /**
  61742. * Gets the output component
  61743. */
  61744. get output(): NodeMaterialConnectionPoint;
  61745. protected _buildBlock(state: NodeMaterialBuildState): this;
  61746. protected _dumpPropertiesCode(): string;
  61747. serialize(): any;
  61748. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61749. }
  61750. }
  61751. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61752. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61753. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61754. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61755. /**
  61756. * Block used to normalize a vector
  61757. */
  61758. export class NormalizeBlock extends NodeMaterialBlock {
  61759. /**
  61760. * Creates a new NormalizeBlock
  61761. * @param name defines the block name
  61762. */
  61763. constructor(name: string);
  61764. /**
  61765. * Gets the current class name
  61766. * @returns the class name
  61767. */
  61768. getClassName(): string;
  61769. /**
  61770. * Gets the input component
  61771. */
  61772. get input(): NodeMaterialConnectionPoint;
  61773. /**
  61774. * Gets the output component
  61775. */
  61776. get output(): NodeMaterialConnectionPoint;
  61777. protected _buildBlock(state: NodeMaterialBuildState): this;
  61778. }
  61779. }
  61780. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61781. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61782. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61783. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61784. import { Scene } from "babylonjs/scene";
  61785. /**
  61786. * Operations supported by the Trigonometry block
  61787. */
  61788. export enum TrigonometryBlockOperations {
  61789. /** Cos */
  61790. Cos = 0,
  61791. /** Sin */
  61792. Sin = 1,
  61793. /** Abs */
  61794. Abs = 2,
  61795. /** Exp */
  61796. Exp = 3,
  61797. /** Exp2 */
  61798. Exp2 = 4,
  61799. /** Round */
  61800. Round = 5,
  61801. /** Floor */
  61802. Floor = 6,
  61803. /** Ceiling */
  61804. Ceiling = 7,
  61805. /** Square root */
  61806. Sqrt = 8,
  61807. /** Log */
  61808. Log = 9,
  61809. /** Tangent */
  61810. Tan = 10,
  61811. /** Arc tangent */
  61812. ArcTan = 11,
  61813. /** Arc cosinus */
  61814. ArcCos = 12,
  61815. /** Arc sinus */
  61816. ArcSin = 13,
  61817. /** Fraction */
  61818. Fract = 14,
  61819. /** Sign */
  61820. Sign = 15,
  61821. /** To radians (from degrees) */
  61822. Radians = 16,
  61823. /** To degrees (from radians) */
  61824. Degrees = 17
  61825. }
  61826. /**
  61827. * Block used to apply trigonometry operation to floats
  61828. */
  61829. export class TrigonometryBlock extends NodeMaterialBlock {
  61830. /**
  61831. * Gets or sets the operation applied by the block
  61832. */
  61833. operation: TrigonometryBlockOperations;
  61834. /**
  61835. * Creates a new TrigonometryBlock
  61836. * @param name defines the block name
  61837. */
  61838. constructor(name: string);
  61839. /**
  61840. * Gets the current class name
  61841. * @returns the class name
  61842. */
  61843. getClassName(): string;
  61844. /**
  61845. * Gets the input component
  61846. */
  61847. get input(): NodeMaterialConnectionPoint;
  61848. /**
  61849. * Gets the output component
  61850. */
  61851. get output(): NodeMaterialConnectionPoint;
  61852. protected _buildBlock(state: NodeMaterialBuildState): this;
  61853. serialize(): any;
  61854. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61855. protected _dumpPropertiesCode(): string;
  61856. }
  61857. }
  61858. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61859. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61860. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61861. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61862. /**
  61863. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61864. */
  61865. export class ColorMergerBlock extends NodeMaterialBlock {
  61866. /**
  61867. * Create a new ColorMergerBlock
  61868. * @param name defines the block name
  61869. */
  61870. constructor(name: string);
  61871. /**
  61872. * Gets the current class name
  61873. * @returns the class name
  61874. */
  61875. getClassName(): string;
  61876. /**
  61877. * Gets the rgb component (input)
  61878. */
  61879. get rgbIn(): NodeMaterialConnectionPoint;
  61880. /**
  61881. * Gets the r component (input)
  61882. */
  61883. get r(): NodeMaterialConnectionPoint;
  61884. /**
  61885. * Gets the g component (input)
  61886. */
  61887. get g(): NodeMaterialConnectionPoint;
  61888. /**
  61889. * Gets the b component (input)
  61890. */
  61891. get b(): NodeMaterialConnectionPoint;
  61892. /**
  61893. * Gets the a component (input)
  61894. */
  61895. get a(): NodeMaterialConnectionPoint;
  61896. /**
  61897. * Gets the rgba component (output)
  61898. */
  61899. get rgba(): NodeMaterialConnectionPoint;
  61900. /**
  61901. * Gets the rgb component (output)
  61902. */
  61903. get rgbOut(): NodeMaterialConnectionPoint;
  61904. /**
  61905. * Gets the rgb component (output)
  61906. * @deprecated Please use rgbOut instead.
  61907. */
  61908. get rgb(): NodeMaterialConnectionPoint;
  61909. protected _buildBlock(state: NodeMaterialBuildState): this;
  61910. }
  61911. }
  61912. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61913. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61914. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61915. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61916. /**
  61917. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61918. */
  61919. export class VectorMergerBlock extends NodeMaterialBlock {
  61920. /**
  61921. * Create a new VectorMergerBlock
  61922. * @param name defines the block name
  61923. */
  61924. constructor(name: string);
  61925. /**
  61926. * Gets the current class name
  61927. * @returns the class name
  61928. */
  61929. getClassName(): string;
  61930. /**
  61931. * Gets the xyz component (input)
  61932. */
  61933. get xyzIn(): NodeMaterialConnectionPoint;
  61934. /**
  61935. * Gets the xy component (input)
  61936. */
  61937. get xyIn(): NodeMaterialConnectionPoint;
  61938. /**
  61939. * Gets the x component (input)
  61940. */
  61941. get x(): NodeMaterialConnectionPoint;
  61942. /**
  61943. * Gets the y component (input)
  61944. */
  61945. get y(): NodeMaterialConnectionPoint;
  61946. /**
  61947. * Gets the z component (input)
  61948. */
  61949. get z(): NodeMaterialConnectionPoint;
  61950. /**
  61951. * Gets the w component (input)
  61952. */
  61953. get w(): NodeMaterialConnectionPoint;
  61954. /**
  61955. * Gets the xyzw component (output)
  61956. */
  61957. get xyzw(): NodeMaterialConnectionPoint;
  61958. /**
  61959. * Gets the xyz component (output)
  61960. */
  61961. get xyzOut(): NodeMaterialConnectionPoint;
  61962. /**
  61963. * Gets the xy component (output)
  61964. */
  61965. get xyOut(): NodeMaterialConnectionPoint;
  61966. /**
  61967. * Gets the xy component (output)
  61968. * @deprecated Please use xyOut instead.
  61969. */
  61970. get xy(): NodeMaterialConnectionPoint;
  61971. /**
  61972. * Gets the xyz component (output)
  61973. * @deprecated Please use xyzOut instead.
  61974. */
  61975. get xyz(): NodeMaterialConnectionPoint;
  61976. protected _buildBlock(state: NodeMaterialBuildState): this;
  61977. }
  61978. }
  61979. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61980. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61981. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61982. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61983. /**
  61984. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61985. */
  61986. export class ColorSplitterBlock extends NodeMaterialBlock {
  61987. /**
  61988. * Create a new ColorSplitterBlock
  61989. * @param name defines the block name
  61990. */
  61991. constructor(name: string);
  61992. /**
  61993. * Gets the current class name
  61994. * @returns the class name
  61995. */
  61996. getClassName(): string;
  61997. /**
  61998. * Gets the rgba component (input)
  61999. */
  62000. get rgba(): NodeMaterialConnectionPoint;
  62001. /**
  62002. * Gets the rgb component (input)
  62003. */
  62004. get rgbIn(): NodeMaterialConnectionPoint;
  62005. /**
  62006. * Gets the rgb component (output)
  62007. */
  62008. get rgbOut(): NodeMaterialConnectionPoint;
  62009. /**
  62010. * Gets the r component (output)
  62011. */
  62012. get r(): NodeMaterialConnectionPoint;
  62013. /**
  62014. * Gets the g component (output)
  62015. */
  62016. get g(): NodeMaterialConnectionPoint;
  62017. /**
  62018. * Gets the b component (output)
  62019. */
  62020. get b(): NodeMaterialConnectionPoint;
  62021. /**
  62022. * Gets the a component (output)
  62023. */
  62024. get a(): NodeMaterialConnectionPoint;
  62025. protected _inputRename(name: string): string;
  62026. protected _outputRename(name: string): string;
  62027. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62028. }
  62029. }
  62030. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62031. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62032. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62033. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62034. /**
  62035. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62036. */
  62037. export class VectorSplitterBlock extends NodeMaterialBlock {
  62038. /**
  62039. * Create a new VectorSplitterBlock
  62040. * @param name defines the block name
  62041. */
  62042. constructor(name: string);
  62043. /**
  62044. * Gets the current class name
  62045. * @returns the class name
  62046. */
  62047. getClassName(): string;
  62048. /**
  62049. * Gets the xyzw component (input)
  62050. */
  62051. get xyzw(): NodeMaterialConnectionPoint;
  62052. /**
  62053. * Gets the xyz component (input)
  62054. */
  62055. get xyzIn(): NodeMaterialConnectionPoint;
  62056. /**
  62057. * Gets the xy component (input)
  62058. */
  62059. get xyIn(): NodeMaterialConnectionPoint;
  62060. /**
  62061. * Gets the xyz component (output)
  62062. */
  62063. get xyzOut(): NodeMaterialConnectionPoint;
  62064. /**
  62065. * Gets the xy component (output)
  62066. */
  62067. get xyOut(): NodeMaterialConnectionPoint;
  62068. /**
  62069. * Gets the x component (output)
  62070. */
  62071. get x(): NodeMaterialConnectionPoint;
  62072. /**
  62073. * Gets the y component (output)
  62074. */
  62075. get y(): NodeMaterialConnectionPoint;
  62076. /**
  62077. * Gets the z component (output)
  62078. */
  62079. get z(): NodeMaterialConnectionPoint;
  62080. /**
  62081. * Gets the w component (output)
  62082. */
  62083. get w(): NodeMaterialConnectionPoint;
  62084. protected _inputRename(name: string): string;
  62085. protected _outputRename(name: string): string;
  62086. protected _buildBlock(state: NodeMaterialBuildState): this;
  62087. }
  62088. }
  62089. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62090. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62091. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62093. /**
  62094. * Block used to lerp between 2 values
  62095. */
  62096. export class LerpBlock extends NodeMaterialBlock {
  62097. /**
  62098. * Creates a new LerpBlock
  62099. * @param name defines the block name
  62100. */
  62101. constructor(name: string);
  62102. /**
  62103. * Gets the current class name
  62104. * @returns the class name
  62105. */
  62106. getClassName(): string;
  62107. /**
  62108. * Gets the left operand input component
  62109. */
  62110. get left(): NodeMaterialConnectionPoint;
  62111. /**
  62112. * Gets the right operand input component
  62113. */
  62114. get right(): NodeMaterialConnectionPoint;
  62115. /**
  62116. * Gets the gradient operand input component
  62117. */
  62118. get gradient(): NodeMaterialConnectionPoint;
  62119. /**
  62120. * Gets the output component
  62121. */
  62122. get output(): NodeMaterialConnectionPoint;
  62123. protected _buildBlock(state: NodeMaterialBuildState): this;
  62124. }
  62125. }
  62126. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62130. /**
  62131. * Block used to divide 2 vectors
  62132. */
  62133. export class DivideBlock extends NodeMaterialBlock {
  62134. /**
  62135. * Creates a new DivideBlock
  62136. * @param name defines the block name
  62137. */
  62138. constructor(name: string);
  62139. /**
  62140. * Gets the current class name
  62141. * @returns the class name
  62142. */
  62143. getClassName(): string;
  62144. /**
  62145. * Gets the left operand input component
  62146. */
  62147. get left(): NodeMaterialConnectionPoint;
  62148. /**
  62149. * Gets the right operand input component
  62150. */
  62151. get right(): NodeMaterialConnectionPoint;
  62152. /**
  62153. * Gets the output component
  62154. */
  62155. get output(): NodeMaterialConnectionPoint;
  62156. protected _buildBlock(state: NodeMaterialBuildState): this;
  62157. }
  62158. }
  62159. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62160. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62161. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62162. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62163. /**
  62164. * Block used to subtract 2 vectors
  62165. */
  62166. export class SubtractBlock extends NodeMaterialBlock {
  62167. /**
  62168. * Creates a new SubtractBlock
  62169. * @param name defines the block name
  62170. */
  62171. constructor(name: string);
  62172. /**
  62173. * Gets the current class name
  62174. * @returns the class name
  62175. */
  62176. getClassName(): string;
  62177. /**
  62178. * Gets the left operand input component
  62179. */
  62180. get left(): NodeMaterialConnectionPoint;
  62181. /**
  62182. * Gets the right operand input component
  62183. */
  62184. get right(): NodeMaterialConnectionPoint;
  62185. /**
  62186. * Gets the output component
  62187. */
  62188. get output(): NodeMaterialConnectionPoint;
  62189. protected _buildBlock(state: NodeMaterialBuildState): this;
  62190. }
  62191. }
  62192. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62194. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62196. /**
  62197. * Block used to step a value
  62198. */
  62199. export class StepBlock extends NodeMaterialBlock {
  62200. /**
  62201. * Creates a new StepBlock
  62202. * @param name defines the block name
  62203. */
  62204. constructor(name: string);
  62205. /**
  62206. * Gets the current class name
  62207. * @returns the class name
  62208. */
  62209. getClassName(): string;
  62210. /**
  62211. * Gets the value operand input component
  62212. */
  62213. get value(): NodeMaterialConnectionPoint;
  62214. /**
  62215. * Gets the edge operand input component
  62216. */
  62217. get edge(): NodeMaterialConnectionPoint;
  62218. /**
  62219. * Gets the output component
  62220. */
  62221. get output(): NodeMaterialConnectionPoint;
  62222. protected _buildBlock(state: NodeMaterialBuildState): this;
  62223. }
  62224. }
  62225. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62226. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62227. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62228. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62229. /**
  62230. * Block used to get the opposite (1 - x) of a value
  62231. */
  62232. export class OneMinusBlock extends NodeMaterialBlock {
  62233. /**
  62234. * Creates a new OneMinusBlock
  62235. * @param name defines the block name
  62236. */
  62237. constructor(name: string);
  62238. /**
  62239. * Gets the current class name
  62240. * @returns the class name
  62241. */
  62242. getClassName(): string;
  62243. /**
  62244. * Gets the input component
  62245. */
  62246. get input(): NodeMaterialConnectionPoint;
  62247. /**
  62248. * Gets the output component
  62249. */
  62250. get output(): NodeMaterialConnectionPoint;
  62251. protected _buildBlock(state: NodeMaterialBuildState): this;
  62252. }
  62253. }
  62254. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62258. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62259. /**
  62260. * Block used to get the view direction
  62261. */
  62262. export class ViewDirectionBlock extends NodeMaterialBlock {
  62263. /**
  62264. * Creates a new ViewDirectionBlock
  62265. * @param name defines the block name
  62266. */
  62267. constructor(name: string);
  62268. /**
  62269. * Gets the current class name
  62270. * @returns the class name
  62271. */
  62272. getClassName(): string;
  62273. /**
  62274. * Gets the world position component
  62275. */
  62276. get worldPosition(): NodeMaterialConnectionPoint;
  62277. /**
  62278. * Gets the camera position component
  62279. */
  62280. get cameraPosition(): NodeMaterialConnectionPoint;
  62281. /**
  62282. * Gets the output component
  62283. */
  62284. get output(): NodeMaterialConnectionPoint;
  62285. autoConfigure(material: NodeMaterial): void;
  62286. protected _buildBlock(state: NodeMaterialBuildState): this;
  62287. }
  62288. }
  62289. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62291. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62292. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62293. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62294. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62295. /**
  62296. * Block used to compute fresnel value
  62297. */
  62298. export class FresnelBlock extends NodeMaterialBlock {
  62299. /**
  62300. * Create a new FresnelBlock
  62301. * @param name defines the block name
  62302. */
  62303. constructor(name: string);
  62304. /**
  62305. * Gets the current class name
  62306. * @returns the class name
  62307. */
  62308. getClassName(): string;
  62309. /**
  62310. * Gets the world normal input component
  62311. */
  62312. get worldNormal(): NodeMaterialConnectionPoint;
  62313. /**
  62314. * Gets the view direction input component
  62315. */
  62316. get viewDirection(): NodeMaterialConnectionPoint;
  62317. /**
  62318. * Gets the bias input component
  62319. */
  62320. get bias(): NodeMaterialConnectionPoint;
  62321. /**
  62322. * Gets the camera (or eye) position component
  62323. */
  62324. get power(): NodeMaterialConnectionPoint;
  62325. /**
  62326. * Gets the fresnel output component
  62327. */
  62328. get fresnel(): NodeMaterialConnectionPoint;
  62329. autoConfigure(material: NodeMaterial): void;
  62330. protected _buildBlock(state: NodeMaterialBuildState): this;
  62331. }
  62332. }
  62333. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62335. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62336. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62337. /**
  62338. * Block used to get the max of 2 values
  62339. */
  62340. export class MaxBlock extends NodeMaterialBlock {
  62341. /**
  62342. * Creates a new MaxBlock
  62343. * @param name defines the block name
  62344. */
  62345. constructor(name: string);
  62346. /**
  62347. * Gets the current class name
  62348. * @returns the class name
  62349. */
  62350. getClassName(): string;
  62351. /**
  62352. * Gets the left operand input component
  62353. */
  62354. get left(): NodeMaterialConnectionPoint;
  62355. /**
  62356. * Gets the right operand input component
  62357. */
  62358. get right(): NodeMaterialConnectionPoint;
  62359. /**
  62360. * Gets the output component
  62361. */
  62362. get output(): NodeMaterialConnectionPoint;
  62363. protected _buildBlock(state: NodeMaterialBuildState): this;
  62364. }
  62365. }
  62366. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62370. /**
  62371. * Block used to get the min of 2 values
  62372. */
  62373. export class MinBlock extends NodeMaterialBlock {
  62374. /**
  62375. * Creates a new MinBlock
  62376. * @param name defines the block name
  62377. */
  62378. constructor(name: string);
  62379. /**
  62380. * Gets the current class name
  62381. * @returns the class name
  62382. */
  62383. getClassName(): string;
  62384. /**
  62385. * Gets the left operand input component
  62386. */
  62387. get left(): NodeMaterialConnectionPoint;
  62388. /**
  62389. * Gets the right operand input component
  62390. */
  62391. get right(): NodeMaterialConnectionPoint;
  62392. /**
  62393. * Gets the output component
  62394. */
  62395. get output(): NodeMaterialConnectionPoint;
  62396. protected _buildBlock(state: NodeMaterialBuildState): this;
  62397. }
  62398. }
  62399. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62403. /**
  62404. * Block used to get the distance between 2 values
  62405. */
  62406. export class DistanceBlock extends NodeMaterialBlock {
  62407. /**
  62408. * Creates a new DistanceBlock
  62409. * @param name defines the block name
  62410. */
  62411. constructor(name: string);
  62412. /**
  62413. * Gets the current class name
  62414. * @returns the class name
  62415. */
  62416. getClassName(): string;
  62417. /**
  62418. * Gets the left operand input component
  62419. */
  62420. get left(): NodeMaterialConnectionPoint;
  62421. /**
  62422. * Gets the right operand input component
  62423. */
  62424. get right(): NodeMaterialConnectionPoint;
  62425. /**
  62426. * Gets the output component
  62427. */
  62428. get output(): NodeMaterialConnectionPoint;
  62429. protected _buildBlock(state: NodeMaterialBuildState): this;
  62430. }
  62431. }
  62432. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62434. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62435. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62436. /**
  62437. * Block used to get the length of a vector
  62438. */
  62439. export class LengthBlock extends NodeMaterialBlock {
  62440. /**
  62441. * Creates a new LengthBlock
  62442. * @param name defines the block name
  62443. */
  62444. constructor(name: string);
  62445. /**
  62446. * Gets the current class name
  62447. * @returns the class name
  62448. */
  62449. getClassName(): string;
  62450. /**
  62451. * Gets the value input component
  62452. */
  62453. get value(): NodeMaterialConnectionPoint;
  62454. /**
  62455. * Gets the output component
  62456. */
  62457. get output(): NodeMaterialConnectionPoint;
  62458. protected _buildBlock(state: NodeMaterialBuildState): this;
  62459. }
  62460. }
  62461. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62462. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62463. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62464. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62465. /**
  62466. * Block used to get negative version of a value (i.e. x * -1)
  62467. */
  62468. export class NegateBlock extends NodeMaterialBlock {
  62469. /**
  62470. * Creates a new NegateBlock
  62471. * @param name defines the block name
  62472. */
  62473. constructor(name: string);
  62474. /**
  62475. * Gets the current class name
  62476. * @returns the class name
  62477. */
  62478. getClassName(): string;
  62479. /**
  62480. * Gets the value input component
  62481. */
  62482. get value(): NodeMaterialConnectionPoint;
  62483. /**
  62484. * Gets the output component
  62485. */
  62486. get output(): NodeMaterialConnectionPoint;
  62487. protected _buildBlock(state: NodeMaterialBuildState): this;
  62488. }
  62489. }
  62490. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62492. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62493. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62494. /**
  62495. * Block used to get the value of the first parameter raised to the power of the second
  62496. */
  62497. export class PowBlock extends NodeMaterialBlock {
  62498. /**
  62499. * Creates a new PowBlock
  62500. * @param name defines the block name
  62501. */
  62502. constructor(name: string);
  62503. /**
  62504. * Gets the current class name
  62505. * @returns the class name
  62506. */
  62507. getClassName(): string;
  62508. /**
  62509. * Gets the value operand input component
  62510. */
  62511. get value(): NodeMaterialConnectionPoint;
  62512. /**
  62513. * Gets the power operand input component
  62514. */
  62515. get power(): NodeMaterialConnectionPoint;
  62516. /**
  62517. * Gets the output component
  62518. */
  62519. get output(): NodeMaterialConnectionPoint;
  62520. protected _buildBlock(state: NodeMaterialBuildState): this;
  62521. }
  62522. }
  62523. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62524. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62525. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62526. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62527. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62528. /**
  62529. * Block used to get a random number
  62530. */
  62531. export class RandomNumberBlock extends NodeMaterialBlock {
  62532. /**
  62533. * Creates a new RandomNumberBlock
  62534. * @param name defines the block name
  62535. */
  62536. constructor(name: string);
  62537. /**
  62538. * Gets the current class name
  62539. * @returns the class name
  62540. */
  62541. getClassName(): string;
  62542. /**
  62543. * Gets the seed input component
  62544. */
  62545. get seed(): NodeMaterialConnectionPoint;
  62546. /**
  62547. * Gets the output component
  62548. */
  62549. get output(): NodeMaterialConnectionPoint;
  62550. protected _buildBlock(state: NodeMaterialBuildState): this;
  62551. }
  62552. }
  62553. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62557. /**
  62558. * Block used to compute arc tangent of 2 values
  62559. */
  62560. export class ArcTan2Block extends NodeMaterialBlock {
  62561. /**
  62562. * Creates a new ArcTan2Block
  62563. * @param name defines the block name
  62564. */
  62565. constructor(name: string);
  62566. /**
  62567. * Gets the current class name
  62568. * @returns the class name
  62569. */
  62570. getClassName(): string;
  62571. /**
  62572. * Gets the x operand input component
  62573. */
  62574. get x(): NodeMaterialConnectionPoint;
  62575. /**
  62576. * Gets the y operand input component
  62577. */
  62578. get y(): NodeMaterialConnectionPoint;
  62579. /**
  62580. * Gets the output component
  62581. */
  62582. get output(): NodeMaterialConnectionPoint;
  62583. protected _buildBlock(state: NodeMaterialBuildState): this;
  62584. }
  62585. }
  62586. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62587. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62588. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62589. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62590. /**
  62591. * Block used to smooth step a value
  62592. */
  62593. export class SmoothStepBlock extends NodeMaterialBlock {
  62594. /**
  62595. * Creates a new SmoothStepBlock
  62596. * @param name defines the block name
  62597. */
  62598. constructor(name: string);
  62599. /**
  62600. * Gets the current class name
  62601. * @returns the class name
  62602. */
  62603. getClassName(): string;
  62604. /**
  62605. * Gets the value operand input component
  62606. */
  62607. get value(): NodeMaterialConnectionPoint;
  62608. /**
  62609. * Gets the first edge operand input component
  62610. */
  62611. get edge0(): NodeMaterialConnectionPoint;
  62612. /**
  62613. * Gets the second edge operand input component
  62614. */
  62615. get edge1(): NodeMaterialConnectionPoint;
  62616. /**
  62617. * Gets the output component
  62618. */
  62619. get output(): NodeMaterialConnectionPoint;
  62620. protected _buildBlock(state: NodeMaterialBuildState): this;
  62621. }
  62622. }
  62623. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62624. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62625. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62626. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62627. /**
  62628. * Block used to get the reciprocal (1 / x) of a value
  62629. */
  62630. export class ReciprocalBlock extends NodeMaterialBlock {
  62631. /**
  62632. * Creates a new ReciprocalBlock
  62633. * @param name defines the block name
  62634. */
  62635. constructor(name: string);
  62636. /**
  62637. * Gets the current class name
  62638. * @returns the class name
  62639. */
  62640. getClassName(): string;
  62641. /**
  62642. * Gets the input component
  62643. */
  62644. get input(): NodeMaterialConnectionPoint;
  62645. /**
  62646. * Gets the output component
  62647. */
  62648. get output(): NodeMaterialConnectionPoint;
  62649. protected _buildBlock(state: NodeMaterialBuildState): this;
  62650. }
  62651. }
  62652. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62653. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62654. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62655. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62656. /**
  62657. * Block used to replace a color by another one
  62658. */
  62659. export class ReplaceColorBlock extends NodeMaterialBlock {
  62660. /**
  62661. * Creates a new ReplaceColorBlock
  62662. * @param name defines the block name
  62663. */
  62664. constructor(name: string);
  62665. /**
  62666. * Gets the current class name
  62667. * @returns the class name
  62668. */
  62669. getClassName(): string;
  62670. /**
  62671. * Gets the value input component
  62672. */
  62673. get value(): NodeMaterialConnectionPoint;
  62674. /**
  62675. * Gets the reference input component
  62676. */
  62677. get reference(): NodeMaterialConnectionPoint;
  62678. /**
  62679. * Gets the distance input component
  62680. */
  62681. get distance(): NodeMaterialConnectionPoint;
  62682. /**
  62683. * Gets the replacement input component
  62684. */
  62685. get replacement(): NodeMaterialConnectionPoint;
  62686. /**
  62687. * Gets the output component
  62688. */
  62689. get output(): NodeMaterialConnectionPoint;
  62690. protected _buildBlock(state: NodeMaterialBuildState): this;
  62691. }
  62692. }
  62693. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62694. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62695. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62696. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62697. /**
  62698. * Block used to posterize a value
  62699. * @see https://en.wikipedia.org/wiki/Posterization
  62700. */
  62701. export class PosterizeBlock extends NodeMaterialBlock {
  62702. /**
  62703. * Creates a new PosterizeBlock
  62704. * @param name defines the block name
  62705. */
  62706. constructor(name: string);
  62707. /**
  62708. * Gets the current class name
  62709. * @returns the class name
  62710. */
  62711. getClassName(): string;
  62712. /**
  62713. * Gets the value input component
  62714. */
  62715. get value(): NodeMaterialConnectionPoint;
  62716. /**
  62717. * Gets the steps input component
  62718. */
  62719. get steps(): NodeMaterialConnectionPoint;
  62720. /**
  62721. * Gets the output component
  62722. */
  62723. get output(): NodeMaterialConnectionPoint;
  62724. protected _buildBlock(state: NodeMaterialBuildState): this;
  62725. }
  62726. }
  62727. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62728. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62729. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62730. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62731. import { Scene } from "babylonjs/scene";
  62732. /**
  62733. * Operations supported by the Wave block
  62734. */
  62735. export enum WaveBlockKind {
  62736. /** SawTooth */
  62737. SawTooth = 0,
  62738. /** Square */
  62739. Square = 1,
  62740. /** Triangle */
  62741. Triangle = 2
  62742. }
  62743. /**
  62744. * Block used to apply wave operation to floats
  62745. */
  62746. export class WaveBlock extends NodeMaterialBlock {
  62747. /**
  62748. * Gets or sets the kibnd of wave to be applied by the block
  62749. */
  62750. kind: WaveBlockKind;
  62751. /**
  62752. * Creates a new WaveBlock
  62753. * @param name defines the block name
  62754. */
  62755. constructor(name: string);
  62756. /**
  62757. * Gets the current class name
  62758. * @returns the class name
  62759. */
  62760. getClassName(): string;
  62761. /**
  62762. * Gets the input component
  62763. */
  62764. get input(): NodeMaterialConnectionPoint;
  62765. /**
  62766. * Gets the output component
  62767. */
  62768. get output(): NodeMaterialConnectionPoint;
  62769. protected _buildBlock(state: NodeMaterialBuildState): this;
  62770. serialize(): any;
  62771. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62772. }
  62773. }
  62774. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62775. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62776. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62777. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62778. import { Color3 } from "babylonjs/Maths/math.color";
  62779. import { Scene } from "babylonjs/scene";
  62780. /**
  62781. * Class used to store a color step for the GradientBlock
  62782. */
  62783. export class GradientBlockColorStep {
  62784. /**
  62785. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62786. */
  62787. step: number;
  62788. /**
  62789. * Gets or sets the color associated with this step
  62790. */
  62791. color: Color3;
  62792. /**
  62793. * Creates a new GradientBlockColorStep
  62794. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62795. * @param color defines the color associated with this step
  62796. */
  62797. constructor(
  62798. /**
  62799. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62800. */
  62801. step: number,
  62802. /**
  62803. * Gets or sets the color associated with this step
  62804. */
  62805. color: Color3);
  62806. }
  62807. /**
  62808. * Block used to return a color from a gradient based on an input value between 0 and 1
  62809. */
  62810. export class GradientBlock extends NodeMaterialBlock {
  62811. /**
  62812. * Gets or sets the list of color steps
  62813. */
  62814. colorSteps: GradientBlockColorStep[];
  62815. /**
  62816. * Creates a new GradientBlock
  62817. * @param name defines the block name
  62818. */
  62819. constructor(name: string);
  62820. /**
  62821. * Gets the current class name
  62822. * @returns the class name
  62823. */
  62824. getClassName(): string;
  62825. /**
  62826. * Gets the gradient input component
  62827. */
  62828. get gradient(): NodeMaterialConnectionPoint;
  62829. /**
  62830. * Gets the output component
  62831. */
  62832. get output(): NodeMaterialConnectionPoint;
  62833. private _writeColorConstant;
  62834. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62835. serialize(): any;
  62836. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62837. protected _dumpPropertiesCode(): string;
  62838. }
  62839. }
  62840. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62844. /**
  62845. * Block used to normalize lerp between 2 values
  62846. */
  62847. export class NLerpBlock extends NodeMaterialBlock {
  62848. /**
  62849. * Creates a new NLerpBlock
  62850. * @param name defines the block name
  62851. */
  62852. constructor(name: string);
  62853. /**
  62854. * Gets the current class name
  62855. * @returns the class name
  62856. */
  62857. getClassName(): string;
  62858. /**
  62859. * Gets the left operand input component
  62860. */
  62861. get left(): NodeMaterialConnectionPoint;
  62862. /**
  62863. * Gets the right operand input component
  62864. */
  62865. get right(): NodeMaterialConnectionPoint;
  62866. /**
  62867. * Gets the gradient operand input component
  62868. */
  62869. get gradient(): NodeMaterialConnectionPoint;
  62870. /**
  62871. * Gets the output component
  62872. */
  62873. get output(): NodeMaterialConnectionPoint;
  62874. protected _buildBlock(state: NodeMaterialBuildState): this;
  62875. }
  62876. }
  62877. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62878. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62879. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62880. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62881. import { Scene } from "babylonjs/scene";
  62882. /**
  62883. * block used to Generate a Worley Noise 3D Noise Pattern
  62884. */
  62885. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62886. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62887. manhattanDistance: boolean;
  62888. /**
  62889. * Creates a new WorleyNoise3DBlock
  62890. * @param name defines the block name
  62891. */
  62892. constructor(name: string);
  62893. /**
  62894. * Gets the current class name
  62895. * @returns the class name
  62896. */
  62897. getClassName(): string;
  62898. /**
  62899. * Gets the seed input component
  62900. */
  62901. get seed(): NodeMaterialConnectionPoint;
  62902. /**
  62903. * Gets the jitter input component
  62904. */
  62905. get jitter(): NodeMaterialConnectionPoint;
  62906. /**
  62907. * Gets the output component
  62908. */
  62909. get output(): NodeMaterialConnectionPoint;
  62910. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62911. /**
  62912. * Exposes the properties to the UI?
  62913. */
  62914. protected _dumpPropertiesCode(): string;
  62915. /**
  62916. * Exposes the properties to the Seralize?
  62917. */
  62918. serialize(): any;
  62919. /**
  62920. * Exposes the properties to the deseralize?
  62921. */
  62922. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62923. }
  62924. }
  62925. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62926. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62927. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62928. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62929. /**
  62930. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62931. */
  62932. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62933. /**
  62934. * Creates a new SimplexPerlin3DBlock
  62935. * @param name defines the block name
  62936. */
  62937. constructor(name: string);
  62938. /**
  62939. * Gets the current class name
  62940. * @returns the class name
  62941. */
  62942. getClassName(): string;
  62943. /**
  62944. * Gets the seed operand input component
  62945. */
  62946. get seed(): NodeMaterialConnectionPoint;
  62947. /**
  62948. * Gets the output component
  62949. */
  62950. get output(): NodeMaterialConnectionPoint;
  62951. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62952. }
  62953. }
  62954. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62955. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62956. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62958. /**
  62959. * Block used to blend normals
  62960. */
  62961. export class NormalBlendBlock extends NodeMaterialBlock {
  62962. /**
  62963. * Creates a new NormalBlendBlock
  62964. * @param name defines the block name
  62965. */
  62966. constructor(name: string);
  62967. /**
  62968. * Gets the current class name
  62969. * @returns the class name
  62970. */
  62971. getClassName(): string;
  62972. /**
  62973. * Gets the first input component
  62974. */
  62975. get normalMap0(): NodeMaterialConnectionPoint;
  62976. /**
  62977. * Gets the second input component
  62978. */
  62979. get normalMap1(): NodeMaterialConnectionPoint;
  62980. /**
  62981. * Gets the output component
  62982. */
  62983. get output(): NodeMaterialConnectionPoint;
  62984. protected _buildBlock(state: NodeMaterialBuildState): this;
  62985. }
  62986. }
  62987. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62988. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62989. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62990. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62991. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62992. /**
  62993. * Block used to rotate a 2d vector by a given angle
  62994. */
  62995. export class Rotate2dBlock extends NodeMaterialBlock {
  62996. /**
  62997. * Creates a new Rotate2dBlock
  62998. * @param name defines the block name
  62999. */
  63000. constructor(name: string);
  63001. /**
  63002. * Gets the current class name
  63003. * @returns the class name
  63004. */
  63005. getClassName(): string;
  63006. /**
  63007. * Gets the input vector
  63008. */
  63009. get input(): NodeMaterialConnectionPoint;
  63010. /**
  63011. * Gets the input angle
  63012. */
  63013. get angle(): NodeMaterialConnectionPoint;
  63014. /**
  63015. * Gets the output component
  63016. */
  63017. get output(): NodeMaterialConnectionPoint;
  63018. autoConfigure(material: NodeMaterial): void;
  63019. protected _buildBlock(state: NodeMaterialBuildState): this;
  63020. }
  63021. }
  63022. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63023. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63024. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63025. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63026. /**
  63027. * Block used to get the reflected vector from a direction and a normal
  63028. */
  63029. export class ReflectBlock extends NodeMaterialBlock {
  63030. /**
  63031. * Creates a new ReflectBlock
  63032. * @param name defines the block name
  63033. */
  63034. constructor(name: string);
  63035. /**
  63036. * Gets the current class name
  63037. * @returns the class name
  63038. */
  63039. getClassName(): string;
  63040. /**
  63041. * Gets the incident component
  63042. */
  63043. get incident(): NodeMaterialConnectionPoint;
  63044. /**
  63045. * Gets the normal component
  63046. */
  63047. get normal(): NodeMaterialConnectionPoint;
  63048. /**
  63049. * Gets the output component
  63050. */
  63051. get output(): NodeMaterialConnectionPoint;
  63052. protected _buildBlock(state: NodeMaterialBuildState): this;
  63053. }
  63054. }
  63055. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63056. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63057. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63058. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63059. /**
  63060. * Block used to get the refracted vector from a direction and a normal
  63061. */
  63062. export class RefractBlock extends NodeMaterialBlock {
  63063. /**
  63064. * Creates a new RefractBlock
  63065. * @param name defines the block name
  63066. */
  63067. constructor(name: string);
  63068. /**
  63069. * Gets the current class name
  63070. * @returns the class name
  63071. */
  63072. getClassName(): string;
  63073. /**
  63074. * Gets the incident component
  63075. */
  63076. get incident(): NodeMaterialConnectionPoint;
  63077. /**
  63078. * Gets the normal component
  63079. */
  63080. get normal(): NodeMaterialConnectionPoint;
  63081. /**
  63082. * Gets the index of refraction component
  63083. */
  63084. get ior(): NodeMaterialConnectionPoint;
  63085. /**
  63086. * Gets the output component
  63087. */
  63088. get output(): NodeMaterialConnectionPoint;
  63089. protected _buildBlock(state: NodeMaterialBuildState): this;
  63090. }
  63091. }
  63092. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63094. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63095. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63096. /**
  63097. * Block used to desaturate a color
  63098. */
  63099. export class DesaturateBlock extends NodeMaterialBlock {
  63100. /**
  63101. * Creates a new DesaturateBlock
  63102. * @param name defines the block name
  63103. */
  63104. constructor(name: string);
  63105. /**
  63106. * Gets the current class name
  63107. * @returns the class name
  63108. */
  63109. getClassName(): string;
  63110. /**
  63111. * Gets the color operand input component
  63112. */
  63113. get color(): NodeMaterialConnectionPoint;
  63114. /**
  63115. * Gets the level operand input component
  63116. */
  63117. get level(): NodeMaterialConnectionPoint;
  63118. /**
  63119. * Gets the output component
  63120. */
  63121. get output(): NodeMaterialConnectionPoint;
  63122. protected _buildBlock(state: NodeMaterialBuildState): this;
  63123. }
  63124. }
  63125. declare module "babylonjs/Materials/Node/Blocks/index" {
  63126. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63127. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63128. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63129. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63130. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63131. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63132. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63133. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63134. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63135. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63136. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63137. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63138. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63139. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63140. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63141. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63142. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63143. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63144. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63145. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63146. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63147. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63148. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63149. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63150. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63151. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63152. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63153. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63154. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63155. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63156. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63157. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63158. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63159. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63160. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63161. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63162. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63163. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63164. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63165. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63166. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63167. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63168. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63169. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63170. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63171. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63172. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63173. }
  63174. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63175. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63176. }
  63177. declare module "babylonjs/Materials/Node/index" {
  63178. export * from "babylonjs/Materials/Node/Enums/index";
  63179. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63180. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63181. export * from "babylonjs/Materials/Node/nodeMaterial";
  63182. export * from "babylonjs/Materials/Node/Blocks/index";
  63183. export * from "babylonjs/Materials/Node/Optimizers/index";
  63184. }
  63185. declare module "babylonjs/Materials/effectRenderer" {
  63186. import { Nullable } from "babylonjs/types";
  63187. import { Texture } from "babylonjs/Materials/Textures/texture";
  63188. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63189. import { Viewport } from "babylonjs/Maths/math.viewport";
  63190. import { Observable } from "babylonjs/Misc/observable";
  63191. import { Effect } from "babylonjs/Materials/effect";
  63192. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63193. import "babylonjs/Shaders/postprocess.vertex";
  63194. /**
  63195. * Effect Render Options
  63196. */
  63197. export interface IEffectRendererOptions {
  63198. /**
  63199. * Defines the vertices positions.
  63200. */
  63201. positions?: number[];
  63202. /**
  63203. * Defines the indices.
  63204. */
  63205. indices?: number[];
  63206. }
  63207. /**
  63208. * Helper class to render one or more effects
  63209. */
  63210. export class EffectRenderer {
  63211. private engine;
  63212. private static _DefaultOptions;
  63213. private _vertexBuffers;
  63214. private _indexBuffer;
  63215. private _ringBufferIndex;
  63216. private _ringScreenBuffer;
  63217. private _fullscreenViewport;
  63218. private _getNextFrameBuffer;
  63219. /**
  63220. * Creates an effect renderer
  63221. * @param engine the engine to use for rendering
  63222. * @param options defines the options of the effect renderer
  63223. */
  63224. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63225. /**
  63226. * Sets the current viewport in normalized coordinates 0-1
  63227. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63228. */
  63229. setViewport(viewport?: Viewport): void;
  63230. /**
  63231. * Binds the embedded attributes buffer to the effect.
  63232. * @param effect Defines the effect to bind the attributes for
  63233. */
  63234. bindBuffers(effect: Effect): void;
  63235. /**
  63236. * Sets the current effect wrapper to use during draw.
  63237. * The effect needs to be ready before calling this api.
  63238. * This also sets the default full screen position attribute.
  63239. * @param effectWrapper Defines the effect to draw with
  63240. */
  63241. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63242. /**
  63243. * Draws a full screen quad.
  63244. */
  63245. draw(): void;
  63246. /**
  63247. * renders one or more effects to a specified texture
  63248. * @param effectWrappers list of effects to renderer
  63249. * @param outputTexture texture to draw to, if null it will render to the screen
  63250. */
  63251. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63252. /**
  63253. * Disposes of the effect renderer
  63254. */
  63255. dispose(): void;
  63256. }
  63257. /**
  63258. * Options to create an EffectWrapper
  63259. */
  63260. interface EffectWrapperCreationOptions {
  63261. /**
  63262. * Engine to use to create the effect
  63263. */
  63264. engine: ThinEngine;
  63265. /**
  63266. * Fragment shader for the effect
  63267. */
  63268. fragmentShader: string;
  63269. /**
  63270. * Vertex shader for the effect
  63271. */
  63272. vertexShader?: string;
  63273. /**
  63274. * Attributes to use in the shader
  63275. */
  63276. attributeNames?: Array<string>;
  63277. /**
  63278. * Uniforms to use in the shader
  63279. */
  63280. uniformNames?: Array<string>;
  63281. /**
  63282. * Texture sampler names to use in the shader
  63283. */
  63284. samplerNames?: Array<string>;
  63285. /**
  63286. * The friendly name of the effect displayed in Spector.
  63287. */
  63288. name?: string;
  63289. }
  63290. /**
  63291. * Wraps an effect to be used for rendering
  63292. */
  63293. export class EffectWrapper {
  63294. /**
  63295. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63296. */
  63297. onApplyObservable: Observable<{}>;
  63298. /**
  63299. * The underlying effect
  63300. */
  63301. effect: Effect;
  63302. /**
  63303. * Creates an effect to be renderer
  63304. * @param creationOptions options to create the effect
  63305. */
  63306. constructor(creationOptions: EffectWrapperCreationOptions);
  63307. /**
  63308. * Disposes of the effect wrapper
  63309. */
  63310. dispose(): void;
  63311. }
  63312. }
  63313. declare module "babylonjs/Materials/index" {
  63314. export * from "babylonjs/Materials/Background/index";
  63315. export * from "babylonjs/Materials/colorCurves";
  63316. export * from "babylonjs/Materials/iEffectFallbacks";
  63317. export * from "babylonjs/Materials/effectFallbacks";
  63318. export * from "babylonjs/Materials/effect";
  63319. export * from "babylonjs/Materials/fresnelParameters";
  63320. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63321. export * from "babylonjs/Materials/material";
  63322. export * from "babylonjs/Materials/materialDefines";
  63323. export * from "babylonjs/Materials/materialHelper";
  63324. export * from "babylonjs/Materials/multiMaterial";
  63325. export * from "babylonjs/Materials/PBR/index";
  63326. export * from "babylonjs/Materials/pushMaterial";
  63327. export * from "babylonjs/Materials/shaderMaterial";
  63328. export * from "babylonjs/Materials/standardMaterial";
  63329. export * from "babylonjs/Materials/Textures/index";
  63330. export * from "babylonjs/Materials/uniformBuffer";
  63331. export * from "babylonjs/Materials/materialFlags";
  63332. export * from "babylonjs/Materials/Node/index";
  63333. export * from "babylonjs/Materials/effectRenderer";
  63334. }
  63335. declare module "babylonjs/Maths/index" {
  63336. export * from "babylonjs/Maths/math.scalar";
  63337. export * from "babylonjs/Maths/math";
  63338. export * from "babylonjs/Maths/sphericalPolynomial";
  63339. }
  63340. declare module "babylonjs/Misc/workerPool" {
  63341. import { IDisposable } from "babylonjs/scene";
  63342. /**
  63343. * Helper class to push actions to a pool of workers.
  63344. */
  63345. export class WorkerPool implements IDisposable {
  63346. private _workerInfos;
  63347. private _pendingActions;
  63348. /**
  63349. * Constructor
  63350. * @param workers Array of workers to use for actions
  63351. */
  63352. constructor(workers: Array<Worker>);
  63353. /**
  63354. * Terminates all workers and clears any pending actions.
  63355. */
  63356. dispose(): void;
  63357. /**
  63358. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63359. * pended until a worker has completed its action.
  63360. * @param action The action to perform. Call onComplete when the action is complete.
  63361. */
  63362. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63363. private _execute;
  63364. }
  63365. }
  63366. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63367. import { IDisposable } from "babylonjs/scene";
  63368. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63369. /**
  63370. * Configuration for Draco compression
  63371. */
  63372. export interface IDracoCompressionConfiguration {
  63373. /**
  63374. * Configuration for the decoder.
  63375. */
  63376. decoder: {
  63377. /**
  63378. * The url to the WebAssembly module.
  63379. */
  63380. wasmUrl?: string;
  63381. /**
  63382. * The url to the WebAssembly binary.
  63383. */
  63384. wasmBinaryUrl?: string;
  63385. /**
  63386. * The url to the fallback JavaScript module.
  63387. */
  63388. fallbackUrl?: string;
  63389. };
  63390. }
  63391. /**
  63392. * Draco compression (https://google.github.io/draco/)
  63393. *
  63394. * This class wraps the Draco module.
  63395. *
  63396. * **Encoder**
  63397. *
  63398. * The encoder is not currently implemented.
  63399. *
  63400. * **Decoder**
  63401. *
  63402. * 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.
  63403. *
  63404. * To update the configuration, use the following code:
  63405. * ```javascript
  63406. * DracoCompression.Configuration = {
  63407. * decoder: {
  63408. * wasmUrl: "<url to the WebAssembly library>",
  63409. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63410. * fallbackUrl: "<url to the fallback JavaScript library>",
  63411. * }
  63412. * };
  63413. * ```
  63414. *
  63415. * 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.
  63416. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63417. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63418. *
  63419. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63420. * ```javascript
  63421. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63422. * ```
  63423. *
  63424. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63425. */
  63426. export class DracoCompression implements IDisposable {
  63427. private _workerPoolPromise?;
  63428. private _decoderModulePromise?;
  63429. /**
  63430. * The configuration. Defaults to the following urls:
  63431. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63432. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63433. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63434. */
  63435. static Configuration: IDracoCompressionConfiguration;
  63436. /**
  63437. * Returns true if the decoder configuration is available.
  63438. */
  63439. static get DecoderAvailable(): boolean;
  63440. /**
  63441. * Default number of workers to create when creating the draco compression object.
  63442. */
  63443. static DefaultNumWorkers: number;
  63444. private static GetDefaultNumWorkers;
  63445. private static _Default;
  63446. /**
  63447. * Default instance for the draco compression object.
  63448. */
  63449. static get Default(): DracoCompression;
  63450. /**
  63451. * Constructor
  63452. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63453. */
  63454. constructor(numWorkers?: number);
  63455. /**
  63456. * Stop all async operations and release resources.
  63457. */
  63458. dispose(): void;
  63459. /**
  63460. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63461. * @returns a promise that resolves when ready
  63462. */
  63463. whenReadyAsync(): Promise<void>;
  63464. /**
  63465. * Decode Draco compressed mesh data to vertex data.
  63466. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63467. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63468. * @returns A promise that resolves with the decoded vertex data
  63469. */
  63470. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63471. [kind: string]: number;
  63472. }): Promise<VertexData>;
  63473. }
  63474. }
  63475. declare module "babylonjs/Meshes/Compression/index" {
  63476. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63477. }
  63478. declare module "babylonjs/Meshes/csg" {
  63479. import { Nullable } from "babylonjs/types";
  63480. import { Scene } from "babylonjs/scene";
  63481. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63482. import { Mesh } from "babylonjs/Meshes/mesh";
  63483. import { Material } from "babylonjs/Materials/material";
  63484. /**
  63485. * Class for building Constructive Solid Geometry
  63486. */
  63487. export class CSG {
  63488. private polygons;
  63489. /**
  63490. * The world matrix
  63491. */
  63492. matrix: Matrix;
  63493. /**
  63494. * Stores the position
  63495. */
  63496. position: Vector3;
  63497. /**
  63498. * Stores the rotation
  63499. */
  63500. rotation: Vector3;
  63501. /**
  63502. * Stores the rotation quaternion
  63503. */
  63504. rotationQuaternion: Nullable<Quaternion>;
  63505. /**
  63506. * Stores the scaling vector
  63507. */
  63508. scaling: Vector3;
  63509. /**
  63510. * Convert the Mesh to CSG
  63511. * @param mesh The Mesh to convert to CSG
  63512. * @returns A new CSG from the Mesh
  63513. */
  63514. static FromMesh(mesh: Mesh): CSG;
  63515. /**
  63516. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63517. * @param polygons Polygons used to construct a CSG solid
  63518. */
  63519. private static FromPolygons;
  63520. /**
  63521. * Clones, or makes a deep copy, of the CSG
  63522. * @returns A new CSG
  63523. */
  63524. clone(): CSG;
  63525. /**
  63526. * Unions this CSG with another CSG
  63527. * @param csg The CSG to union against this CSG
  63528. * @returns The unioned CSG
  63529. */
  63530. union(csg: CSG): CSG;
  63531. /**
  63532. * Unions this CSG with another CSG in place
  63533. * @param csg The CSG to union against this CSG
  63534. */
  63535. unionInPlace(csg: CSG): void;
  63536. /**
  63537. * Subtracts this CSG with another CSG
  63538. * @param csg The CSG to subtract against this CSG
  63539. * @returns A new CSG
  63540. */
  63541. subtract(csg: CSG): CSG;
  63542. /**
  63543. * Subtracts this CSG with another CSG in place
  63544. * @param csg The CSG to subtact against this CSG
  63545. */
  63546. subtractInPlace(csg: CSG): void;
  63547. /**
  63548. * Intersect this CSG with another CSG
  63549. * @param csg The CSG to intersect against this CSG
  63550. * @returns A new CSG
  63551. */
  63552. intersect(csg: CSG): CSG;
  63553. /**
  63554. * Intersects this CSG with another CSG in place
  63555. * @param csg The CSG to intersect against this CSG
  63556. */
  63557. intersectInPlace(csg: CSG): void;
  63558. /**
  63559. * Return a new CSG solid with solid and empty space switched. This solid is
  63560. * not modified.
  63561. * @returns A new CSG solid with solid and empty space switched
  63562. */
  63563. inverse(): CSG;
  63564. /**
  63565. * Inverses the CSG in place
  63566. */
  63567. inverseInPlace(): void;
  63568. /**
  63569. * This is used to keep meshes transformations so they can be restored
  63570. * when we build back a Babylon Mesh
  63571. * NB : All CSG operations are performed in world coordinates
  63572. * @param csg The CSG to copy the transform attributes from
  63573. * @returns This CSG
  63574. */
  63575. copyTransformAttributes(csg: CSG): CSG;
  63576. /**
  63577. * Build Raw mesh from CSG
  63578. * Coordinates here are in world space
  63579. * @param name The name of the mesh geometry
  63580. * @param scene The Scene
  63581. * @param keepSubMeshes Specifies if the submeshes should be kept
  63582. * @returns A new Mesh
  63583. */
  63584. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63585. /**
  63586. * Build Mesh from CSG taking material and transforms into account
  63587. * @param name The name of the Mesh
  63588. * @param material The material of the Mesh
  63589. * @param scene The Scene
  63590. * @param keepSubMeshes Specifies if submeshes should be kept
  63591. * @returns The new Mesh
  63592. */
  63593. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63594. }
  63595. }
  63596. declare module "babylonjs/Meshes/trailMesh" {
  63597. import { Mesh } from "babylonjs/Meshes/mesh";
  63598. import { Scene } from "babylonjs/scene";
  63599. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63600. /**
  63601. * Class used to create a trail following a mesh
  63602. */
  63603. export class TrailMesh extends Mesh {
  63604. private _generator;
  63605. private _autoStart;
  63606. private _running;
  63607. private _diameter;
  63608. private _length;
  63609. private _sectionPolygonPointsCount;
  63610. private _sectionVectors;
  63611. private _sectionNormalVectors;
  63612. private _beforeRenderObserver;
  63613. /**
  63614. * @constructor
  63615. * @param name The value used by scene.getMeshByName() to do a lookup.
  63616. * @param generator The mesh or transform node to generate a trail.
  63617. * @param scene The scene to add this mesh to.
  63618. * @param diameter Diameter of trailing mesh. Default is 1.
  63619. * @param length Length of trailing mesh. Default is 60.
  63620. * @param autoStart Automatically start trailing mesh. Default true.
  63621. */
  63622. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63623. /**
  63624. * "TrailMesh"
  63625. * @returns "TrailMesh"
  63626. */
  63627. getClassName(): string;
  63628. private _createMesh;
  63629. /**
  63630. * Start trailing mesh.
  63631. */
  63632. start(): void;
  63633. /**
  63634. * Stop trailing mesh.
  63635. */
  63636. stop(): void;
  63637. /**
  63638. * Update trailing mesh geometry.
  63639. */
  63640. update(): void;
  63641. /**
  63642. * Returns a new TrailMesh object.
  63643. * @param name is a string, the name given to the new mesh
  63644. * @param newGenerator use new generator object for cloned trail mesh
  63645. * @returns a new mesh
  63646. */
  63647. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63648. /**
  63649. * Serializes this trail mesh
  63650. * @param serializationObject object to write serialization to
  63651. */
  63652. serialize(serializationObject: any): void;
  63653. /**
  63654. * Parses a serialized trail mesh
  63655. * @param parsedMesh the serialized mesh
  63656. * @param scene the scene to create the trail mesh in
  63657. * @returns the created trail mesh
  63658. */
  63659. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63660. }
  63661. }
  63662. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63663. import { Nullable } from "babylonjs/types";
  63664. import { Scene } from "babylonjs/scene";
  63665. import { Vector4 } from "babylonjs/Maths/math.vector";
  63666. import { Color4 } from "babylonjs/Maths/math.color";
  63667. import { Mesh } from "babylonjs/Meshes/mesh";
  63668. /**
  63669. * Class containing static functions to help procedurally build meshes
  63670. */
  63671. export class TiledBoxBuilder {
  63672. /**
  63673. * Creates a box mesh
  63674. * 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)
  63675. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63679. * @param name defines the name of the mesh
  63680. * @param options defines the options used to create the mesh
  63681. * @param scene defines the hosting scene
  63682. * @returns the box mesh
  63683. */
  63684. static CreateTiledBox(name: string, options: {
  63685. pattern?: number;
  63686. width?: number;
  63687. height?: number;
  63688. depth?: number;
  63689. tileSize?: number;
  63690. tileWidth?: number;
  63691. tileHeight?: number;
  63692. alignHorizontal?: number;
  63693. alignVertical?: number;
  63694. faceUV?: Vector4[];
  63695. faceColors?: Color4[];
  63696. sideOrientation?: number;
  63697. updatable?: boolean;
  63698. }, scene?: Nullable<Scene>): Mesh;
  63699. }
  63700. }
  63701. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63702. import { Vector4 } from "babylonjs/Maths/math.vector";
  63703. import { Mesh } from "babylonjs/Meshes/mesh";
  63704. /**
  63705. * Class containing static functions to help procedurally build meshes
  63706. */
  63707. export class TorusKnotBuilder {
  63708. /**
  63709. * Creates a torus knot mesh
  63710. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63711. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63712. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63713. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63715. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63717. * @param name defines the name of the mesh
  63718. * @param options defines the options used to create the mesh
  63719. * @param scene defines the hosting scene
  63720. * @returns the torus knot mesh
  63721. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63722. */
  63723. static CreateTorusKnot(name: string, options: {
  63724. radius?: number;
  63725. tube?: number;
  63726. radialSegments?: number;
  63727. tubularSegments?: number;
  63728. p?: number;
  63729. q?: number;
  63730. updatable?: boolean;
  63731. sideOrientation?: number;
  63732. frontUVs?: Vector4;
  63733. backUVs?: Vector4;
  63734. }, scene: any): Mesh;
  63735. }
  63736. }
  63737. declare module "babylonjs/Meshes/polygonMesh" {
  63738. import { Scene } from "babylonjs/scene";
  63739. import { Vector2 } from "babylonjs/Maths/math.vector";
  63740. import { Mesh } from "babylonjs/Meshes/mesh";
  63741. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63742. import { Path2 } from "babylonjs/Maths/math.path";
  63743. /**
  63744. * Polygon
  63745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63746. */
  63747. export class Polygon {
  63748. /**
  63749. * Creates a rectangle
  63750. * @param xmin bottom X coord
  63751. * @param ymin bottom Y coord
  63752. * @param xmax top X coord
  63753. * @param ymax top Y coord
  63754. * @returns points that make the resulting rectation
  63755. */
  63756. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63757. /**
  63758. * Creates a circle
  63759. * @param radius radius of circle
  63760. * @param cx scale in x
  63761. * @param cy scale in y
  63762. * @param numberOfSides number of sides that make up the circle
  63763. * @returns points that make the resulting circle
  63764. */
  63765. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63766. /**
  63767. * Creates a polygon from input string
  63768. * @param input Input polygon data
  63769. * @returns the parsed points
  63770. */
  63771. static Parse(input: string): Vector2[];
  63772. /**
  63773. * Starts building a polygon from x and y coordinates
  63774. * @param x x coordinate
  63775. * @param y y coordinate
  63776. * @returns the started path2
  63777. */
  63778. static StartingAt(x: number, y: number): Path2;
  63779. }
  63780. /**
  63781. * Builds a polygon
  63782. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63783. */
  63784. export class PolygonMeshBuilder {
  63785. private _points;
  63786. private _outlinepoints;
  63787. private _holes;
  63788. private _name;
  63789. private _scene;
  63790. private _epoints;
  63791. private _eholes;
  63792. private _addToepoint;
  63793. /**
  63794. * Babylon reference to the earcut plugin.
  63795. */
  63796. bjsEarcut: any;
  63797. /**
  63798. * Creates a PolygonMeshBuilder
  63799. * @param name name of the builder
  63800. * @param contours Path of the polygon
  63801. * @param scene scene to add to when creating the mesh
  63802. * @param earcutInjection can be used to inject your own earcut reference
  63803. */
  63804. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63805. /**
  63806. * Adds a whole within the polygon
  63807. * @param hole Array of points defining the hole
  63808. * @returns this
  63809. */
  63810. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63811. /**
  63812. * Creates the polygon
  63813. * @param updatable If the mesh should be updatable
  63814. * @param depth The depth of the mesh created
  63815. * @returns the created mesh
  63816. */
  63817. build(updatable?: boolean, depth?: number): Mesh;
  63818. /**
  63819. * Creates the polygon
  63820. * @param depth The depth of the mesh created
  63821. * @returns the created VertexData
  63822. */
  63823. buildVertexData(depth?: number): VertexData;
  63824. /**
  63825. * Adds a side to the polygon
  63826. * @param positions points that make the polygon
  63827. * @param normals normals of the polygon
  63828. * @param uvs uvs of the polygon
  63829. * @param indices indices of the polygon
  63830. * @param bounds bounds of the polygon
  63831. * @param points points of the polygon
  63832. * @param depth depth of the polygon
  63833. * @param flip flip of the polygon
  63834. */
  63835. private addSide;
  63836. }
  63837. }
  63838. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63839. import { Scene } from "babylonjs/scene";
  63840. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63841. import { Color4 } from "babylonjs/Maths/math.color";
  63842. import { Mesh } from "babylonjs/Meshes/mesh";
  63843. import { Nullable } from "babylonjs/types";
  63844. /**
  63845. * Class containing static functions to help procedurally build meshes
  63846. */
  63847. export class PolygonBuilder {
  63848. /**
  63849. * Creates a polygon mesh
  63850. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63851. * * 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
  63852. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63854. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63855. * * Remember you can only change the shape positions, not their number when updating a polygon
  63856. * @param name defines the name of the mesh
  63857. * @param options defines the options used to create the mesh
  63858. * @param scene defines the hosting scene
  63859. * @param earcutInjection can be used to inject your own earcut reference
  63860. * @returns the polygon mesh
  63861. */
  63862. static CreatePolygon(name: string, options: {
  63863. shape: Vector3[];
  63864. holes?: Vector3[][];
  63865. depth?: number;
  63866. faceUV?: Vector4[];
  63867. faceColors?: Color4[];
  63868. updatable?: boolean;
  63869. sideOrientation?: number;
  63870. frontUVs?: Vector4;
  63871. backUVs?: Vector4;
  63872. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63873. /**
  63874. * Creates an extruded polygon mesh, with depth in the Y direction.
  63875. * * 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)
  63876. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63877. * @param name defines the name of the mesh
  63878. * @param options defines the options used to create the mesh
  63879. * @param scene defines the hosting scene
  63880. * @param earcutInjection can be used to inject your own earcut reference
  63881. * @returns the polygon mesh
  63882. */
  63883. static ExtrudePolygon(name: string, options: {
  63884. shape: Vector3[];
  63885. holes?: Vector3[][];
  63886. depth?: number;
  63887. faceUV?: Vector4[];
  63888. faceColors?: Color4[];
  63889. updatable?: boolean;
  63890. sideOrientation?: number;
  63891. frontUVs?: Vector4;
  63892. backUVs?: Vector4;
  63893. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63894. }
  63895. }
  63896. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63897. import { Scene } from "babylonjs/scene";
  63898. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63899. import { Mesh } from "babylonjs/Meshes/mesh";
  63900. import { Nullable } from "babylonjs/types";
  63901. /**
  63902. * Class containing static functions to help procedurally build meshes
  63903. */
  63904. export class LatheBuilder {
  63905. /**
  63906. * Creates lathe mesh.
  63907. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63908. * * 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
  63909. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63910. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63911. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63912. * * 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
  63913. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63914. * * 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
  63915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63917. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63919. * @param name defines the name of the mesh
  63920. * @param options defines the options used to create the mesh
  63921. * @param scene defines the hosting scene
  63922. * @returns the lathe mesh
  63923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63924. */
  63925. static CreateLathe(name: string, options: {
  63926. shape: Vector3[];
  63927. radius?: number;
  63928. tessellation?: number;
  63929. clip?: number;
  63930. arc?: number;
  63931. closed?: boolean;
  63932. updatable?: boolean;
  63933. sideOrientation?: number;
  63934. frontUVs?: Vector4;
  63935. backUVs?: Vector4;
  63936. cap?: number;
  63937. invertUV?: boolean;
  63938. }, scene?: Nullable<Scene>): Mesh;
  63939. }
  63940. }
  63941. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63942. import { Nullable } from "babylonjs/types";
  63943. import { Scene } from "babylonjs/scene";
  63944. import { Vector4 } from "babylonjs/Maths/math.vector";
  63945. import { Mesh } from "babylonjs/Meshes/mesh";
  63946. /**
  63947. * Class containing static functions to help procedurally build meshes
  63948. */
  63949. export class TiledPlaneBuilder {
  63950. /**
  63951. * Creates a tiled plane mesh
  63952. * * The parameter `pattern` will, depending on value, do nothing or
  63953. * * * flip (reflect about central vertical) alternate tiles across and up
  63954. * * * flip every tile on alternate rows
  63955. * * * rotate (180 degs) alternate tiles across and up
  63956. * * * rotate every tile on alternate rows
  63957. * * * flip and rotate alternate tiles across and up
  63958. * * * flip and rotate every tile on alternate rows
  63959. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63960. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63962. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63963. * * 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)
  63964. * * 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)
  63965. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63966. * @param name defines the name of the mesh
  63967. * @param options defines the options used to create the mesh
  63968. * @param scene defines the hosting scene
  63969. * @returns the box mesh
  63970. */
  63971. static CreateTiledPlane(name: string, options: {
  63972. pattern?: number;
  63973. tileSize?: number;
  63974. tileWidth?: number;
  63975. tileHeight?: number;
  63976. size?: number;
  63977. width?: number;
  63978. height?: number;
  63979. alignHorizontal?: number;
  63980. alignVertical?: number;
  63981. sideOrientation?: number;
  63982. frontUVs?: Vector4;
  63983. backUVs?: Vector4;
  63984. updatable?: boolean;
  63985. }, scene?: Nullable<Scene>): Mesh;
  63986. }
  63987. }
  63988. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63989. import { Nullable } from "babylonjs/types";
  63990. import { Scene } from "babylonjs/scene";
  63991. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63992. import { Mesh } from "babylonjs/Meshes/mesh";
  63993. /**
  63994. * Class containing static functions to help procedurally build meshes
  63995. */
  63996. export class TubeBuilder {
  63997. /**
  63998. * Creates a tube mesh.
  63999. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64000. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64001. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64002. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64003. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64004. * * 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)
  64005. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64006. * * 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
  64007. * * 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
  64008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64010. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64012. * @param name defines the name of the mesh
  64013. * @param options defines the options used to create the mesh
  64014. * @param scene defines the hosting scene
  64015. * @returns the tube mesh
  64016. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64017. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64018. */
  64019. static CreateTube(name: string, options: {
  64020. path: Vector3[];
  64021. radius?: number;
  64022. tessellation?: number;
  64023. radiusFunction?: {
  64024. (i: number, distance: number): number;
  64025. };
  64026. cap?: number;
  64027. arc?: number;
  64028. updatable?: boolean;
  64029. sideOrientation?: number;
  64030. frontUVs?: Vector4;
  64031. backUVs?: Vector4;
  64032. instance?: Mesh;
  64033. invertUV?: boolean;
  64034. }, scene?: Nullable<Scene>): Mesh;
  64035. }
  64036. }
  64037. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64038. import { Scene } from "babylonjs/scene";
  64039. import { Vector4 } from "babylonjs/Maths/math.vector";
  64040. import { Mesh } from "babylonjs/Meshes/mesh";
  64041. import { Nullable } from "babylonjs/types";
  64042. /**
  64043. * Class containing static functions to help procedurally build meshes
  64044. */
  64045. export class IcoSphereBuilder {
  64046. /**
  64047. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64048. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64049. * * 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`)
  64050. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64051. * * 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
  64052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64055. * @param name defines the name of the mesh
  64056. * @param options defines the options used to create the mesh
  64057. * @param scene defines the hosting scene
  64058. * @returns the icosahedron mesh
  64059. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64060. */
  64061. static CreateIcoSphere(name: string, options: {
  64062. radius?: number;
  64063. radiusX?: number;
  64064. radiusY?: number;
  64065. radiusZ?: number;
  64066. flat?: boolean;
  64067. subdivisions?: number;
  64068. sideOrientation?: number;
  64069. frontUVs?: Vector4;
  64070. backUVs?: Vector4;
  64071. updatable?: boolean;
  64072. }, scene?: Nullable<Scene>): Mesh;
  64073. }
  64074. }
  64075. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64076. import { Vector3 } from "babylonjs/Maths/math.vector";
  64077. import { Mesh } from "babylonjs/Meshes/mesh";
  64078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64079. /**
  64080. * Class containing static functions to help procedurally build meshes
  64081. */
  64082. export class DecalBuilder {
  64083. /**
  64084. * Creates a decal mesh.
  64085. * 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
  64086. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64087. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64088. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64089. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64090. * @param name defines the name of the mesh
  64091. * @param sourceMesh defines the mesh where the decal must be applied
  64092. * @param options defines the options used to create the mesh
  64093. * @param scene defines the hosting scene
  64094. * @returns the decal mesh
  64095. * @see https://doc.babylonjs.com/how_to/decals
  64096. */
  64097. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64098. position?: Vector3;
  64099. normal?: Vector3;
  64100. size?: Vector3;
  64101. angle?: number;
  64102. }): Mesh;
  64103. }
  64104. }
  64105. declare module "babylonjs/Meshes/meshBuilder" {
  64106. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64107. import { Nullable } from "babylonjs/types";
  64108. import { Scene } from "babylonjs/scene";
  64109. import { Mesh } from "babylonjs/Meshes/mesh";
  64110. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64111. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64113. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64114. import { Plane } from "babylonjs/Maths/math.plane";
  64115. /**
  64116. * Class containing static functions to help procedurally build meshes
  64117. */
  64118. export class MeshBuilder {
  64119. /**
  64120. * Creates a box mesh
  64121. * * The parameter `size` sets the size (float) of each box side (default 1)
  64122. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64123. * * 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)
  64124. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64128. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64129. * @param name defines the name of the mesh
  64130. * @param options defines the options used to create the mesh
  64131. * @param scene defines the hosting scene
  64132. * @returns the box mesh
  64133. */
  64134. static CreateBox(name: string, options: {
  64135. size?: number;
  64136. width?: number;
  64137. height?: number;
  64138. depth?: number;
  64139. faceUV?: Vector4[];
  64140. faceColors?: Color4[];
  64141. sideOrientation?: number;
  64142. frontUVs?: Vector4;
  64143. backUVs?: Vector4;
  64144. updatable?: boolean;
  64145. }, scene?: Nullable<Scene>): Mesh;
  64146. /**
  64147. * Creates a tiled box mesh
  64148. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64150. * @param name defines the name of the mesh
  64151. * @param options defines the options used to create the mesh
  64152. * @param scene defines the hosting scene
  64153. * @returns the tiled box mesh
  64154. */
  64155. static CreateTiledBox(name: string, options: {
  64156. pattern?: number;
  64157. size?: number;
  64158. width?: number;
  64159. height?: number;
  64160. depth: number;
  64161. tileSize?: number;
  64162. tileWidth?: number;
  64163. tileHeight?: number;
  64164. faceUV?: Vector4[];
  64165. faceColors?: Color4[];
  64166. alignHorizontal?: number;
  64167. alignVertical?: number;
  64168. sideOrientation?: number;
  64169. updatable?: boolean;
  64170. }, scene?: Nullable<Scene>): Mesh;
  64171. /**
  64172. * Creates a sphere mesh
  64173. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64174. * * 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`)
  64175. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64176. * * 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
  64177. * * 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)
  64178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64179. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64181. * @param name defines the name of the mesh
  64182. * @param options defines the options used to create the mesh
  64183. * @param scene defines the hosting scene
  64184. * @returns the sphere mesh
  64185. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64186. */
  64187. static CreateSphere(name: string, options: {
  64188. segments?: number;
  64189. diameter?: number;
  64190. diameterX?: number;
  64191. diameterY?: number;
  64192. diameterZ?: number;
  64193. arc?: number;
  64194. slice?: number;
  64195. sideOrientation?: number;
  64196. frontUVs?: Vector4;
  64197. backUVs?: Vector4;
  64198. updatable?: boolean;
  64199. }, scene?: Nullable<Scene>): Mesh;
  64200. /**
  64201. * Creates a plane polygonal mesh. By default, this is a disc
  64202. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64203. * * 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
  64204. * * 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
  64205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64208. * @param name defines the name of the mesh
  64209. * @param options defines the options used to create the mesh
  64210. * @param scene defines the hosting scene
  64211. * @returns the plane polygonal mesh
  64212. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64213. */
  64214. static CreateDisc(name: string, options: {
  64215. radius?: number;
  64216. tessellation?: number;
  64217. arc?: number;
  64218. updatable?: boolean;
  64219. sideOrientation?: number;
  64220. frontUVs?: Vector4;
  64221. backUVs?: Vector4;
  64222. }, scene?: Nullable<Scene>): Mesh;
  64223. /**
  64224. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64225. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64226. * * 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`)
  64227. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64228. * * 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
  64229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64232. * @param name defines the name of the mesh
  64233. * @param options defines the options used to create the mesh
  64234. * @param scene defines the hosting scene
  64235. * @returns the icosahedron mesh
  64236. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64237. */
  64238. static CreateIcoSphere(name: string, options: {
  64239. radius?: number;
  64240. radiusX?: number;
  64241. radiusY?: number;
  64242. radiusZ?: number;
  64243. flat?: boolean;
  64244. subdivisions?: number;
  64245. sideOrientation?: number;
  64246. frontUVs?: Vector4;
  64247. backUVs?: Vector4;
  64248. updatable?: boolean;
  64249. }, scene?: Nullable<Scene>): Mesh;
  64250. /**
  64251. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64252. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64253. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64254. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64255. * * 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
  64256. * * 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
  64257. * * 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
  64258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64260. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64261. * * 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
  64262. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64263. * * 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
  64264. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64266. * @param name defines the name of the mesh
  64267. * @param options defines the options used to create the mesh
  64268. * @param scene defines the hosting scene
  64269. * @returns the ribbon mesh
  64270. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64271. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64272. */
  64273. static CreateRibbon(name: string, options: {
  64274. pathArray: Vector3[][];
  64275. closeArray?: boolean;
  64276. closePath?: boolean;
  64277. offset?: number;
  64278. updatable?: boolean;
  64279. sideOrientation?: number;
  64280. frontUVs?: Vector4;
  64281. backUVs?: Vector4;
  64282. instance?: Mesh;
  64283. invertUV?: boolean;
  64284. uvs?: Vector2[];
  64285. colors?: Color4[];
  64286. }, scene?: Nullable<Scene>): Mesh;
  64287. /**
  64288. * Creates a cylinder or a cone mesh
  64289. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64290. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64291. * * 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.
  64292. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64293. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64294. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64295. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64296. * * 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).
  64297. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64298. * * 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).
  64299. * * 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
  64300. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64301. * * 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
  64302. * * 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.
  64303. * * If `enclose` is false, a ring surface is one element.
  64304. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64305. * * 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
  64306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64307. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64309. * @param name defines the name of the mesh
  64310. * @param options defines the options used to create the mesh
  64311. * @param scene defines the hosting scene
  64312. * @returns the cylinder mesh
  64313. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64314. */
  64315. static CreateCylinder(name: string, options: {
  64316. height?: number;
  64317. diameterTop?: number;
  64318. diameterBottom?: number;
  64319. diameter?: number;
  64320. tessellation?: number;
  64321. subdivisions?: number;
  64322. arc?: number;
  64323. faceColors?: Color4[];
  64324. faceUV?: Vector4[];
  64325. updatable?: boolean;
  64326. hasRings?: boolean;
  64327. enclose?: boolean;
  64328. cap?: number;
  64329. sideOrientation?: number;
  64330. frontUVs?: Vector4;
  64331. backUVs?: Vector4;
  64332. }, scene?: Nullable<Scene>): Mesh;
  64333. /**
  64334. * Creates a torus mesh
  64335. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64336. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64337. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64339. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64341. * @param name defines the name of the mesh
  64342. * @param options defines the options used to create the mesh
  64343. * @param scene defines the hosting scene
  64344. * @returns the torus mesh
  64345. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64346. */
  64347. static CreateTorus(name: string, options: {
  64348. diameter?: number;
  64349. thickness?: number;
  64350. tessellation?: number;
  64351. updatable?: boolean;
  64352. sideOrientation?: number;
  64353. frontUVs?: Vector4;
  64354. backUVs?: Vector4;
  64355. }, scene?: Nullable<Scene>): Mesh;
  64356. /**
  64357. * Creates a torus knot mesh
  64358. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64359. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64360. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64361. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64365. * @param name defines the name of the mesh
  64366. * @param options defines the options used to create the mesh
  64367. * @param scene defines the hosting scene
  64368. * @returns the torus knot mesh
  64369. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64370. */
  64371. static CreateTorusKnot(name: string, options: {
  64372. radius?: number;
  64373. tube?: number;
  64374. radialSegments?: number;
  64375. tubularSegments?: number;
  64376. p?: number;
  64377. q?: number;
  64378. updatable?: boolean;
  64379. sideOrientation?: number;
  64380. frontUVs?: Vector4;
  64381. backUVs?: Vector4;
  64382. }, scene?: Nullable<Scene>): Mesh;
  64383. /**
  64384. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64385. * * 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
  64386. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64387. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64388. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64389. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64390. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64391. * * 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
  64392. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64394. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64395. * @param name defines the name of the new line system
  64396. * @param options defines the options used to create the line system
  64397. * @param scene defines the hosting scene
  64398. * @returns a new line system mesh
  64399. */
  64400. static CreateLineSystem(name: string, options: {
  64401. lines: Vector3[][];
  64402. updatable?: boolean;
  64403. instance?: Nullable<LinesMesh>;
  64404. colors?: Nullable<Color4[][]>;
  64405. useVertexAlpha?: boolean;
  64406. }, scene: Nullable<Scene>): LinesMesh;
  64407. /**
  64408. * Creates a line mesh
  64409. * 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
  64410. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64411. * * The parameter `points` is an array successive Vector3
  64412. * * 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
  64413. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64414. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64415. * * When updating an instance, remember that only point positions can change, not the number of points
  64416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64417. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64418. * @param name defines the name of the new line system
  64419. * @param options defines the options used to create the line system
  64420. * @param scene defines the hosting scene
  64421. * @returns a new line mesh
  64422. */
  64423. static CreateLines(name: string, options: {
  64424. points: Vector3[];
  64425. updatable?: boolean;
  64426. instance?: Nullable<LinesMesh>;
  64427. colors?: Color4[];
  64428. useVertexAlpha?: boolean;
  64429. }, scene?: Nullable<Scene>): LinesMesh;
  64430. /**
  64431. * Creates a dashed line mesh
  64432. * * 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
  64433. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64434. * * The parameter `points` is an array successive Vector3
  64435. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64436. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64437. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64438. * * 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
  64439. * * When updating an instance, remember that only point positions can change, not the number of points
  64440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64441. * @param name defines the name of the mesh
  64442. * @param options defines the options used to create the mesh
  64443. * @param scene defines the hosting scene
  64444. * @returns the dashed line mesh
  64445. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64446. */
  64447. static CreateDashedLines(name: string, options: {
  64448. points: Vector3[];
  64449. dashSize?: number;
  64450. gapSize?: number;
  64451. dashNb?: number;
  64452. updatable?: boolean;
  64453. instance?: LinesMesh;
  64454. }, scene?: Nullable<Scene>): LinesMesh;
  64455. /**
  64456. * 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.
  64457. * * 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.
  64458. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64459. * * 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.
  64460. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64461. * * 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
  64462. * * 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
  64463. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64466. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64468. * @param name defines the name of the mesh
  64469. * @param options defines the options used to create the mesh
  64470. * @param scene defines the hosting scene
  64471. * @returns the extruded shape mesh
  64472. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64474. */
  64475. static ExtrudeShape(name: string, options: {
  64476. shape: Vector3[];
  64477. path: Vector3[];
  64478. scale?: number;
  64479. rotation?: number;
  64480. cap?: number;
  64481. updatable?: boolean;
  64482. sideOrientation?: number;
  64483. frontUVs?: Vector4;
  64484. backUVs?: Vector4;
  64485. instance?: Mesh;
  64486. invertUV?: boolean;
  64487. }, scene?: Nullable<Scene>): Mesh;
  64488. /**
  64489. * Creates an custom extruded shape mesh.
  64490. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64491. * * 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.
  64492. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64493. * * 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
  64494. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64495. * * 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
  64496. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64497. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64498. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64499. * * 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
  64500. * * 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
  64501. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64506. * @param name defines the name of the mesh
  64507. * @param options defines the options used to create the mesh
  64508. * @param scene defines the hosting scene
  64509. * @returns the custom extruded shape mesh
  64510. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64511. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64513. */
  64514. static ExtrudeShapeCustom(name: string, options: {
  64515. shape: Vector3[];
  64516. path: Vector3[];
  64517. scaleFunction?: any;
  64518. rotationFunction?: any;
  64519. ribbonCloseArray?: boolean;
  64520. ribbonClosePath?: boolean;
  64521. cap?: number;
  64522. updatable?: boolean;
  64523. sideOrientation?: number;
  64524. frontUVs?: Vector4;
  64525. backUVs?: Vector4;
  64526. instance?: Mesh;
  64527. invertUV?: boolean;
  64528. }, scene?: Nullable<Scene>): Mesh;
  64529. /**
  64530. * Creates lathe mesh.
  64531. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64532. * * 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
  64533. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64534. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64535. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64536. * * 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
  64537. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64538. * * 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
  64539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64541. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64543. * @param name defines the name of the mesh
  64544. * @param options defines the options used to create the mesh
  64545. * @param scene defines the hosting scene
  64546. * @returns the lathe mesh
  64547. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64548. */
  64549. static CreateLathe(name: string, options: {
  64550. shape: Vector3[];
  64551. radius?: number;
  64552. tessellation?: number;
  64553. clip?: number;
  64554. arc?: number;
  64555. closed?: boolean;
  64556. updatable?: boolean;
  64557. sideOrientation?: number;
  64558. frontUVs?: Vector4;
  64559. backUVs?: Vector4;
  64560. cap?: number;
  64561. invertUV?: boolean;
  64562. }, scene?: Nullable<Scene>): Mesh;
  64563. /**
  64564. * Creates a tiled plane mesh
  64565. * * You can set a limited pattern arrangement with the tiles
  64566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64569. * @param name defines the name of the mesh
  64570. * @param options defines the options used to create the mesh
  64571. * @param scene defines the hosting scene
  64572. * @returns the plane mesh
  64573. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64574. */
  64575. static CreateTiledPlane(name: string, options: {
  64576. pattern?: number;
  64577. tileSize?: number;
  64578. tileWidth?: number;
  64579. tileHeight?: number;
  64580. size?: number;
  64581. width?: number;
  64582. height?: number;
  64583. alignHorizontal?: number;
  64584. alignVertical?: number;
  64585. sideOrientation?: number;
  64586. frontUVs?: Vector4;
  64587. backUVs?: Vector4;
  64588. updatable?: boolean;
  64589. }, scene?: Nullable<Scene>): Mesh;
  64590. /**
  64591. * Creates a plane mesh
  64592. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64593. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64594. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64598. * @param name defines the name of the mesh
  64599. * @param options defines the options used to create the mesh
  64600. * @param scene defines the hosting scene
  64601. * @returns the plane mesh
  64602. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64603. */
  64604. static CreatePlane(name: string, options: {
  64605. size?: number;
  64606. width?: number;
  64607. height?: number;
  64608. sideOrientation?: number;
  64609. frontUVs?: Vector4;
  64610. backUVs?: Vector4;
  64611. updatable?: boolean;
  64612. sourcePlane?: Plane;
  64613. }, scene?: Nullable<Scene>): Mesh;
  64614. /**
  64615. * Creates a ground mesh
  64616. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64617. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64619. * @param name defines the name of the mesh
  64620. * @param options defines the options used to create the mesh
  64621. * @param scene defines the hosting scene
  64622. * @returns the ground mesh
  64623. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64624. */
  64625. static CreateGround(name: string, options: {
  64626. width?: number;
  64627. height?: number;
  64628. subdivisions?: number;
  64629. subdivisionsX?: number;
  64630. subdivisionsY?: number;
  64631. updatable?: boolean;
  64632. }, scene?: Nullable<Scene>): Mesh;
  64633. /**
  64634. * Creates a tiled ground mesh
  64635. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64636. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64637. * * 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
  64638. * * 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
  64639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64640. * @param name defines the name of the mesh
  64641. * @param options defines the options used to create the mesh
  64642. * @param scene defines the hosting scene
  64643. * @returns the tiled ground mesh
  64644. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64645. */
  64646. static CreateTiledGround(name: string, options: {
  64647. xmin: number;
  64648. zmin: number;
  64649. xmax: number;
  64650. zmax: number;
  64651. subdivisions?: {
  64652. w: number;
  64653. h: number;
  64654. };
  64655. precision?: {
  64656. w: number;
  64657. h: number;
  64658. };
  64659. updatable?: boolean;
  64660. }, scene?: Nullable<Scene>): Mesh;
  64661. /**
  64662. * Creates a ground mesh from a height map
  64663. * * The parameter `url` sets the URL of the height map image resource.
  64664. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64665. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64666. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64667. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64668. * * 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.
  64669. * * 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).
  64670. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64672. * @param name defines the name of the mesh
  64673. * @param url defines the url to the height map
  64674. * @param options defines the options used to create the mesh
  64675. * @param scene defines the hosting scene
  64676. * @returns the ground mesh
  64677. * @see https://doc.babylonjs.com/babylon101/height_map
  64678. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64679. */
  64680. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64681. width?: number;
  64682. height?: number;
  64683. subdivisions?: number;
  64684. minHeight?: number;
  64685. maxHeight?: number;
  64686. colorFilter?: Color3;
  64687. alphaFilter?: number;
  64688. updatable?: boolean;
  64689. onReady?: (mesh: GroundMesh) => void;
  64690. }, scene?: Nullable<Scene>): GroundMesh;
  64691. /**
  64692. * Creates a polygon mesh
  64693. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64694. * * 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
  64695. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64698. * * Remember you can only change the shape positions, not their number when updating a polygon
  64699. * @param name defines the name of the mesh
  64700. * @param options defines the options used to create the mesh
  64701. * @param scene defines the hosting scene
  64702. * @param earcutInjection can be used to inject your own earcut reference
  64703. * @returns the polygon mesh
  64704. */
  64705. static CreatePolygon(name: string, options: {
  64706. shape: Vector3[];
  64707. holes?: Vector3[][];
  64708. depth?: number;
  64709. faceUV?: Vector4[];
  64710. faceColors?: Color4[];
  64711. updatable?: boolean;
  64712. sideOrientation?: number;
  64713. frontUVs?: Vector4;
  64714. backUVs?: Vector4;
  64715. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64716. /**
  64717. * Creates an extruded polygon mesh, with depth in the Y direction.
  64718. * * 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)
  64719. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64720. * @param name defines the name of the mesh
  64721. * @param options defines the options used to create the mesh
  64722. * @param scene defines the hosting scene
  64723. * @param earcutInjection can be used to inject your own earcut reference
  64724. * @returns the polygon mesh
  64725. */
  64726. static ExtrudePolygon(name: string, options: {
  64727. shape: Vector3[];
  64728. holes?: Vector3[][];
  64729. depth?: number;
  64730. faceUV?: Vector4[];
  64731. faceColors?: Color4[];
  64732. updatable?: boolean;
  64733. sideOrientation?: number;
  64734. frontUVs?: Vector4;
  64735. backUVs?: Vector4;
  64736. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64737. /**
  64738. * Creates a tube mesh.
  64739. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64740. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64741. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64742. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64743. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64744. * * 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)
  64745. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64746. * * 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
  64747. * * 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
  64748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64750. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64752. * @param name defines the name of the mesh
  64753. * @param options defines the options used to create the mesh
  64754. * @param scene defines the hosting scene
  64755. * @returns the tube mesh
  64756. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64757. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64758. */
  64759. static CreateTube(name: string, options: {
  64760. path: Vector3[];
  64761. radius?: number;
  64762. tessellation?: number;
  64763. radiusFunction?: {
  64764. (i: number, distance: number): number;
  64765. };
  64766. cap?: number;
  64767. arc?: number;
  64768. updatable?: boolean;
  64769. sideOrientation?: number;
  64770. frontUVs?: Vector4;
  64771. backUVs?: Vector4;
  64772. instance?: Mesh;
  64773. invertUV?: boolean;
  64774. }, scene?: Nullable<Scene>): Mesh;
  64775. /**
  64776. * Creates a polyhedron mesh
  64777. * * 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
  64778. * * The parameter `size` (positive float, default 1) sets the polygon size
  64779. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64780. * * 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`
  64781. * * 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
  64782. * * 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)`)
  64783. * * 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
  64784. * * 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
  64785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64788. * @param name defines the name of the mesh
  64789. * @param options defines the options used to create the mesh
  64790. * @param scene defines the hosting scene
  64791. * @returns the polyhedron mesh
  64792. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64793. */
  64794. static CreatePolyhedron(name: string, options: {
  64795. type?: number;
  64796. size?: number;
  64797. sizeX?: number;
  64798. sizeY?: number;
  64799. sizeZ?: number;
  64800. custom?: any;
  64801. faceUV?: Vector4[];
  64802. faceColors?: Color4[];
  64803. flat?: boolean;
  64804. updatable?: boolean;
  64805. sideOrientation?: number;
  64806. frontUVs?: Vector4;
  64807. backUVs?: Vector4;
  64808. }, scene?: Nullable<Scene>): Mesh;
  64809. /**
  64810. * Creates a decal mesh.
  64811. * 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
  64812. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64813. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64814. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64815. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64816. * @param name defines the name of the mesh
  64817. * @param sourceMesh defines the mesh where the decal must be applied
  64818. * @param options defines the options used to create the mesh
  64819. * @param scene defines the hosting scene
  64820. * @returns the decal mesh
  64821. * @see https://doc.babylonjs.com/how_to/decals
  64822. */
  64823. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64824. position?: Vector3;
  64825. normal?: Vector3;
  64826. size?: Vector3;
  64827. angle?: number;
  64828. }): Mesh;
  64829. }
  64830. }
  64831. declare module "babylonjs/Meshes/meshSimplification" {
  64832. import { Mesh } from "babylonjs/Meshes/mesh";
  64833. /**
  64834. * A simplifier interface for future simplification implementations
  64835. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64836. */
  64837. export interface ISimplifier {
  64838. /**
  64839. * Simplification of a given mesh according to the given settings.
  64840. * Since this requires computation, it is assumed that the function runs async.
  64841. * @param settings The settings of the simplification, including quality and distance
  64842. * @param successCallback A callback that will be called after the mesh was simplified.
  64843. * @param errorCallback in case of an error, this callback will be called. optional.
  64844. */
  64845. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64846. }
  64847. /**
  64848. * Expected simplification settings.
  64849. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64850. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64851. */
  64852. export interface ISimplificationSettings {
  64853. /**
  64854. * Gets or sets the expected quality
  64855. */
  64856. quality: number;
  64857. /**
  64858. * Gets or sets the distance when this optimized version should be used
  64859. */
  64860. distance: number;
  64861. /**
  64862. * Gets an already optimized mesh
  64863. */
  64864. optimizeMesh?: boolean;
  64865. }
  64866. /**
  64867. * Class used to specify simplification options
  64868. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64869. */
  64870. export class SimplificationSettings implements ISimplificationSettings {
  64871. /** expected quality */
  64872. quality: number;
  64873. /** distance when this optimized version should be used */
  64874. distance: number;
  64875. /** already optimized mesh */
  64876. optimizeMesh?: boolean | undefined;
  64877. /**
  64878. * Creates a SimplificationSettings
  64879. * @param quality expected quality
  64880. * @param distance distance when this optimized version should be used
  64881. * @param optimizeMesh already optimized mesh
  64882. */
  64883. constructor(
  64884. /** expected quality */
  64885. quality: number,
  64886. /** distance when this optimized version should be used */
  64887. distance: number,
  64888. /** already optimized mesh */
  64889. optimizeMesh?: boolean | undefined);
  64890. }
  64891. /**
  64892. * Interface used to define a simplification task
  64893. */
  64894. export interface ISimplificationTask {
  64895. /**
  64896. * Array of settings
  64897. */
  64898. settings: Array<ISimplificationSettings>;
  64899. /**
  64900. * Simplification type
  64901. */
  64902. simplificationType: SimplificationType;
  64903. /**
  64904. * Mesh to simplify
  64905. */
  64906. mesh: Mesh;
  64907. /**
  64908. * Callback called on success
  64909. */
  64910. successCallback?: () => void;
  64911. /**
  64912. * Defines if parallel processing can be used
  64913. */
  64914. parallelProcessing: boolean;
  64915. }
  64916. /**
  64917. * Queue used to order the simplification tasks
  64918. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64919. */
  64920. export class SimplificationQueue {
  64921. private _simplificationArray;
  64922. /**
  64923. * Gets a boolean indicating that the process is still running
  64924. */
  64925. running: boolean;
  64926. /**
  64927. * Creates a new queue
  64928. */
  64929. constructor();
  64930. /**
  64931. * Adds a new simplification task
  64932. * @param task defines a task to add
  64933. */
  64934. addTask(task: ISimplificationTask): void;
  64935. /**
  64936. * Execute next task
  64937. */
  64938. executeNext(): void;
  64939. /**
  64940. * Execute a simplification task
  64941. * @param task defines the task to run
  64942. */
  64943. runSimplification(task: ISimplificationTask): void;
  64944. private getSimplifier;
  64945. }
  64946. /**
  64947. * The implemented types of simplification
  64948. * At the moment only Quadratic Error Decimation is implemented
  64949. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64950. */
  64951. export enum SimplificationType {
  64952. /** Quadratic error decimation */
  64953. QUADRATIC = 0
  64954. }
  64955. /**
  64956. * An implementation of the Quadratic Error simplification algorithm.
  64957. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  64958. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  64959. * @author RaananW
  64960. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64961. */
  64962. export class QuadraticErrorSimplification implements ISimplifier {
  64963. private _mesh;
  64964. private triangles;
  64965. private vertices;
  64966. private references;
  64967. private _reconstructedMesh;
  64968. /** Gets or sets the number pf sync interations */
  64969. syncIterations: number;
  64970. /** Gets or sets the aggressiveness of the simplifier */
  64971. aggressiveness: number;
  64972. /** Gets or sets the number of allowed iterations for decimation */
  64973. decimationIterations: number;
  64974. /** Gets or sets the espilon to use for bounding box computation */
  64975. boundingBoxEpsilon: number;
  64976. /**
  64977. * Creates a new QuadraticErrorSimplification
  64978. * @param _mesh defines the target mesh
  64979. */
  64980. constructor(_mesh: Mesh);
  64981. /**
  64982. * Simplification of a given mesh according to the given settings.
  64983. * Since this requires computation, it is assumed that the function runs async.
  64984. * @param settings The settings of the simplification, including quality and distance
  64985. * @param successCallback A callback that will be called after the mesh was simplified.
  64986. */
  64987. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  64988. private runDecimation;
  64989. private initWithMesh;
  64990. private init;
  64991. private reconstructMesh;
  64992. private initDecimatedMesh;
  64993. private isFlipped;
  64994. private updateTriangles;
  64995. private identifyBorder;
  64996. private updateMesh;
  64997. private vertexError;
  64998. private calculateError;
  64999. }
  65000. }
  65001. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  65002. import { Scene } from "babylonjs/scene";
  65003. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  65004. import { ISceneComponent } from "babylonjs/sceneComponent";
  65005. module "babylonjs/scene" {
  65006. interface Scene {
  65007. /** @hidden (Backing field) */
  65008. _simplificationQueue: SimplificationQueue;
  65009. /**
  65010. * Gets or sets the simplification queue attached to the scene
  65011. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65012. */
  65013. simplificationQueue: SimplificationQueue;
  65014. }
  65015. }
  65016. module "babylonjs/Meshes/mesh" {
  65017. interface Mesh {
  65018. /**
  65019. * Simplify the mesh according to the given array of settings.
  65020. * Function will return immediately and will simplify async
  65021. * @param settings a collection of simplification settings
  65022. * @param parallelProcessing should all levels calculate parallel or one after the other
  65023. * @param simplificationType the type of simplification to run
  65024. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65025. * @returns the current mesh
  65026. */
  65027. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65028. }
  65029. }
  65030. /**
  65031. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65032. * created in a scene
  65033. */
  65034. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65035. /**
  65036. * The component name helpfull to identify the component in the list of scene components.
  65037. */
  65038. readonly name: string;
  65039. /**
  65040. * The scene the component belongs to.
  65041. */
  65042. scene: Scene;
  65043. /**
  65044. * Creates a new instance of the component for the given scene
  65045. * @param scene Defines the scene to register the component in
  65046. */
  65047. constructor(scene: Scene);
  65048. /**
  65049. * Registers the component in a given scene
  65050. */
  65051. register(): void;
  65052. /**
  65053. * Rebuilds the elements related to this component in case of
  65054. * context lost for instance.
  65055. */
  65056. rebuild(): void;
  65057. /**
  65058. * Disposes the component and the associated ressources
  65059. */
  65060. dispose(): void;
  65061. private _beforeCameraUpdate;
  65062. }
  65063. }
  65064. declare module "babylonjs/Meshes/Builders/index" {
  65065. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65066. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65067. export * from "babylonjs/Meshes/Builders/discBuilder";
  65068. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65069. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65070. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65071. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65072. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65073. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65074. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65075. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65076. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65077. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65078. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65079. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65080. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65081. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65082. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65083. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65084. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65085. }
  65086. declare module "babylonjs/Meshes/index" {
  65087. export * from "babylonjs/Meshes/abstractMesh";
  65088. export * from "babylonjs/Meshes/buffer";
  65089. export * from "babylonjs/Meshes/Compression/index";
  65090. export * from "babylonjs/Meshes/csg";
  65091. export * from "babylonjs/Meshes/geometry";
  65092. export * from "babylonjs/Meshes/groundMesh";
  65093. export * from "babylonjs/Meshes/trailMesh";
  65094. export * from "babylonjs/Meshes/instancedMesh";
  65095. export * from "babylonjs/Meshes/linesMesh";
  65096. export * from "babylonjs/Meshes/mesh";
  65097. export * from "babylonjs/Meshes/mesh.vertexData";
  65098. export * from "babylonjs/Meshes/meshBuilder";
  65099. export * from "babylonjs/Meshes/meshSimplification";
  65100. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65101. export * from "babylonjs/Meshes/polygonMesh";
  65102. export * from "babylonjs/Meshes/subMesh";
  65103. export * from "babylonjs/Meshes/meshLODLevel";
  65104. export * from "babylonjs/Meshes/transformNode";
  65105. export * from "babylonjs/Meshes/Builders/index";
  65106. export * from "babylonjs/Meshes/dataBuffer";
  65107. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65108. }
  65109. declare module "babylonjs/Morph/index" {
  65110. export * from "babylonjs/Morph/morphTarget";
  65111. export * from "babylonjs/Morph/morphTargetManager";
  65112. }
  65113. declare module "babylonjs/Navigation/INavigationEngine" {
  65114. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65115. import { Vector3 } from "babylonjs/Maths/math";
  65116. import { Mesh } from "babylonjs/Meshes/mesh";
  65117. import { Scene } from "babylonjs/scene";
  65118. /**
  65119. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65120. */
  65121. export interface INavigationEnginePlugin {
  65122. /**
  65123. * plugin name
  65124. */
  65125. name: string;
  65126. /**
  65127. * Creates a navigation mesh
  65128. * @param meshes array of all the geometry used to compute the navigatio mesh
  65129. * @param parameters bunch of parameters used to filter geometry
  65130. */
  65131. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65132. /**
  65133. * Create a navigation mesh debug mesh
  65134. * @param scene is where the mesh will be added
  65135. * @returns debug display mesh
  65136. */
  65137. createDebugNavMesh(scene: Scene): Mesh;
  65138. /**
  65139. * Get a navigation mesh constrained position, closest to the parameter position
  65140. * @param position world position
  65141. * @returns the closest point to position constrained by the navigation mesh
  65142. */
  65143. getClosestPoint(position: Vector3): Vector3;
  65144. /**
  65145. * Get a navigation mesh constrained position, within a particular radius
  65146. * @param position world position
  65147. * @param maxRadius the maximum distance to the constrained world position
  65148. * @returns the closest point to position constrained by the navigation mesh
  65149. */
  65150. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65151. /**
  65152. * Compute the final position from a segment made of destination-position
  65153. * @param position world position
  65154. * @param destination world position
  65155. * @returns the resulting point along the navmesh
  65156. */
  65157. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65158. /**
  65159. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65160. * @param start world position
  65161. * @param end world position
  65162. * @returns array containing world position composing the path
  65163. */
  65164. computePath(start: Vector3, end: Vector3): Vector3[];
  65165. /**
  65166. * If this plugin is supported
  65167. * @returns true if plugin is supported
  65168. */
  65169. isSupported(): boolean;
  65170. /**
  65171. * Create a new Crowd so you can add agents
  65172. * @param maxAgents the maximum agent count in the crowd
  65173. * @param maxAgentRadius the maximum radius an agent can have
  65174. * @param scene to attach the crowd to
  65175. * @returns the crowd you can add agents to
  65176. */
  65177. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65178. /**
  65179. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65180. * The queries will try to find a solution within those bounds
  65181. * default is (1,1,1)
  65182. * @param extent x,y,z value that define the extent around the queries point of reference
  65183. */
  65184. setDefaultQueryExtent(extent: Vector3): void;
  65185. /**
  65186. * Get the Bounding box extent specified by setDefaultQueryExtent
  65187. * @returns the box extent values
  65188. */
  65189. getDefaultQueryExtent(): Vector3;
  65190. /**
  65191. * Release all resources
  65192. */
  65193. dispose(): void;
  65194. }
  65195. /**
  65196. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65197. */
  65198. export interface ICrowd {
  65199. /**
  65200. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65201. * You can attach anything to that node. The node position is updated in the scene update tick.
  65202. * @param pos world position that will be constrained by the navigation mesh
  65203. * @param parameters agent parameters
  65204. * @param transform hooked to the agent that will be update by the scene
  65205. * @returns agent index
  65206. */
  65207. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65208. /**
  65209. * Returns the agent position in world space
  65210. * @param index agent index returned by addAgent
  65211. * @returns world space position
  65212. */
  65213. getAgentPosition(index: number): Vector3;
  65214. /**
  65215. * Gets the agent velocity in world space
  65216. * @param index agent index returned by addAgent
  65217. * @returns world space velocity
  65218. */
  65219. getAgentVelocity(index: number): Vector3;
  65220. /**
  65221. * remove a particular agent previously created
  65222. * @param index agent index returned by addAgent
  65223. */
  65224. removeAgent(index: number): void;
  65225. /**
  65226. * get the list of all agents attached to this crowd
  65227. * @returns list of agent indices
  65228. */
  65229. getAgents(): number[];
  65230. /**
  65231. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65232. * @param deltaTime in seconds
  65233. */
  65234. update(deltaTime: number): void;
  65235. /**
  65236. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65237. * @param index agent index returned by addAgent
  65238. * @param destination targeted world position
  65239. */
  65240. agentGoto(index: number, destination: Vector3): void;
  65241. /**
  65242. * Teleport the agent to a new position
  65243. * @param index agent index returned by addAgent
  65244. * @param destination targeted world position
  65245. */
  65246. agentTeleport(index: number, destination: Vector3): void;
  65247. /**
  65248. * Update agent parameters
  65249. * @param index agent index returned by addAgent
  65250. * @param parameters agent parameters
  65251. */
  65252. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65253. /**
  65254. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65255. * The queries will try to find a solution within those bounds
  65256. * default is (1,1,1)
  65257. * @param extent x,y,z value that define the extent around the queries point of reference
  65258. */
  65259. setDefaultQueryExtent(extent: Vector3): void;
  65260. /**
  65261. * Get the Bounding box extent specified by setDefaultQueryExtent
  65262. * @returns the box extent values
  65263. */
  65264. getDefaultQueryExtent(): Vector3;
  65265. /**
  65266. * Release all resources
  65267. */
  65268. dispose(): void;
  65269. }
  65270. /**
  65271. * Configures an agent
  65272. */
  65273. export interface IAgentParameters {
  65274. /**
  65275. * Agent radius. [Limit: >= 0]
  65276. */
  65277. radius: number;
  65278. /**
  65279. * Agent height. [Limit: > 0]
  65280. */
  65281. height: number;
  65282. /**
  65283. * Maximum allowed acceleration. [Limit: >= 0]
  65284. */
  65285. maxAcceleration: number;
  65286. /**
  65287. * Maximum allowed speed. [Limit: >= 0]
  65288. */
  65289. maxSpeed: number;
  65290. /**
  65291. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65292. */
  65293. collisionQueryRange: number;
  65294. /**
  65295. * The path visibility optimization range. [Limit: > 0]
  65296. */
  65297. pathOptimizationRange: number;
  65298. /**
  65299. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65300. */
  65301. separationWeight: number;
  65302. }
  65303. /**
  65304. * Configures the navigation mesh creation
  65305. */
  65306. export interface INavMeshParameters {
  65307. /**
  65308. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65309. */
  65310. cs: number;
  65311. /**
  65312. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65313. */
  65314. ch: number;
  65315. /**
  65316. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65317. */
  65318. walkableSlopeAngle: number;
  65319. /**
  65320. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65321. * be considered walkable. [Limit: >= 3] [Units: vx]
  65322. */
  65323. walkableHeight: number;
  65324. /**
  65325. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65326. */
  65327. walkableClimb: number;
  65328. /**
  65329. * The distance to erode/shrink the walkable area of the heightfield away from
  65330. * obstructions. [Limit: >=0] [Units: vx]
  65331. */
  65332. walkableRadius: number;
  65333. /**
  65334. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65335. */
  65336. maxEdgeLen: number;
  65337. /**
  65338. * The maximum distance a simplfied contour's border edges should deviate
  65339. * the original raw contour. [Limit: >=0] [Units: vx]
  65340. */
  65341. maxSimplificationError: number;
  65342. /**
  65343. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65344. */
  65345. minRegionArea: number;
  65346. /**
  65347. * Any regions with a span count smaller than this value will, if possible,
  65348. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65349. */
  65350. mergeRegionArea: number;
  65351. /**
  65352. * The maximum number of vertices allowed for polygons generated during the
  65353. * contour to polygon conversion process. [Limit: >= 3]
  65354. */
  65355. maxVertsPerPoly: number;
  65356. /**
  65357. * Sets the sampling distance to use when generating the detail mesh.
  65358. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65359. */
  65360. detailSampleDist: number;
  65361. /**
  65362. * The maximum distance the detail mesh surface should deviate from heightfield
  65363. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65364. */
  65365. detailSampleMaxError: number;
  65366. }
  65367. }
  65368. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65369. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65370. import { Mesh } from "babylonjs/Meshes/mesh";
  65371. import { Scene } from "babylonjs/scene";
  65372. import { Vector3 } from "babylonjs/Maths/math";
  65373. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65374. /**
  65375. * RecastJS navigation plugin
  65376. */
  65377. export class RecastJSPlugin implements INavigationEnginePlugin {
  65378. /**
  65379. * Reference to the Recast library
  65380. */
  65381. bjsRECAST: any;
  65382. /**
  65383. * plugin name
  65384. */
  65385. name: string;
  65386. /**
  65387. * the first navmesh created. We might extend this to support multiple navmeshes
  65388. */
  65389. navMesh: any;
  65390. /**
  65391. * Initializes the recastJS plugin
  65392. * @param recastInjection can be used to inject your own recast reference
  65393. */
  65394. constructor(recastInjection?: any);
  65395. /**
  65396. * Creates a navigation mesh
  65397. * @param meshes array of all the geometry used to compute the navigatio mesh
  65398. * @param parameters bunch of parameters used to filter geometry
  65399. */
  65400. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65401. /**
  65402. * Create a navigation mesh debug mesh
  65403. * @param scene is where the mesh will be added
  65404. * @returns debug display mesh
  65405. */
  65406. createDebugNavMesh(scene: Scene): Mesh;
  65407. /**
  65408. * Get a navigation mesh constrained position, closest to the parameter position
  65409. * @param position world position
  65410. * @returns the closest point to position constrained by the navigation mesh
  65411. */
  65412. getClosestPoint(position: Vector3): Vector3;
  65413. /**
  65414. * Get a navigation mesh constrained position, within a particular radius
  65415. * @param position world position
  65416. * @param maxRadius the maximum distance to the constrained world position
  65417. * @returns the closest point to position constrained by the navigation mesh
  65418. */
  65419. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65420. /**
  65421. * Compute the final position from a segment made of destination-position
  65422. * @param position world position
  65423. * @param destination world position
  65424. * @returns the resulting point along the navmesh
  65425. */
  65426. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65427. /**
  65428. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65429. * @param start world position
  65430. * @param end world position
  65431. * @returns array containing world position composing the path
  65432. */
  65433. computePath(start: Vector3, end: Vector3): Vector3[];
  65434. /**
  65435. * Create a new Crowd so you can add agents
  65436. * @param maxAgents the maximum agent count in the crowd
  65437. * @param maxAgentRadius the maximum radius an agent can have
  65438. * @param scene to attach the crowd to
  65439. * @returns the crowd you can add agents to
  65440. */
  65441. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65442. /**
  65443. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65444. * The queries will try to find a solution within those bounds
  65445. * default is (1,1,1)
  65446. * @param extent x,y,z value that define the extent around the queries point of reference
  65447. */
  65448. setDefaultQueryExtent(extent: Vector3): void;
  65449. /**
  65450. * Get the Bounding box extent specified by setDefaultQueryExtent
  65451. * @returns the box extent values
  65452. */
  65453. getDefaultQueryExtent(): Vector3;
  65454. /**
  65455. * Disposes
  65456. */
  65457. dispose(): void;
  65458. /**
  65459. * If this plugin is supported
  65460. * @returns true if plugin is supported
  65461. */
  65462. isSupported(): boolean;
  65463. }
  65464. /**
  65465. * Recast detour crowd implementation
  65466. */
  65467. export class RecastJSCrowd implements ICrowd {
  65468. /**
  65469. * Recast/detour plugin
  65470. */
  65471. bjsRECASTPlugin: RecastJSPlugin;
  65472. /**
  65473. * Link to the detour crowd
  65474. */
  65475. recastCrowd: any;
  65476. /**
  65477. * One transform per agent
  65478. */
  65479. transforms: TransformNode[];
  65480. /**
  65481. * All agents created
  65482. */
  65483. agents: number[];
  65484. /**
  65485. * Link to the scene is kept to unregister the crowd from the scene
  65486. */
  65487. private _scene;
  65488. /**
  65489. * Observer for crowd updates
  65490. */
  65491. private _onBeforeAnimationsObserver;
  65492. /**
  65493. * Constructor
  65494. * @param plugin recastJS plugin
  65495. * @param maxAgents the maximum agent count in the crowd
  65496. * @param maxAgentRadius the maximum radius an agent can have
  65497. * @param scene to attach the crowd to
  65498. * @returns the crowd you can add agents to
  65499. */
  65500. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65501. /**
  65502. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65503. * You can attach anything to that node. The node position is updated in the scene update tick.
  65504. * @param pos world position that will be constrained by the navigation mesh
  65505. * @param parameters agent parameters
  65506. * @param transform hooked to the agent that will be update by the scene
  65507. * @returns agent index
  65508. */
  65509. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65510. /**
  65511. * Returns the agent position in world space
  65512. * @param index agent index returned by addAgent
  65513. * @returns world space position
  65514. */
  65515. getAgentPosition(index: number): Vector3;
  65516. /**
  65517. * Returns the agent velocity in world space
  65518. * @param index agent index returned by addAgent
  65519. * @returns world space velocity
  65520. */
  65521. getAgentVelocity(index: number): Vector3;
  65522. /**
  65523. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65524. * @param index agent index returned by addAgent
  65525. * @param destination targeted world position
  65526. */
  65527. agentGoto(index: number, destination: Vector3): void;
  65528. /**
  65529. * Teleport the agent to a new position
  65530. * @param index agent index returned by addAgent
  65531. * @param destination targeted world position
  65532. */
  65533. agentTeleport(index: number, destination: Vector3): void;
  65534. /**
  65535. * Update agent parameters
  65536. * @param index agent index returned by addAgent
  65537. * @param parameters agent parameters
  65538. */
  65539. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65540. /**
  65541. * remove a particular agent previously created
  65542. * @param index agent index returned by addAgent
  65543. */
  65544. removeAgent(index: number): void;
  65545. /**
  65546. * get the list of all agents attached to this crowd
  65547. * @returns list of agent indices
  65548. */
  65549. getAgents(): number[];
  65550. /**
  65551. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65552. * @param deltaTime in seconds
  65553. */
  65554. update(deltaTime: number): void;
  65555. /**
  65556. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65557. * The queries will try to find a solution within those bounds
  65558. * default is (1,1,1)
  65559. * @param extent x,y,z value that define the extent around the queries point of reference
  65560. */
  65561. setDefaultQueryExtent(extent: Vector3): void;
  65562. /**
  65563. * Get the Bounding box extent specified by setDefaultQueryExtent
  65564. * @returns the box extent values
  65565. */
  65566. getDefaultQueryExtent(): Vector3;
  65567. /**
  65568. * Release all resources
  65569. */
  65570. dispose(): void;
  65571. }
  65572. }
  65573. declare module "babylonjs/Navigation/Plugins/index" {
  65574. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65575. }
  65576. declare module "babylonjs/Navigation/index" {
  65577. export * from "babylonjs/Navigation/INavigationEngine";
  65578. export * from "babylonjs/Navigation/Plugins/index";
  65579. }
  65580. declare module "babylonjs/Offline/database" {
  65581. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65582. /**
  65583. * Class used to enable access to IndexedDB
  65584. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65585. */
  65586. export class Database implements IOfflineProvider {
  65587. private _callbackManifestChecked;
  65588. private _currentSceneUrl;
  65589. private _db;
  65590. private _enableSceneOffline;
  65591. private _enableTexturesOffline;
  65592. private _manifestVersionFound;
  65593. private _mustUpdateRessources;
  65594. private _hasReachedQuota;
  65595. private _isSupported;
  65596. private _idbFactory;
  65597. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65598. private static IsUASupportingBlobStorage;
  65599. /**
  65600. * Gets a boolean indicating if Database storate is enabled (off by default)
  65601. */
  65602. static IDBStorageEnabled: boolean;
  65603. /**
  65604. * Gets a boolean indicating if scene must be saved in the database
  65605. */
  65606. get enableSceneOffline(): boolean;
  65607. /**
  65608. * Gets a boolean indicating if textures must be saved in the database
  65609. */
  65610. get enableTexturesOffline(): boolean;
  65611. /**
  65612. * Creates a new Database
  65613. * @param urlToScene defines the url to load the scene
  65614. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65615. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65616. */
  65617. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65618. private static _ParseURL;
  65619. private static _ReturnFullUrlLocation;
  65620. private _checkManifestFile;
  65621. /**
  65622. * Open the database and make it available
  65623. * @param successCallback defines the callback to call on success
  65624. * @param errorCallback defines the callback to call on error
  65625. */
  65626. open(successCallback: () => void, errorCallback: () => void): void;
  65627. /**
  65628. * Loads an image from the database
  65629. * @param url defines the url to load from
  65630. * @param image defines the target DOM image
  65631. */
  65632. loadImage(url: string, image: HTMLImageElement): void;
  65633. private _loadImageFromDBAsync;
  65634. private _saveImageIntoDBAsync;
  65635. private _checkVersionFromDB;
  65636. private _loadVersionFromDBAsync;
  65637. private _saveVersionIntoDBAsync;
  65638. /**
  65639. * Loads a file from database
  65640. * @param url defines the URL to load from
  65641. * @param sceneLoaded defines a callback to call on success
  65642. * @param progressCallBack defines a callback to call when progress changed
  65643. * @param errorCallback defines a callback to call on error
  65644. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65645. */
  65646. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65647. private _loadFileAsync;
  65648. private _saveFileAsync;
  65649. /**
  65650. * Validates if xhr data is correct
  65651. * @param xhr defines the request to validate
  65652. * @param dataType defines the expected data type
  65653. * @returns true if data is correct
  65654. */
  65655. private static _ValidateXHRData;
  65656. }
  65657. }
  65658. declare module "babylonjs/Offline/index" {
  65659. export * from "babylonjs/Offline/database";
  65660. export * from "babylonjs/Offline/IOfflineProvider";
  65661. }
  65662. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65663. /** @hidden */
  65664. export var gpuUpdateParticlesPixelShader: {
  65665. name: string;
  65666. shader: string;
  65667. };
  65668. }
  65669. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65670. /** @hidden */
  65671. export var gpuUpdateParticlesVertexShader: {
  65672. name: string;
  65673. shader: string;
  65674. };
  65675. }
  65676. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65677. /** @hidden */
  65678. export var clipPlaneFragmentDeclaration2: {
  65679. name: string;
  65680. shader: string;
  65681. };
  65682. }
  65683. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65684. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65685. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65686. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65687. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65688. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65689. /** @hidden */
  65690. export var gpuRenderParticlesPixelShader: {
  65691. name: string;
  65692. shader: string;
  65693. };
  65694. }
  65695. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65696. /** @hidden */
  65697. export var clipPlaneVertexDeclaration2: {
  65698. name: string;
  65699. shader: string;
  65700. };
  65701. }
  65702. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65703. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65704. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65705. /** @hidden */
  65706. export var gpuRenderParticlesVertexShader: {
  65707. name: string;
  65708. shader: string;
  65709. };
  65710. }
  65711. declare module "babylonjs/Particles/gpuParticleSystem" {
  65712. import { Nullable } from "babylonjs/types";
  65713. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65714. import { Observable } from "babylonjs/Misc/observable";
  65715. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65716. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65717. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65718. import { Scene, IDisposable } from "babylonjs/scene";
  65719. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65720. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65721. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65722. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65723. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65724. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65725. /**
  65726. * This represents a GPU particle system in Babylon
  65727. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65728. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65729. */
  65730. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65731. /**
  65732. * The layer mask we are rendering the particles through.
  65733. */
  65734. layerMask: number;
  65735. private _capacity;
  65736. private _activeCount;
  65737. private _currentActiveCount;
  65738. private _accumulatedCount;
  65739. private _renderEffect;
  65740. private _updateEffect;
  65741. private _buffer0;
  65742. private _buffer1;
  65743. private _spriteBuffer;
  65744. private _updateVAO;
  65745. private _renderVAO;
  65746. private _targetIndex;
  65747. private _sourceBuffer;
  65748. private _targetBuffer;
  65749. private _engine;
  65750. private _currentRenderId;
  65751. private _started;
  65752. private _stopped;
  65753. private _timeDelta;
  65754. private _randomTexture;
  65755. private _randomTexture2;
  65756. private _attributesStrideSize;
  65757. private _updateEffectOptions;
  65758. private _randomTextureSize;
  65759. private _actualFrame;
  65760. private readonly _rawTextureWidth;
  65761. /**
  65762. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65763. */
  65764. static get IsSupported(): boolean;
  65765. /**
  65766. * An event triggered when the system is disposed.
  65767. */
  65768. onDisposeObservable: Observable<GPUParticleSystem>;
  65769. /**
  65770. * Gets the maximum number of particles active at the same time.
  65771. * @returns The max number of active particles.
  65772. */
  65773. getCapacity(): number;
  65774. /**
  65775. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65776. * to override the particles.
  65777. */
  65778. forceDepthWrite: boolean;
  65779. /**
  65780. * Gets or set the number of active particles
  65781. */
  65782. get activeParticleCount(): number;
  65783. set activeParticleCount(value: number);
  65784. private _preWarmDone;
  65785. /**
  65786. * Specifies if the particles are updated in emitter local space or world space.
  65787. * This is always false for GPU particles
  65788. */
  65789. get isLocal(): boolean;
  65790. set isLocal(value: boolean);
  65791. /**
  65792. * Is this system ready to be used/rendered
  65793. * @return true if the system is ready
  65794. */
  65795. isReady(): boolean;
  65796. /**
  65797. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65798. * @returns True if it has been started, otherwise false.
  65799. */
  65800. isStarted(): boolean;
  65801. /**
  65802. * Starts the particle system and begins to emit
  65803. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65804. */
  65805. start(delay?: number): void;
  65806. /**
  65807. * Stops the particle system.
  65808. */
  65809. stop(): void;
  65810. /**
  65811. * Remove all active particles
  65812. */
  65813. reset(): void;
  65814. /**
  65815. * Returns the string "GPUParticleSystem"
  65816. * @returns a string containing the class name
  65817. */
  65818. getClassName(): string;
  65819. private _colorGradientsTexture;
  65820. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65821. /**
  65822. * Adds a new color gradient
  65823. * @param gradient defines the gradient to use (between 0 and 1)
  65824. * @param color1 defines the color to affect to the specified gradient
  65825. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65826. * @returns the current particle system
  65827. */
  65828. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65829. /**
  65830. * Remove a specific color gradient
  65831. * @param gradient defines the gradient to remove
  65832. * @returns the current particle system
  65833. */
  65834. removeColorGradient(gradient: number): GPUParticleSystem;
  65835. private _angularSpeedGradientsTexture;
  65836. private _sizeGradientsTexture;
  65837. private _velocityGradientsTexture;
  65838. private _limitVelocityGradientsTexture;
  65839. private _dragGradientsTexture;
  65840. private _addFactorGradient;
  65841. /**
  65842. * Adds a new size gradient
  65843. * @param gradient defines the gradient to use (between 0 and 1)
  65844. * @param factor defines the size factor to affect to the specified gradient
  65845. * @returns the current particle system
  65846. */
  65847. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65848. /**
  65849. * Remove a specific size gradient
  65850. * @param gradient defines the gradient to remove
  65851. * @returns the current particle system
  65852. */
  65853. removeSizeGradient(gradient: number): GPUParticleSystem;
  65854. /**
  65855. * Adds a new angular speed gradient
  65856. * @param gradient defines the gradient to use (between 0 and 1)
  65857. * @param factor defines the angular speed to affect to the specified gradient
  65858. * @returns the current particle system
  65859. */
  65860. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65861. /**
  65862. * Remove a specific angular speed gradient
  65863. * @param gradient defines the gradient to remove
  65864. * @returns the current particle system
  65865. */
  65866. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65867. /**
  65868. * Adds a new velocity gradient
  65869. * @param gradient defines the gradient to use (between 0 and 1)
  65870. * @param factor defines the velocity to affect to the specified gradient
  65871. * @returns the current particle system
  65872. */
  65873. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65874. /**
  65875. * Remove a specific velocity gradient
  65876. * @param gradient defines the gradient to remove
  65877. * @returns the current particle system
  65878. */
  65879. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65880. /**
  65881. * Adds a new limit velocity gradient
  65882. * @param gradient defines the gradient to use (between 0 and 1)
  65883. * @param factor defines the limit velocity value to affect to the specified gradient
  65884. * @returns the current particle system
  65885. */
  65886. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65887. /**
  65888. * Remove a specific limit velocity gradient
  65889. * @param gradient defines the gradient to remove
  65890. * @returns the current particle system
  65891. */
  65892. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65893. /**
  65894. * Adds a new drag gradient
  65895. * @param gradient defines the gradient to use (between 0 and 1)
  65896. * @param factor defines the drag value to affect to the specified gradient
  65897. * @returns the current particle system
  65898. */
  65899. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65900. /**
  65901. * Remove a specific drag gradient
  65902. * @param gradient defines the gradient to remove
  65903. * @returns the current particle system
  65904. */
  65905. removeDragGradient(gradient: number): GPUParticleSystem;
  65906. /**
  65907. * Not supported by GPUParticleSystem
  65908. * @param gradient defines the gradient to use (between 0 and 1)
  65909. * @param factor defines the emit rate value to affect to the specified gradient
  65910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65911. * @returns the current particle system
  65912. */
  65913. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65914. /**
  65915. * Not supported by GPUParticleSystem
  65916. * @param gradient defines the gradient to remove
  65917. * @returns the current particle system
  65918. */
  65919. removeEmitRateGradient(gradient: number): IParticleSystem;
  65920. /**
  65921. * Not supported by GPUParticleSystem
  65922. * @param gradient defines the gradient to use (between 0 and 1)
  65923. * @param factor defines the start size value to affect to the specified gradient
  65924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65925. * @returns the current particle system
  65926. */
  65927. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65928. /**
  65929. * Not supported by GPUParticleSystem
  65930. * @param gradient defines the gradient to remove
  65931. * @returns the current particle system
  65932. */
  65933. removeStartSizeGradient(gradient: number): IParticleSystem;
  65934. /**
  65935. * Not supported by GPUParticleSystem
  65936. * @param gradient defines the gradient to use (between 0 and 1)
  65937. * @param min defines the color remap minimal range
  65938. * @param max defines the color remap maximal range
  65939. * @returns the current particle system
  65940. */
  65941. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65942. /**
  65943. * Not supported by GPUParticleSystem
  65944. * @param gradient defines the gradient to remove
  65945. * @returns the current particle system
  65946. */
  65947. removeColorRemapGradient(): IParticleSystem;
  65948. /**
  65949. * Not supported by GPUParticleSystem
  65950. * @param gradient defines the gradient to use (between 0 and 1)
  65951. * @param min defines the alpha remap minimal range
  65952. * @param max defines the alpha remap maximal range
  65953. * @returns the current particle system
  65954. */
  65955. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65956. /**
  65957. * Not supported by GPUParticleSystem
  65958. * @param gradient defines the gradient to remove
  65959. * @returns the current particle system
  65960. */
  65961. removeAlphaRemapGradient(): IParticleSystem;
  65962. /**
  65963. * Not supported by GPUParticleSystem
  65964. * @param gradient defines the gradient to use (between 0 and 1)
  65965. * @param color defines the color to affect to the specified gradient
  65966. * @returns the current particle system
  65967. */
  65968. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65969. /**
  65970. * Not supported by GPUParticleSystem
  65971. * @param gradient defines the gradient to remove
  65972. * @returns the current particle system
  65973. */
  65974. removeRampGradient(): IParticleSystem;
  65975. /**
  65976. * Not supported by GPUParticleSystem
  65977. * @returns the list of ramp gradients
  65978. */
  65979. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65980. /**
  65981. * Not supported by GPUParticleSystem
  65982. * Gets or sets a boolean indicating that ramp gradients must be used
  65983. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65984. */
  65985. get useRampGradients(): boolean;
  65986. set useRampGradients(value: boolean);
  65987. /**
  65988. * Not supported by GPUParticleSystem
  65989. * @param gradient defines the gradient to use (between 0 and 1)
  65990. * @param factor defines the life time factor to affect to the specified gradient
  65991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65992. * @returns the current particle system
  65993. */
  65994. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65995. /**
  65996. * Not supported by GPUParticleSystem
  65997. * @param gradient defines the gradient to remove
  65998. * @returns the current particle system
  65999. */
  66000. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66001. /**
  66002. * Instantiates a GPU particle system.
  66003. * 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.
  66004. * @param name The name of the particle system
  66005. * @param options The options used to create the system
  66006. * @param scene The scene the particle system belongs to
  66007. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66008. */
  66009. constructor(name: string, options: Partial<{
  66010. capacity: number;
  66011. randomTextureSize: number;
  66012. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  66013. protected _reset(): void;
  66014. private _createUpdateVAO;
  66015. private _createRenderVAO;
  66016. private _initialize;
  66017. /** @hidden */
  66018. _recreateUpdateEffect(): void;
  66019. /** @hidden */
  66020. _recreateRenderEffect(): void;
  66021. /**
  66022. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66023. * @param preWarm defines if we are in the pre-warmimg phase
  66024. */
  66025. animate(preWarm?: boolean): void;
  66026. private _createFactorGradientTexture;
  66027. private _createSizeGradientTexture;
  66028. private _createAngularSpeedGradientTexture;
  66029. private _createVelocityGradientTexture;
  66030. private _createLimitVelocityGradientTexture;
  66031. private _createDragGradientTexture;
  66032. private _createColorGradientTexture;
  66033. /**
  66034. * Renders the particle system in its current state
  66035. * @param preWarm defines if the system should only update the particles but not render them
  66036. * @returns the current number of particles
  66037. */
  66038. render(preWarm?: boolean): number;
  66039. /**
  66040. * Rebuilds the particle system
  66041. */
  66042. rebuild(): void;
  66043. private _releaseBuffers;
  66044. private _releaseVAOs;
  66045. /**
  66046. * Disposes the particle system and free the associated resources
  66047. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66048. */
  66049. dispose(disposeTexture?: boolean): void;
  66050. /**
  66051. * Clones the particle system.
  66052. * @param name The name of the cloned object
  66053. * @param newEmitter The new emitter to use
  66054. * @returns the cloned particle system
  66055. */
  66056. clone(name: string, newEmitter: any): GPUParticleSystem;
  66057. /**
  66058. * Serializes the particle system to a JSON object.
  66059. * @returns the JSON object
  66060. */
  66061. serialize(): any;
  66062. /**
  66063. * Parses a JSON object to create a GPU particle system.
  66064. * @param parsedParticleSystem The JSON object to parse
  66065. * @param scene The scene to create the particle system in
  66066. * @param rootUrl The root url to use to load external dependencies like texture
  66067. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66068. * @returns the parsed GPU particle system
  66069. */
  66070. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66071. }
  66072. }
  66073. declare module "babylonjs/Particles/particleSystemSet" {
  66074. import { Nullable } from "babylonjs/types";
  66075. import { Color3 } from "babylonjs/Maths/math.color";
  66076. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66078. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66079. import { Scene, IDisposable } from "babylonjs/scene";
  66080. /**
  66081. * Represents a set of particle systems working together to create a specific effect
  66082. */
  66083. export class ParticleSystemSet implements IDisposable {
  66084. /**
  66085. * Gets or sets base Assets URL
  66086. */
  66087. static BaseAssetsUrl: string;
  66088. private _emitterCreationOptions;
  66089. private _emitterNode;
  66090. /**
  66091. * Gets the particle system list
  66092. */
  66093. systems: IParticleSystem[];
  66094. /**
  66095. * Gets the emitter node used with this set
  66096. */
  66097. get emitterNode(): Nullable<TransformNode>;
  66098. /**
  66099. * Creates a new emitter mesh as a sphere
  66100. * @param options defines the options used to create the sphere
  66101. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66102. * @param scene defines the hosting scene
  66103. */
  66104. setEmitterAsSphere(options: {
  66105. diameter: number;
  66106. segments: number;
  66107. color: Color3;
  66108. }, renderingGroupId: number, scene: Scene): void;
  66109. /**
  66110. * Starts all particle systems of the set
  66111. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66112. */
  66113. start(emitter?: AbstractMesh): void;
  66114. /**
  66115. * Release all associated resources
  66116. */
  66117. dispose(): void;
  66118. /**
  66119. * Serialize the set into a JSON compatible object
  66120. * @returns a JSON compatible representation of the set
  66121. */
  66122. serialize(): any;
  66123. /**
  66124. * Parse a new ParticleSystemSet from a serialized source
  66125. * @param data defines a JSON compatible representation of the set
  66126. * @param scene defines the hosting scene
  66127. * @param gpu defines if we want GPU particles or CPU particles
  66128. * @returns a new ParticleSystemSet
  66129. */
  66130. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66131. }
  66132. }
  66133. declare module "babylonjs/Particles/particleHelper" {
  66134. import { Nullable } from "babylonjs/types";
  66135. import { Scene } from "babylonjs/scene";
  66136. import { Vector3 } from "babylonjs/Maths/math.vector";
  66137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66138. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66139. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66140. /**
  66141. * This class is made for on one-liner static method to help creating particle system set.
  66142. */
  66143. export class ParticleHelper {
  66144. /**
  66145. * Gets or sets base Assets URL
  66146. */
  66147. static BaseAssetsUrl: string;
  66148. /**
  66149. * Create a default particle system that you can tweak
  66150. * @param emitter defines the emitter to use
  66151. * @param capacity defines the system capacity (default is 500 particles)
  66152. * @param scene defines the hosting scene
  66153. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66154. * @returns the new Particle system
  66155. */
  66156. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66157. /**
  66158. * This is the main static method (one-liner) of this helper to create different particle systems
  66159. * @param type This string represents the type to the particle system to create
  66160. * @param scene The scene where the particle system should live
  66161. * @param gpu If the system will use gpu
  66162. * @returns the ParticleSystemSet created
  66163. */
  66164. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66165. /**
  66166. * Static function used to export a particle system to a ParticleSystemSet variable.
  66167. * Please note that the emitter shape is not exported
  66168. * @param systems defines the particle systems to export
  66169. * @returns the created particle system set
  66170. */
  66171. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66172. }
  66173. }
  66174. declare module "babylonjs/Particles/particleSystemComponent" {
  66175. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66176. import { Effect } from "babylonjs/Materials/effect";
  66177. import "babylonjs/Shaders/particles.vertex";
  66178. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66179. module "babylonjs/Engines/engine" {
  66180. interface Engine {
  66181. /**
  66182. * Create an effect to use with particle systems.
  66183. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66184. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66185. * @param uniformsNames defines a list of attribute names
  66186. * @param samplers defines an array of string used to represent textures
  66187. * @param defines defines the string containing the defines to use to compile the shaders
  66188. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66189. * @param onCompiled defines a function to call when the effect creation is successful
  66190. * @param onError defines a function to call when the effect creation has failed
  66191. * @returns the new Effect
  66192. */
  66193. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66194. }
  66195. }
  66196. module "babylonjs/Meshes/mesh" {
  66197. interface Mesh {
  66198. /**
  66199. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66200. * @returns an array of IParticleSystem
  66201. */
  66202. getEmittedParticleSystems(): IParticleSystem[];
  66203. /**
  66204. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66205. * @returns an array of IParticleSystem
  66206. */
  66207. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66208. }
  66209. }
  66210. /**
  66211. * @hidden
  66212. */
  66213. export var _IDoNeedToBeInTheBuild: number;
  66214. }
  66215. declare module "babylonjs/Particles/pointsCloudSystem" {
  66216. import { Color4 } from "babylonjs/Maths/math";
  66217. import { Mesh } from "babylonjs/Meshes/mesh";
  66218. import { Scene, IDisposable } from "babylonjs/scene";
  66219. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66220. /** Defines the 4 color options */
  66221. export enum PointColor {
  66222. /** color value */
  66223. Color = 2,
  66224. /** uv value */
  66225. UV = 1,
  66226. /** random value */
  66227. Random = 0,
  66228. /** stated value */
  66229. Stated = 3
  66230. }
  66231. /**
  66232. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66233. * 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.
  66234. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66235. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66236. *
  66237. * Full documentation here : TO BE ENTERED
  66238. */
  66239. export class PointsCloudSystem implements IDisposable {
  66240. /**
  66241. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66242. * Example : var p = SPS.particles[i];
  66243. */
  66244. particles: CloudPoint[];
  66245. /**
  66246. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66247. */
  66248. nbParticles: number;
  66249. /**
  66250. * This a counter for your own usage. It's not set by any SPS functions.
  66251. */
  66252. counter: number;
  66253. /**
  66254. * The PCS name. This name is also given to the underlying mesh.
  66255. */
  66256. name: string;
  66257. /**
  66258. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66259. */
  66260. mesh: Mesh;
  66261. /**
  66262. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66263. * Please read :
  66264. */
  66265. vars: any;
  66266. /**
  66267. * @hidden
  66268. */
  66269. _size: number;
  66270. private _scene;
  66271. private _promises;
  66272. private _positions;
  66273. private _indices;
  66274. private _normals;
  66275. private _colors;
  66276. private _uvs;
  66277. private _indices32;
  66278. private _positions32;
  66279. private _colors32;
  66280. private _uvs32;
  66281. private _updatable;
  66282. private _isVisibilityBoxLocked;
  66283. private _alwaysVisible;
  66284. private _groups;
  66285. private _groupCounter;
  66286. private _computeParticleColor;
  66287. private _computeParticleTexture;
  66288. private _computeParticleRotation;
  66289. private _computeBoundingBox;
  66290. private _isReady;
  66291. /**
  66292. * Creates a PCS (Points Cloud System) object
  66293. * @param name (String) is the PCS name, this will be the underlying mesh name
  66294. * @param pointSize (number) is the size for each point
  66295. * @param scene (Scene) is the scene in which the PCS is added
  66296. * @param options defines the options of the PCS e.g.
  66297. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66298. */
  66299. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66300. updatable?: boolean;
  66301. });
  66302. /**
  66303. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66304. * If no points were added to the PCS, the returned mesh is just a single point.
  66305. * @returns a promise for the created mesh
  66306. */
  66307. buildMeshAsync(): Promise<Mesh>;
  66308. /**
  66309. * @hidden
  66310. */
  66311. private _buildMesh;
  66312. private _addParticle;
  66313. private _randomUnitVector;
  66314. private _getColorIndicesForCoord;
  66315. private _setPointsColorOrUV;
  66316. private _colorFromTexture;
  66317. private _calculateDensity;
  66318. /**
  66319. * Adds points to the PCS in random positions within a unit sphere
  66320. * @param nb (positive integer) the number of particles to be created from this model
  66321. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66322. * @returns the number of groups in the system
  66323. */
  66324. addPoints(nb: number, pointFunction?: any): number;
  66325. /**
  66326. * Adds points to the PCS from the surface of the model shape
  66327. * @param mesh is any Mesh object that will be used as a surface model for the points
  66328. * @param nb (positive integer) the number of particles to be created from this model
  66329. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66330. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66331. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66332. * @returns the number of groups in the system
  66333. */
  66334. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66335. /**
  66336. * Adds points to the PCS inside the model shape
  66337. * @param mesh is any Mesh object that will be used as a surface model for the points
  66338. * @param nb (positive integer) the number of particles to be created from this model
  66339. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66340. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66341. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66342. * @returns the number of groups in the system
  66343. */
  66344. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66345. /**
  66346. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66347. * This method calls `updateParticle()` for each particle of the SPS.
  66348. * For an animated SPS, it is usually called within the render loop.
  66349. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66350. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66351. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66352. * @returns the PCS.
  66353. */
  66354. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66355. /**
  66356. * Disposes the PCS.
  66357. */
  66358. dispose(): void;
  66359. /**
  66360. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66361. * doc :
  66362. * @returns the PCS.
  66363. */
  66364. refreshVisibleSize(): PointsCloudSystem;
  66365. /**
  66366. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66367. * @param size the size (float) of the visibility box
  66368. * note : this doesn't lock the PCS mesh bounding box.
  66369. * doc :
  66370. */
  66371. setVisibilityBox(size: number): void;
  66372. /**
  66373. * Gets whether the PCS is always visible or not
  66374. * doc :
  66375. */
  66376. get isAlwaysVisible(): boolean;
  66377. /**
  66378. * Sets the PCS as always visible or not
  66379. * doc :
  66380. */
  66381. set isAlwaysVisible(val: boolean);
  66382. /**
  66383. * Tells to `setParticles()` to compute the particle rotations or not
  66384. * Default value : false. The PCS is faster when it's set to false
  66385. * Note : particle rotations are only applied to parent particles
  66386. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66387. */
  66388. set computeParticleRotation(val: boolean);
  66389. /**
  66390. * Tells to `setParticles()` to compute the particle colors or not.
  66391. * Default value : true. The PCS is faster when it's set to false.
  66392. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66393. */
  66394. set computeParticleColor(val: boolean);
  66395. set computeParticleTexture(val: boolean);
  66396. /**
  66397. * Gets if `setParticles()` computes the particle colors or not.
  66398. * Default value : false. The PCS is faster when it's set to false.
  66399. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66400. */
  66401. get computeParticleColor(): boolean;
  66402. /**
  66403. * Gets if `setParticles()` computes the particle textures or not.
  66404. * Default value : false. The PCS is faster when it's set to false.
  66405. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66406. */
  66407. get computeParticleTexture(): boolean;
  66408. /**
  66409. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66410. */
  66411. set computeBoundingBox(val: boolean);
  66412. /**
  66413. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66414. */
  66415. get computeBoundingBox(): boolean;
  66416. /**
  66417. * This function does nothing. It may be overwritten to set all the particle first values.
  66418. * The PCS doesn't call this function, you may have to call it by your own.
  66419. * doc :
  66420. */
  66421. initParticles(): void;
  66422. /**
  66423. * This function does nothing. It may be overwritten to recycle a particle
  66424. * The PCS doesn't call this function, you can to call it
  66425. * doc :
  66426. * @param particle The particle to recycle
  66427. * @returns the recycled particle
  66428. */
  66429. recycleParticle(particle: CloudPoint): CloudPoint;
  66430. /**
  66431. * Updates a particle : this function should be overwritten by the user.
  66432. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66433. * doc :
  66434. * @example : just set a particle position or velocity and recycle conditions
  66435. * @param particle The particle to update
  66436. * @returns the updated particle
  66437. */
  66438. updateParticle(particle: CloudPoint): CloudPoint;
  66439. /**
  66440. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66441. * This does nothing and may be overwritten by the user.
  66442. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66443. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66444. * @param update the boolean update value actually passed to setParticles()
  66445. */
  66446. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66447. /**
  66448. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66449. * This will be passed three parameters.
  66450. * This does nothing and may be overwritten by the user.
  66451. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66452. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66453. * @param update the boolean update value actually passed to setParticles()
  66454. */
  66455. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66456. }
  66457. }
  66458. declare module "babylonjs/Particles/cloudPoint" {
  66459. import { Nullable } from "babylonjs/types";
  66460. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66461. import { Mesh } from "babylonjs/Meshes/mesh";
  66462. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66463. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66464. /**
  66465. * Represents one particle of a points cloud system.
  66466. */
  66467. export class CloudPoint {
  66468. /**
  66469. * particle global index
  66470. */
  66471. idx: number;
  66472. /**
  66473. * The color of the particle
  66474. */
  66475. color: Nullable<Color4>;
  66476. /**
  66477. * The world space position of the particle.
  66478. */
  66479. position: Vector3;
  66480. /**
  66481. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66482. */
  66483. rotation: Vector3;
  66484. /**
  66485. * The world space rotation quaternion of the particle.
  66486. */
  66487. rotationQuaternion: Nullable<Quaternion>;
  66488. /**
  66489. * The uv of the particle.
  66490. */
  66491. uv: Nullable<Vector2>;
  66492. /**
  66493. * The current speed of the particle.
  66494. */
  66495. velocity: Vector3;
  66496. /**
  66497. * The pivot point in the particle local space.
  66498. */
  66499. pivot: Vector3;
  66500. /**
  66501. * Must the particle be translated from its pivot point in its local space ?
  66502. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66503. * Default : false
  66504. */
  66505. translateFromPivot: boolean;
  66506. /**
  66507. * Index of this particle in the global "positions" array (Internal use)
  66508. * @hidden
  66509. */
  66510. _pos: number;
  66511. /**
  66512. * @hidden Index of this particle in the global "indices" array (Internal use)
  66513. */
  66514. _ind: number;
  66515. /**
  66516. * Group this particle belongs to
  66517. */
  66518. _group: PointsGroup;
  66519. /**
  66520. * Group id of this particle
  66521. */
  66522. groupId: number;
  66523. /**
  66524. * Index of the particle in its group id (Internal use)
  66525. */
  66526. idxInGroup: number;
  66527. /**
  66528. * @hidden Particle BoundingInfo object (Internal use)
  66529. */
  66530. _boundingInfo: BoundingInfo;
  66531. /**
  66532. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66533. */
  66534. _pcs: PointsCloudSystem;
  66535. /**
  66536. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66537. */
  66538. _stillInvisible: boolean;
  66539. /**
  66540. * @hidden Last computed particle rotation matrix
  66541. */
  66542. _rotationMatrix: number[];
  66543. /**
  66544. * Parent particle Id, if any.
  66545. * Default null.
  66546. */
  66547. parentId: Nullable<number>;
  66548. /**
  66549. * @hidden Internal global position in the PCS.
  66550. */
  66551. _globalPosition: Vector3;
  66552. /**
  66553. * Creates a Point Cloud object.
  66554. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66555. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66556. * @param group (PointsGroup) is the group the particle belongs to
  66557. * @param groupId (integer) is the group identifier in the PCS.
  66558. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66559. * @param pcs defines the PCS it is associated to
  66560. */
  66561. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66562. /**
  66563. * get point size
  66564. */
  66565. get size(): Vector3;
  66566. /**
  66567. * Set point size
  66568. */
  66569. set size(scale: Vector3);
  66570. /**
  66571. * Legacy support, changed quaternion to rotationQuaternion
  66572. */
  66573. get quaternion(): Nullable<Quaternion>;
  66574. /**
  66575. * Legacy support, changed quaternion to rotationQuaternion
  66576. */
  66577. set quaternion(q: Nullable<Quaternion>);
  66578. /**
  66579. * Returns a boolean. True if the particle intersects a mesh, else false
  66580. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66581. * @param target is the object (point or mesh) what the intersection is computed against
  66582. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66583. * @returns true if it intersects
  66584. */
  66585. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66586. /**
  66587. * get the rotation matrix of the particle
  66588. * @hidden
  66589. */
  66590. getRotationMatrix(m: Matrix): void;
  66591. }
  66592. /**
  66593. * Represents a group of points in a points cloud system
  66594. * * PCS internal tool, don't use it manually.
  66595. */
  66596. export class PointsGroup {
  66597. /**
  66598. * The group id
  66599. * @hidden
  66600. */
  66601. groupID: number;
  66602. /**
  66603. * image data for group (internal use)
  66604. * @hidden
  66605. */
  66606. _groupImageData: Nullable<ArrayBufferView>;
  66607. /**
  66608. * Image Width (internal use)
  66609. * @hidden
  66610. */
  66611. _groupImgWidth: number;
  66612. /**
  66613. * Image Height (internal use)
  66614. * @hidden
  66615. */
  66616. _groupImgHeight: number;
  66617. /**
  66618. * Custom position function (internal use)
  66619. * @hidden
  66620. */
  66621. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66622. /**
  66623. * density per facet for surface points
  66624. * @hidden
  66625. */
  66626. _groupDensity: number[];
  66627. /**
  66628. * Only when points are colored by texture carries pointer to texture list array
  66629. * @hidden
  66630. */
  66631. _textureNb: number;
  66632. /**
  66633. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66634. * PCS internal tool, don't use it manually.
  66635. * @hidden
  66636. */
  66637. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66638. }
  66639. }
  66640. declare module "babylonjs/Particles/index" {
  66641. export * from "babylonjs/Particles/baseParticleSystem";
  66642. export * from "babylonjs/Particles/EmitterTypes/index";
  66643. export * from "babylonjs/Particles/gpuParticleSystem";
  66644. export * from "babylonjs/Particles/IParticleSystem";
  66645. export * from "babylonjs/Particles/particle";
  66646. export * from "babylonjs/Particles/particleHelper";
  66647. export * from "babylonjs/Particles/particleSystem";
  66648. export * from "babylonjs/Particles/particleSystemComponent";
  66649. export * from "babylonjs/Particles/particleSystemSet";
  66650. export * from "babylonjs/Particles/solidParticle";
  66651. export * from "babylonjs/Particles/solidParticleSystem";
  66652. export * from "babylonjs/Particles/cloudPoint";
  66653. export * from "babylonjs/Particles/pointsCloudSystem";
  66654. export * from "babylonjs/Particles/subEmitter";
  66655. }
  66656. declare module "babylonjs/Physics/physicsEngineComponent" {
  66657. import { Nullable } from "babylonjs/types";
  66658. import { Observable, Observer } from "babylonjs/Misc/observable";
  66659. import { Vector3 } from "babylonjs/Maths/math.vector";
  66660. import { Mesh } from "babylonjs/Meshes/mesh";
  66661. import { ISceneComponent } from "babylonjs/sceneComponent";
  66662. import { Scene } from "babylonjs/scene";
  66663. import { Node } from "babylonjs/node";
  66664. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66665. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66666. module "babylonjs/scene" {
  66667. interface Scene {
  66668. /** @hidden (Backing field) */
  66669. _physicsEngine: Nullable<IPhysicsEngine>;
  66670. /** @hidden */
  66671. _physicsTimeAccumulator: number;
  66672. /**
  66673. * Gets the current physics engine
  66674. * @returns a IPhysicsEngine or null if none attached
  66675. */
  66676. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66677. /**
  66678. * Enables physics to the current scene
  66679. * @param gravity defines the scene's gravity for the physics engine
  66680. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66681. * @return a boolean indicating if the physics engine was initialized
  66682. */
  66683. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66684. /**
  66685. * Disables and disposes the physics engine associated with the scene
  66686. */
  66687. disablePhysicsEngine(): void;
  66688. /**
  66689. * Gets a boolean indicating if there is an active physics engine
  66690. * @returns a boolean indicating if there is an active physics engine
  66691. */
  66692. isPhysicsEnabled(): boolean;
  66693. /**
  66694. * Deletes a physics compound impostor
  66695. * @param compound defines the compound to delete
  66696. */
  66697. deleteCompoundImpostor(compound: any): void;
  66698. /**
  66699. * An event triggered when physic simulation is about to be run
  66700. */
  66701. onBeforePhysicsObservable: Observable<Scene>;
  66702. /**
  66703. * An event triggered when physic simulation has been done
  66704. */
  66705. onAfterPhysicsObservable: Observable<Scene>;
  66706. }
  66707. }
  66708. module "babylonjs/Meshes/abstractMesh" {
  66709. interface AbstractMesh {
  66710. /** @hidden */
  66711. _physicsImpostor: Nullable<PhysicsImpostor>;
  66712. /**
  66713. * Gets or sets impostor used for physic simulation
  66714. * @see http://doc.babylonjs.com/features/physics_engine
  66715. */
  66716. physicsImpostor: Nullable<PhysicsImpostor>;
  66717. /**
  66718. * Gets the current physics impostor
  66719. * @see http://doc.babylonjs.com/features/physics_engine
  66720. * @returns a physics impostor or null
  66721. */
  66722. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66723. /** Apply a physic impulse to the mesh
  66724. * @param force defines the force to apply
  66725. * @param contactPoint defines where to apply the force
  66726. * @returns the current mesh
  66727. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66728. */
  66729. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66730. /**
  66731. * Creates a physic joint between two meshes
  66732. * @param otherMesh defines the other mesh to use
  66733. * @param pivot1 defines the pivot to use on this mesh
  66734. * @param pivot2 defines the pivot to use on the other mesh
  66735. * @param options defines additional options (can be plugin dependent)
  66736. * @returns the current mesh
  66737. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66738. */
  66739. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66740. /** @hidden */
  66741. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66742. }
  66743. }
  66744. /**
  66745. * Defines the physics engine scene component responsible to manage a physics engine
  66746. */
  66747. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66748. /**
  66749. * The component name helpful to identify the component in the list of scene components.
  66750. */
  66751. readonly name: string;
  66752. /**
  66753. * The scene the component belongs to.
  66754. */
  66755. scene: Scene;
  66756. /**
  66757. * Creates a new instance of the component for the given scene
  66758. * @param scene Defines the scene to register the component in
  66759. */
  66760. constructor(scene: Scene);
  66761. /**
  66762. * Registers the component in a given scene
  66763. */
  66764. register(): void;
  66765. /**
  66766. * Rebuilds the elements related to this component in case of
  66767. * context lost for instance.
  66768. */
  66769. rebuild(): void;
  66770. /**
  66771. * Disposes the component and the associated ressources
  66772. */
  66773. dispose(): void;
  66774. }
  66775. }
  66776. declare module "babylonjs/Physics/physicsHelper" {
  66777. import { Nullable } from "babylonjs/types";
  66778. import { Vector3 } from "babylonjs/Maths/math.vector";
  66779. import { Mesh } from "babylonjs/Meshes/mesh";
  66780. import { Scene } from "babylonjs/scene";
  66781. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66782. /**
  66783. * A helper for physics simulations
  66784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66785. */
  66786. export class PhysicsHelper {
  66787. private _scene;
  66788. private _physicsEngine;
  66789. /**
  66790. * Initializes the Physics helper
  66791. * @param scene Babylon.js scene
  66792. */
  66793. constructor(scene: Scene);
  66794. /**
  66795. * Applies a radial explosion impulse
  66796. * @param origin the origin of the explosion
  66797. * @param radiusOrEventOptions the radius or the options of radial explosion
  66798. * @param strength the explosion strength
  66799. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66800. * @returns A physics radial explosion event, or null
  66801. */
  66802. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66803. /**
  66804. * Applies a radial explosion force
  66805. * @param origin the origin of the explosion
  66806. * @param radiusOrEventOptions the radius or the options of radial explosion
  66807. * @param strength the explosion strength
  66808. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66809. * @returns A physics radial explosion event, or null
  66810. */
  66811. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66812. /**
  66813. * Creates a gravitational field
  66814. * @param origin the origin of the explosion
  66815. * @param radiusOrEventOptions the radius or the options of radial explosion
  66816. * @param strength the explosion strength
  66817. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66818. * @returns A physics gravitational field event, or null
  66819. */
  66820. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66821. /**
  66822. * Creates a physics updraft event
  66823. * @param origin the origin of the updraft
  66824. * @param radiusOrEventOptions the radius or the options of the updraft
  66825. * @param strength the strength of the updraft
  66826. * @param height the height of the updraft
  66827. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66828. * @returns A physics updraft event, or null
  66829. */
  66830. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66831. /**
  66832. * Creates a physics vortex event
  66833. * @param origin the of the vortex
  66834. * @param radiusOrEventOptions the radius or the options of the vortex
  66835. * @param strength the strength of the vortex
  66836. * @param height the height of the vortex
  66837. * @returns a Physics vortex event, or null
  66838. * A physics vortex event or null
  66839. */
  66840. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66841. }
  66842. /**
  66843. * Represents a physics radial explosion event
  66844. */
  66845. class PhysicsRadialExplosionEvent {
  66846. private _scene;
  66847. private _options;
  66848. private _sphere;
  66849. private _dataFetched;
  66850. /**
  66851. * Initializes a radial explosioin event
  66852. * @param _scene BabylonJS scene
  66853. * @param _options The options for the vortex event
  66854. */
  66855. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66856. /**
  66857. * Returns the data related to the radial explosion event (sphere).
  66858. * @returns The radial explosion event data
  66859. */
  66860. getData(): PhysicsRadialExplosionEventData;
  66861. /**
  66862. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66863. * @param impostor A physics imposter
  66864. * @param origin the origin of the explosion
  66865. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66866. */
  66867. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66868. /**
  66869. * Triggers affecterd impostors callbacks
  66870. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66871. */
  66872. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66873. /**
  66874. * Disposes the sphere.
  66875. * @param force Specifies if the sphere should be disposed by force
  66876. */
  66877. dispose(force?: boolean): void;
  66878. /*** Helpers ***/
  66879. private _prepareSphere;
  66880. private _intersectsWithSphere;
  66881. }
  66882. /**
  66883. * Represents a gravitational field event
  66884. */
  66885. class PhysicsGravitationalFieldEvent {
  66886. private _physicsHelper;
  66887. private _scene;
  66888. private _origin;
  66889. private _options;
  66890. private _tickCallback;
  66891. private _sphere;
  66892. private _dataFetched;
  66893. /**
  66894. * Initializes the physics gravitational field event
  66895. * @param _physicsHelper A physics helper
  66896. * @param _scene BabylonJS scene
  66897. * @param _origin The origin position of the gravitational field event
  66898. * @param _options The options for the vortex event
  66899. */
  66900. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66901. /**
  66902. * Returns the data related to the gravitational field event (sphere).
  66903. * @returns A gravitational field event
  66904. */
  66905. getData(): PhysicsGravitationalFieldEventData;
  66906. /**
  66907. * Enables the gravitational field.
  66908. */
  66909. enable(): void;
  66910. /**
  66911. * Disables the gravitational field.
  66912. */
  66913. disable(): void;
  66914. /**
  66915. * Disposes the sphere.
  66916. * @param force The force to dispose from the gravitational field event
  66917. */
  66918. dispose(force?: boolean): void;
  66919. private _tick;
  66920. }
  66921. /**
  66922. * Represents a physics updraft event
  66923. */
  66924. class PhysicsUpdraftEvent {
  66925. private _scene;
  66926. private _origin;
  66927. private _options;
  66928. private _physicsEngine;
  66929. private _originTop;
  66930. private _originDirection;
  66931. private _tickCallback;
  66932. private _cylinder;
  66933. private _cylinderPosition;
  66934. private _dataFetched;
  66935. /**
  66936. * Initializes the physics updraft event
  66937. * @param _scene BabylonJS scene
  66938. * @param _origin The origin position of the updraft
  66939. * @param _options The options for the updraft event
  66940. */
  66941. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66942. /**
  66943. * Returns the data related to the updraft event (cylinder).
  66944. * @returns A physics updraft event
  66945. */
  66946. getData(): PhysicsUpdraftEventData;
  66947. /**
  66948. * Enables the updraft.
  66949. */
  66950. enable(): void;
  66951. /**
  66952. * Disables the updraft.
  66953. */
  66954. disable(): void;
  66955. /**
  66956. * Disposes the cylinder.
  66957. * @param force Specifies if the updraft should be disposed by force
  66958. */
  66959. dispose(force?: boolean): void;
  66960. private getImpostorHitData;
  66961. private _tick;
  66962. /*** Helpers ***/
  66963. private _prepareCylinder;
  66964. private _intersectsWithCylinder;
  66965. }
  66966. /**
  66967. * Represents a physics vortex event
  66968. */
  66969. class PhysicsVortexEvent {
  66970. private _scene;
  66971. private _origin;
  66972. private _options;
  66973. private _physicsEngine;
  66974. private _originTop;
  66975. private _tickCallback;
  66976. private _cylinder;
  66977. private _cylinderPosition;
  66978. private _dataFetched;
  66979. /**
  66980. * Initializes the physics vortex event
  66981. * @param _scene The BabylonJS scene
  66982. * @param _origin The origin position of the vortex
  66983. * @param _options The options for the vortex event
  66984. */
  66985. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66986. /**
  66987. * Returns the data related to the vortex event (cylinder).
  66988. * @returns The physics vortex event data
  66989. */
  66990. getData(): PhysicsVortexEventData;
  66991. /**
  66992. * Enables the vortex.
  66993. */
  66994. enable(): void;
  66995. /**
  66996. * Disables the cortex.
  66997. */
  66998. disable(): void;
  66999. /**
  67000. * Disposes the sphere.
  67001. * @param force
  67002. */
  67003. dispose(force?: boolean): void;
  67004. private getImpostorHitData;
  67005. private _tick;
  67006. /*** Helpers ***/
  67007. private _prepareCylinder;
  67008. private _intersectsWithCylinder;
  67009. }
  67010. /**
  67011. * Options fot the radial explosion event
  67012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67013. */
  67014. export class PhysicsRadialExplosionEventOptions {
  67015. /**
  67016. * The radius of the sphere for the radial explosion.
  67017. */
  67018. radius: number;
  67019. /**
  67020. * The strenth of the explosion.
  67021. */
  67022. strength: number;
  67023. /**
  67024. * The strenght of the force in correspondence to the distance of the affected object
  67025. */
  67026. falloff: PhysicsRadialImpulseFalloff;
  67027. /**
  67028. * Sphere options for the radial explosion.
  67029. */
  67030. sphere: {
  67031. segments: number;
  67032. diameter: number;
  67033. };
  67034. /**
  67035. * Sphere options for the radial explosion.
  67036. */
  67037. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67038. }
  67039. /**
  67040. * Options fot the updraft event
  67041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67042. */
  67043. export class PhysicsUpdraftEventOptions {
  67044. /**
  67045. * The radius of the cylinder for the vortex
  67046. */
  67047. radius: number;
  67048. /**
  67049. * The strenth of the updraft.
  67050. */
  67051. strength: number;
  67052. /**
  67053. * The height of the cylinder for the updraft.
  67054. */
  67055. height: number;
  67056. /**
  67057. * The mode for the the updraft.
  67058. */
  67059. updraftMode: PhysicsUpdraftMode;
  67060. }
  67061. /**
  67062. * Options fot the vortex event
  67063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67064. */
  67065. export class PhysicsVortexEventOptions {
  67066. /**
  67067. * The radius of the cylinder for the vortex
  67068. */
  67069. radius: number;
  67070. /**
  67071. * The strenth of the vortex.
  67072. */
  67073. strength: number;
  67074. /**
  67075. * The height of the cylinder for the vortex.
  67076. */
  67077. height: number;
  67078. /**
  67079. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67080. */
  67081. centripetalForceThreshold: number;
  67082. /**
  67083. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67084. */
  67085. centripetalForceMultiplier: number;
  67086. /**
  67087. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67088. */
  67089. centrifugalForceMultiplier: number;
  67090. /**
  67091. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67092. */
  67093. updraftForceMultiplier: number;
  67094. }
  67095. /**
  67096. * The strenght of the force in correspondence to the distance of the affected object
  67097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67098. */
  67099. export enum PhysicsRadialImpulseFalloff {
  67100. /** Defines that impulse is constant in strength across it's whole radius */
  67101. Constant = 0,
  67102. /** Defines that impulse gets weaker if it's further from the origin */
  67103. Linear = 1
  67104. }
  67105. /**
  67106. * The strength of the force in correspondence to the distance of the affected object
  67107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67108. */
  67109. export enum PhysicsUpdraftMode {
  67110. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67111. Center = 0,
  67112. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67113. Perpendicular = 1
  67114. }
  67115. /**
  67116. * Interface for a physics hit data
  67117. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67118. */
  67119. export interface PhysicsHitData {
  67120. /**
  67121. * The force applied at the contact point
  67122. */
  67123. force: Vector3;
  67124. /**
  67125. * The contact point
  67126. */
  67127. contactPoint: Vector3;
  67128. /**
  67129. * The distance from the origin to the contact point
  67130. */
  67131. distanceFromOrigin: number;
  67132. }
  67133. /**
  67134. * Interface for radial explosion event data
  67135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67136. */
  67137. export interface PhysicsRadialExplosionEventData {
  67138. /**
  67139. * A sphere used for the radial explosion event
  67140. */
  67141. sphere: Mesh;
  67142. }
  67143. /**
  67144. * Interface for gravitational field event data
  67145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67146. */
  67147. export interface PhysicsGravitationalFieldEventData {
  67148. /**
  67149. * A sphere mesh used for the gravitational field event
  67150. */
  67151. sphere: Mesh;
  67152. }
  67153. /**
  67154. * Interface for updraft event data
  67155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67156. */
  67157. export interface PhysicsUpdraftEventData {
  67158. /**
  67159. * A cylinder used for the updraft event
  67160. */
  67161. cylinder: Mesh;
  67162. }
  67163. /**
  67164. * Interface for vortex event data
  67165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67166. */
  67167. export interface PhysicsVortexEventData {
  67168. /**
  67169. * A cylinder used for the vortex event
  67170. */
  67171. cylinder: Mesh;
  67172. }
  67173. /**
  67174. * Interface for an affected physics impostor
  67175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67176. */
  67177. export interface PhysicsAffectedImpostorWithData {
  67178. /**
  67179. * The impostor affected by the effect
  67180. */
  67181. impostor: PhysicsImpostor;
  67182. /**
  67183. * The data about the hit/horce from the explosion
  67184. */
  67185. hitData: PhysicsHitData;
  67186. }
  67187. }
  67188. declare module "babylonjs/Physics/Plugins/index" {
  67189. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67190. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67191. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67192. }
  67193. declare module "babylonjs/Physics/index" {
  67194. export * from "babylonjs/Physics/IPhysicsEngine";
  67195. export * from "babylonjs/Physics/physicsEngine";
  67196. export * from "babylonjs/Physics/physicsEngineComponent";
  67197. export * from "babylonjs/Physics/physicsHelper";
  67198. export * from "babylonjs/Physics/physicsImpostor";
  67199. export * from "babylonjs/Physics/physicsJoint";
  67200. export * from "babylonjs/Physics/Plugins/index";
  67201. }
  67202. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67203. /** @hidden */
  67204. export var blackAndWhitePixelShader: {
  67205. name: string;
  67206. shader: string;
  67207. };
  67208. }
  67209. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67210. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67211. import { Camera } from "babylonjs/Cameras/camera";
  67212. import { Engine } from "babylonjs/Engines/engine";
  67213. import "babylonjs/Shaders/blackAndWhite.fragment";
  67214. /**
  67215. * Post process used to render in black and white
  67216. */
  67217. export class BlackAndWhitePostProcess extends PostProcess {
  67218. /**
  67219. * Linear about to convert he result to black and white (default: 1)
  67220. */
  67221. degree: number;
  67222. /**
  67223. * Creates a black and white post process
  67224. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67225. * @param name The name of the effect.
  67226. * @param options The required width/height ratio to downsize to before computing the render pass.
  67227. * @param camera The camera to apply the render pass to.
  67228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67229. * @param engine The engine which the post process will be applied. (default: current engine)
  67230. * @param reusable If the post process can be reused on the same frame. (default: false)
  67231. */
  67232. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67233. }
  67234. }
  67235. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67236. import { Nullable } from "babylonjs/types";
  67237. import { Camera } from "babylonjs/Cameras/camera";
  67238. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67239. import { Engine } from "babylonjs/Engines/engine";
  67240. /**
  67241. * This represents a set of one or more post processes in Babylon.
  67242. * A post process can be used to apply a shader to a texture after it is rendered.
  67243. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67244. */
  67245. export class PostProcessRenderEffect {
  67246. private _postProcesses;
  67247. private _getPostProcesses;
  67248. private _singleInstance;
  67249. private _cameras;
  67250. private _indicesForCamera;
  67251. /**
  67252. * Name of the effect
  67253. * @hidden
  67254. */
  67255. _name: string;
  67256. /**
  67257. * Instantiates a post process render effect.
  67258. * A post process can be used to apply a shader to a texture after it is rendered.
  67259. * @param engine The engine the effect is tied to
  67260. * @param name The name of the effect
  67261. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67262. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67263. */
  67264. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67265. /**
  67266. * Checks if all the post processes in the effect are supported.
  67267. */
  67268. get isSupported(): boolean;
  67269. /**
  67270. * Updates the current state of the effect
  67271. * @hidden
  67272. */
  67273. _update(): void;
  67274. /**
  67275. * Attaches the effect on cameras
  67276. * @param cameras The camera to attach to.
  67277. * @hidden
  67278. */
  67279. _attachCameras(cameras: Camera): void;
  67280. /**
  67281. * Attaches the effect on cameras
  67282. * @param cameras The camera to attach to.
  67283. * @hidden
  67284. */
  67285. _attachCameras(cameras: Camera[]): void;
  67286. /**
  67287. * Detaches the effect on cameras
  67288. * @param cameras The camera to detatch from.
  67289. * @hidden
  67290. */
  67291. _detachCameras(cameras: Camera): void;
  67292. /**
  67293. * Detatches the effect on cameras
  67294. * @param cameras The camera to detatch from.
  67295. * @hidden
  67296. */
  67297. _detachCameras(cameras: Camera[]): void;
  67298. /**
  67299. * Enables the effect on given cameras
  67300. * @param cameras The camera to enable.
  67301. * @hidden
  67302. */
  67303. _enable(cameras: Camera): void;
  67304. /**
  67305. * Enables the effect on given cameras
  67306. * @param cameras The camera to enable.
  67307. * @hidden
  67308. */
  67309. _enable(cameras: Nullable<Camera[]>): void;
  67310. /**
  67311. * Disables the effect on the given cameras
  67312. * @param cameras The camera to disable.
  67313. * @hidden
  67314. */
  67315. _disable(cameras: Camera): void;
  67316. /**
  67317. * Disables the effect on the given cameras
  67318. * @param cameras The camera to disable.
  67319. * @hidden
  67320. */
  67321. _disable(cameras: Nullable<Camera[]>): void;
  67322. /**
  67323. * Gets a list of the post processes contained in the effect.
  67324. * @param camera The camera to get the post processes on.
  67325. * @returns The list of the post processes in the effect.
  67326. */
  67327. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67328. }
  67329. }
  67330. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67331. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67332. /** @hidden */
  67333. export var extractHighlightsPixelShader: {
  67334. name: string;
  67335. shader: string;
  67336. };
  67337. }
  67338. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67339. import { Nullable } from "babylonjs/types";
  67340. import { Camera } from "babylonjs/Cameras/camera";
  67341. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67342. import { Engine } from "babylonjs/Engines/engine";
  67343. import "babylonjs/Shaders/extractHighlights.fragment";
  67344. /**
  67345. * 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.
  67346. */
  67347. export class ExtractHighlightsPostProcess extends PostProcess {
  67348. /**
  67349. * The luminance threshold, pixels below this value will be set to black.
  67350. */
  67351. threshold: number;
  67352. /** @hidden */
  67353. _exposure: number;
  67354. /**
  67355. * Post process which has the input texture to be used when performing highlight extraction
  67356. * @hidden
  67357. */
  67358. _inputPostProcess: Nullable<PostProcess>;
  67359. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67360. }
  67361. }
  67362. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67363. /** @hidden */
  67364. export var bloomMergePixelShader: {
  67365. name: string;
  67366. shader: string;
  67367. };
  67368. }
  67369. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67370. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67371. import { Nullable } from "babylonjs/types";
  67372. import { Engine } from "babylonjs/Engines/engine";
  67373. import { Camera } from "babylonjs/Cameras/camera";
  67374. import "babylonjs/Shaders/bloomMerge.fragment";
  67375. /**
  67376. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67377. */
  67378. export class BloomMergePostProcess extends PostProcess {
  67379. /** Weight of the bloom to be added to the original input. */
  67380. weight: number;
  67381. /**
  67382. * Creates a new instance of @see BloomMergePostProcess
  67383. * @param name The name of the effect.
  67384. * @param originalFromInput Post process which's input will be used for the merge.
  67385. * @param blurred Blurred highlights post process which's output will be used.
  67386. * @param weight Weight of the bloom to be added to the original input.
  67387. * @param options The required width/height ratio to downsize to before computing the render pass.
  67388. * @param camera The camera to apply the render pass to.
  67389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67390. * @param engine The engine which the post process will be applied. (default: current engine)
  67391. * @param reusable If the post process can be reused on the same frame. (default: false)
  67392. * @param textureType Type of textures used when performing the post process. (default: 0)
  67393. * @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)
  67394. */
  67395. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67396. /** Weight of the bloom to be added to the original input. */
  67397. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67398. }
  67399. }
  67400. declare module "babylonjs/PostProcesses/bloomEffect" {
  67401. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67402. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67403. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67404. import { Camera } from "babylonjs/Cameras/camera";
  67405. import { Scene } from "babylonjs/scene";
  67406. /**
  67407. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67408. */
  67409. export class BloomEffect extends PostProcessRenderEffect {
  67410. private bloomScale;
  67411. /**
  67412. * @hidden Internal
  67413. */
  67414. _effects: Array<PostProcess>;
  67415. /**
  67416. * @hidden Internal
  67417. */
  67418. _downscale: ExtractHighlightsPostProcess;
  67419. private _blurX;
  67420. private _blurY;
  67421. private _merge;
  67422. /**
  67423. * The luminance threshold to find bright areas of the image to bloom.
  67424. */
  67425. get threshold(): number;
  67426. set threshold(value: number);
  67427. /**
  67428. * The strength of the bloom.
  67429. */
  67430. get weight(): number;
  67431. set weight(value: number);
  67432. /**
  67433. * Specifies the size of the bloom blur kernel, relative to the final output size
  67434. */
  67435. get kernel(): number;
  67436. set kernel(value: number);
  67437. /**
  67438. * Creates a new instance of @see BloomEffect
  67439. * @param scene The scene the effect belongs to.
  67440. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67441. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67442. * @param bloomWeight The the strength of bloom.
  67443. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67444. * @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)
  67445. */
  67446. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67447. /**
  67448. * Disposes each of the internal effects for a given camera.
  67449. * @param camera The camera to dispose the effect on.
  67450. */
  67451. disposeEffects(camera: Camera): void;
  67452. /**
  67453. * @hidden Internal
  67454. */
  67455. _updateEffects(): void;
  67456. /**
  67457. * Internal
  67458. * @returns if all the contained post processes are ready.
  67459. * @hidden
  67460. */
  67461. _isReady(): boolean;
  67462. }
  67463. }
  67464. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67465. /** @hidden */
  67466. export var chromaticAberrationPixelShader: {
  67467. name: string;
  67468. shader: string;
  67469. };
  67470. }
  67471. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67472. import { Vector2 } from "babylonjs/Maths/math.vector";
  67473. import { Nullable } from "babylonjs/types";
  67474. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67475. import { Camera } from "babylonjs/Cameras/camera";
  67476. import { Engine } from "babylonjs/Engines/engine";
  67477. import "babylonjs/Shaders/chromaticAberration.fragment";
  67478. /**
  67479. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67480. */
  67481. export class ChromaticAberrationPostProcess extends PostProcess {
  67482. /**
  67483. * The amount of seperation of rgb channels (default: 30)
  67484. */
  67485. aberrationAmount: number;
  67486. /**
  67487. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67488. */
  67489. radialIntensity: number;
  67490. /**
  67491. * 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))
  67492. */
  67493. direction: Vector2;
  67494. /**
  67495. * 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))
  67496. */
  67497. centerPosition: Vector2;
  67498. /**
  67499. * Creates a new instance ChromaticAberrationPostProcess
  67500. * @param name The name of the effect.
  67501. * @param screenWidth The width of the screen to apply the effect on.
  67502. * @param screenHeight The height of the screen to apply the effect on.
  67503. * @param options The required width/height ratio to downsize to before computing the render pass.
  67504. * @param camera The camera to apply the render pass to.
  67505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67506. * @param engine The engine which the post process will be applied. (default: current engine)
  67507. * @param reusable If the post process can be reused on the same frame. (default: false)
  67508. * @param textureType Type of textures used when performing the post process. (default: 0)
  67509. * @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)
  67510. */
  67511. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67512. }
  67513. }
  67514. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67515. /** @hidden */
  67516. export var circleOfConfusionPixelShader: {
  67517. name: string;
  67518. shader: string;
  67519. };
  67520. }
  67521. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67522. import { Nullable } from "babylonjs/types";
  67523. import { Engine } from "babylonjs/Engines/engine";
  67524. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67525. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67526. import { Camera } from "babylonjs/Cameras/camera";
  67527. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67528. /**
  67529. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67530. */
  67531. export class CircleOfConfusionPostProcess extends PostProcess {
  67532. /**
  67533. * 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.
  67534. */
  67535. lensSize: number;
  67536. /**
  67537. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67538. */
  67539. fStop: number;
  67540. /**
  67541. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67542. */
  67543. focusDistance: number;
  67544. /**
  67545. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67546. */
  67547. focalLength: number;
  67548. private _depthTexture;
  67549. /**
  67550. * Creates a new instance CircleOfConfusionPostProcess
  67551. * @param name The name of the effect.
  67552. * @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.
  67553. * @param options The required width/height ratio to downsize to before computing the render pass.
  67554. * @param camera The camera to apply the render pass to.
  67555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67556. * @param engine The engine which the post process will be applied. (default: current engine)
  67557. * @param reusable If the post process can be reused on the same frame. (default: false)
  67558. * @param textureType Type of textures used when performing the post process. (default: 0)
  67559. * @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)
  67560. */
  67561. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67562. /**
  67563. * 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.
  67564. */
  67565. set depthTexture(value: RenderTargetTexture);
  67566. }
  67567. }
  67568. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67569. /** @hidden */
  67570. export var colorCorrectionPixelShader: {
  67571. name: string;
  67572. shader: string;
  67573. };
  67574. }
  67575. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67576. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67577. import { Engine } from "babylonjs/Engines/engine";
  67578. import { Camera } from "babylonjs/Cameras/camera";
  67579. import "babylonjs/Shaders/colorCorrection.fragment";
  67580. /**
  67581. *
  67582. * This post-process allows the modification of rendered colors by using
  67583. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67584. *
  67585. * The object needs to be provided an url to a texture containing the color
  67586. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67587. * Use an image editing software to tweak the LUT to match your needs.
  67588. *
  67589. * For an example of a color LUT, see here:
  67590. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67591. * For explanations on color grading, see here:
  67592. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67593. *
  67594. */
  67595. export class ColorCorrectionPostProcess extends PostProcess {
  67596. private _colorTableTexture;
  67597. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67598. }
  67599. }
  67600. declare module "babylonjs/Shaders/convolution.fragment" {
  67601. /** @hidden */
  67602. export var convolutionPixelShader: {
  67603. name: string;
  67604. shader: string;
  67605. };
  67606. }
  67607. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67608. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67609. import { Nullable } from "babylonjs/types";
  67610. import { Camera } from "babylonjs/Cameras/camera";
  67611. import { Engine } from "babylonjs/Engines/engine";
  67612. import "babylonjs/Shaders/convolution.fragment";
  67613. /**
  67614. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67615. * input texture to perform effects such as edge detection or sharpening
  67616. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67617. */
  67618. export class ConvolutionPostProcess extends PostProcess {
  67619. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67620. kernel: number[];
  67621. /**
  67622. * Creates a new instance ConvolutionPostProcess
  67623. * @param name The name of the effect.
  67624. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67625. * @param options The required width/height ratio to downsize to before computing the render pass.
  67626. * @param camera The camera to apply the render pass to.
  67627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67628. * @param engine The engine which the post process will be applied. (default: current engine)
  67629. * @param reusable If the post process can be reused on the same frame. (default: false)
  67630. * @param textureType Type of textures used when performing the post process. (default: 0)
  67631. */
  67632. constructor(name: string,
  67633. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67634. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67635. /**
  67636. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67637. */
  67638. static EdgeDetect0Kernel: number[];
  67639. /**
  67640. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67641. */
  67642. static EdgeDetect1Kernel: number[];
  67643. /**
  67644. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67645. */
  67646. static EdgeDetect2Kernel: number[];
  67647. /**
  67648. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67649. */
  67650. static SharpenKernel: number[];
  67651. /**
  67652. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67653. */
  67654. static EmbossKernel: number[];
  67655. /**
  67656. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67657. */
  67658. static GaussianKernel: number[];
  67659. }
  67660. }
  67661. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67662. import { Nullable } from "babylonjs/types";
  67663. import { Vector2 } from "babylonjs/Maths/math.vector";
  67664. import { Camera } from "babylonjs/Cameras/camera";
  67665. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67666. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67667. import { Engine } from "babylonjs/Engines/engine";
  67668. import { Scene } from "babylonjs/scene";
  67669. /**
  67670. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67671. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67672. * based on samples that have a large difference in distance than the center pixel.
  67673. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67674. */
  67675. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67676. direction: Vector2;
  67677. /**
  67678. * Creates a new instance CircleOfConfusionPostProcess
  67679. * @param name The name of the effect.
  67680. * @param scene The scene the effect belongs to.
  67681. * @param direction The direction the blur should be applied.
  67682. * @param kernel The size of the kernel used to blur.
  67683. * @param options The required width/height ratio to downsize to before computing the render pass.
  67684. * @param camera The camera to apply the render pass to.
  67685. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67686. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67688. * @param engine The engine which the post process will be applied. (default: current engine)
  67689. * @param reusable If the post process can be reused on the same frame. (default: false)
  67690. * @param textureType Type of textures used when performing the post process. (default: 0)
  67691. * @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)
  67692. */
  67693. 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);
  67694. }
  67695. }
  67696. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67697. /** @hidden */
  67698. export var depthOfFieldMergePixelShader: {
  67699. name: string;
  67700. shader: string;
  67701. };
  67702. }
  67703. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67704. import { Nullable } from "babylonjs/types";
  67705. import { Camera } from "babylonjs/Cameras/camera";
  67706. import { Effect } from "babylonjs/Materials/effect";
  67707. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67708. import { Engine } from "babylonjs/Engines/engine";
  67709. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67710. /**
  67711. * Options to be set when merging outputs from the default pipeline.
  67712. */
  67713. export class DepthOfFieldMergePostProcessOptions {
  67714. /**
  67715. * The original image to merge on top of
  67716. */
  67717. originalFromInput: PostProcess;
  67718. /**
  67719. * Parameters to perform the merge of the depth of field effect
  67720. */
  67721. depthOfField?: {
  67722. circleOfConfusion: PostProcess;
  67723. blurSteps: Array<PostProcess>;
  67724. };
  67725. /**
  67726. * Parameters to perform the merge of bloom effect
  67727. */
  67728. bloom?: {
  67729. blurred: PostProcess;
  67730. weight: number;
  67731. };
  67732. }
  67733. /**
  67734. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67735. */
  67736. export class DepthOfFieldMergePostProcess extends PostProcess {
  67737. private blurSteps;
  67738. /**
  67739. * Creates a new instance of DepthOfFieldMergePostProcess
  67740. * @param name The name of the effect.
  67741. * @param originalFromInput Post process which's input will be used for the merge.
  67742. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67743. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67744. * @param options The required width/height ratio to downsize to before computing the render pass.
  67745. * @param camera The camera to apply the render pass to.
  67746. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67747. * @param engine The engine which the post process will be applied. (default: current engine)
  67748. * @param reusable If the post process can be reused on the same frame. (default: false)
  67749. * @param textureType Type of textures used when performing the post process. (default: 0)
  67750. * @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)
  67751. */
  67752. 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);
  67753. /**
  67754. * Updates the effect with the current post process compile time values and recompiles the shader.
  67755. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67756. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67757. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67758. * @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
  67759. * @param onCompiled Called when the shader has been compiled.
  67760. * @param onError Called if there is an error when compiling a shader.
  67761. */
  67762. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67763. }
  67764. }
  67765. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67766. import { Nullable } from "babylonjs/types";
  67767. import { Camera } from "babylonjs/Cameras/camera";
  67768. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67769. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67770. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67771. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67772. import { Scene } from "babylonjs/scene";
  67773. /**
  67774. * Specifies the level of max blur that should be applied when using the depth of field effect
  67775. */
  67776. export enum DepthOfFieldEffectBlurLevel {
  67777. /**
  67778. * Subtle blur
  67779. */
  67780. Low = 0,
  67781. /**
  67782. * Medium blur
  67783. */
  67784. Medium = 1,
  67785. /**
  67786. * Large blur
  67787. */
  67788. High = 2
  67789. }
  67790. /**
  67791. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67792. */
  67793. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67794. private _circleOfConfusion;
  67795. /**
  67796. * @hidden Internal, blurs from high to low
  67797. */
  67798. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67799. private _depthOfFieldBlurY;
  67800. private _dofMerge;
  67801. /**
  67802. * @hidden Internal post processes in depth of field effect
  67803. */
  67804. _effects: Array<PostProcess>;
  67805. /**
  67806. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67807. */
  67808. set focalLength(value: number);
  67809. get focalLength(): number;
  67810. /**
  67811. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67812. */
  67813. set fStop(value: number);
  67814. get fStop(): number;
  67815. /**
  67816. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67817. */
  67818. set focusDistance(value: number);
  67819. get focusDistance(): number;
  67820. /**
  67821. * 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.
  67822. */
  67823. set lensSize(value: number);
  67824. get lensSize(): number;
  67825. /**
  67826. * Creates a new instance DepthOfFieldEffect
  67827. * @param scene The scene the effect belongs to.
  67828. * @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.
  67829. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67830. * @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)
  67831. */
  67832. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67833. /**
  67834. * Get the current class name of the current effet
  67835. * @returns "DepthOfFieldEffect"
  67836. */
  67837. getClassName(): string;
  67838. /**
  67839. * 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.
  67840. */
  67841. set depthTexture(value: RenderTargetTexture);
  67842. /**
  67843. * Disposes each of the internal effects for a given camera.
  67844. * @param camera The camera to dispose the effect on.
  67845. */
  67846. disposeEffects(camera: Camera): void;
  67847. /**
  67848. * @hidden Internal
  67849. */
  67850. _updateEffects(): void;
  67851. /**
  67852. * Internal
  67853. * @returns if all the contained post processes are ready.
  67854. * @hidden
  67855. */
  67856. _isReady(): boolean;
  67857. }
  67858. }
  67859. declare module "babylonjs/Shaders/displayPass.fragment" {
  67860. /** @hidden */
  67861. export var displayPassPixelShader: {
  67862. name: string;
  67863. shader: string;
  67864. };
  67865. }
  67866. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  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/displayPass.fragment";
  67872. /**
  67873. * DisplayPassPostProcess which produces an output the same as it's input
  67874. */
  67875. export class DisplayPassPostProcess extends PostProcess {
  67876. /**
  67877. * Creates the DisplayPassPostProcess
  67878. * @param name The name of the effect.
  67879. * @param options The required width/height ratio to downsize to before computing the render pass.
  67880. * @param camera The camera to apply the render pass to.
  67881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67882. * @param engine The engine which the post process will be applied. (default: current engine)
  67883. * @param reusable If the post process can be reused on the same frame. (default: false)
  67884. */
  67885. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67886. }
  67887. }
  67888. declare module "babylonjs/Shaders/filter.fragment" {
  67889. /** @hidden */
  67890. export var filterPixelShader: {
  67891. name: string;
  67892. shader: string;
  67893. };
  67894. }
  67895. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67896. import { Nullable } from "babylonjs/types";
  67897. import { Matrix } from "babylonjs/Maths/math.vector";
  67898. import { Camera } from "babylonjs/Cameras/camera";
  67899. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67900. import { Engine } from "babylonjs/Engines/engine";
  67901. import "babylonjs/Shaders/filter.fragment";
  67902. /**
  67903. * Applies a kernel filter to the image
  67904. */
  67905. export class FilterPostProcess extends PostProcess {
  67906. /** The matrix to be applied to the image */
  67907. kernelMatrix: Matrix;
  67908. /**
  67909. *
  67910. * @param name The name of the effect.
  67911. * @param kernelMatrix The matrix to be applied to the image
  67912. * @param options The required width/height ratio to downsize to before computing the render pass.
  67913. * @param camera The camera to apply the render pass to.
  67914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67915. * @param engine The engine which the post process will be applied. (default: current engine)
  67916. * @param reusable If the post process can be reused on the same frame. (default: false)
  67917. */
  67918. constructor(name: string,
  67919. /** The matrix to be applied to the image */
  67920. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67921. }
  67922. }
  67923. declare module "babylonjs/Shaders/fxaa.fragment" {
  67924. /** @hidden */
  67925. export var fxaaPixelShader: {
  67926. name: string;
  67927. shader: string;
  67928. };
  67929. }
  67930. declare module "babylonjs/Shaders/fxaa.vertex" {
  67931. /** @hidden */
  67932. export var fxaaVertexShader: {
  67933. name: string;
  67934. shader: string;
  67935. };
  67936. }
  67937. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67938. import { Nullable } from "babylonjs/types";
  67939. import { Camera } from "babylonjs/Cameras/camera";
  67940. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67941. import { Engine } from "babylonjs/Engines/engine";
  67942. import "babylonjs/Shaders/fxaa.fragment";
  67943. import "babylonjs/Shaders/fxaa.vertex";
  67944. /**
  67945. * Fxaa post process
  67946. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67947. */
  67948. export class FxaaPostProcess extends PostProcess {
  67949. /** @hidden */
  67950. texelWidth: number;
  67951. /** @hidden */
  67952. texelHeight: number;
  67953. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67954. private _getDefines;
  67955. }
  67956. }
  67957. declare module "babylonjs/Shaders/grain.fragment" {
  67958. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67959. /** @hidden */
  67960. export var grainPixelShader: {
  67961. name: string;
  67962. shader: string;
  67963. };
  67964. }
  67965. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67966. import { Nullable } from "babylonjs/types";
  67967. import { Camera } from "babylonjs/Cameras/camera";
  67968. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67969. import { Engine } from "babylonjs/Engines/engine";
  67970. import "babylonjs/Shaders/grain.fragment";
  67971. /**
  67972. * The GrainPostProcess adds noise to the image at mid luminance levels
  67973. */
  67974. export class GrainPostProcess extends PostProcess {
  67975. /**
  67976. * The intensity of the grain added (default: 30)
  67977. */
  67978. intensity: number;
  67979. /**
  67980. * If the grain should be randomized on every frame
  67981. */
  67982. animated: boolean;
  67983. /**
  67984. * Creates a new instance of @see GrainPostProcess
  67985. * @param name The name of the effect.
  67986. * @param options The required width/height ratio to downsize to before computing the render pass.
  67987. * @param camera The camera to apply the render pass to.
  67988. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67989. * @param engine The engine which the post process will be applied. (default: current engine)
  67990. * @param reusable If the post process can be reused on the same frame. (default: false)
  67991. * @param textureType Type of textures used when performing the post process. (default: 0)
  67992. * @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)
  67993. */
  67994. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67995. }
  67996. }
  67997. declare module "babylonjs/Shaders/highlights.fragment" {
  67998. /** @hidden */
  67999. export var highlightsPixelShader: {
  68000. name: string;
  68001. shader: string;
  68002. };
  68003. }
  68004. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  68005. import { Nullable } from "babylonjs/types";
  68006. import { Camera } from "babylonjs/Cameras/camera";
  68007. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68008. import { Engine } from "babylonjs/Engines/engine";
  68009. import "babylonjs/Shaders/highlights.fragment";
  68010. /**
  68011. * Extracts highlights from the image
  68012. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68013. */
  68014. export class HighlightsPostProcess extends PostProcess {
  68015. /**
  68016. * Extracts highlights from the image
  68017. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68018. * @param name The name of the effect.
  68019. * @param options The required width/height ratio to downsize to before computing the render pass.
  68020. * @param camera The camera to apply the render pass to.
  68021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68022. * @param engine The engine which the post process will be applied. (default: current engine)
  68023. * @param reusable If the post process can be reused on the same frame. (default: false)
  68024. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68025. */
  68026. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68027. }
  68028. }
  68029. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  68030. /** @hidden */
  68031. export var mrtFragmentDeclaration: {
  68032. name: string;
  68033. shader: string;
  68034. };
  68035. }
  68036. declare module "babylonjs/Shaders/geometry.fragment" {
  68037. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  68038. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  68039. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  68040. /** @hidden */
  68041. export var geometryPixelShader: {
  68042. name: string;
  68043. shader: string;
  68044. };
  68045. }
  68046. declare module "babylonjs/Shaders/geometry.vertex" {
  68047. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68048. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68049. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68050. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68051. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68052. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68053. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68054. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  68055. /** @hidden */
  68056. export var geometryVertexShader: {
  68057. name: string;
  68058. shader: string;
  68059. };
  68060. }
  68061. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  68062. import { Matrix } from "babylonjs/Maths/math.vector";
  68063. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68064. import { Mesh } from "babylonjs/Meshes/mesh";
  68065. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68066. import { Effect } from "babylonjs/Materials/effect";
  68067. import { Scene } from "babylonjs/scene";
  68068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68069. import "babylonjs/Shaders/geometry.fragment";
  68070. import "babylonjs/Shaders/geometry.vertex";
  68071. /** @hidden */
  68072. interface ISavedTransformationMatrix {
  68073. world: Matrix;
  68074. viewProjection: Matrix;
  68075. }
  68076. /**
  68077. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68078. */
  68079. export class GeometryBufferRenderer {
  68080. /**
  68081. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68082. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68083. */
  68084. static readonly POSITION_TEXTURE_TYPE: number;
  68085. /**
  68086. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68087. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68088. */
  68089. static readonly VELOCITY_TEXTURE_TYPE: number;
  68090. /**
  68091. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68092. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68093. */
  68094. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68095. /**
  68096. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68097. * in order to compute objects velocities when enableVelocity is set to "true"
  68098. * @hidden
  68099. */
  68100. _previousTransformationMatrices: {
  68101. [index: number]: ISavedTransformationMatrix;
  68102. };
  68103. /**
  68104. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68105. * in order to compute objects velocities when enableVelocity is set to "true"
  68106. * @hidden
  68107. */
  68108. _previousBonesTransformationMatrices: {
  68109. [index: number]: Float32Array;
  68110. };
  68111. /**
  68112. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68113. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68114. */
  68115. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68116. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68117. renderTransparentMeshes: boolean;
  68118. private _scene;
  68119. private _multiRenderTarget;
  68120. private _ratio;
  68121. private _enablePosition;
  68122. private _enableVelocity;
  68123. private _enableReflectivity;
  68124. private _positionIndex;
  68125. private _velocityIndex;
  68126. private _reflectivityIndex;
  68127. protected _effect: Effect;
  68128. protected _cachedDefines: string;
  68129. /**
  68130. * Set the render list (meshes to be rendered) used in the G buffer.
  68131. */
  68132. set renderList(meshes: Mesh[]);
  68133. /**
  68134. * Gets wether or not G buffer are supported by the running hardware.
  68135. * This requires draw buffer supports
  68136. */
  68137. get isSupported(): boolean;
  68138. /**
  68139. * Returns the index of the given texture type in the G-Buffer textures array
  68140. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68141. * @returns the index of the given texture type in the G-Buffer textures array
  68142. */
  68143. getTextureIndex(textureType: number): number;
  68144. /**
  68145. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68146. */
  68147. get enablePosition(): boolean;
  68148. /**
  68149. * Sets whether or not objects positions are enabled for the G buffer.
  68150. */
  68151. set enablePosition(enable: boolean);
  68152. /**
  68153. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68154. */
  68155. get enableVelocity(): boolean;
  68156. /**
  68157. * Sets wether or not objects velocities are enabled for the G buffer.
  68158. */
  68159. set enableVelocity(enable: boolean);
  68160. /**
  68161. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68162. */
  68163. get enableReflectivity(): boolean;
  68164. /**
  68165. * Sets wether or not objects roughness are enabled for the G buffer.
  68166. */
  68167. set enableReflectivity(enable: boolean);
  68168. /**
  68169. * Gets the scene associated with the buffer.
  68170. */
  68171. get scene(): Scene;
  68172. /**
  68173. * Gets the ratio used by the buffer during its creation.
  68174. * How big is the buffer related to the main canvas.
  68175. */
  68176. get ratio(): number;
  68177. /** @hidden */
  68178. static _SceneComponentInitialization: (scene: Scene) => void;
  68179. /**
  68180. * Creates a new G Buffer for the scene
  68181. * @param scene The scene the buffer belongs to
  68182. * @param ratio How big is the buffer related to the main canvas.
  68183. */
  68184. constructor(scene: Scene, ratio?: number);
  68185. /**
  68186. * Checks wether everything is ready to render a submesh to the G buffer.
  68187. * @param subMesh the submesh to check readiness for
  68188. * @param useInstances is the mesh drawn using instance or not
  68189. * @returns true if ready otherwise false
  68190. */
  68191. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68192. /**
  68193. * Gets the current underlying G Buffer.
  68194. * @returns the buffer
  68195. */
  68196. getGBuffer(): MultiRenderTarget;
  68197. /**
  68198. * Gets the number of samples used to render the buffer (anti aliasing).
  68199. */
  68200. get samples(): number;
  68201. /**
  68202. * Sets the number of samples used to render the buffer (anti aliasing).
  68203. */
  68204. set samples(value: number);
  68205. /**
  68206. * Disposes the renderer and frees up associated resources.
  68207. */
  68208. dispose(): void;
  68209. protected _createRenderTargets(): void;
  68210. private _copyBonesTransformationMatrices;
  68211. }
  68212. }
  68213. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68214. import { Nullable } from "babylonjs/types";
  68215. import { Scene } from "babylonjs/scene";
  68216. import { ISceneComponent } from "babylonjs/sceneComponent";
  68217. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68218. module "babylonjs/scene" {
  68219. interface Scene {
  68220. /** @hidden (Backing field) */
  68221. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68222. /**
  68223. * Gets or Sets the current geometry buffer associated to the scene.
  68224. */
  68225. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68226. /**
  68227. * Enables a GeometryBufferRender and associates it with the scene
  68228. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68229. * @returns the GeometryBufferRenderer
  68230. */
  68231. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68232. /**
  68233. * Disables the GeometryBufferRender associated with the scene
  68234. */
  68235. disableGeometryBufferRenderer(): void;
  68236. }
  68237. }
  68238. /**
  68239. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68240. * in several rendering techniques.
  68241. */
  68242. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68243. /**
  68244. * The component name helpful to identify the component in the list of scene components.
  68245. */
  68246. readonly name: string;
  68247. /**
  68248. * The scene the component belongs to.
  68249. */
  68250. scene: Scene;
  68251. /**
  68252. * Creates a new instance of the component for the given scene
  68253. * @param scene Defines the scene to register the component in
  68254. */
  68255. constructor(scene: Scene);
  68256. /**
  68257. * Registers the component in a given scene
  68258. */
  68259. register(): void;
  68260. /**
  68261. * Rebuilds the elements related to this component in case of
  68262. * context lost for instance.
  68263. */
  68264. rebuild(): void;
  68265. /**
  68266. * Disposes the component and the associated ressources
  68267. */
  68268. dispose(): void;
  68269. private _gatherRenderTargets;
  68270. }
  68271. }
  68272. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68273. /** @hidden */
  68274. export var motionBlurPixelShader: {
  68275. name: string;
  68276. shader: string;
  68277. };
  68278. }
  68279. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68280. import { Nullable } from "babylonjs/types";
  68281. import { Camera } from "babylonjs/Cameras/camera";
  68282. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68283. import { Scene } from "babylonjs/scene";
  68284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68285. import "babylonjs/Animations/animatable";
  68286. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68287. import "babylonjs/Shaders/motionBlur.fragment";
  68288. import { Engine } from "babylonjs/Engines/engine";
  68289. /**
  68290. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68291. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68292. * As an example, all you have to do is to create the post-process:
  68293. * var mb = new BABYLON.MotionBlurPostProcess(
  68294. * 'mb', // The name of the effect.
  68295. * scene, // The scene containing the objects to blur according to their velocity.
  68296. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68297. * camera // The camera to apply the render pass to.
  68298. * );
  68299. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68300. */
  68301. export class MotionBlurPostProcess extends PostProcess {
  68302. /**
  68303. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68304. */
  68305. motionStrength: number;
  68306. /**
  68307. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68308. */
  68309. get motionBlurSamples(): number;
  68310. /**
  68311. * Sets the number of iterations to be used for motion blur quality
  68312. */
  68313. set motionBlurSamples(samples: number);
  68314. private _motionBlurSamples;
  68315. private _geometryBufferRenderer;
  68316. /**
  68317. * Creates a new instance MotionBlurPostProcess
  68318. * @param name The name of the effect.
  68319. * @param scene The scene containing the objects to blur according to their velocity.
  68320. * @param options The required width/height ratio to downsize to before computing the render pass.
  68321. * @param camera The camera to apply the render pass to.
  68322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68323. * @param engine The engine which the post process will be applied. (default: current engine)
  68324. * @param reusable If the post process can be reused on the same frame. (default: false)
  68325. * @param textureType Type of textures used when performing the post process. (default: 0)
  68326. * @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)
  68327. */
  68328. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68329. /**
  68330. * Excludes the given skinned mesh from computing bones velocities.
  68331. * 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.
  68332. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68333. */
  68334. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68335. /**
  68336. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68337. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68338. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68339. */
  68340. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68341. /**
  68342. * Disposes the post process.
  68343. * @param camera The camera to dispose the post process on.
  68344. */
  68345. dispose(camera?: Camera): void;
  68346. }
  68347. }
  68348. declare module "babylonjs/Shaders/refraction.fragment" {
  68349. /** @hidden */
  68350. export var refractionPixelShader: {
  68351. name: string;
  68352. shader: string;
  68353. };
  68354. }
  68355. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68356. import { Color3 } from "babylonjs/Maths/math.color";
  68357. import { Camera } from "babylonjs/Cameras/camera";
  68358. import { Texture } from "babylonjs/Materials/Textures/texture";
  68359. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68360. import { Engine } from "babylonjs/Engines/engine";
  68361. import "babylonjs/Shaders/refraction.fragment";
  68362. /**
  68363. * Post process which applies a refractin texture
  68364. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68365. */
  68366. export class RefractionPostProcess extends PostProcess {
  68367. /** the base color of the refraction (used to taint the rendering) */
  68368. color: Color3;
  68369. /** simulated refraction depth */
  68370. depth: number;
  68371. /** the coefficient of the base color (0 to remove base color tainting) */
  68372. colorLevel: number;
  68373. private _refTexture;
  68374. private _ownRefractionTexture;
  68375. /**
  68376. * Gets or sets the refraction texture
  68377. * Please note that you are responsible for disposing the texture if you set it manually
  68378. */
  68379. get refractionTexture(): Texture;
  68380. set refractionTexture(value: Texture);
  68381. /**
  68382. * Initializes the RefractionPostProcess
  68383. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68384. * @param name The name of the effect.
  68385. * @param refractionTextureUrl Url of the refraction texture to use
  68386. * @param color the base color of the refraction (used to taint the rendering)
  68387. * @param depth simulated refraction depth
  68388. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68389. * @param camera The camera to apply the render pass to.
  68390. * @param options The required width/height ratio to downsize to before computing the render pass.
  68391. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68392. * @param engine The engine which the post process will be applied. (default: current engine)
  68393. * @param reusable If the post process can be reused on the same frame. (default: false)
  68394. */
  68395. constructor(name: string, refractionTextureUrl: string,
  68396. /** the base color of the refraction (used to taint the rendering) */
  68397. color: Color3,
  68398. /** simulated refraction depth */
  68399. depth: number,
  68400. /** the coefficient of the base color (0 to remove base color tainting) */
  68401. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68402. /**
  68403. * Disposes of the post process
  68404. * @param camera Camera to dispose post process on
  68405. */
  68406. dispose(camera: Camera): void;
  68407. }
  68408. }
  68409. declare module "babylonjs/Shaders/sharpen.fragment" {
  68410. /** @hidden */
  68411. export var sharpenPixelShader: {
  68412. name: string;
  68413. shader: string;
  68414. };
  68415. }
  68416. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68417. import { Nullable } from "babylonjs/types";
  68418. import { Camera } from "babylonjs/Cameras/camera";
  68419. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68420. import "babylonjs/Shaders/sharpen.fragment";
  68421. import { Engine } from "babylonjs/Engines/engine";
  68422. /**
  68423. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68424. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68425. */
  68426. export class SharpenPostProcess extends PostProcess {
  68427. /**
  68428. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68429. */
  68430. colorAmount: number;
  68431. /**
  68432. * How much sharpness should be applied (default: 0.3)
  68433. */
  68434. edgeAmount: number;
  68435. /**
  68436. * Creates a new instance ConvolutionPostProcess
  68437. * @param name The name of the effect.
  68438. * @param options The required width/height ratio to downsize to before computing the render pass.
  68439. * @param camera The camera to apply the render pass to.
  68440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68441. * @param engine The engine which the post process will be applied. (default: current engine)
  68442. * @param reusable If the post process can be reused on the same frame. (default: false)
  68443. * @param textureType Type of textures used when performing the post process. (default: 0)
  68444. * @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)
  68445. */
  68446. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68447. }
  68448. }
  68449. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68450. import { Nullable } from "babylonjs/types";
  68451. import { Camera } from "babylonjs/Cameras/camera";
  68452. import { Engine } from "babylonjs/Engines/engine";
  68453. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68454. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68455. /**
  68456. * PostProcessRenderPipeline
  68457. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68458. */
  68459. export class PostProcessRenderPipeline {
  68460. private engine;
  68461. private _renderEffects;
  68462. private _renderEffectsForIsolatedPass;
  68463. /**
  68464. * List of inspectable custom properties (used by the Inspector)
  68465. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68466. */
  68467. inspectableCustomProperties: IInspectable[];
  68468. /**
  68469. * @hidden
  68470. */
  68471. protected _cameras: Camera[];
  68472. /** @hidden */
  68473. _name: string;
  68474. /**
  68475. * Gets pipeline name
  68476. */
  68477. get name(): string;
  68478. /** Gets the list of attached cameras */
  68479. get cameras(): Camera[];
  68480. /**
  68481. * Initializes a PostProcessRenderPipeline
  68482. * @param engine engine to add the pipeline to
  68483. * @param name name of the pipeline
  68484. */
  68485. constructor(engine: Engine, name: string);
  68486. /**
  68487. * Gets the class name
  68488. * @returns "PostProcessRenderPipeline"
  68489. */
  68490. getClassName(): string;
  68491. /**
  68492. * If all the render effects in the pipeline are supported
  68493. */
  68494. get isSupported(): boolean;
  68495. /**
  68496. * Adds an effect to the pipeline
  68497. * @param renderEffect the effect to add
  68498. */
  68499. addEffect(renderEffect: PostProcessRenderEffect): void;
  68500. /** @hidden */
  68501. _rebuild(): void;
  68502. /** @hidden */
  68503. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68504. /** @hidden */
  68505. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68506. /** @hidden */
  68507. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68508. /** @hidden */
  68509. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68510. /** @hidden */
  68511. _attachCameras(cameras: Camera, unique: boolean): void;
  68512. /** @hidden */
  68513. _attachCameras(cameras: Camera[], unique: boolean): void;
  68514. /** @hidden */
  68515. _detachCameras(cameras: Camera): void;
  68516. /** @hidden */
  68517. _detachCameras(cameras: Nullable<Camera[]>): void;
  68518. /** @hidden */
  68519. _update(): void;
  68520. /** @hidden */
  68521. _reset(): void;
  68522. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68523. /**
  68524. * Disposes of the pipeline
  68525. */
  68526. dispose(): void;
  68527. }
  68528. }
  68529. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68530. import { Camera } from "babylonjs/Cameras/camera";
  68531. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68532. /**
  68533. * PostProcessRenderPipelineManager class
  68534. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68535. */
  68536. export class PostProcessRenderPipelineManager {
  68537. private _renderPipelines;
  68538. /**
  68539. * Initializes a PostProcessRenderPipelineManager
  68540. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68541. */
  68542. constructor();
  68543. /**
  68544. * Gets the list of supported render pipelines
  68545. */
  68546. get supportedPipelines(): PostProcessRenderPipeline[];
  68547. /**
  68548. * Adds a pipeline to the manager
  68549. * @param renderPipeline The pipeline to add
  68550. */
  68551. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68552. /**
  68553. * Attaches a camera to the pipeline
  68554. * @param renderPipelineName The name of the pipeline to attach to
  68555. * @param cameras the camera to attach
  68556. * @param unique if the camera can be attached multiple times to the pipeline
  68557. */
  68558. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68559. /**
  68560. * Detaches a camera from the pipeline
  68561. * @param renderPipelineName The name of the pipeline to detach from
  68562. * @param cameras the camera to detach
  68563. */
  68564. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68565. /**
  68566. * Enables an effect by name on a pipeline
  68567. * @param renderPipelineName the name of the pipeline to enable the effect in
  68568. * @param renderEffectName the name of the effect to enable
  68569. * @param cameras the cameras that the effect should be enabled on
  68570. */
  68571. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68572. /**
  68573. * Disables an effect by name on a pipeline
  68574. * @param renderPipelineName the name of the pipeline to disable the effect in
  68575. * @param renderEffectName the name of the effect to disable
  68576. * @param cameras the cameras that the effect should be disabled on
  68577. */
  68578. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68579. /**
  68580. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68581. */
  68582. update(): void;
  68583. /** @hidden */
  68584. _rebuild(): void;
  68585. /**
  68586. * Disposes of the manager and pipelines
  68587. */
  68588. dispose(): void;
  68589. }
  68590. }
  68591. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68592. import { ISceneComponent } from "babylonjs/sceneComponent";
  68593. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68594. import { Scene } from "babylonjs/scene";
  68595. module "babylonjs/scene" {
  68596. interface Scene {
  68597. /** @hidden (Backing field) */
  68598. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68599. /**
  68600. * Gets the postprocess render pipeline manager
  68601. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68602. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68603. */
  68604. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68605. }
  68606. }
  68607. /**
  68608. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68609. */
  68610. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68611. /**
  68612. * The component name helpfull to identify the component in the list of scene components.
  68613. */
  68614. readonly name: string;
  68615. /**
  68616. * The scene the component belongs to.
  68617. */
  68618. scene: Scene;
  68619. /**
  68620. * Creates a new instance of the component for the given scene
  68621. * @param scene Defines the scene to register the component in
  68622. */
  68623. constructor(scene: Scene);
  68624. /**
  68625. * Registers the component in a given scene
  68626. */
  68627. register(): void;
  68628. /**
  68629. * Rebuilds the elements related to this component in case of
  68630. * context lost for instance.
  68631. */
  68632. rebuild(): void;
  68633. /**
  68634. * Disposes the component and the associated ressources
  68635. */
  68636. dispose(): void;
  68637. private _gatherRenderTargets;
  68638. }
  68639. }
  68640. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68641. import { Nullable } from "babylonjs/types";
  68642. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68643. import { Camera } from "babylonjs/Cameras/camera";
  68644. import { IDisposable } from "babylonjs/scene";
  68645. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68646. import { Scene } from "babylonjs/scene";
  68647. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68648. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68649. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68650. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68651. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68652. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68653. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68654. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68655. import { Animation } from "babylonjs/Animations/animation";
  68656. /**
  68657. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68658. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68659. */
  68660. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68661. private _scene;
  68662. private _camerasToBeAttached;
  68663. /**
  68664. * ID of the sharpen post process,
  68665. */
  68666. private readonly SharpenPostProcessId;
  68667. /**
  68668. * @ignore
  68669. * ID of the image processing post process;
  68670. */
  68671. readonly ImageProcessingPostProcessId: string;
  68672. /**
  68673. * @ignore
  68674. * ID of the Fast Approximate Anti-Aliasing post process;
  68675. */
  68676. readonly FxaaPostProcessId: string;
  68677. /**
  68678. * ID of the chromatic aberration post process,
  68679. */
  68680. private readonly ChromaticAberrationPostProcessId;
  68681. /**
  68682. * ID of the grain post process
  68683. */
  68684. private readonly GrainPostProcessId;
  68685. /**
  68686. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68687. */
  68688. sharpen: SharpenPostProcess;
  68689. private _sharpenEffect;
  68690. private bloom;
  68691. /**
  68692. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68693. */
  68694. depthOfField: DepthOfFieldEffect;
  68695. /**
  68696. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68697. */
  68698. fxaa: FxaaPostProcess;
  68699. /**
  68700. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68701. */
  68702. imageProcessing: ImageProcessingPostProcess;
  68703. /**
  68704. * Chromatic aberration post process which will shift rgb colors in the image
  68705. */
  68706. chromaticAberration: ChromaticAberrationPostProcess;
  68707. private _chromaticAberrationEffect;
  68708. /**
  68709. * Grain post process which add noise to the image
  68710. */
  68711. grain: GrainPostProcess;
  68712. private _grainEffect;
  68713. /**
  68714. * Glow post process which adds a glow to emissive areas of the image
  68715. */
  68716. private _glowLayer;
  68717. /**
  68718. * Animations which can be used to tweak settings over a period of time
  68719. */
  68720. animations: Animation[];
  68721. private _imageProcessingConfigurationObserver;
  68722. private _sharpenEnabled;
  68723. private _bloomEnabled;
  68724. private _depthOfFieldEnabled;
  68725. private _depthOfFieldBlurLevel;
  68726. private _fxaaEnabled;
  68727. private _imageProcessingEnabled;
  68728. private _defaultPipelineTextureType;
  68729. private _bloomScale;
  68730. private _chromaticAberrationEnabled;
  68731. private _grainEnabled;
  68732. private _buildAllowed;
  68733. /**
  68734. * Gets active scene
  68735. */
  68736. get scene(): Scene;
  68737. /**
  68738. * Enable or disable the sharpen process from the pipeline
  68739. */
  68740. set sharpenEnabled(enabled: boolean);
  68741. get sharpenEnabled(): boolean;
  68742. private _resizeObserver;
  68743. private _hardwareScaleLevel;
  68744. private _bloomKernel;
  68745. /**
  68746. * Specifies the size of the bloom blur kernel, relative to the final output size
  68747. */
  68748. get bloomKernel(): number;
  68749. set bloomKernel(value: number);
  68750. /**
  68751. * Specifies the weight of the bloom in the final rendering
  68752. */
  68753. private _bloomWeight;
  68754. /**
  68755. * Specifies the luma threshold for the area that will be blurred by the bloom
  68756. */
  68757. private _bloomThreshold;
  68758. private _hdr;
  68759. /**
  68760. * The strength of the bloom.
  68761. */
  68762. set bloomWeight(value: number);
  68763. get bloomWeight(): number;
  68764. /**
  68765. * The strength of the bloom.
  68766. */
  68767. set bloomThreshold(value: number);
  68768. get bloomThreshold(): number;
  68769. /**
  68770. * The scale of the bloom, lower value will provide better performance.
  68771. */
  68772. set bloomScale(value: number);
  68773. get bloomScale(): number;
  68774. /**
  68775. * Enable or disable the bloom from the pipeline
  68776. */
  68777. set bloomEnabled(enabled: boolean);
  68778. get bloomEnabled(): boolean;
  68779. private _rebuildBloom;
  68780. /**
  68781. * If the depth of field is enabled.
  68782. */
  68783. get depthOfFieldEnabled(): boolean;
  68784. set depthOfFieldEnabled(enabled: boolean);
  68785. /**
  68786. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68787. */
  68788. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68789. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68790. /**
  68791. * If the anti aliasing is enabled.
  68792. */
  68793. set fxaaEnabled(enabled: boolean);
  68794. get fxaaEnabled(): boolean;
  68795. private _samples;
  68796. /**
  68797. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68798. */
  68799. set samples(sampleCount: number);
  68800. get samples(): number;
  68801. /**
  68802. * If image processing is enabled.
  68803. */
  68804. set imageProcessingEnabled(enabled: boolean);
  68805. get imageProcessingEnabled(): boolean;
  68806. /**
  68807. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68808. */
  68809. set glowLayerEnabled(enabled: boolean);
  68810. get glowLayerEnabled(): boolean;
  68811. /**
  68812. * Gets the glow layer (or null if not defined)
  68813. */
  68814. get glowLayer(): Nullable<GlowLayer>;
  68815. /**
  68816. * Enable or disable the chromaticAberration process from the pipeline
  68817. */
  68818. set chromaticAberrationEnabled(enabled: boolean);
  68819. get chromaticAberrationEnabled(): boolean;
  68820. /**
  68821. * Enable or disable the grain process from the pipeline
  68822. */
  68823. set grainEnabled(enabled: boolean);
  68824. get grainEnabled(): boolean;
  68825. /**
  68826. * @constructor
  68827. * @param name - The rendering pipeline name (default: "")
  68828. * @param hdr - If high dynamic range textures should be used (default: true)
  68829. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68830. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68831. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68832. */
  68833. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68834. /**
  68835. * Get the class name
  68836. * @returns "DefaultRenderingPipeline"
  68837. */
  68838. getClassName(): string;
  68839. /**
  68840. * Force the compilation of the entire pipeline.
  68841. */
  68842. prepare(): void;
  68843. private _hasCleared;
  68844. private _prevPostProcess;
  68845. private _prevPrevPostProcess;
  68846. private _setAutoClearAndTextureSharing;
  68847. private _depthOfFieldSceneObserver;
  68848. private _buildPipeline;
  68849. private _disposePostProcesses;
  68850. /**
  68851. * Adds a camera to the pipeline
  68852. * @param camera the camera to be added
  68853. */
  68854. addCamera(camera: Camera): void;
  68855. /**
  68856. * Removes a camera from the pipeline
  68857. * @param camera the camera to remove
  68858. */
  68859. removeCamera(camera: Camera): void;
  68860. /**
  68861. * Dispose of the pipeline and stop all post processes
  68862. */
  68863. dispose(): void;
  68864. /**
  68865. * Serialize the rendering pipeline (Used when exporting)
  68866. * @returns the serialized object
  68867. */
  68868. serialize(): any;
  68869. /**
  68870. * Parse the serialized pipeline
  68871. * @param source Source pipeline.
  68872. * @param scene The scene to load the pipeline to.
  68873. * @param rootUrl The URL of the serialized pipeline.
  68874. * @returns An instantiated pipeline from the serialized object.
  68875. */
  68876. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68877. }
  68878. }
  68879. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68880. /** @hidden */
  68881. export var lensHighlightsPixelShader: {
  68882. name: string;
  68883. shader: string;
  68884. };
  68885. }
  68886. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68887. /** @hidden */
  68888. export var depthOfFieldPixelShader: {
  68889. name: string;
  68890. shader: string;
  68891. };
  68892. }
  68893. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68894. import { Camera } from "babylonjs/Cameras/camera";
  68895. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68896. import { Scene } from "babylonjs/scene";
  68897. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68898. import "babylonjs/Shaders/chromaticAberration.fragment";
  68899. import "babylonjs/Shaders/lensHighlights.fragment";
  68900. import "babylonjs/Shaders/depthOfField.fragment";
  68901. /**
  68902. * BABYLON.JS Chromatic Aberration GLSL Shader
  68903. * Author: Olivier Guyot
  68904. * Separates very slightly R, G and B colors on the edges of the screen
  68905. * Inspired by Francois Tarlier & Martins Upitis
  68906. */
  68907. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68908. /**
  68909. * @ignore
  68910. * The chromatic aberration PostProcess id in the pipeline
  68911. */
  68912. LensChromaticAberrationEffect: string;
  68913. /**
  68914. * @ignore
  68915. * The highlights enhancing PostProcess id in the pipeline
  68916. */
  68917. HighlightsEnhancingEffect: string;
  68918. /**
  68919. * @ignore
  68920. * The depth-of-field PostProcess id in the pipeline
  68921. */
  68922. LensDepthOfFieldEffect: string;
  68923. private _scene;
  68924. private _depthTexture;
  68925. private _grainTexture;
  68926. private _chromaticAberrationPostProcess;
  68927. private _highlightsPostProcess;
  68928. private _depthOfFieldPostProcess;
  68929. private _edgeBlur;
  68930. private _grainAmount;
  68931. private _chromaticAberration;
  68932. private _distortion;
  68933. private _highlightsGain;
  68934. private _highlightsThreshold;
  68935. private _dofDistance;
  68936. private _dofAperture;
  68937. private _dofDarken;
  68938. private _dofPentagon;
  68939. private _blurNoise;
  68940. /**
  68941. * @constructor
  68942. *
  68943. * Effect parameters are as follow:
  68944. * {
  68945. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68946. * edge_blur: number; // from 0 to x (1 for realism)
  68947. * distortion: number; // from 0 to x (1 for realism)
  68948. * grain_amount: number; // from 0 to 1
  68949. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68950. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68951. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68952. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68953. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68954. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68955. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68956. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68957. * }
  68958. * Note: if an effect parameter is unset, effect is disabled
  68959. *
  68960. * @param name The rendering pipeline name
  68961. * @param parameters - An object containing all parameters (see above)
  68962. * @param scene The scene linked to this pipeline
  68963. * @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)
  68964. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68965. */
  68966. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68967. /**
  68968. * Get the class name
  68969. * @returns "LensRenderingPipeline"
  68970. */
  68971. getClassName(): string;
  68972. /**
  68973. * Gets associated scene
  68974. */
  68975. get scene(): Scene;
  68976. /**
  68977. * Gets or sets the edge blur
  68978. */
  68979. get edgeBlur(): number;
  68980. set edgeBlur(value: number);
  68981. /**
  68982. * Gets or sets the grain amount
  68983. */
  68984. get grainAmount(): number;
  68985. set grainAmount(value: number);
  68986. /**
  68987. * Gets or sets the chromatic aberration amount
  68988. */
  68989. get chromaticAberration(): number;
  68990. set chromaticAberration(value: number);
  68991. /**
  68992. * Gets or sets the depth of field aperture
  68993. */
  68994. get dofAperture(): number;
  68995. set dofAperture(value: number);
  68996. /**
  68997. * Gets or sets the edge distortion
  68998. */
  68999. get edgeDistortion(): number;
  69000. set edgeDistortion(value: number);
  69001. /**
  69002. * Gets or sets the depth of field distortion
  69003. */
  69004. get dofDistortion(): number;
  69005. set dofDistortion(value: number);
  69006. /**
  69007. * Gets or sets the darken out of focus amount
  69008. */
  69009. get darkenOutOfFocus(): number;
  69010. set darkenOutOfFocus(value: number);
  69011. /**
  69012. * Gets or sets a boolean indicating if blur noise is enabled
  69013. */
  69014. get blurNoise(): boolean;
  69015. set blurNoise(value: boolean);
  69016. /**
  69017. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69018. */
  69019. get pentagonBokeh(): boolean;
  69020. set pentagonBokeh(value: boolean);
  69021. /**
  69022. * Gets or sets the highlight grain amount
  69023. */
  69024. get highlightsGain(): number;
  69025. set highlightsGain(value: number);
  69026. /**
  69027. * Gets or sets the highlight threshold
  69028. */
  69029. get highlightsThreshold(): number;
  69030. set highlightsThreshold(value: number);
  69031. /**
  69032. * Sets the amount of blur at the edges
  69033. * @param amount blur amount
  69034. */
  69035. setEdgeBlur(amount: number): void;
  69036. /**
  69037. * Sets edge blur to 0
  69038. */
  69039. disableEdgeBlur(): void;
  69040. /**
  69041. * Sets the amout of grain
  69042. * @param amount Amount of grain
  69043. */
  69044. setGrainAmount(amount: number): void;
  69045. /**
  69046. * Set grain amount to 0
  69047. */
  69048. disableGrain(): void;
  69049. /**
  69050. * Sets the chromatic aberration amount
  69051. * @param amount amount of chromatic aberration
  69052. */
  69053. setChromaticAberration(amount: number): void;
  69054. /**
  69055. * Sets chromatic aberration amount to 0
  69056. */
  69057. disableChromaticAberration(): void;
  69058. /**
  69059. * Sets the EdgeDistortion amount
  69060. * @param amount amount of EdgeDistortion
  69061. */
  69062. setEdgeDistortion(amount: number): void;
  69063. /**
  69064. * Sets edge distortion to 0
  69065. */
  69066. disableEdgeDistortion(): void;
  69067. /**
  69068. * Sets the FocusDistance amount
  69069. * @param amount amount of FocusDistance
  69070. */
  69071. setFocusDistance(amount: number): void;
  69072. /**
  69073. * Disables depth of field
  69074. */
  69075. disableDepthOfField(): void;
  69076. /**
  69077. * Sets the Aperture amount
  69078. * @param amount amount of Aperture
  69079. */
  69080. setAperture(amount: number): void;
  69081. /**
  69082. * Sets the DarkenOutOfFocus amount
  69083. * @param amount amount of DarkenOutOfFocus
  69084. */
  69085. setDarkenOutOfFocus(amount: number): void;
  69086. private _pentagonBokehIsEnabled;
  69087. /**
  69088. * Creates a pentagon bokeh effect
  69089. */
  69090. enablePentagonBokeh(): void;
  69091. /**
  69092. * Disables the pentagon bokeh effect
  69093. */
  69094. disablePentagonBokeh(): void;
  69095. /**
  69096. * Enables noise blur
  69097. */
  69098. enableNoiseBlur(): void;
  69099. /**
  69100. * Disables noise blur
  69101. */
  69102. disableNoiseBlur(): void;
  69103. /**
  69104. * Sets the HighlightsGain amount
  69105. * @param amount amount of HighlightsGain
  69106. */
  69107. setHighlightsGain(amount: number): void;
  69108. /**
  69109. * Sets the HighlightsThreshold amount
  69110. * @param amount amount of HighlightsThreshold
  69111. */
  69112. setHighlightsThreshold(amount: number): void;
  69113. /**
  69114. * Disables highlights
  69115. */
  69116. disableHighlights(): void;
  69117. /**
  69118. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69119. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69120. */
  69121. dispose(disableDepthRender?: boolean): void;
  69122. private _createChromaticAberrationPostProcess;
  69123. private _createHighlightsPostProcess;
  69124. private _createDepthOfFieldPostProcess;
  69125. private _createGrainTexture;
  69126. }
  69127. }
  69128. declare module "babylonjs/Shaders/ssao2.fragment" {
  69129. /** @hidden */
  69130. export var ssao2PixelShader: {
  69131. name: string;
  69132. shader: string;
  69133. };
  69134. }
  69135. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69136. /** @hidden */
  69137. export var ssaoCombinePixelShader: {
  69138. name: string;
  69139. shader: string;
  69140. };
  69141. }
  69142. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69143. import { Camera } from "babylonjs/Cameras/camera";
  69144. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69145. import { Scene } from "babylonjs/scene";
  69146. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69147. import "babylonjs/Shaders/ssao2.fragment";
  69148. import "babylonjs/Shaders/ssaoCombine.fragment";
  69149. /**
  69150. * Render pipeline to produce ssao effect
  69151. */
  69152. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69153. /**
  69154. * @ignore
  69155. * The PassPostProcess id in the pipeline that contains the original scene color
  69156. */
  69157. SSAOOriginalSceneColorEffect: string;
  69158. /**
  69159. * @ignore
  69160. * The SSAO PostProcess id in the pipeline
  69161. */
  69162. SSAORenderEffect: string;
  69163. /**
  69164. * @ignore
  69165. * The horizontal blur PostProcess id in the pipeline
  69166. */
  69167. SSAOBlurHRenderEffect: string;
  69168. /**
  69169. * @ignore
  69170. * The vertical blur PostProcess id in the pipeline
  69171. */
  69172. SSAOBlurVRenderEffect: string;
  69173. /**
  69174. * @ignore
  69175. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69176. */
  69177. SSAOCombineRenderEffect: string;
  69178. /**
  69179. * The output strength of the SSAO post-process. Default value is 1.0.
  69180. */
  69181. totalStrength: number;
  69182. /**
  69183. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69184. */
  69185. maxZ: number;
  69186. /**
  69187. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69188. */
  69189. minZAspect: number;
  69190. private _samples;
  69191. /**
  69192. * Number of samples used for the SSAO calculations. Default value is 8
  69193. */
  69194. set samples(n: number);
  69195. get samples(): number;
  69196. private _textureSamples;
  69197. /**
  69198. * Number of samples to use for antialiasing
  69199. */
  69200. set textureSamples(n: number);
  69201. get textureSamples(): number;
  69202. /**
  69203. * Ratio object used for SSAO ratio and blur ratio
  69204. */
  69205. private _ratio;
  69206. /**
  69207. * Dynamically generated sphere sampler.
  69208. */
  69209. private _sampleSphere;
  69210. /**
  69211. * Blur filter offsets
  69212. */
  69213. private _samplerOffsets;
  69214. private _expensiveBlur;
  69215. /**
  69216. * If bilateral blur should be used
  69217. */
  69218. set expensiveBlur(b: boolean);
  69219. get expensiveBlur(): boolean;
  69220. /**
  69221. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69222. */
  69223. radius: number;
  69224. /**
  69225. * The base color of the SSAO post-process
  69226. * The final result is "base + ssao" between [0, 1]
  69227. */
  69228. base: number;
  69229. /**
  69230. * Support test.
  69231. */
  69232. static get IsSupported(): boolean;
  69233. private _scene;
  69234. private _depthTexture;
  69235. private _normalTexture;
  69236. private _randomTexture;
  69237. private _originalColorPostProcess;
  69238. private _ssaoPostProcess;
  69239. private _blurHPostProcess;
  69240. private _blurVPostProcess;
  69241. private _ssaoCombinePostProcess;
  69242. /**
  69243. * Gets active scene
  69244. */
  69245. get scene(): Scene;
  69246. /**
  69247. * @constructor
  69248. * @param name The rendering pipeline name
  69249. * @param scene The scene linked to this pipeline
  69250. * @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 }
  69251. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69252. */
  69253. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69254. /**
  69255. * Get the class name
  69256. * @returns "SSAO2RenderingPipeline"
  69257. */
  69258. getClassName(): string;
  69259. /**
  69260. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69261. */
  69262. dispose(disableGeometryBufferRenderer?: boolean): void;
  69263. private _createBlurPostProcess;
  69264. /** @hidden */
  69265. _rebuild(): void;
  69266. private _bits;
  69267. private _radicalInverse_VdC;
  69268. private _hammersley;
  69269. private _hemisphereSample_uniform;
  69270. private _generateHemisphere;
  69271. private _createSSAOPostProcess;
  69272. private _createSSAOCombinePostProcess;
  69273. private _createRandomTexture;
  69274. /**
  69275. * Serialize the rendering pipeline (Used when exporting)
  69276. * @returns the serialized object
  69277. */
  69278. serialize(): any;
  69279. /**
  69280. * Parse the serialized pipeline
  69281. * @param source Source pipeline.
  69282. * @param scene The scene to load the pipeline to.
  69283. * @param rootUrl The URL of the serialized pipeline.
  69284. * @returns An instantiated pipeline from the serialized object.
  69285. */
  69286. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69287. }
  69288. }
  69289. declare module "babylonjs/Shaders/ssao.fragment" {
  69290. /** @hidden */
  69291. export var ssaoPixelShader: {
  69292. name: string;
  69293. shader: string;
  69294. };
  69295. }
  69296. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69297. import { Camera } from "babylonjs/Cameras/camera";
  69298. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69299. import { Scene } from "babylonjs/scene";
  69300. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69301. import "babylonjs/Shaders/ssao.fragment";
  69302. import "babylonjs/Shaders/ssaoCombine.fragment";
  69303. /**
  69304. * Render pipeline to produce ssao effect
  69305. */
  69306. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69307. /**
  69308. * @ignore
  69309. * The PassPostProcess id in the pipeline that contains the original scene color
  69310. */
  69311. SSAOOriginalSceneColorEffect: string;
  69312. /**
  69313. * @ignore
  69314. * The SSAO PostProcess id in the pipeline
  69315. */
  69316. SSAORenderEffect: string;
  69317. /**
  69318. * @ignore
  69319. * The horizontal blur PostProcess id in the pipeline
  69320. */
  69321. SSAOBlurHRenderEffect: string;
  69322. /**
  69323. * @ignore
  69324. * The vertical blur PostProcess id in the pipeline
  69325. */
  69326. SSAOBlurVRenderEffect: string;
  69327. /**
  69328. * @ignore
  69329. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69330. */
  69331. SSAOCombineRenderEffect: string;
  69332. /**
  69333. * The output strength of the SSAO post-process. Default value is 1.0.
  69334. */
  69335. totalStrength: number;
  69336. /**
  69337. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69338. */
  69339. radius: number;
  69340. /**
  69341. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69342. * Must not be equal to fallOff and superior to fallOff.
  69343. * Default value is 0.0075
  69344. */
  69345. area: number;
  69346. /**
  69347. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69348. * Must not be equal to area and inferior to area.
  69349. * Default value is 0.000001
  69350. */
  69351. fallOff: number;
  69352. /**
  69353. * The base color of the SSAO post-process
  69354. * The final result is "base + ssao" between [0, 1]
  69355. */
  69356. base: number;
  69357. private _scene;
  69358. private _depthTexture;
  69359. private _randomTexture;
  69360. private _originalColorPostProcess;
  69361. private _ssaoPostProcess;
  69362. private _blurHPostProcess;
  69363. private _blurVPostProcess;
  69364. private _ssaoCombinePostProcess;
  69365. private _firstUpdate;
  69366. /**
  69367. * Gets active scene
  69368. */
  69369. get scene(): Scene;
  69370. /**
  69371. * @constructor
  69372. * @param name - The rendering pipeline name
  69373. * @param scene - The scene linked to this pipeline
  69374. * @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 }
  69375. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69376. */
  69377. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69378. /**
  69379. * Get the class name
  69380. * @returns "SSAORenderingPipeline"
  69381. */
  69382. getClassName(): string;
  69383. /**
  69384. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69385. */
  69386. dispose(disableDepthRender?: boolean): void;
  69387. private _createBlurPostProcess;
  69388. /** @hidden */
  69389. _rebuild(): void;
  69390. private _createSSAOPostProcess;
  69391. private _createSSAOCombinePostProcess;
  69392. private _createRandomTexture;
  69393. }
  69394. }
  69395. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69396. /** @hidden */
  69397. export var screenSpaceReflectionPixelShader: {
  69398. name: string;
  69399. shader: string;
  69400. };
  69401. }
  69402. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69403. import { Nullable } from "babylonjs/types";
  69404. import { Camera } from "babylonjs/Cameras/camera";
  69405. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69406. import { Scene } from "babylonjs/scene";
  69407. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69408. import { Engine } from "babylonjs/Engines/engine";
  69409. /**
  69410. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69411. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69412. */
  69413. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69414. /**
  69415. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69416. */
  69417. threshold: number;
  69418. /**
  69419. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69420. */
  69421. strength: number;
  69422. /**
  69423. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69424. */
  69425. reflectionSpecularFalloffExponent: number;
  69426. /**
  69427. * 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]
  69428. */
  69429. step: number;
  69430. /**
  69431. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69432. */
  69433. roughnessFactor: number;
  69434. private _geometryBufferRenderer;
  69435. private _enableSmoothReflections;
  69436. private _reflectionSamples;
  69437. private _smoothSteps;
  69438. /**
  69439. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69440. * @param name The name of the effect.
  69441. * @param scene The scene containing the objects to calculate reflections.
  69442. * @param options The required width/height ratio to downsize to before computing the render pass.
  69443. * @param camera The camera to apply the render pass to.
  69444. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69445. * @param engine The engine which the post process will be applied. (default: current engine)
  69446. * @param reusable If the post process can be reused on the same frame. (default: false)
  69447. * @param textureType Type of textures used when performing the post process. (default: 0)
  69448. * @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)
  69449. */
  69450. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69451. /**
  69452. * Gets wether or not smoothing reflections is enabled.
  69453. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69454. */
  69455. get enableSmoothReflections(): boolean;
  69456. /**
  69457. * Sets wether or not smoothing reflections is enabled.
  69458. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69459. */
  69460. set enableSmoothReflections(enabled: boolean);
  69461. /**
  69462. * Gets the number of samples taken while computing reflections. More samples count is high,
  69463. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69464. */
  69465. get reflectionSamples(): number;
  69466. /**
  69467. * Sets the number of samples taken while computing reflections. More samples count is high,
  69468. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69469. */
  69470. set reflectionSamples(samples: number);
  69471. /**
  69472. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69473. * more the post-process will require GPU power and can generate a drop in FPS.
  69474. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69475. */
  69476. get smoothSteps(): number;
  69477. set smoothSteps(steps: number);
  69478. private _updateEffectDefines;
  69479. }
  69480. }
  69481. declare module "babylonjs/Shaders/standard.fragment" {
  69482. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69483. /** @hidden */
  69484. export var standardPixelShader: {
  69485. name: string;
  69486. shader: string;
  69487. };
  69488. }
  69489. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69490. import { Nullable } from "babylonjs/types";
  69491. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69492. import { Camera } from "babylonjs/Cameras/camera";
  69493. import { Texture } from "babylonjs/Materials/Textures/texture";
  69494. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69495. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69496. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69497. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69498. import { IDisposable } from "babylonjs/scene";
  69499. import { SpotLight } from "babylonjs/Lights/spotLight";
  69500. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69501. import { Scene } from "babylonjs/scene";
  69502. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69503. import { Animation } from "babylonjs/Animations/animation";
  69504. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69505. import "babylonjs/Shaders/standard.fragment";
  69506. /**
  69507. * Standard rendering pipeline
  69508. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69509. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69510. */
  69511. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69512. /**
  69513. * Public members
  69514. */
  69515. /**
  69516. * Post-process which contains the original scene color before the pipeline applies all the effects
  69517. */
  69518. originalPostProcess: Nullable<PostProcess>;
  69519. /**
  69520. * Post-process used to down scale an image x4
  69521. */
  69522. downSampleX4PostProcess: Nullable<PostProcess>;
  69523. /**
  69524. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69525. */
  69526. brightPassPostProcess: Nullable<PostProcess>;
  69527. /**
  69528. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69529. */
  69530. blurHPostProcesses: PostProcess[];
  69531. /**
  69532. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69533. */
  69534. blurVPostProcesses: PostProcess[];
  69535. /**
  69536. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69537. */
  69538. textureAdderPostProcess: Nullable<PostProcess>;
  69539. /**
  69540. * Post-process used to create volumetric lighting effect
  69541. */
  69542. volumetricLightPostProcess: Nullable<PostProcess>;
  69543. /**
  69544. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69545. */
  69546. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69547. /**
  69548. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69549. */
  69550. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69551. /**
  69552. * Post-process used to merge the volumetric light effect and the real scene color
  69553. */
  69554. volumetricLightMergePostProces: Nullable<PostProcess>;
  69555. /**
  69556. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69557. */
  69558. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69559. /**
  69560. * Base post-process used to calculate the average luminance of the final image for HDR
  69561. */
  69562. luminancePostProcess: Nullable<PostProcess>;
  69563. /**
  69564. * Post-processes used to create down sample post-processes in order to get
  69565. * the average luminance of the final image for HDR
  69566. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69567. */
  69568. luminanceDownSamplePostProcesses: PostProcess[];
  69569. /**
  69570. * Post-process used to create a HDR effect (light adaptation)
  69571. */
  69572. hdrPostProcess: Nullable<PostProcess>;
  69573. /**
  69574. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69575. */
  69576. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69577. /**
  69578. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69579. */
  69580. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69581. /**
  69582. * Post-process used to merge the final HDR post-process and the real scene color
  69583. */
  69584. hdrFinalPostProcess: Nullable<PostProcess>;
  69585. /**
  69586. * Post-process used to create a lens flare effect
  69587. */
  69588. lensFlarePostProcess: Nullable<PostProcess>;
  69589. /**
  69590. * Post-process that merges the result of the lens flare post-process and the real scene color
  69591. */
  69592. lensFlareComposePostProcess: Nullable<PostProcess>;
  69593. /**
  69594. * Post-process used to create a motion blur effect
  69595. */
  69596. motionBlurPostProcess: Nullable<PostProcess>;
  69597. /**
  69598. * Post-process used to create a depth of field effect
  69599. */
  69600. depthOfFieldPostProcess: Nullable<PostProcess>;
  69601. /**
  69602. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69603. */
  69604. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69605. /**
  69606. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69607. */
  69608. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69609. /**
  69610. * Represents the brightness threshold in order to configure the illuminated surfaces
  69611. */
  69612. brightThreshold: number;
  69613. /**
  69614. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69615. */
  69616. blurWidth: number;
  69617. /**
  69618. * Sets if the blur for highlighted surfaces must be only horizontal
  69619. */
  69620. horizontalBlur: boolean;
  69621. /**
  69622. * Gets the overall exposure used by the pipeline
  69623. */
  69624. get exposure(): number;
  69625. /**
  69626. * Sets the overall exposure used by the pipeline
  69627. */
  69628. set exposure(value: number);
  69629. /**
  69630. * Texture used typically to simulate "dirty" on camera lens
  69631. */
  69632. lensTexture: Nullable<Texture>;
  69633. /**
  69634. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69635. */
  69636. volumetricLightCoefficient: number;
  69637. /**
  69638. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69639. */
  69640. volumetricLightPower: number;
  69641. /**
  69642. * Used the set the blur intensity to smooth the volumetric lights
  69643. */
  69644. volumetricLightBlurScale: number;
  69645. /**
  69646. * Light (spot or directional) used to generate the volumetric lights rays
  69647. * The source light must have a shadow generate so the pipeline can get its
  69648. * depth map
  69649. */
  69650. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69651. /**
  69652. * For eye adaptation, represents the minimum luminance the eye can see
  69653. */
  69654. hdrMinimumLuminance: number;
  69655. /**
  69656. * For eye adaptation, represents the decrease luminance speed
  69657. */
  69658. hdrDecreaseRate: number;
  69659. /**
  69660. * For eye adaptation, represents the increase luminance speed
  69661. */
  69662. hdrIncreaseRate: number;
  69663. /**
  69664. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69665. */
  69666. get hdrAutoExposure(): boolean;
  69667. /**
  69668. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69669. */
  69670. set hdrAutoExposure(value: boolean);
  69671. /**
  69672. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69673. */
  69674. lensColorTexture: Nullable<Texture>;
  69675. /**
  69676. * The overall strengh for the lens flare effect
  69677. */
  69678. lensFlareStrength: number;
  69679. /**
  69680. * Dispersion coefficient for lens flare ghosts
  69681. */
  69682. lensFlareGhostDispersal: number;
  69683. /**
  69684. * Main lens flare halo width
  69685. */
  69686. lensFlareHaloWidth: number;
  69687. /**
  69688. * Based on the lens distortion effect, defines how much the lens flare result
  69689. * is distorted
  69690. */
  69691. lensFlareDistortionStrength: number;
  69692. /**
  69693. * Configures the blur intensity used for for lens flare (halo)
  69694. */
  69695. lensFlareBlurWidth: number;
  69696. /**
  69697. * Lens star texture must be used to simulate rays on the flares and is available
  69698. * in the documentation
  69699. */
  69700. lensStarTexture: Nullable<Texture>;
  69701. /**
  69702. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69703. * flare effect by taking account of the dirt texture
  69704. */
  69705. lensFlareDirtTexture: Nullable<Texture>;
  69706. /**
  69707. * Represents the focal length for the depth of field effect
  69708. */
  69709. depthOfFieldDistance: number;
  69710. /**
  69711. * Represents the blur intensity for the blurred part of the depth of field effect
  69712. */
  69713. depthOfFieldBlurWidth: number;
  69714. /**
  69715. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69716. */
  69717. get motionStrength(): number;
  69718. /**
  69719. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69720. */
  69721. set motionStrength(strength: number);
  69722. /**
  69723. * Gets wether or not the motion blur post-process is object based or screen based.
  69724. */
  69725. get objectBasedMotionBlur(): boolean;
  69726. /**
  69727. * Sets wether or not the motion blur post-process should be object based or screen based
  69728. */
  69729. set objectBasedMotionBlur(value: boolean);
  69730. /**
  69731. * List of animations for the pipeline (IAnimatable implementation)
  69732. */
  69733. animations: Animation[];
  69734. /**
  69735. * Private members
  69736. */
  69737. private _scene;
  69738. private _currentDepthOfFieldSource;
  69739. private _basePostProcess;
  69740. private _fixedExposure;
  69741. private _currentExposure;
  69742. private _hdrAutoExposure;
  69743. private _hdrCurrentLuminance;
  69744. private _motionStrength;
  69745. private _isObjectBasedMotionBlur;
  69746. private _floatTextureType;
  69747. private _camerasToBeAttached;
  69748. private _ratio;
  69749. private _bloomEnabled;
  69750. private _depthOfFieldEnabled;
  69751. private _vlsEnabled;
  69752. private _lensFlareEnabled;
  69753. private _hdrEnabled;
  69754. private _motionBlurEnabled;
  69755. private _fxaaEnabled;
  69756. private _screenSpaceReflectionsEnabled;
  69757. private _motionBlurSamples;
  69758. private _volumetricLightStepsCount;
  69759. private _samples;
  69760. /**
  69761. * @ignore
  69762. * Specifies if the bloom pipeline is enabled
  69763. */
  69764. get BloomEnabled(): boolean;
  69765. set BloomEnabled(enabled: boolean);
  69766. /**
  69767. * @ignore
  69768. * Specifies if the depth of field pipeline is enabed
  69769. */
  69770. get DepthOfFieldEnabled(): boolean;
  69771. set DepthOfFieldEnabled(enabled: boolean);
  69772. /**
  69773. * @ignore
  69774. * Specifies if the lens flare pipeline is enabed
  69775. */
  69776. get LensFlareEnabled(): boolean;
  69777. set LensFlareEnabled(enabled: boolean);
  69778. /**
  69779. * @ignore
  69780. * Specifies if the HDR pipeline is enabled
  69781. */
  69782. get HDREnabled(): boolean;
  69783. set HDREnabled(enabled: boolean);
  69784. /**
  69785. * @ignore
  69786. * Specifies if the volumetric lights scattering effect is enabled
  69787. */
  69788. get VLSEnabled(): boolean;
  69789. set VLSEnabled(enabled: boolean);
  69790. /**
  69791. * @ignore
  69792. * Specifies if the motion blur effect is enabled
  69793. */
  69794. get MotionBlurEnabled(): boolean;
  69795. set MotionBlurEnabled(enabled: boolean);
  69796. /**
  69797. * Specifies if anti-aliasing is enabled
  69798. */
  69799. get fxaaEnabled(): boolean;
  69800. set fxaaEnabled(enabled: boolean);
  69801. /**
  69802. * Specifies if screen space reflections are enabled.
  69803. */
  69804. get screenSpaceReflectionsEnabled(): boolean;
  69805. set screenSpaceReflectionsEnabled(enabled: boolean);
  69806. /**
  69807. * Specifies the number of steps used to calculate the volumetric lights
  69808. * Typically in interval [50, 200]
  69809. */
  69810. get volumetricLightStepsCount(): number;
  69811. set volumetricLightStepsCount(count: number);
  69812. /**
  69813. * Specifies the number of samples used for the motion blur effect
  69814. * Typically in interval [16, 64]
  69815. */
  69816. get motionBlurSamples(): number;
  69817. set motionBlurSamples(samples: number);
  69818. /**
  69819. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69820. */
  69821. get samples(): number;
  69822. set samples(sampleCount: number);
  69823. /**
  69824. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69825. * @constructor
  69826. * @param name The rendering pipeline name
  69827. * @param scene The scene linked to this pipeline
  69828. * @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)
  69829. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69830. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69831. */
  69832. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69833. private _buildPipeline;
  69834. private _createDownSampleX4PostProcess;
  69835. private _createBrightPassPostProcess;
  69836. private _createBlurPostProcesses;
  69837. private _createTextureAdderPostProcess;
  69838. private _createVolumetricLightPostProcess;
  69839. private _createLuminancePostProcesses;
  69840. private _createHdrPostProcess;
  69841. private _createLensFlarePostProcess;
  69842. private _createDepthOfFieldPostProcess;
  69843. private _createMotionBlurPostProcess;
  69844. private _getDepthTexture;
  69845. private _disposePostProcesses;
  69846. /**
  69847. * Dispose of the pipeline and stop all post processes
  69848. */
  69849. dispose(): void;
  69850. /**
  69851. * Serialize the rendering pipeline (Used when exporting)
  69852. * @returns the serialized object
  69853. */
  69854. serialize(): any;
  69855. /**
  69856. * Parse the serialized pipeline
  69857. * @param source Source pipeline.
  69858. * @param scene The scene to load the pipeline to.
  69859. * @param rootUrl The URL of the serialized pipeline.
  69860. * @returns An instantiated pipeline from the serialized object.
  69861. */
  69862. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69863. /**
  69864. * Luminance steps
  69865. */
  69866. static LuminanceSteps: number;
  69867. }
  69868. }
  69869. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69870. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69871. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69872. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69873. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69874. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69875. }
  69876. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69877. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69878. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69879. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69880. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69881. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69882. }
  69883. declare module "babylonjs/Shaders/tonemap.fragment" {
  69884. /** @hidden */
  69885. export var tonemapPixelShader: {
  69886. name: string;
  69887. shader: string;
  69888. };
  69889. }
  69890. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69891. import { Camera } from "babylonjs/Cameras/camera";
  69892. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69893. import "babylonjs/Shaders/tonemap.fragment";
  69894. import { Engine } from "babylonjs/Engines/engine";
  69895. /** Defines operator used for tonemapping */
  69896. export enum TonemappingOperator {
  69897. /** Hable */
  69898. Hable = 0,
  69899. /** Reinhard */
  69900. Reinhard = 1,
  69901. /** HejiDawson */
  69902. HejiDawson = 2,
  69903. /** Photographic */
  69904. Photographic = 3
  69905. }
  69906. /**
  69907. * Defines a post process to apply tone mapping
  69908. */
  69909. export class TonemapPostProcess extends PostProcess {
  69910. private _operator;
  69911. /** Defines the required exposure adjustement */
  69912. exposureAdjustment: number;
  69913. /**
  69914. * Creates a new TonemapPostProcess
  69915. * @param name defines the name of the postprocess
  69916. * @param _operator defines the operator to use
  69917. * @param exposureAdjustment defines the required exposure adjustement
  69918. * @param camera defines the camera to use (can be null)
  69919. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69920. * @param engine defines the hosting engine (can be ignore if camera is set)
  69921. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69922. */
  69923. constructor(name: string, _operator: TonemappingOperator,
  69924. /** Defines the required exposure adjustement */
  69925. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69926. }
  69927. }
  69928. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69929. /** @hidden */
  69930. export var volumetricLightScatteringPixelShader: {
  69931. name: string;
  69932. shader: string;
  69933. };
  69934. }
  69935. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69936. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69937. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69938. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69939. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69940. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69941. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69942. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69943. /** @hidden */
  69944. export var volumetricLightScatteringPassVertexShader: {
  69945. name: string;
  69946. shader: string;
  69947. };
  69948. }
  69949. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69950. /** @hidden */
  69951. export var volumetricLightScatteringPassPixelShader: {
  69952. name: string;
  69953. shader: string;
  69954. };
  69955. }
  69956. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69957. import { Vector3 } from "babylonjs/Maths/math.vector";
  69958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69959. import { Mesh } from "babylonjs/Meshes/mesh";
  69960. import { Camera } from "babylonjs/Cameras/camera";
  69961. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69962. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69963. import { Scene } from "babylonjs/scene";
  69964. import "babylonjs/Meshes/Builders/planeBuilder";
  69965. import "babylonjs/Shaders/depth.vertex";
  69966. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69967. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69968. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69969. import { Engine } from "babylonjs/Engines/engine";
  69970. /**
  69971. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69972. */
  69973. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69974. private _volumetricLightScatteringPass;
  69975. private _volumetricLightScatteringRTT;
  69976. private _viewPort;
  69977. private _screenCoordinates;
  69978. private _cachedDefines;
  69979. /**
  69980. * If not undefined, the mesh position is computed from the attached node position
  69981. */
  69982. attachedNode: {
  69983. position: Vector3;
  69984. };
  69985. /**
  69986. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69987. */
  69988. customMeshPosition: Vector3;
  69989. /**
  69990. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69991. */
  69992. useCustomMeshPosition: boolean;
  69993. /**
  69994. * If the post-process should inverse the light scattering direction
  69995. */
  69996. invert: boolean;
  69997. /**
  69998. * The internal mesh used by the post-process
  69999. */
  70000. mesh: Mesh;
  70001. /**
  70002. * @hidden
  70003. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70004. */
  70005. get useDiffuseColor(): boolean;
  70006. set useDiffuseColor(useDiffuseColor: boolean);
  70007. /**
  70008. * Array containing the excluded meshes not rendered in the internal pass
  70009. */
  70010. excludedMeshes: AbstractMesh[];
  70011. /**
  70012. * Controls the overall intensity of the post-process
  70013. */
  70014. exposure: number;
  70015. /**
  70016. * Dissipates each sample's contribution in range [0, 1]
  70017. */
  70018. decay: number;
  70019. /**
  70020. * Controls the overall intensity of each sample
  70021. */
  70022. weight: number;
  70023. /**
  70024. * Controls the density of each sample
  70025. */
  70026. density: number;
  70027. /**
  70028. * @constructor
  70029. * @param name The post-process name
  70030. * @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)
  70031. * @param camera The camera that the post-process will be attached to
  70032. * @param mesh The mesh used to create the light scattering
  70033. * @param samples The post-process quality, default 100
  70034. * @param samplingModeThe post-process filtering mode
  70035. * @param engine The babylon engine
  70036. * @param reusable If the post-process is reusable
  70037. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70038. */
  70039. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70040. /**
  70041. * Returns the string "VolumetricLightScatteringPostProcess"
  70042. * @returns "VolumetricLightScatteringPostProcess"
  70043. */
  70044. getClassName(): string;
  70045. private _isReady;
  70046. /**
  70047. * Sets the new light position for light scattering effect
  70048. * @param position The new custom light position
  70049. */
  70050. setCustomMeshPosition(position: Vector3): void;
  70051. /**
  70052. * Returns the light position for light scattering effect
  70053. * @return Vector3 The custom light position
  70054. */
  70055. getCustomMeshPosition(): Vector3;
  70056. /**
  70057. * Disposes the internal assets and detaches the post-process from the camera
  70058. */
  70059. dispose(camera: Camera): void;
  70060. /**
  70061. * Returns the render target texture used by the post-process
  70062. * @return the render target texture used by the post-process
  70063. */
  70064. getPass(): RenderTargetTexture;
  70065. private _meshExcluded;
  70066. private _createPass;
  70067. private _updateMeshScreenCoordinates;
  70068. /**
  70069. * Creates a default mesh for the Volumeric Light Scattering post-process
  70070. * @param name The mesh name
  70071. * @param scene The scene where to create the mesh
  70072. * @return the default mesh
  70073. */
  70074. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70075. }
  70076. }
  70077. declare module "babylonjs/PostProcesses/index" {
  70078. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70079. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70080. export * from "babylonjs/PostProcesses/bloomEffect";
  70081. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70082. export * from "babylonjs/PostProcesses/blurPostProcess";
  70083. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70084. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70085. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70086. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70087. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70088. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70089. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70090. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70091. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70092. export * from "babylonjs/PostProcesses/filterPostProcess";
  70093. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70094. export * from "babylonjs/PostProcesses/grainPostProcess";
  70095. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70096. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70097. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70098. export * from "babylonjs/PostProcesses/passPostProcess";
  70099. export * from "babylonjs/PostProcesses/postProcess";
  70100. export * from "babylonjs/PostProcesses/postProcessManager";
  70101. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70102. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70103. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70104. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70105. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70106. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70107. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70108. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70109. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70110. }
  70111. declare module "babylonjs/Probes/index" {
  70112. export * from "babylonjs/Probes/reflectionProbe";
  70113. }
  70114. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70115. import { Scene } from "babylonjs/scene";
  70116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70117. import { SmartArray } from "babylonjs/Misc/smartArray";
  70118. import { ISceneComponent } from "babylonjs/sceneComponent";
  70119. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70120. import "babylonjs/Meshes/Builders/boxBuilder";
  70121. import "babylonjs/Shaders/color.fragment";
  70122. import "babylonjs/Shaders/color.vertex";
  70123. import { Color3 } from "babylonjs/Maths/math.color";
  70124. module "babylonjs/scene" {
  70125. interface Scene {
  70126. /** @hidden (Backing field) */
  70127. _boundingBoxRenderer: BoundingBoxRenderer;
  70128. /** @hidden (Backing field) */
  70129. _forceShowBoundingBoxes: boolean;
  70130. /**
  70131. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70132. */
  70133. forceShowBoundingBoxes: boolean;
  70134. /**
  70135. * Gets the bounding box renderer associated with the scene
  70136. * @returns a BoundingBoxRenderer
  70137. */
  70138. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70139. }
  70140. }
  70141. module "babylonjs/Meshes/abstractMesh" {
  70142. interface AbstractMesh {
  70143. /** @hidden (Backing field) */
  70144. _showBoundingBox: boolean;
  70145. /**
  70146. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70147. */
  70148. showBoundingBox: boolean;
  70149. }
  70150. }
  70151. /**
  70152. * Component responsible of rendering the bounding box of the meshes in a scene.
  70153. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70154. */
  70155. export class BoundingBoxRenderer implements ISceneComponent {
  70156. /**
  70157. * The component name helpfull to identify the component in the list of scene components.
  70158. */
  70159. readonly name: string;
  70160. /**
  70161. * The scene the component belongs to.
  70162. */
  70163. scene: Scene;
  70164. /**
  70165. * Color of the bounding box lines placed in front of an object
  70166. */
  70167. frontColor: Color3;
  70168. /**
  70169. * Color of the bounding box lines placed behind an object
  70170. */
  70171. backColor: Color3;
  70172. /**
  70173. * Defines if the renderer should show the back lines or not
  70174. */
  70175. showBackLines: boolean;
  70176. /**
  70177. * @hidden
  70178. */
  70179. renderList: SmartArray<BoundingBox>;
  70180. private _colorShader;
  70181. private _vertexBuffers;
  70182. private _indexBuffer;
  70183. private _fillIndexBuffer;
  70184. private _fillIndexData;
  70185. /**
  70186. * Instantiates a new bounding box renderer in a scene.
  70187. * @param scene the scene the renderer renders in
  70188. */
  70189. constructor(scene: Scene);
  70190. /**
  70191. * Registers the component in a given scene
  70192. */
  70193. register(): void;
  70194. private _evaluateSubMesh;
  70195. private _activeMesh;
  70196. private _prepareRessources;
  70197. private _createIndexBuffer;
  70198. /**
  70199. * Rebuilds the elements related to this component in case of
  70200. * context lost for instance.
  70201. */
  70202. rebuild(): void;
  70203. /**
  70204. * @hidden
  70205. */
  70206. reset(): void;
  70207. /**
  70208. * Render the bounding boxes of a specific rendering group
  70209. * @param renderingGroupId defines the rendering group to render
  70210. */
  70211. render(renderingGroupId: number): void;
  70212. /**
  70213. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70214. * @param mesh Define the mesh to render the occlusion bounding box for
  70215. */
  70216. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70217. /**
  70218. * Dispose and release the resources attached to this renderer.
  70219. */
  70220. dispose(): void;
  70221. }
  70222. }
  70223. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70224. import { Nullable } from "babylonjs/types";
  70225. import { Scene } from "babylonjs/scene";
  70226. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70227. import { Camera } from "babylonjs/Cameras/camera";
  70228. import { ISceneComponent } from "babylonjs/sceneComponent";
  70229. module "babylonjs/scene" {
  70230. interface Scene {
  70231. /** @hidden (Backing field) */
  70232. _depthRenderer: {
  70233. [id: string]: DepthRenderer;
  70234. };
  70235. /**
  70236. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70237. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70238. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70239. * @returns the created depth renderer
  70240. */
  70241. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70242. /**
  70243. * Disables a depth renderer for a given camera
  70244. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70245. */
  70246. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70247. }
  70248. }
  70249. /**
  70250. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70251. * in several rendering techniques.
  70252. */
  70253. export class DepthRendererSceneComponent implements ISceneComponent {
  70254. /**
  70255. * The component name helpfull to identify the component in the list of scene components.
  70256. */
  70257. readonly name: string;
  70258. /**
  70259. * The scene the component belongs to.
  70260. */
  70261. scene: Scene;
  70262. /**
  70263. * Creates a new instance of the component for the given scene
  70264. * @param scene Defines the scene to register the component in
  70265. */
  70266. constructor(scene: Scene);
  70267. /**
  70268. * Registers the component in a given scene
  70269. */
  70270. register(): void;
  70271. /**
  70272. * Rebuilds the elements related to this component in case of
  70273. * context lost for instance.
  70274. */
  70275. rebuild(): void;
  70276. /**
  70277. * Disposes the component and the associated ressources
  70278. */
  70279. dispose(): void;
  70280. private _gatherRenderTargets;
  70281. private _gatherActiveCameraRenderTargets;
  70282. }
  70283. }
  70284. declare module "babylonjs/Shaders/outline.fragment" {
  70285. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70286. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70287. /** @hidden */
  70288. export var outlinePixelShader: {
  70289. name: string;
  70290. shader: string;
  70291. };
  70292. }
  70293. declare module "babylonjs/Shaders/outline.vertex" {
  70294. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70295. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70296. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70297. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70298. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70299. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70300. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70301. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70302. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70303. /** @hidden */
  70304. export var outlineVertexShader: {
  70305. name: string;
  70306. shader: string;
  70307. };
  70308. }
  70309. declare module "babylonjs/Rendering/outlineRenderer" {
  70310. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70311. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70312. import { Scene } from "babylonjs/scene";
  70313. import { ISceneComponent } from "babylonjs/sceneComponent";
  70314. import "babylonjs/Shaders/outline.fragment";
  70315. import "babylonjs/Shaders/outline.vertex";
  70316. module "babylonjs/scene" {
  70317. interface Scene {
  70318. /** @hidden */
  70319. _outlineRenderer: OutlineRenderer;
  70320. /**
  70321. * Gets the outline renderer associated with the scene
  70322. * @returns a OutlineRenderer
  70323. */
  70324. getOutlineRenderer(): OutlineRenderer;
  70325. }
  70326. }
  70327. module "babylonjs/Meshes/abstractMesh" {
  70328. interface AbstractMesh {
  70329. /** @hidden (Backing field) */
  70330. _renderOutline: boolean;
  70331. /**
  70332. * Gets or sets a boolean indicating if the outline must be rendered as well
  70333. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70334. */
  70335. renderOutline: boolean;
  70336. /** @hidden (Backing field) */
  70337. _renderOverlay: boolean;
  70338. /**
  70339. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70340. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70341. */
  70342. renderOverlay: boolean;
  70343. }
  70344. }
  70345. /**
  70346. * This class is responsible to draw bothe outline/overlay of meshes.
  70347. * It should not be used directly but through the available method on mesh.
  70348. */
  70349. export class OutlineRenderer implements ISceneComponent {
  70350. /**
  70351. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70352. */
  70353. private static _StencilReference;
  70354. /**
  70355. * The name of the component. Each component must have a unique name.
  70356. */
  70357. name: string;
  70358. /**
  70359. * The scene the component belongs to.
  70360. */
  70361. scene: Scene;
  70362. /**
  70363. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70364. */
  70365. zOffset: number;
  70366. private _engine;
  70367. private _effect;
  70368. private _cachedDefines;
  70369. private _savedDepthWrite;
  70370. /**
  70371. * Instantiates a new outline renderer. (There could be only one per scene).
  70372. * @param scene Defines the scene it belongs to
  70373. */
  70374. constructor(scene: Scene);
  70375. /**
  70376. * Register the component to one instance of a scene.
  70377. */
  70378. register(): void;
  70379. /**
  70380. * Rebuilds the elements related to this component in case of
  70381. * context lost for instance.
  70382. */
  70383. rebuild(): void;
  70384. /**
  70385. * Disposes the component and the associated ressources.
  70386. */
  70387. dispose(): void;
  70388. /**
  70389. * Renders the outline in the canvas.
  70390. * @param subMesh Defines the sumesh to render
  70391. * @param batch Defines the batch of meshes in case of instances
  70392. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70393. */
  70394. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70395. /**
  70396. * Returns whether or not the outline renderer is ready for a given submesh.
  70397. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70398. * @param subMesh Defines the submesh to check readyness for
  70399. * @param useInstances Defines wheter wee are trying to render instances or not
  70400. * @returns true if ready otherwise false
  70401. */
  70402. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70403. private _beforeRenderingMesh;
  70404. private _afterRenderingMesh;
  70405. }
  70406. }
  70407. declare module "babylonjs/Rendering/index" {
  70408. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70409. export * from "babylonjs/Rendering/depthRenderer";
  70410. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70411. export * from "babylonjs/Rendering/edgesRenderer";
  70412. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70413. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70414. export * from "babylonjs/Rendering/outlineRenderer";
  70415. export * from "babylonjs/Rendering/renderingGroup";
  70416. export * from "babylonjs/Rendering/renderingManager";
  70417. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70418. }
  70419. declare module "babylonjs/Sprites/ISprites" {
  70420. /**
  70421. * Defines the basic options interface of a Sprite Frame Source Size.
  70422. */
  70423. export interface ISpriteJSONSpriteSourceSize {
  70424. /**
  70425. * number of the original width of the Frame
  70426. */
  70427. w: number;
  70428. /**
  70429. * number of the original height of the Frame
  70430. */
  70431. h: number;
  70432. }
  70433. /**
  70434. * Defines the basic options interface of a Sprite Frame Data.
  70435. */
  70436. export interface ISpriteJSONSpriteFrameData {
  70437. /**
  70438. * number of the x offset of the Frame
  70439. */
  70440. x: number;
  70441. /**
  70442. * number of the y offset of the Frame
  70443. */
  70444. y: number;
  70445. /**
  70446. * number of the width of the Frame
  70447. */
  70448. w: number;
  70449. /**
  70450. * number of the height of the Frame
  70451. */
  70452. h: number;
  70453. }
  70454. /**
  70455. * Defines the basic options interface of a JSON Sprite.
  70456. */
  70457. export interface ISpriteJSONSprite {
  70458. /**
  70459. * string name of the Frame
  70460. */
  70461. filename: string;
  70462. /**
  70463. * ISpriteJSONSpriteFrame basic object of the frame data
  70464. */
  70465. frame: ISpriteJSONSpriteFrameData;
  70466. /**
  70467. * boolean to flag is the frame was rotated.
  70468. */
  70469. rotated: boolean;
  70470. /**
  70471. * boolean to flag is the frame was trimmed.
  70472. */
  70473. trimmed: boolean;
  70474. /**
  70475. * ISpriteJSONSpriteFrame basic object of the source data
  70476. */
  70477. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70478. /**
  70479. * ISpriteJSONSpriteFrame basic object of the source data
  70480. */
  70481. sourceSize: ISpriteJSONSpriteSourceSize;
  70482. }
  70483. /**
  70484. * Defines the basic options interface of a JSON atlas.
  70485. */
  70486. export interface ISpriteJSONAtlas {
  70487. /**
  70488. * Array of objects that contain the frame data.
  70489. */
  70490. frames: Array<ISpriteJSONSprite>;
  70491. /**
  70492. * object basic object containing the sprite meta data.
  70493. */
  70494. meta?: object;
  70495. }
  70496. }
  70497. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70498. /** @hidden */
  70499. export var spriteMapPixelShader: {
  70500. name: string;
  70501. shader: string;
  70502. };
  70503. }
  70504. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70505. /** @hidden */
  70506. export var spriteMapVertexShader: {
  70507. name: string;
  70508. shader: string;
  70509. };
  70510. }
  70511. declare module "babylonjs/Sprites/spriteMap" {
  70512. import { IDisposable, Scene } from "babylonjs/scene";
  70513. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70514. import { Texture } from "babylonjs/Materials/Textures/texture";
  70515. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70516. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70517. import "babylonjs/Meshes/Builders/planeBuilder";
  70518. import "babylonjs/Shaders/spriteMap.fragment";
  70519. import "babylonjs/Shaders/spriteMap.vertex";
  70520. /**
  70521. * Defines the basic options interface of a SpriteMap
  70522. */
  70523. export interface ISpriteMapOptions {
  70524. /**
  70525. * Vector2 of the number of cells in the grid.
  70526. */
  70527. stageSize?: Vector2;
  70528. /**
  70529. * Vector2 of the size of the output plane in World Units.
  70530. */
  70531. outputSize?: Vector2;
  70532. /**
  70533. * Vector3 of the position of the output plane in World Units.
  70534. */
  70535. outputPosition?: Vector3;
  70536. /**
  70537. * Vector3 of the rotation of the output plane.
  70538. */
  70539. outputRotation?: Vector3;
  70540. /**
  70541. * number of layers that the system will reserve in resources.
  70542. */
  70543. layerCount?: number;
  70544. /**
  70545. * number of max animation frames a single cell will reserve in resources.
  70546. */
  70547. maxAnimationFrames?: number;
  70548. /**
  70549. * number cell index of the base tile when the system compiles.
  70550. */
  70551. baseTile?: number;
  70552. /**
  70553. * boolean flip the sprite after its been repositioned by the framing data.
  70554. */
  70555. flipU?: boolean;
  70556. /**
  70557. * Vector3 scalar of the global RGB values of the SpriteMap.
  70558. */
  70559. colorMultiply?: Vector3;
  70560. }
  70561. /**
  70562. * Defines the IDisposable interface in order to be cleanable from resources.
  70563. */
  70564. export interface ISpriteMap extends IDisposable {
  70565. /**
  70566. * String name of the SpriteMap.
  70567. */
  70568. name: string;
  70569. /**
  70570. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70571. */
  70572. atlasJSON: ISpriteJSONAtlas;
  70573. /**
  70574. * Texture of the SpriteMap.
  70575. */
  70576. spriteSheet: Texture;
  70577. /**
  70578. * The parameters to initialize the SpriteMap with.
  70579. */
  70580. options: ISpriteMapOptions;
  70581. }
  70582. /**
  70583. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70584. */
  70585. export class SpriteMap implements ISpriteMap {
  70586. /** The Name of the spriteMap */
  70587. name: string;
  70588. /** The JSON file with the frame and meta data */
  70589. atlasJSON: ISpriteJSONAtlas;
  70590. /** The systems Sprite Sheet Texture */
  70591. spriteSheet: Texture;
  70592. /** Arguments passed with the Constructor */
  70593. options: ISpriteMapOptions;
  70594. /** Public Sprite Storage array, parsed from atlasJSON */
  70595. sprites: Array<ISpriteJSONSprite>;
  70596. /** Returns the Number of Sprites in the System */
  70597. get spriteCount(): number;
  70598. /** Returns the Position of Output Plane*/
  70599. get position(): Vector3;
  70600. /** Returns the Position of Output Plane*/
  70601. set position(v: Vector3);
  70602. /** Returns the Rotation of Output Plane*/
  70603. get rotation(): Vector3;
  70604. /** Returns the Rotation of Output Plane*/
  70605. set rotation(v: Vector3);
  70606. /** Sets the AnimationMap*/
  70607. get animationMap(): RawTexture;
  70608. /** Sets the AnimationMap*/
  70609. set animationMap(v: RawTexture);
  70610. /** Scene that the SpriteMap was created in */
  70611. private _scene;
  70612. /** Texture Buffer of Float32 that holds tile frame data*/
  70613. private _frameMap;
  70614. /** Texture Buffers of Float32 that holds tileMap data*/
  70615. private _tileMaps;
  70616. /** Texture Buffer of Float32 that holds Animation Data*/
  70617. private _animationMap;
  70618. /** Custom ShaderMaterial Central to the System*/
  70619. private _material;
  70620. /** Custom ShaderMaterial Central to the System*/
  70621. private _output;
  70622. /** Systems Time Ticker*/
  70623. private _time;
  70624. /**
  70625. * Creates a new SpriteMap
  70626. * @param name defines the SpriteMaps Name
  70627. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70628. * @param spriteSheet is the Texture that the Sprites are on.
  70629. * @param options a basic deployment configuration
  70630. * @param scene The Scene that the map is deployed on
  70631. */
  70632. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70633. /**
  70634. * Returns tileID location
  70635. * @returns Vector2 the cell position ID
  70636. */
  70637. getTileID(): Vector2;
  70638. /**
  70639. * Gets the UV location of the mouse over the SpriteMap.
  70640. * @returns Vector2 the UV position of the mouse interaction
  70641. */
  70642. getMousePosition(): Vector2;
  70643. /**
  70644. * Creates the "frame" texture Buffer
  70645. * -------------------------------------
  70646. * Structure of frames
  70647. * "filename": "Falling-Water-2.png",
  70648. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70649. * "rotated": true,
  70650. * "trimmed": true,
  70651. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70652. * "sourceSize": {"w":32,"h":32}
  70653. * @returns RawTexture of the frameMap
  70654. */
  70655. private _createFrameBuffer;
  70656. /**
  70657. * Creates the tileMap texture Buffer
  70658. * @param buffer normally and array of numbers, or a false to generate from scratch
  70659. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70660. * @returns RawTexture of the tileMap
  70661. */
  70662. private _createTileBuffer;
  70663. /**
  70664. * Modifies the data of the tileMaps
  70665. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70666. * @param pos is the iVector2 Coordinates of the Tile
  70667. * @param tile The SpriteIndex of the new Tile
  70668. */
  70669. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70670. /**
  70671. * Creates the animationMap texture Buffer
  70672. * @param buffer normally and array of numbers, or a false to generate from scratch
  70673. * @returns RawTexture of the animationMap
  70674. */
  70675. private _createTileAnimationBuffer;
  70676. /**
  70677. * Modifies the data of the animationMap
  70678. * @param cellID is the Index of the Sprite
  70679. * @param _frame is the target Animation frame
  70680. * @param toCell is the Target Index of the next frame of the animation
  70681. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70682. * @param speed is a global scalar of the time variable on the map.
  70683. */
  70684. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70685. /**
  70686. * Exports the .tilemaps file
  70687. */
  70688. saveTileMaps(): void;
  70689. /**
  70690. * Imports the .tilemaps file
  70691. * @param url of the .tilemaps file
  70692. */
  70693. loadTileMaps(url: string): void;
  70694. /**
  70695. * Release associated resources
  70696. */
  70697. dispose(): void;
  70698. }
  70699. }
  70700. declare module "babylonjs/Sprites/spritePackedManager" {
  70701. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70702. import { Scene } from "babylonjs/scene";
  70703. /**
  70704. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70705. * @see http://doc.babylonjs.com/babylon101/sprites
  70706. */
  70707. export class SpritePackedManager extends SpriteManager {
  70708. /** defines the packed manager's name */
  70709. name: string;
  70710. /**
  70711. * Creates a new sprite manager from a packed sprite sheet
  70712. * @param name defines the manager's name
  70713. * @param imgUrl defines the sprite sheet url
  70714. * @param capacity defines the maximum allowed number of sprites
  70715. * @param scene defines the hosting scene
  70716. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70717. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70718. * @param samplingMode defines the smapling mode to use with spritesheet
  70719. * @param fromPacked set to true; do not alter
  70720. */
  70721. constructor(
  70722. /** defines the packed manager's name */
  70723. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70724. }
  70725. }
  70726. declare module "babylonjs/Sprites/index" {
  70727. export * from "babylonjs/Sprites/sprite";
  70728. export * from "babylonjs/Sprites/ISprites";
  70729. export * from "babylonjs/Sprites/spriteManager";
  70730. export * from "babylonjs/Sprites/spriteMap";
  70731. export * from "babylonjs/Sprites/spritePackedManager";
  70732. export * from "babylonjs/Sprites/spriteSceneComponent";
  70733. }
  70734. declare module "babylonjs/States/index" {
  70735. export * from "babylonjs/States/alphaCullingState";
  70736. export * from "babylonjs/States/depthCullingState";
  70737. export * from "babylonjs/States/stencilState";
  70738. }
  70739. declare module "babylonjs/Misc/assetsManager" {
  70740. import { Scene } from "babylonjs/scene";
  70741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70742. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70743. import { Skeleton } from "babylonjs/Bones/skeleton";
  70744. import { Observable } from "babylonjs/Misc/observable";
  70745. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70746. import { Texture } from "babylonjs/Materials/Textures/texture";
  70747. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70748. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70749. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70750. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70751. /**
  70752. * Defines the list of states available for a task inside a AssetsManager
  70753. */
  70754. export enum AssetTaskState {
  70755. /**
  70756. * Initialization
  70757. */
  70758. INIT = 0,
  70759. /**
  70760. * Running
  70761. */
  70762. RUNNING = 1,
  70763. /**
  70764. * Done
  70765. */
  70766. DONE = 2,
  70767. /**
  70768. * Error
  70769. */
  70770. ERROR = 3
  70771. }
  70772. /**
  70773. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70774. */
  70775. export abstract class AbstractAssetTask {
  70776. /**
  70777. * Task name
  70778. */ name: string;
  70779. /**
  70780. * Callback called when the task is successful
  70781. */
  70782. onSuccess: (task: any) => void;
  70783. /**
  70784. * Callback called when the task is not successful
  70785. */
  70786. onError: (task: any, message?: string, exception?: any) => void;
  70787. /**
  70788. * Creates a new AssetsManager
  70789. * @param name defines the name of the task
  70790. */
  70791. constructor(
  70792. /**
  70793. * Task name
  70794. */ name: string);
  70795. private _isCompleted;
  70796. private _taskState;
  70797. private _errorObject;
  70798. /**
  70799. * Get if the task is completed
  70800. */
  70801. get isCompleted(): boolean;
  70802. /**
  70803. * Gets the current state of the task
  70804. */
  70805. get taskState(): AssetTaskState;
  70806. /**
  70807. * Gets the current error object (if task is in error)
  70808. */
  70809. get errorObject(): {
  70810. message?: string;
  70811. exception?: any;
  70812. };
  70813. /**
  70814. * Internal only
  70815. * @hidden
  70816. */
  70817. _setErrorObject(message?: string, exception?: any): void;
  70818. /**
  70819. * Execute the current task
  70820. * @param scene defines the scene where you want your assets to be loaded
  70821. * @param onSuccess is a callback called when the task is successfully executed
  70822. * @param onError is a callback called if an error occurs
  70823. */
  70824. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70825. /**
  70826. * Execute the current task
  70827. * @param scene defines the scene where you want your assets to be loaded
  70828. * @param onSuccess is a callback called when the task is successfully executed
  70829. * @param onError is a callback called if an error occurs
  70830. */
  70831. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70832. /**
  70833. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70834. * This can be used with failed tasks that have the reason for failure fixed.
  70835. */
  70836. reset(): void;
  70837. private onErrorCallback;
  70838. private onDoneCallback;
  70839. }
  70840. /**
  70841. * Define the interface used by progress events raised during assets loading
  70842. */
  70843. export interface IAssetsProgressEvent {
  70844. /**
  70845. * Defines the number of remaining tasks to process
  70846. */
  70847. remainingCount: number;
  70848. /**
  70849. * Defines the total number of tasks
  70850. */
  70851. totalCount: number;
  70852. /**
  70853. * Defines the task that was just processed
  70854. */
  70855. task: AbstractAssetTask;
  70856. }
  70857. /**
  70858. * Class used to share progress information about assets loading
  70859. */
  70860. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70861. /**
  70862. * Defines the number of remaining tasks to process
  70863. */
  70864. remainingCount: number;
  70865. /**
  70866. * Defines the total number of tasks
  70867. */
  70868. totalCount: number;
  70869. /**
  70870. * Defines the task that was just processed
  70871. */
  70872. task: AbstractAssetTask;
  70873. /**
  70874. * Creates a AssetsProgressEvent
  70875. * @param remainingCount defines the number of remaining tasks to process
  70876. * @param totalCount defines the total number of tasks
  70877. * @param task defines the task that was just processed
  70878. */
  70879. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70880. }
  70881. /**
  70882. * Define a task used by AssetsManager to load meshes
  70883. */
  70884. export class MeshAssetTask extends AbstractAssetTask {
  70885. /**
  70886. * Defines the name of the task
  70887. */
  70888. name: string;
  70889. /**
  70890. * Defines the list of mesh's names you want to load
  70891. */
  70892. meshesNames: any;
  70893. /**
  70894. * Defines the root url to use as a base to load your meshes and associated resources
  70895. */
  70896. rootUrl: string;
  70897. /**
  70898. * Defines the filename of the scene to load from
  70899. */
  70900. sceneFilename: string;
  70901. /**
  70902. * Gets the list of loaded meshes
  70903. */
  70904. loadedMeshes: Array<AbstractMesh>;
  70905. /**
  70906. * Gets the list of loaded particle systems
  70907. */
  70908. loadedParticleSystems: Array<IParticleSystem>;
  70909. /**
  70910. * Gets the list of loaded skeletons
  70911. */
  70912. loadedSkeletons: Array<Skeleton>;
  70913. /**
  70914. * Gets the list of loaded animation groups
  70915. */
  70916. loadedAnimationGroups: Array<AnimationGroup>;
  70917. /**
  70918. * Callback called when the task is successful
  70919. */
  70920. onSuccess: (task: MeshAssetTask) => void;
  70921. /**
  70922. * Callback called when the task is successful
  70923. */
  70924. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70925. /**
  70926. * Creates a new MeshAssetTask
  70927. * @param name defines the name of the task
  70928. * @param meshesNames defines the list of mesh's names you want to load
  70929. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70930. * @param sceneFilename defines the filename of the scene to load from
  70931. */
  70932. constructor(
  70933. /**
  70934. * Defines the name of the task
  70935. */
  70936. name: string,
  70937. /**
  70938. * Defines the list of mesh's names you want to load
  70939. */
  70940. meshesNames: any,
  70941. /**
  70942. * Defines the root url to use as a base to load your meshes and associated resources
  70943. */
  70944. rootUrl: string,
  70945. /**
  70946. * Defines the filename of the scene to load from
  70947. */
  70948. sceneFilename: string);
  70949. /**
  70950. * Execute the current task
  70951. * @param scene defines the scene where you want your assets to be loaded
  70952. * @param onSuccess is a callback called when the task is successfully executed
  70953. * @param onError is a callback called if an error occurs
  70954. */
  70955. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70956. }
  70957. /**
  70958. * Define a task used by AssetsManager to load text content
  70959. */
  70960. export class TextFileAssetTask extends AbstractAssetTask {
  70961. /**
  70962. * Defines the name of the task
  70963. */
  70964. name: string;
  70965. /**
  70966. * Defines the location of the file to load
  70967. */
  70968. url: string;
  70969. /**
  70970. * Gets the loaded text string
  70971. */
  70972. text: string;
  70973. /**
  70974. * Callback called when the task is successful
  70975. */
  70976. onSuccess: (task: TextFileAssetTask) => void;
  70977. /**
  70978. * Callback called when the task is successful
  70979. */
  70980. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70981. /**
  70982. * Creates a new TextFileAssetTask object
  70983. * @param name defines the name of the task
  70984. * @param url defines the location of the file to load
  70985. */
  70986. constructor(
  70987. /**
  70988. * Defines the name of the task
  70989. */
  70990. name: string,
  70991. /**
  70992. * Defines the location of the file to load
  70993. */
  70994. url: string);
  70995. /**
  70996. * Execute the current task
  70997. * @param scene defines the scene where you want your assets to be loaded
  70998. * @param onSuccess is a callback called when the task is successfully executed
  70999. * @param onError is a callback called if an error occurs
  71000. */
  71001. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71002. }
  71003. /**
  71004. * Define a task used by AssetsManager to load binary data
  71005. */
  71006. export class BinaryFileAssetTask extends AbstractAssetTask {
  71007. /**
  71008. * Defines the name of the task
  71009. */
  71010. name: string;
  71011. /**
  71012. * Defines the location of the file to load
  71013. */
  71014. url: string;
  71015. /**
  71016. * Gets the lodaded data (as an array buffer)
  71017. */
  71018. data: ArrayBuffer;
  71019. /**
  71020. * Callback called when the task is successful
  71021. */
  71022. onSuccess: (task: BinaryFileAssetTask) => void;
  71023. /**
  71024. * Callback called when the task is successful
  71025. */
  71026. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71027. /**
  71028. * Creates a new BinaryFileAssetTask object
  71029. * @param name defines the name of the new task
  71030. * @param url defines the location of the file to load
  71031. */
  71032. constructor(
  71033. /**
  71034. * Defines the name of the task
  71035. */
  71036. name: string,
  71037. /**
  71038. * Defines the location of the file to load
  71039. */
  71040. url: string);
  71041. /**
  71042. * Execute the current task
  71043. * @param scene defines the scene where you want your assets to be loaded
  71044. * @param onSuccess is a callback called when the task is successfully executed
  71045. * @param onError is a callback called if an error occurs
  71046. */
  71047. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71048. }
  71049. /**
  71050. * Define a task used by AssetsManager to load images
  71051. */
  71052. export class ImageAssetTask extends AbstractAssetTask {
  71053. /**
  71054. * Defines the name of the task
  71055. */
  71056. name: string;
  71057. /**
  71058. * Defines the location of the image to load
  71059. */
  71060. url: string;
  71061. /**
  71062. * Gets the loaded images
  71063. */
  71064. image: HTMLImageElement;
  71065. /**
  71066. * Callback called when the task is successful
  71067. */
  71068. onSuccess: (task: ImageAssetTask) => void;
  71069. /**
  71070. * Callback called when the task is successful
  71071. */
  71072. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71073. /**
  71074. * Creates a new ImageAssetTask
  71075. * @param name defines the name of the task
  71076. * @param url defines the location of the image to load
  71077. */
  71078. constructor(
  71079. /**
  71080. * Defines the name of the task
  71081. */
  71082. name: string,
  71083. /**
  71084. * Defines the location of the image to load
  71085. */
  71086. url: string);
  71087. /**
  71088. * Execute the current task
  71089. * @param scene defines the scene where you want your assets to be loaded
  71090. * @param onSuccess is a callback called when the task is successfully executed
  71091. * @param onError is a callback called if an error occurs
  71092. */
  71093. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71094. }
  71095. /**
  71096. * Defines the interface used by texture loading tasks
  71097. */
  71098. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71099. /**
  71100. * Gets the loaded texture
  71101. */
  71102. texture: TEX;
  71103. }
  71104. /**
  71105. * Define a task used by AssetsManager to load 2D textures
  71106. */
  71107. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71108. /**
  71109. * Defines the name of the task
  71110. */
  71111. name: string;
  71112. /**
  71113. * Defines the location of the file to load
  71114. */
  71115. url: string;
  71116. /**
  71117. * Defines if mipmap should not be generated (default is false)
  71118. */
  71119. noMipmap?: boolean | undefined;
  71120. /**
  71121. * Defines if texture must be inverted on Y axis (default is false)
  71122. */
  71123. invertY?: boolean | undefined;
  71124. /**
  71125. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71126. */
  71127. samplingMode: number;
  71128. /**
  71129. * Gets the loaded texture
  71130. */
  71131. texture: Texture;
  71132. /**
  71133. * Callback called when the task is successful
  71134. */
  71135. onSuccess: (task: TextureAssetTask) => void;
  71136. /**
  71137. * Callback called when the task is successful
  71138. */
  71139. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71140. /**
  71141. * Creates a new TextureAssetTask object
  71142. * @param name defines the name of the task
  71143. * @param url defines the location of the file to load
  71144. * @param noMipmap defines if mipmap should not be generated (default is false)
  71145. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71146. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71147. */
  71148. constructor(
  71149. /**
  71150. * Defines the name of the task
  71151. */
  71152. name: string,
  71153. /**
  71154. * Defines the location of the file to load
  71155. */
  71156. url: string,
  71157. /**
  71158. * Defines if mipmap should not be generated (default is false)
  71159. */
  71160. noMipmap?: boolean | undefined,
  71161. /**
  71162. * Defines if texture must be inverted on Y axis (default is false)
  71163. */
  71164. invertY?: boolean | undefined,
  71165. /**
  71166. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71167. */
  71168. samplingMode?: number);
  71169. /**
  71170. * Execute the current task
  71171. * @param scene defines the scene where you want your assets to be loaded
  71172. * @param onSuccess is a callback called when the task is successfully executed
  71173. * @param onError is a callback called if an error occurs
  71174. */
  71175. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71176. }
  71177. /**
  71178. * Define a task used by AssetsManager to load cube textures
  71179. */
  71180. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71181. /**
  71182. * Defines the name of the task
  71183. */
  71184. name: string;
  71185. /**
  71186. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71187. */
  71188. url: string;
  71189. /**
  71190. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71191. */
  71192. extensions?: string[] | undefined;
  71193. /**
  71194. * Defines if mipmaps should not be generated (default is false)
  71195. */
  71196. noMipmap?: boolean | undefined;
  71197. /**
  71198. * Defines the explicit list of files (undefined by default)
  71199. */
  71200. files?: string[] | undefined;
  71201. /**
  71202. * Gets the loaded texture
  71203. */
  71204. texture: CubeTexture;
  71205. /**
  71206. * Callback called when the task is successful
  71207. */
  71208. onSuccess: (task: CubeTextureAssetTask) => void;
  71209. /**
  71210. * Callback called when the task is successful
  71211. */
  71212. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71213. /**
  71214. * Creates a new CubeTextureAssetTask
  71215. * @param name defines the name of the task
  71216. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71217. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71218. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71219. * @param files defines the explicit list of files (undefined by default)
  71220. */
  71221. constructor(
  71222. /**
  71223. * Defines the name of the task
  71224. */
  71225. name: string,
  71226. /**
  71227. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71228. */
  71229. url: string,
  71230. /**
  71231. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71232. */
  71233. extensions?: string[] | undefined,
  71234. /**
  71235. * Defines if mipmaps should not be generated (default is false)
  71236. */
  71237. noMipmap?: boolean | undefined,
  71238. /**
  71239. * Defines the explicit list of files (undefined by default)
  71240. */
  71241. files?: string[] | undefined);
  71242. /**
  71243. * Execute the current task
  71244. * @param scene defines the scene where you want your assets to be loaded
  71245. * @param onSuccess is a callback called when the task is successfully executed
  71246. * @param onError is a callback called if an error occurs
  71247. */
  71248. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71249. }
  71250. /**
  71251. * Define a task used by AssetsManager to load HDR cube textures
  71252. */
  71253. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71254. /**
  71255. * Defines the name of the task
  71256. */
  71257. name: string;
  71258. /**
  71259. * Defines the location of the file to load
  71260. */
  71261. url: string;
  71262. /**
  71263. * Defines the desired size (the more it increases the longer the generation will be)
  71264. */
  71265. size: number;
  71266. /**
  71267. * Defines if mipmaps should not be generated (default is false)
  71268. */
  71269. noMipmap: boolean;
  71270. /**
  71271. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71272. */
  71273. generateHarmonics: boolean;
  71274. /**
  71275. * 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)
  71276. */
  71277. gammaSpace: boolean;
  71278. /**
  71279. * Internal Use Only
  71280. */
  71281. reserved: boolean;
  71282. /**
  71283. * Gets the loaded texture
  71284. */
  71285. texture: HDRCubeTexture;
  71286. /**
  71287. * Callback called when the task is successful
  71288. */
  71289. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71290. /**
  71291. * Callback called when the task is successful
  71292. */
  71293. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71294. /**
  71295. * Creates a new HDRCubeTextureAssetTask object
  71296. * @param name defines the name of the task
  71297. * @param url defines the location of the file to load
  71298. * @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.
  71299. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71300. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71301. * @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)
  71302. * @param reserved Internal use only
  71303. */
  71304. constructor(
  71305. /**
  71306. * Defines the name of the task
  71307. */
  71308. name: string,
  71309. /**
  71310. * Defines the location of the file to load
  71311. */
  71312. url: string,
  71313. /**
  71314. * Defines the desired size (the more it increases the longer the generation will be)
  71315. */
  71316. size: number,
  71317. /**
  71318. * Defines if mipmaps should not be generated (default is false)
  71319. */
  71320. noMipmap?: boolean,
  71321. /**
  71322. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71323. */
  71324. generateHarmonics?: boolean,
  71325. /**
  71326. * 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)
  71327. */
  71328. gammaSpace?: boolean,
  71329. /**
  71330. * Internal Use Only
  71331. */
  71332. reserved?: boolean);
  71333. /**
  71334. * Execute the current task
  71335. * @param scene defines the scene where you want your assets to be loaded
  71336. * @param onSuccess is a callback called when the task is successfully executed
  71337. * @param onError is a callback called if an error occurs
  71338. */
  71339. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71340. }
  71341. /**
  71342. * Define a task used by AssetsManager to load Equirectangular cube textures
  71343. */
  71344. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71345. /**
  71346. * Defines the name of the task
  71347. */
  71348. name: string;
  71349. /**
  71350. * Defines the location of the file to load
  71351. */
  71352. url: string;
  71353. /**
  71354. * Defines the desired size (the more it increases the longer the generation will be)
  71355. */
  71356. size: number;
  71357. /**
  71358. * Defines if mipmaps should not be generated (default is false)
  71359. */
  71360. noMipmap: boolean;
  71361. /**
  71362. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71363. * but the standard material would require them in Gamma space) (default is true)
  71364. */
  71365. gammaSpace: boolean;
  71366. /**
  71367. * Gets the loaded texture
  71368. */
  71369. texture: EquiRectangularCubeTexture;
  71370. /**
  71371. * Callback called when the task is successful
  71372. */
  71373. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71374. /**
  71375. * Callback called when the task is successful
  71376. */
  71377. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71378. /**
  71379. * Creates a new EquiRectangularCubeTextureAssetTask object
  71380. * @param name defines the name of the task
  71381. * @param url defines the location of the file to load
  71382. * @param size defines the desired size (the more it increases the longer the generation will be)
  71383. * If the size is omitted this implies you are using a preprocessed cubemap.
  71384. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71385. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71386. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71387. * (default is true)
  71388. */
  71389. constructor(
  71390. /**
  71391. * Defines the name of the task
  71392. */
  71393. name: string,
  71394. /**
  71395. * Defines the location of the file to load
  71396. */
  71397. url: string,
  71398. /**
  71399. * Defines the desired size (the more it increases the longer the generation will be)
  71400. */
  71401. size: number,
  71402. /**
  71403. * Defines if mipmaps should not be generated (default is false)
  71404. */
  71405. noMipmap?: boolean,
  71406. /**
  71407. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71408. * but the standard material would require them in Gamma space) (default is true)
  71409. */
  71410. gammaSpace?: boolean);
  71411. /**
  71412. * Execute the current task
  71413. * @param scene defines the scene where you want your assets to be loaded
  71414. * @param onSuccess is a callback called when the task is successfully executed
  71415. * @param onError is a callback called if an error occurs
  71416. */
  71417. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71418. }
  71419. /**
  71420. * This class can be used to easily import assets into a scene
  71421. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71422. */
  71423. export class AssetsManager {
  71424. private _scene;
  71425. private _isLoading;
  71426. protected _tasks: AbstractAssetTask[];
  71427. protected _waitingTasksCount: number;
  71428. protected _totalTasksCount: number;
  71429. /**
  71430. * Callback called when all tasks are processed
  71431. */
  71432. onFinish: (tasks: AbstractAssetTask[]) => void;
  71433. /**
  71434. * Callback called when a task is successful
  71435. */
  71436. onTaskSuccess: (task: AbstractAssetTask) => void;
  71437. /**
  71438. * Callback called when a task had an error
  71439. */
  71440. onTaskError: (task: AbstractAssetTask) => void;
  71441. /**
  71442. * Callback called when a task is done (whatever the result is)
  71443. */
  71444. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71445. /**
  71446. * Observable called when all tasks are processed
  71447. */
  71448. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71449. /**
  71450. * Observable called when a task had an error
  71451. */
  71452. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71453. /**
  71454. * Observable called when all tasks were executed
  71455. */
  71456. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71457. /**
  71458. * Observable called when a task is done (whatever the result is)
  71459. */
  71460. onProgressObservable: Observable<IAssetsProgressEvent>;
  71461. /**
  71462. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71463. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71464. */
  71465. useDefaultLoadingScreen: boolean;
  71466. /**
  71467. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71468. * when all assets have been downloaded.
  71469. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71470. */
  71471. autoHideLoadingUI: boolean;
  71472. /**
  71473. * Creates a new AssetsManager
  71474. * @param scene defines the scene to work on
  71475. */
  71476. constructor(scene: Scene);
  71477. /**
  71478. * Add a MeshAssetTask to the list of active tasks
  71479. * @param taskName defines the name of the new task
  71480. * @param meshesNames defines the name of meshes to load
  71481. * @param rootUrl defines the root url to use to locate files
  71482. * @param sceneFilename defines the filename of the scene file
  71483. * @returns a new MeshAssetTask object
  71484. */
  71485. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71486. /**
  71487. * Add a TextFileAssetTask to the list of active tasks
  71488. * @param taskName defines the name of the new task
  71489. * @param url defines the url of the file to load
  71490. * @returns a new TextFileAssetTask object
  71491. */
  71492. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71493. /**
  71494. * Add a BinaryFileAssetTask to the list of active tasks
  71495. * @param taskName defines the name of the new task
  71496. * @param url defines the url of the file to load
  71497. * @returns a new BinaryFileAssetTask object
  71498. */
  71499. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71500. /**
  71501. * Add a ImageAssetTask to the list of active tasks
  71502. * @param taskName defines the name of the new task
  71503. * @param url defines the url of the file to load
  71504. * @returns a new ImageAssetTask object
  71505. */
  71506. addImageTask(taskName: string, url: string): ImageAssetTask;
  71507. /**
  71508. * Add a TextureAssetTask to the list of active tasks
  71509. * @param taskName defines the name of the new task
  71510. * @param url defines the url of the file to load
  71511. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71512. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71513. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71514. * @returns a new TextureAssetTask object
  71515. */
  71516. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71517. /**
  71518. * Add a CubeTextureAssetTask to the list of active tasks
  71519. * @param taskName defines the name of the new task
  71520. * @param url defines the url of the file to load
  71521. * @param extensions defines the extension to use to load the cube map (can be null)
  71522. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71523. * @param files defines the list of files to load (can be null)
  71524. * @returns a new CubeTextureAssetTask object
  71525. */
  71526. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71527. /**
  71528. *
  71529. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71530. * @param taskName defines the name of the new task
  71531. * @param url defines the url of the file to load
  71532. * @param size defines the size you want for the cubemap (can be null)
  71533. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71534. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71535. * @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)
  71536. * @param reserved Internal use only
  71537. * @returns a new HDRCubeTextureAssetTask object
  71538. */
  71539. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71540. /**
  71541. *
  71542. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71543. * @param taskName defines the name of the new task
  71544. * @param url defines the url of the file to load
  71545. * @param size defines the size you want for the cubemap (can be null)
  71546. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71547. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71548. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71549. * @returns a new EquiRectangularCubeTextureAssetTask object
  71550. */
  71551. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71552. /**
  71553. * Remove a task from the assets manager.
  71554. * @param task the task to remove
  71555. */
  71556. removeTask(task: AbstractAssetTask): void;
  71557. private _decreaseWaitingTasksCount;
  71558. private _runTask;
  71559. /**
  71560. * Reset the AssetsManager and remove all tasks
  71561. * @return the current instance of the AssetsManager
  71562. */
  71563. reset(): AssetsManager;
  71564. /**
  71565. * Start the loading process
  71566. * @return the current instance of the AssetsManager
  71567. */
  71568. load(): AssetsManager;
  71569. /**
  71570. * Start the loading process as an async operation
  71571. * @return a promise returning the list of failed tasks
  71572. */
  71573. loadAsync(): Promise<void>;
  71574. }
  71575. }
  71576. declare module "babylonjs/Misc/deferred" {
  71577. /**
  71578. * Wrapper class for promise with external resolve and reject.
  71579. */
  71580. export class Deferred<T> {
  71581. /**
  71582. * The promise associated with this deferred object.
  71583. */
  71584. readonly promise: Promise<T>;
  71585. private _resolve;
  71586. private _reject;
  71587. /**
  71588. * The resolve method of the promise associated with this deferred object.
  71589. */
  71590. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71591. /**
  71592. * The reject method of the promise associated with this deferred object.
  71593. */
  71594. get reject(): (reason?: any) => void;
  71595. /**
  71596. * Constructor for this deferred object.
  71597. */
  71598. constructor();
  71599. }
  71600. }
  71601. declare module "babylonjs/Misc/meshExploder" {
  71602. import { Mesh } from "babylonjs/Meshes/mesh";
  71603. /**
  71604. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71605. */
  71606. export class MeshExploder {
  71607. private _centerMesh;
  71608. private _meshes;
  71609. private _meshesOrigins;
  71610. private _toCenterVectors;
  71611. private _scaledDirection;
  71612. private _newPosition;
  71613. private _centerPosition;
  71614. /**
  71615. * Explodes meshes from a center mesh.
  71616. * @param meshes The meshes to explode.
  71617. * @param centerMesh The mesh to be center of explosion.
  71618. */
  71619. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71620. private _setCenterMesh;
  71621. /**
  71622. * Get class name
  71623. * @returns "MeshExploder"
  71624. */
  71625. getClassName(): string;
  71626. /**
  71627. * "Exploded meshes"
  71628. * @returns Array of meshes with the centerMesh at index 0.
  71629. */
  71630. getMeshes(): Array<Mesh>;
  71631. /**
  71632. * Explodes meshes giving a specific direction
  71633. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71634. */
  71635. explode(direction?: number): void;
  71636. }
  71637. }
  71638. declare module "babylonjs/Misc/filesInput" {
  71639. import { Engine } from "babylonjs/Engines/engine";
  71640. import { Scene } from "babylonjs/scene";
  71641. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71642. /**
  71643. * Class used to help managing file picking and drag'n'drop
  71644. */
  71645. export class FilesInput {
  71646. /**
  71647. * List of files ready to be loaded
  71648. */
  71649. static get FilesToLoad(): {
  71650. [key: string]: File;
  71651. };
  71652. /**
  71653. * Callback called when a file is processed
  71654. */
  71655. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71656. private _engine;
  71657. private _currentScene;
  71658. private _sceneLoadedCallback;
  71659. private _progressCallback;
  71660. private _additionalRenderLoopLogicCallback;
  71661. private _textureLoadingCallback;
  71662. private _startingProcessingFilesCallback;
  71663. private _onReloadCallback;
  71664. private _errorCallback;
  71665. private _elementToMonitor;
  71666. private _sceneFileToLoad;
  71667. private _filesToLoad;
  71668. /**
  71669. * Creates a new FilesInput
  71670. * @param engine defines the rendering engine
  71671. * @param scene defines the hosting scene
  71672. * @param sceneLoadedCallback callback called when scene is loaded
  71673. * @param progressCallback callback called to track progress
  71674. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71675. * @param textureLoadingCallback callback called when a texture is loading
  71676. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71677. * @param onReloadCallback callback called when a reload is requested
  71678. * @param errorCallback callback call if an error occurs
  71679. */
  71680. 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);
  71681. private _dragEnterHandler;
  71682. private _dragOverHandler;
  71683. private _dropHandler;
  71684. /**
  71685. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71686. * @param elementToMonitor defines the DOM element to track
  71687. */
  71688. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71689. /**
  71690. * Release all associated resources
  71691. */
  71692. dispose(): void;
  71693. private renderFunction;
  71694. private drag;
  71695. private drop;
  71696. private _traverseFolder;
  71697. private _processFiles;
  71698. /**
  71699. * Load files from a drop event
  71700. * @param event defines the drop event to use as source
  71701. */
  71702. loadFiles(event: any): void;
  71703. private _processReload;
  71704. /**
  71705. * Reload the current scene from the loaded files
  71706. */
  71707. reload(): void;
  71708. }
  71709. }
  71710. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71711. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71712. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71713. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71714. }
  71715. declare module "babylonjs/Misc/sceneOptimizer" {
  71716. import { Scene, IDisposable } from "babylonjs/scene";
  71717. import { Observable } from "babylonjs/Misc/observable";
  71718. /**
  71719. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71720. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71721. */
  71722. export class SceneOptimization {
  71723. /**
  71724. * Defines the priority of this optimization (0 by default which means first in the list)
  71725. */
  71726. priority: number;
  71727. /**
  71728. * Gets a string describing the action executed by the current optimization
  71729. * @returns description string
  71730. */
  71731. getDescription(): string;
  71732. /**
  71733. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71734. * @param scene defines the current scene where to apply this optimization
  71735. * @param optimizer defines the current optimizer
  71736. * @returns true if everything that can be done was applied
  71737. */
  71738. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71739. /**
  71740. * Creates the SceneOptimization object
  71741. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71742. * @param desc defines the description associated with the optimization
  71743. */
  71744. constructor(
  71745. /**
  71746. * Defines the priority of this optimization (0 by default which means first in the list)
  71747. */
  71748. priority?: number);
  71749. }
  71750. /**
  71751. * Defines an optimization used to reduce the size of render target textures
  71752. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71753. */
  71754. export class TextureOptimization extends SceneOptimization {
  71755. /**
  71756. * Defines the priority of this optimization (0 by default which means first in the list)
  71757. */
  71758. priority: number;
  71759. /**
  71760. * 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
  71761. */
  71762. maximumSize: number;
  71763. /**
  71764. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71765. */
  71766. step: number;
  71767. /**
  71768. * Gets a string describing the action executed by the current optimization
  71769. * @returns description string
  71770. */
  71771. getDescription(): string;
  71772. /**
  71773. * Creates the TextureOptimization object
  71774. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71775. * @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
  71776. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71777. */
  71778. constructor(
  71779. /**
  71780. * Defines the priority of this optimization (0 by default which means first in the list)
  71781. */
  71782. priority?: number,
  71783. /**
  71784. * 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
  71785. */
  71786. maximumSize?: number,
  71787. /**
  71788. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71789. */
  71790. step?: number);
  71791. /**
  71792. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71793. * @param scene defines the current scene where to apply this optimization
  71794. * @param optimizer defines the current optimizer
  71795. * @returns true if everything that can be done was applied
  71796. */
  71797. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71798. }
  71799. /**
  71800. * Defines an optimization used to increase or decrease the rendering resolution
  71801. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71802. */
  71803. export class HardwareScalingOptimization extends SceneOptimization {
  71804. /**
  71805. * Defines the priority of this optimization (0 by default which means first in the list)
  71806. */
  71807. priority: number;
  71808. /**
  71809. * Defines the maximum scale to use (2 by default)
  71810. */
  71811. maximumScale: number;
  71812. /**
  71813. * Defines the step to use between two passes (0.5 by default)
  71814. */
  71815. step: number;
  71816. private _currentScale;
  71817. private _directionOffset;
  71818. /**
  71819. * Gets a string describing the action executed by the current optimization
  71820. * @return description string
  71821. */
  71822. getDescription(): string;
  71823. /**
  71824. * Creates the HardwareScalingOptimization object
  71825. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71826. * @param maximumScale defines the maximum scale to use (2 by default)
  71827. * @param step defines the step to use between two passes (0.5 by default)
  71828. */
  71829. constructor(
  71830. /**
  71831. * Defines the priority of this optimization (0 by default which means first in the list)
  71832. */
  71833. priority?: number,
  71834. /**
  71835. * Defines the maximum scale to use (2 by default)
  71836. */
  71837. maximumScale?: number,
  71838. /**
  71839. * Defines the step to use between two passes (0.5 by default)
  71840. */
  71841. step?: number);
  71842. /**
  71843. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71844. * @param scene defines the current scene where to apply this optimization
  71845. * @param optimizer defines the current optimizer
  71846. * @returns true if everything that can be done was applied
  71847. */
  71848. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71849. }
  71850. /**
  71851. * Defines an optimization used to remove shadows
  71852. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71853. */
  71854. export class ShadowsOptimization extends SceneOptimization {
  71855. /**
  71856. * Gets a string describing the action executed by the current optimization
  71857. * @return description string
  71858. */
  71859. getDescription(): string;
  71860. /**
  71861. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71862. * @param scene defines the current scene where to apply this optimization
  71863. * @param optimizer defines the current optimizer
  71864. * @returns true if everything that can be done was applied
  71865. */
  71866. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71867. }
  71868. /**
  71869. * Defines an optimization used to turn post-processes off
  71870. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71871. */
  71872. export class PostProcessesOptimization extends SceneOptimization {
  71873. /**
  71874. * Gets a string describing the action executed by the current optimization
  71875. * @return description string
  71876. */
  71877. getDescription(): string;
  71878. /**
  71879. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71880. * @param scene defines the current scene where to apply this optimization
  71881. * @param optimizer defines the current optimizer
  71882. * @returns true if everything that can be done was applied
  71883. */
  71884. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71885. }
  71886. /**
  71887. * Defines an optimization used to turn lens flares off
  71888. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71889. */
  71890. export class LensFlaresOptimization extends SceneOptimization {
  71891. /**
  71892. * Gets a string describing the action executed by the current optimization
  71893. * @return description string
  71894. */
  71895. getDescription(): string;
  71896. /**
  71897. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71898. * @param scene defines the current scene where to apply this optimization
  71899. * @param optimizer defines the current optimizer
  71900. * @returns true if everything that can be done was applied
  71901. */
  71902. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71903. }
  71904. /**
  71905. * Defines an optimization based on user defined callback.
  71906. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71907. */
  71908. export class CustomOptimization extends SceneOptimization {
  71909. /**
  71910. * Callback called to apply the custom optimization.
  71911. */
  71912. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71913. /**
  71914. * Callback called to get custom description
  71915. */
  71916. onGetDescription: () => string;
  71917. /**
  71918. * Gets a string describing the action executed by the current optimization
  71919. * @returns description string
  71920. */
  71921. getDescription(): string;
  71922. /**
  71923. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71924. * @param scene defines the current scene where to apply this optimization
  71925. * @param optimizer defines the current optimizer
  71926. * @returns true if everything that can be done was applied
  71927. */
  71928. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71929. }
  71930. /**
  71931. * Defines an optimization used to turn particles off
  71932. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71933. */
  71934. export class ParticlesOptimization extends SceneOptimization {
  71935. /**
  71936. * Gets a string describing the action executed by the current optimization
  71937. * @return description string
  71938. */
  71939. getDescription(): string;
  71940. /**
  71941. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71942. * @param scene defines the current scene where to apply this optimization
  71943. * @param optimizer defines the current optimizer
  71944. * @returns true if everything that can be done was applied
  71945. */
  71946. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71947. }
  71948. /**
  71949. * Defines an optimization used to turn render targets off
  71950. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71951. */
  71952. export class RenderTargetsOptimization extends SceneOptimization {
  71953. /**
  71954. * Gets a string describing the action executed by the current optimization
  71955. * @return description string
  71956. */
  71957. getDescription(): string;
  71958. /**
  71959. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71960. * @param scene defines the current scene where to apply this optimization
  71961. * @param optimizer defines the current optimizer
  71962. * @returns true if everything that can be done was applied
  71963. */
  71964. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71965. }
  71966. /**
  71967. * Defines an optimization used to merge meshes with compatible materials
  71968. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71969. */
  71970. export class MergeMeshesOptimization extends SceneOptimization {
  71971. private static _UpdateSelectionTree;
  71972. /**
  71973. * Gets or sets a boolean which defines if optimization octree has to be updated
  71974. */
  71975. static get UpdateSelectionTree(): boolean;
  71976. /**
  71977. * Gets or sets a boolean which defines if optimization octree has to be updated
  71978. */
  71979. static set UpdateSelectionTree(value: boolean);
  71980. /**
  71981. * Gets a string describing the action executed by the current optimization
  71982. * @return description string
  71983. */
  71984. getDescription(): string;
  71985. private _canBeMerged;
  71986. /**
  71987. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71988. * @param scene defines the current scene where to apply this optimization
  71989. * @param optimizer defines the current optimizer
  71990. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71991. * @returns true if everything that can be done was applied
  71992. */
  71993. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71994. }
  71995. /**
  71996. * Defines a list of options used by SceneOptimizer
  71997. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71998. */
  71999. export class SceneOptimizerOptions {
  72000. /**
  72001. * Defines the target frame rate to reach (60 by default)
  72002. */
  72003. targetFrameRate: number;
  72004. /**
  72005. * Defines the interval between two checkes (2000ms by default)
  72006. */
  72007. trackerDuration: number;
  72008. /**
  72009. * Gets the list of optimizations to apply
  72010. */
  72011. optimizations: SceneOptimization[];
  72012. /**
  72013. * Creates a new list of options used by SceneOptimizer
  72014. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72015. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72016. */
  72017. constructor(
  72018. /**
  72019. * Defines the target frame rate to reach (60 by default)
  72020. */
  72021. targetFrameRate?: number,
  72022. /**
  72023. * Defines the interval between two checkes (2000ms by default)
  72024. */
  72025. trackerDuration?: number);
  72026. /**
  72027. * Add a new optimization
  72028. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72029. * @returns the current SceneOptimizerOptions
  72030. */
  72031. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72032. /**
  72033. * Add a new custom optimization
  72034. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72035. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72036. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72037. * @returns the current SceneOptimizerOptions
  72038. */
  72039. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72040. /**
  72041. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72042. * @param targetFrameRate defines the target frame rate (60 by default)
  72043. * @returns a SceneOptimizerOptions object
  72044. */
  72045. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72046. /**
  72047. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72048. * @param targetFrameRate defines the target frame rate (60 by default)
  72049. * @returns a SceneOptimizerOptions object
  72050. */
  72051. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72052. /**
  72053. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72054. * @param targetFrameRate defines the target frame rate (60 by default)
  72055. * @returns a SceneOptimizerOptions object
  72056. */
  72057. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72058. }
  72059. /**
  72060. * Class used to run optimizations in order to reach a target frame rate
  72061. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72062. */
  72063. export class SceneOptimizer implements IDisposable {
  72064. private _isRunning;
  72065. private _options;
  72066. private _scene;
  72067. private _currentPriorityLevel;
  72068. private _targetFrameRate;
  72069. private _trackerDuration;
  72070. private _currentFrameRate;
  72071. private _sceneDisposeObserver;
  72072. private _improvementMode;
  72073. /**
  72074. * Defines an observable called when the optimizer reaches the target frame rate
  72075. */
  72076. onSuccessObservable: Observable<SceneOptimizer>;
  72077. /**
  72078. * Defines an observable called when the optimizer enables an optimization
  72079. */
  72080. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72081. /**
  72082. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72083. */
  72084. onFailureObservable: Observable<SceneOptimizer>;
  72085. /**
  72086. * Gets a boolean indicating if the optimizer is in improvement mode
  72087. */
  72088. get isInImprovementMode(): boolean;
  72089. /**
  72090. * Gets the current priority level (0 at start)
  72091. */
  72092. get currentPriorityLevel(): number;
  72093. /**
  72094. * Gets the current frame rate checked by the SceneOptimizer
  72095. */
  72096. get currentFrameRate(): number;
  72097. /**
  72098. * Gets or sets the current target frame rate (60 by default)
  72099. */
  72100. get targetFrameRate(): number;
  72101. /**
  72102. * Gets or sets the current target frame rate (60 by default)
  72103. */
  72104. set targetFrameRate(value: number);
  72105. /**
  72106. * Gets or sets the current interval between two checks (every 2000ms by default)
  72107. */
  72108. get trackerDuration(): number;
  72109. /**
  72110. * Gets or sets the current interval between two checks (every 2000ms by default)
  72111. */
  72112. set trackerDuration(value: number);
  72113. /**
  72114. * Gets the list of active optimizations
  72115. */
  72116. get optimizations(): SceneOptimization[];
  72117. /**
  72118. * Creates a new SceneOptimizer
  72119. * @param scene defines the scene to work on
  72120. * @param options defines the options to use with the SceneOptimizer
  72121. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72122. * @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)
  72123. */
  72124. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72125. /**
  72126. * Stops the current optimizer
  72127. */
  72128. stop(): void;
  72129. /**
  72130. * Reset the optimizer to initial step (current priority level = 0)
  72131. */
  72132. reset(): void;
  72133. /**
  72134. * Start the optimizer. By default it will try to reach a specific framerate
  72135. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72136. */
  72137. start(): void;
  72138. private _checkCurrentState;
  72139. /**
  72140. * Release all resources
  72141. */
  72142. dispose(): void;
  72143. /**
  72144. * Helper function to create a SceneOptimizer with one single line of code
  72145. * @param scene defines the scene to work on
  72146. * @param options defines the options to use with the SceneOptimizer
  72147. * @param onSuccess defines a callback to call on success
  72148. * @param onFailure defines a callback to call on failure
  72149. * @returns the new SceneOptimizer object
  72150. */
  72151. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72152. }
  72153. }
  72154. declare module "babylonjs/Misc/sceneSerializer" {
  72155. import { Scene } from "babylonjs/scene";
  72156. /**
  72157. * Class used to serialize a scene into a string
  72158. */
  72159. export class SceneSerializer {
  72160. /**
  72161. * Clear cache used by a previous serialization
  72162. */
  72163. static ClearCache(): void;
  72164. /**
  72165. * Serialize a scene into a JSON compatible object
  72166. * @param scene defines the scene to serialize
  72167. * @returns a JSON compatible object
  72168. */
  72169. static Serialize(scene: Scene): any;
  72170. /**
  72171. * Serialize a mesh into a JSON compatible object
  72172. * @param toSerialize defines the mesh to serialize
  72173. * @param withParents defines if parents must be serialized as well
  72174. * @param withChildren defines if children must be serialized as well
  72175. * @returns a JSON compatible object
  72176. */
  72177. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72178. }
  72179. }
  72180. declare module "babylonjs/Misc/textureTools" {
  72181. import { Texture } from "babylonjs/Materials/Textures/texture";
  72182. /**
  72183. * Class used to host texture specific utilities
  72184. */
  72185. export class TextureTools {
  72186. /**
  72187. * Uses the GPU to create a copy texture rescaled at a given size
  72188. * @param texture Texture to copy from
  72189. * @param width defines the desired width
  72190. * @param height defines the desired height
  72191. * @param useBilinearMode defines if bilinear mode has to be used
  72192. * @return the generated texture
  72193. */
  72194. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72195. }
  72196. }
  72197. declare module "babylonjs/Misc/videoRecorder" {
  72198. import { Nullable } from "babylonjs/types";
  72199. import { Engine } from "babylonjs/Engines/engine";
  72200. /**
  72201. * This represents the different options available for the video capture.
  72202. */
  72203. export interface VideoRecorderOptions {
  72204. /** Defines the mime type of the video. */
  72205. mimeType: string;
  72206. /** Defines the FPS the video should be recorded at. */
  72207. fps: number;
  72208. /** Defines the chunk size for the recording data. */
  72209. recordChunckSize: number;
  72210. /** The audio tracks to attach to the recording. */
  72211. audioTracks?: MediaStreamTrack[];
  72212. }
  72213. /**
  72214. * This can help with recording videos from BabylonJS.
  72215. * This is based on the available WebRTC functionalities of the browser.
  72216. *
  72217. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72218. */
  72219. export class VideoRecorder {
  72220. private static readonly _defaultOptions;
  72221. /**
  72222. * Returns whether or not the VideoRecorder is available in your browser.
  72223. * @param engine Defines the Babylon Engine.
  72224. * @returns true if supported otherwise false.
  72225. */
  72226. static IsSupported(engine: Engine): boolean;
  72227. private readonly _options;
  72228. private _canvas;
  72229. private _mediaRecorder;
  72230. private _recordedChunks;
  72231. private _fileName;
  72232. private _resolve;
  72233. private _reject;
  72234. /**
  72235. * True when a recording is already in progress.
  72236. */
  72237. get isRecording(): boolean;
  72238. /**
  72239. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72240. * @param engine Defines the BabylonJS Engine you wish to record.
  72241. * @param options Defines options that can be used to customize the capture.
  72242. */
  72243. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72244. /**
  72245. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72246. */
  72247. stopRecording(): void;
  72248. /**
  72249. * Starts recording the canvas for a max duration specified in parameters.
  72250. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72251. * If null no automatic download will start and you can rely on the promise to get the data back.
  72252. * @param maxDuration Defines the maximum recording time in seconds.
  72253. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72254. * @return A promise callback at the end of the recording with the video data in Blob.
  72255. */
  72256. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72257. /**
  72258. * Releases internal resources used during the recording.
  72259. */
  72260. dispose(): void;
  72261. private _handleDataAvailable;
  72262. private _handleError;
  72263. private _handleStop;
  72264. }
  72265. }
  72266. declare module "babylonjs/Misc/screenshotTools" {
  72267. import { Camera } from "babylonjs/Cameras/camera";
  72268. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72269. import { Engine } from "babylonjs/Engines/engine";
  72270. /**
  72271. * Class containing a set of static utilities functions for screenshots
  72272. */
  72273. export class ScreenshotTools {
  72274. /**
  72275. * Captures a screenshot of the current rendering
  72276. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72277. * @param engine defines the rendering engine
  72278. * @param camera defines the source camera
  72279. * @param size This parameter can be set to a single number or to an object with the
  72280. * following (optional) properties: precision, width, height. If a single number is passed,
  72281. * it will be used for both width and height. If an object is passed, the screenshot size
  72282. * will be derived from the parameters. The precision property is a multiplier allowing
  72283. * rendering at a higher or lower resolution
  72284. * @param successCallback defines the callback receives a single parameter which contains the
  72285. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72286. * src parameter of an <img> to display it
  72287. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72288. * Check your browser for supported MIME types
  72289. */
  72290. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72291. /**
  72292. * Captures a screenshot of the current rendering
  72293. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72294. * @param engine defines the rendering engine
  72295. * @param camera defines the source camera
  72296. * @param size This parameter can be set to a single number or to an object with the
  72297. * following (optional) properties: precision, width, height. If a single number is passed,
  72298. * it will be used for both width and height. If an object is passed, the screenshot size
  72299. * will be derived from the parameters. The precision property is a multiplier allowing
  72300. * rendering at a higher or lower resolution
  72301. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72302. * Check your browser for supported MIME types
  72303. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72304. * to the src parameter of an <img> to display it
  72305. */
  72306. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72307. /**
  72308. * Generates an image screenshot from the specified camera.
  72309. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72310. * @param engine The engine to use for rendering
  72311. * @param camera The camera to use for rendering
  72312. * @param size This parameter can be set to a single number or to an object with the
  72313. * following (optional) properties: precision, width, height. If a single number is passed,
  72314. * it will be used for both width and height. If an object is passed, the screenshot size
  72315. * will be derived from the parameters. The precision property is a multiplier allowing
  72316. * rendering at a higher or lower resolution
  72317. * @param successCallback The callback receives a single parameter which contains the
  72318. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72319. * src parameter of an <img> to display it
  72320. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72321. * Check your browser for supported MIME types
  72322. * @param samples Texture samples (default: 1)
  72323. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72324. * @param fileName A name for for the downloaded file.
  72325. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72326. */
  72327. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72328. /**
  72329. * Generates an image screenshot from the specified camera.
  72330. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72331. * @param engine The engine to use for rendering
  72332. * @param camera The camera to use for rendering
  72333. * @param size This parameter can be set to a single number or to an object with the
  72334. * following (optional) properties: precision, width, height. If a single number is passed,
  72335. * it will be used for both width and height. If an object is passed, the screenshot size
  72336. * will be derived from the parameters. The precision property is a multiplier allowing
  72337. * rendering at a higher or lower resolution
  72338. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72339. * Check your browser for supported MIME types
  72340. * @param samples Texture samples (default: 1)
  72341. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72342. * @param fileName A name for for the downloaded file.
  72343. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72344. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72345. * to the src parameter of an <img> to display it
  72346. */
  72347. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72348. /**
  72349. * Gets height and width for screenshot size
  72350. * @private
  72351. */
  72352. private static _getScreenshotSize;
  72353. }
  72354. }
  72355. declare module "babylonjs/Misc/dataReader" {
  72356. /**
  72357. * Interface for a data buffer
  72358. */
  72359. export interface IDataBuffer {
  72360. /**
  72361. * Reads bytes from the data buffer.
  72362. * @param byteOffset The byte offset to read
  72363. * @param byteLength The byte length to read
  72364. * @returns A promise that resolves when the bytes are read
  72365. */
  72366. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72367. /**
  72368. * The byte length of the buffer.
  72369. */
  72370. readonly byteLength: number;
  72371. }
  72372. /**
  72373. * Utility class for reading from a data buffer
  72374. */
  72375. export class DataReader {
  72376. /**
  72377. * The data buffer associated with this data reader.
  72378. */
  72379. readonly buffer: IDataBuffer;
  72380. /**
  72381. * The current byte offset from the beginning of the data buffer.
  72382. */
  72383. byteOffset: number;
  72384. private _dataView;
  72385. private _dataByteOffset;
  72386. /**
  72387. * Constructor
  72388. * @param buffer The buffer to read
  72389. */
  72390. constructor(buffer: IDataBuffer);
  72391. /**
  72392. * Loads the given byte length.
  72393. * @param byteLength The byte length to load
  72394. * @returns A promise that resolves when the load is complete
  72395. */
  72396. loadAsync(byteLength: number): Promise<void>;
  72397. /**
  72398. * Read a unsigned 32-bit integer from the currently loaded data range.
  72399. * @returns The 32-bit integer read
  72400. */
  72401. readUint32(): number;
  72402. /**
  72403. * Read a byte array from the currently loaded data range.
  72404. * @param byteLength The byte length to read
  72405. * @returns The byte array read
  72406. */
  72407. readUint8Array(byteLength: number): Uint8Array;
  72408. /**
  72409. * Read a string from the currently loaded data range.
  72410. * @param byteLength The byte length to read
  72411. * @returns The string read
  72412. */
  72413. readString(byteLength: number): string;
  72414. /**
  72415. * Skips the given byte length the currently loaded data range.
  72416. * @param byteLength The byte length to skip
  72417. */
  72418. skipBytes(byteLength: number): void;
  72419. }
  72420. }
  72421. declare module "babylonjs/Misc/dataStorage" {
  72422. /**
  72423. * Class for storing data to local storage if available or in-memory storage otherwise
  72424. */
  72425. export class DataStorage {
  72426. private static _Storage;
  72427. private static _GetStorage;
  72428. /**
  72429. * Reads a string from the data storage
  72430. * @param key The key to read
  72431. * @param defaultValue The value if the key doesn't exist
  72432. * @returns The string value
  72433. */
  72434. static ReadString(key: string, defaultValue: string): string;
  72435. /**
  72436. * Writes a string to the data storage
  72437. * @param key The key to write
  72438. * @param value The value to write
  72439. */
  72440. static WriteString(key: string, value: string): void;
  72441. /**
  72442. * Reads a boolean from the data storage
  72443. * @param key The key to read
  72444. * @param defaultValue The value if the key doesn't exist
  72445. * @returns The boolean value
  72446. */
  72447. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72448. /**
  72449. * Writes a boolean to the data storage
  72450. * @param key The key to write
  72451. * @param value The value to write
  72452. */
  72453. static WriteBoolean(key: string, value: boolean): void;
  72454. /**
  72455. * Reads a number from the data storage
  72456. * @param key The key to read
  72457. * @param defaultValue The value if the key doesn't exist
  72458. * @returns The number value
  72459. */
  72460. static ReadNumber(key: string, defaultValue: number): number;
  72461. /**
  72462. * Writes a number to the data storage
  72463. * @param key The key to write
  72464. * @param value The value to write
  72465. */
  72466. static WriteNumber(key: string, value: number): void;
  72467. }
  72468. }
  72469. declare module "babylonjs/Misc/index" {
  72470. export * from "babylonjs/Misc/andOrNotEvaluator";
  72471. export * from "babylonjs/Misc/assetsManager";
  72472. export * from "babylonjs/Misc/basis";
  72473. export * from "babylonjs/Misc/dds";
  72474. export * from "babylonjs/Misc/decorators";
  72475. export * from "babylonjs/Misc/deferred";
  72476. export * from "babylonjs/Misc/environmentTextureTools";
  72477. export * from "babylonjs/Misc/meshExploder";
  72478. export * from "babylonjs/Misc/filesInput";
  72479. export * from "babylonjs/Misc/HighDynamicRange/index";
  72480. export * from "babylonjs/Misc/khronosTextureContainer";
  72481. export * from "babylonjs/Misc/observable";
  72482. export * from "babylonjs/Misc/performanceMonitor";
  72483. export * from "babylonjs/Misc/promise";
  72484. export * from "babylonjs/Misc/sceneOptimizer";
  72485. export * from "babylonjs/Misc/sceneSerializer";
  72486. export * from "babylonjs/Misc/smartArray";
  72487. export * from "babylonjs/Misc/stringDictionary";
  72488. export * from "babylonjs/Misc/tags";
  72489. export * from "babylonjs/Misc/textureTools";
  72490. export * from "babylonjs/Misc/tga";
  72491. export * from "babylonjs/Misc/tools";
  72492. export * from "babylonjs/Misc/videoRecorder";
  72493. export * from "babylonjs/Misc/virtualJoystick";
  72494. export * from "babylonjs/Misc/workerPool";
  72495. export * from "babylonjs/Misc/logger";
  72496. export * from "babylonjs/Misc/typeStore";
  72497. export * from "babylonjs/Misc/filesInputStore";
  72498. export * from "babylonjs/Misc/deepCopier";
  72499. export * from "babylonjs/Misc/pivotTools";
  72500. export * from "babylonjs/Misc/precisionDate";
  72501. export * from "babylonjs/Misc/screenshotTools";
  72502. export * from "babylonjs/Misc/typeStore";
  72503. export * from "babylonjs/Misc/webRequest";
  72504. export * from "babylonjs/Misc/iInspectable";
  72505. export * from "babylonjs/Misc/brdfTextureTools";
  72506. export * from "babylonjs/Misc/rgbdTextureTools";
  72507. export * from "babylonjs/Misc/gradients";
  72508. export * from "babylonjs/Misc/perfCounter";
  72509. export * from "babylonjs/Misc/fileRequest";
  72510. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72511. export * from "babylonjs/Misc/retryStrategy";
  72512. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72513. export * from "babylonjs/Misc/canvasGenerator";
  72514. export * from "babylonjs/Misc/fileTools";
  72515. export * from "babylonjs/Misc/stringTools";
  72516. export * from "babylonjs/Misc/dataReader";
  72517. export * from "babylonjs/Misc/minMaxReducer";
  72518. export * from "babylonjs/Misc/depthReducer";
  72519. export * from "babylonjs/Misc/dataStorage";
  72520. }
  72521. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72522. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72523. import { Observable } from "babylonjs/Misc/observable";
  72524. import { Matrix } from "babylonjs/Maths/math.vector";
  72525. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72526. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72527. /**
  72528. * Options used for hit testing
  72529. */
  72530. export interface IWebXRHitTestOptions {
  72531. /**
  72532. * Only test when user interacted with the scene. Default - hit test every frame
  72533. */
  72534. testOnPointerDownOnly?: boolean;
  72535. /**
  72536. * The node to use to transform the local results to world coordinates
  72537. */
  72538. worldParentNode?: TransformNode;
  72539. }
  72540. /**
  72541. * Interface defining the babylon result of raycasting/hit-test
  72542. */
  72543. export interface IWebXRHitResult {
  72544. /**
  72545. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72546. */
  72547. transformationMatrix: Matrix;
  72548. /**
  72549. * The native hit test result
  72550. */
  72551. xrHitResult: XRHitResult;
  72552. }
  72553. /**
  72554. * The currently-working hit-test module.
  72555. * Hit test (or Ray-casting) is used to interact with the real world.
  72556. * For further information read here - https://github.com/immersive-web/hit-test
  72557. */
  72558. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72559. /**
  72560. * options to use when constructing this feature
  72561. */
  72562. readonly options: IWebXRHitTestOptions;
  72563. private _direction;
  72564. private _mat;
  72565. private _onSelectEnabled;
  72566. private _origin;
  72567. /**
  72568. * The module's name
  72569. */
  72570. static readonly Name: string;
  72571. /**
  72572. * The (Babylon) version of this module.
  72573. * This is an integer representing the implementation version.
  72574. * This number does not correspond to the WebXR specs version
  72575. */
  72576. static readonly Version: number;
  72577. /**
  72578. * Populated with the last native XR Hit Results
  72579. */
  72580. lastNativeXRHitResults: XRHitResult[];
  72581. /**
  72582. * Triggered when new babylon (transformed) hit test results are available
  72583. */
  72584. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72585. /**
  72586. * Creates a new instance of the (legacy version) hit test feature
  72587. * @param _xrSessionManager an instance of WebXRSessionManager
  72588. * @param options options to use when constructing this feature
  72589. */
  72590. constructor(_xrSessionManager: WebXRSessionManager,
  72591. /**
  72592. * options to use when constructing this feature
  72593. */
  72594. options?: IWebXRHitTestOptions);
  72595. /**
  72596. * execute a hit test with an XR Ray
  72597. *
  72598. * @param xrSession a native xrSession that will execute this hit test
  72599. * @param xrRay the ray (position and direction) to use for ray-casting
  72600. * @param referenceSpace native XR reference space to use for the hit-test
  72601. * @param filter filter function that will filter the results
  72602. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72603. */
  72604. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72605. /**
  72606. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72607. * @param event the (select) event to use to select with
  72608. * @param referenceSpace the reference space to use for this hit test
  72609. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72610. */
  72611. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72612. /**
  72613. * attach this feature
  72614. * Will usually be called by the features manager
  72615. *
  72616. * @returns true if successful.
  72617. */
  72618. attach(): boolean;
  72619. /**
  72620. * detach this feature.
  72621. * Will usually be called by the features manager
  72622. *
  72623. * @returns true if successful.
  72624. */
  72625. detach(): boolean;
  72626. /**
  72627. * Dispose this feature and all of the resources attached
  72628. */
  72629. dispose(): void;
  72630. protected _onXRFrame(frame: XRFrame): void;
  72631. private _onHitTestResults;
  72632. private _onSelect;
  72633. }
  72634. }
  72635. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72636. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72637. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72638. import { Observable } from "babylonjs/Misc/observable";
  72639. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72640. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72641. /**
  72642. * Options used in the plane detector module
  72643. */
  72644. export interface IWebXRPlaneDetectorOptions {
  72645. /**
  72646. * The node to use to transform the local results to world coordinates
  72647. */
  72648. worldParentNode?: TransformNode;
  72649. }
  72650. /**
  72651. * A babylon interface for a WebXR plane.
  72652. * A Plane is actually a polygon, built from N points in space
  72653. *
  72654. * Supported in chrome 79, not supported in canary 81 ATM
  72655. */
  72656. export interface IWebXRPlane {
  72657. /**
  72658. * a babylon-assigned ID for this polygon
  72659. */
  72660. id: number;
  72661. /**
  72662. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72663. */
  72664. polygonDefinition: Array<Vector3>;
  72665. /**
  72666. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72667. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72668. */
  72669. transformationMatrix: Matrix;
  72670. /**
  72671. * the native xr-plane object
  72672. */
  72673. xrPlane: XRPlane;
  72674. }
  72675. /**
  72676. * The plane detector is used to detect planes in the real world when in AR
  72677. * For more information see https://github.com/immersive-web/real-world-geometry/
  72678. */
  72679. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72680. private _options;
  72681. private _detectedPlanes;
  72682. private _enabled;
  72683. private _lastFrameDetected;
  72684. /**
  72685. * The module's name
  72686. */
  72687. static readonly Name: string;
  72688. /**
  72689. * The (Babylon) version of this module.
  72690. * This is an integer representing the implementation version.
  72691. * This number does not correspond to the WebXR specs version
  72692. */
  72693. static readonly Version: number;
  72694. /**
  72695. * Observers registered here will be executed when a new plane was added to the session
  72696. */
  72697. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72698. /**
  72699. * Observers registered here will be executed when a plane is no longer detected in the session
  72700. */
  72701. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72702. /**
  72703. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72704. * This can execute N times every frame
  72705. */
  72706. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72707. /**
  72708. * construct a new Plane Detector
  72709. * @param _xrSessionManager an instance of xr Session manager
  72710. * @param _options configuration to use when constructing this feature
  72711. */
  72712. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72713. /**
  72714. * Dispose this feature and all of the resources attached
  72715. */
  72716. dispose(): void;
  72717. protected _onXRFrame(frame: XRFrame): void;
  72718. private _init;
  72719. private _updatePlaneWithXRPlane;
  72720. /**
  72721. * avoiding using Array.find for global support.
  72722. * @param xrPlane the plane to find in the array
  72723. */
  72724. private findIndexInPlaneArray;
  72725. }
  72726. }
  72727. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72728. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72729. import { Observable } from "babylonjs/Misc/observable";
  72730. import { Matrix } from "babylonjs/Maths/math.vector";
  72731. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72732. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72733. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72734. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72735. /**
  72736. * Configuration options of the anchor system
  72737. */
  72738. export interface IWebXRAnchorSystemOptions {
  72739. /**
  72740. * Should a new anchor be added every time a select event is triggered
  72741. */
  72742. addAnchorOnSelect?: boolean;
  72743. /**
  72744. * should the anchor system use plane detection.
  72745. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72746. */
  72747. usePlaneDetection?: boolean;
  72748. /**
  72749. * a node that will be used to convert local to world coordinates
  72750. */
  72751. worldParentNode?: TransformNode;
  72752. }
  72753. /**
  72754. * A babylon container for an XR Anchor
  72755. */
  72756. export interface IWebXRAnchor {
  72757. /**
  72758. * A babylon-assigned ID for this anchor
  72759. */
  72760. id: number;
  72761. /**
  72762. * Transformation matrix to apply to an object attached to this anchor
  72763. */
  72764. transformationMatrix: Matrix;
  72765. /**
  72766. * The native anchor object
  72767. */
  72768. xrAnchor: XRAnchor;
  72769. }
  72770. /**
  72771. * An implementation of the anchor system of WebXR.
  72772. * Note that the current documented implementation is not available in any browser. Future implementations
  72773. * will use the frame to create an anchor and not the session or a detected plane
  72774. * For further information see https://github.com/immersive-web/anchors/
  72775. */
  72776. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72777. private _options;
  72778. private _enabled;
  72779. private _hitTestModule;
  72780. private _lastFrameDetected;
  72781. private _onSelect;
  72782. private _planeDetector;
  72783. private _trackedAnchors;
  72784. /**
  72785. * The module's name
  72786. */
  72787. static readonly Name: string;
  72788. /**
  72789. * The (Babylon) version of this module.
  72790. * This is an integer representing the implementation version.
  72791. * This number does not correspond to the WebXR specs version
  72792. */
  72793. static readonly Version: number;
  72794. /**
  72795. * Observers registered here will be executed when a new anchor was added to the session
  72796. */
  72797. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72798. /**
  72799. * Observers registered here will be executed when an anchor was removed from the session
  72800. */
  72801. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72802. /**
  72803. * Observers registered here will be executed when an existing anchor updates
  72804. * This can execute N times every frame
  72805. */
  72806. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72807. /**
  72808. * constructs a new anchor system
  72809. * @param _xrSessionManager an instance of WebXRSessionManager
  72810. * @param _options configuration object for this feature
  72811. */
  72812. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72813. /**
  72814. * Add anchor at a specific XR point.
  72815. *
  72816. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72817. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72818. * @returns a promise the fulfills when the anchor was created
  72819. */
  72820. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72821. /**
  72822. * attach this feature
  72823. * Will usually be called by the features manager
  72824. *
  72825. * @returns true if successful.
  72826. */
  72827. attach(): boolean;
  72828. /**
  72829. * detach this feature.
  72830. * Will usually be called by the features manager
  72831. *
  72832. * @returns true if successful.
  72833. */
  72834. detach(): boolean;
  72835. /**
  72836. * Dispose this feature and all of the resources attached
  72837. */
  72838. dispose(): void;
  72839. /**
  72840. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72841. * @param hitTestModule the hit-test module to use.
  72842. */
  72843. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72844. /**
  72845. * set the plane detector to use in order to create anchors from frames
  72846. * @param planeDetector the plane-detector module to use
  72847. * @param enable enable plane-anchors. default is true
  72848. */
  72849. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72850. protected _onXRFrame(frame: XRFrame): void;
  72851. /**
  72852. * avoiding using Array.find for global support.
  72853. * @param xrAnchor the plane to find in the array
  72854. */
  72855. private _findIndexInAnchorArray;
  72856. private _updateAnchorWithXRFrame;
  72857. }
  72858. }
  72859. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72860. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72862. import { Observable } from "babylonjs/Misc/observable";
  72863. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72864. /**
  72865. * Options interface for the background remover plugin
  72866. */
  72867. export interface IWebXRBackgroundRemoverOptions {
  72868. /**
  72869. * Further background meshes to disable when entering AR
  72870. */
  72871. backgroundMeshes?: AbstractMesh[];
  72872. /**
  72873. * flags to configure the removal of the environment helper.
  72874. * If not set, the entire background will be removed. If set, flags should be set as well.
  72875. */
  72876. environmentHelperRemovalFlags?: {
  72877. /**
  72878. * Should the skybox be removed (default false)
  72879. */
  72880. skyBox?: boolean;
  72881. /**
  72882. * Should the ground be removed (default false)
  72883. */
  72884. ground?: boolean;
  72885. };
  72886. /**
  72887. * don't disable the environment helper
  72888. */
  72889. ignoreEnvironmentHelper?: boolean;
  72890. }
  72891. /**
  72892. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72893. */
  72894. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72895. /**
  72896. * read-only options to be used in this module
  72897. */
  72898. readonly options: IWebXRBackgroundRemoverOptions;
  72899. /**
  72900. * The module's name
  72901. */
  72902. static readonly Name: string;
  72903. /**
  72904. * The (Babylon) version of this module.
  72905. * This is an integer representing the implementation version.
  72906. * This number does not correspond to the WebXR specs version
  72907. */
  72908. static readonly Version: number;
  72909. /**
  72910. * registered observers will be triggered when the background state changes
  72911. */
  72912. onBackgroundStateChangedObservable: Observable<boolean>;
  72913. /**
  72914. * constructs a new background remover module
  72915. * @param _xrSessionManager the session manager for this module
  72916. * @param options read-only options to be used in this module
  72917. */
  72918. constructor(_xrSessionManager: WebXRSessionManager,
  72919. /**
  72920. * read-only options to be used in this module
  72921. */
  72922. options?: IWebXRBackgroundRemoverOptions);
  72923. /**
  72924. * attach this feature
  72925. * Will usually be called by the features manager
  72926. *
  72927. * @returns true if successful.
  72928. */
  72929. attach(): boolean;
  72930. /**
  72931. * detach this feature.
  72932. * Will usually be called by the features manager
  72933. *
  72934. * @returns true if successful.
  72935. */
  72936. detach(): boolean;
  72937. /**
  72938. * Dispose this feature and all of the resources attached
  72939. */
  72940. dispose(): void;
  72941. protected _onXRFrame(_xrFrame: XRFrame): void;
  72942. private _setBackgroundState;
  72943. }
  72944. }
  72945. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72946. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72947. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72948. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72949. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72950. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72951. import { Nullable } from "babylonjs/types";
  72952. /**
  72953. * Options for the controller physics feature
  72954. */
  72955. export class IWebXRControllerPhysicsOptions {
  72956. /**
  72957. * Should the headset get its own impostor
  72958. */
  72959. enableHeadsetImpostor?: boolean;
  72960. /**
  72961. * Optional parameters for the headset impostor
  72962. */
  72963. headsetImpostorParams?: {
  72964. /**
  72965. * The type of impostor to create. Default is sphere
  72966. */
  72967. impostorType: number;
  72968. /**
  72969. * the size of the impostor. Defaults to 10cm
  72970. */
  72971. impostorSize?: number | {
  72972. width: number;
  72973. height: number;
  72974. depth: number;
  72975. };
  72976. /**
  72977. * Friction definitions
  72978. */
  72979. friction?: number;
  72980. /**
  72981. * Restitution
  72982. */
  72983. restitution?: number;
  72984. };
  72985. /**
  72986. * The physics properties of the future impostors
  72987. */
  72988. physicsProperties?: {
  72989. /**
  72990. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72991. * Note that this requires a physics engine that supports mesh impostors!
  72992. */
  72993. useControllerMesh?: boolean;
  72994. /**
  72995. * The type of impostor to create. Default is sphere
  72996. */
  72997. impostorType?: number;
  72998. /**
  72999. * the size of the impostor. Defaults to 10cm
  73000. */
  73001. impostorSize?: number | {
  73002. width: number;
  73003. height: number;
  73004. depth: number;
  73005. };
  73006. /**
  73007. * Friction definitions
  73008. */
  73009. friction?: number;
  73010. /**
  73011. * Restitution
  73012. */
  73013. restitution?: number;
  73014. };
  73015. /**
  73016. * the xr input to use with this pointer selection
  73017. */
  73018. xrInput: WebXRInput;
  73019. }
  73020. /**
  73021. * Add physics impostor to your webxr controllers,
  73022. * including naive calculation of their linear and angular velocity
  73023. */
  73024. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73025. private readonly _options;
  73026. private _attachController;
  73027. private _controllers;
  73028. private _debugMode;
  73029. private _delta;
  73030. private _headsetImpostor?;
  73031. private _headsetMesh?;
  73032. private _lastTimestamp;
  73033. private _tmpQuaternion;
  73034. private _tmpVector;
  73035. /**
  73036. * The module's name
  73037. */
  73038. static readonly Name: string;
  73039. /**
  73040. * The (Babylon) version of this module.
  73041. * This is an integer representing the implementation version.
  73042. * This number does not correspond to the webxr specs version
  73043. */
  73044. static readonly Version: number;
  73045. /**
  73046. * Construct a new Controller Physics Feature
  73047. * @param _xrSessionManager the corresponding xr session manager
  73048. * @param _options options to create this feature with
  73049. */
  73050. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73051. /**
  73052. * @hidden
  73053. * enable debugging - will show console outputs and the impostor mesh
  73054. */
  73055. _enablePhysicsDebug(): void;
  73056. /**
  73057. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73058. * @param xrController the controller to add
  73059. */
  73060. addController(xrController: WebXRInputSource): void;
  73061. /**
  73062. * attach this feature
  73063. * Will usually be called by the features manager
  73064. *
  73065. * @returns true if successful.
  73066. */
  73067. attach(): boolean;
  73068. /**
  73069. * detach this feature.
  73070. * Will usually be called by the features manager
  73071. *
  73072. * @returns true if successful.
  73073. */
  73074. detach(): boolean;
  73075. /**
  73076. * Get the headset impostor, if enabled
  73077. * @returns the impostor
  73078. */
  73079. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73080. /**
  73081. * Get the physics impostor of a specific controller.
  73082. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73083. * @param controller the controller or the controller id of which to get the impostor
  73084. * @returns the impostor or null
  73085. */
  73086. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73087. /**
  73088. * Update the physics properties provided in the constructor
  73089. * @param newProperties the new properties object
  73090. */
  73091. setPhysicsProperties(newProperties: {
  73092. impostorType?: number;
  73093. impostorSize?: number | {
  73094. width: number;
  73095. height: number;
  73096. depth: number;
  73097. };
  73098. friction?: number;
  73099. restitution?: number;
  73100. }): void;
  73101. protected _onXRFrame(_xrFrame: any): void;
  73102. private _detachController;
  73103. }
  73104. }
  73105. declare module "babylonjs/XR/features/index" {
  73106. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  73107. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  73108. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  73109. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  73110. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  73111. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  73112. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  73113. }
  73114. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  73115. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73117. import { Scene } from "babylonjs/scene";
  73118. /**
  73119. * The motion controller class for all microsoft mixed reality controllers
  73120. */
  73121. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73122. protected readonly _mapping: {
  73123. defaultButton: {
  73124. "valueNodeName": string;
  73125. "unpressedNodeName": string;
  73126. "pressedNodeName": string;
  73127. };
  73128. defaultAxis: {
  73129. "valueNodeName": string;
  73130. "minNodeName": string;
  73131. "maxNodeName": string;
  73132. };
  73133. buttons: {
  73134. "xr-standard-trigger": {
  73135. "rootNodeName": string;
  73136. "componentProperty": string;
  73137. "states": string[];
  73138. };
  73139. "xr-standard-squeeze": {
  73140. "rootNodeName": string;
  73141. "componentProperty": string;
  73142. "states": string[];
  73143. };
  73144. "xr-standard-touchpad": {
  73145. "rootNodeName": string;
  73146. "labelAnchorNodeName": string;
  73147. "touchPointNodeName": string;
  73148. };
  73149. "xr-standard-thumbstick": {
  73150. "rootNodeName": string;
  73151. "componentProperty": string;
  73152. "states": string[];
  73153. };
  73154. };
  73155. axes: {
  73156. "xr-standard-touchpad": {
  73157. "x-axis": {
  73158. "rootNodeName": string;
  73159. };
  73160. "y-axis": {
  73161. "rootNodeName": string;
  73162. };
  73163. };
  73164. "xr-standard-thumbstick": {
  73165. "x-axis": {
  73166. "rootNodeName": string;
  73167. };
  73168. "y-axis": {
  73169. "rootNodeName": string;
  73170. };
  73171. };
  73172. };
  73173. };
  73174. /**
  73175. * The base url used to load the left and right controller models
  73176. */
  73177. static MODEL_BASE_URL: string;
  73178. /**
  73179. * The name of the left controller model file
  73180. */
  73181. static MODEL_LEFT_FILENAME: string;
  73182. /**
  73183. * The name of the right controller model file
  73184. */
  73185. static MODEL_RIGHT_FILENAME: string;
  73186. profileId: string;
  73187. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73188. protected _getFilenameAndPath(): {
  73189. filename: string;
  73190. path: string;
  73191. };
  73192. protected _getModelLoadingConstraints(): boolean;
  73193. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73194. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73195. protected _updateModel(): void;
  73196. }
  73197. }
  73198. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73199. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73201. import { Scene } from "babylonjs/scene";
  73202. /**
  73203. * The motion controller class for oculus touch (quest, rift).
  73204. * This class supports legacy mapping as well the standard xr mapping
  73205. */
  73206. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73207. private _forceLegacyControllers;
  73208. private _modelRootNode;
  73209. /**
  73210. * The base url used to load the left and right controller models
  73211. */
  73212. static MODEL_BASE_URL: string;
  73213. /**
  73214. * The name of the left controller model file
  73215. */
  73216. static MODEL_LEFT_FILENAME: string;
  73217. /**
  73218. * The name of the right controller model file
  73219. */
  73220. static MODEL_RIGHT_FILENAME: string;
  73221. /**
  73222. * Base Url for the Quest controller model.
  73223. */
  73224. static QUEST_MODEL_BASE_URL: string;
  73225. profileId: string;
  73226. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73227. protected _getFilenameAndPath(): {
  73228. filename: string;
  73229. path: string;
  73230. };
  73231. protected _getModelLoadingConstraints(): boolean;
  73232. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73233. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73234. protected _updateModel(): void;
  73235. /**
  73236. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73237. * between the touch and touch 2.
  73238. */
  73239. private _isQuest;
  73240. }
  73241. }
  73242. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73243. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73244. import { Scene } from "babylonjs/scene";
  73245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73246. /**
  73247. * The motion controller class for the standard HTC-Vive controllers
  73248. */
  73249. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73250. private _modelRootNode;
  73251. /**
  73252. * The base url used to load the left and right controller models
  73253. */
  73254. static MODEL_BASE_URL: string;
  73255. /**
  73256. * File name for the controller model.
  73257. */
  73258. static MODEL_FILENAME: string;
  73259. profileId: string;
  73260. /**
  73261. * Create a new Vive motion controller object
  73262. * @param scene the scene to use to create this controller
  73263. * @param gamepadObject the corresponding gamepad object
  73264. * @param handness the handness of the controller
  73265. */
  73266. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73267. protected _getFilenameAndPath(): {
  73268. filename: string;
  73269. path: string;
  73270. };
  73271. protected _getModelLoadingConstraints(): boolean;
  73272. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73273. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73274. protected _updateModel(): void;
  73275. }
  73276. }
  73277. declare module "babylonjs/XR/motionController/index" {
  73278. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73279. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73280. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73281. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73282. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73283. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73284. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73285. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73286. }
  73287. declare module "babylonjs/XR/index" {
  73288. export * from "babylonjs/XR/webXRCamera";
  73289. export * from "babylonjs/XR/webXREnterExitUI";
  73290. export * from "babylonjs/XR/webXRExperienceHelper";
  73291. export * from "babylonjs/XR/webXRInput";
  73292. export * from "babylonjs/XR/webXRInputSource";
  73293. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73294. export * from "babylonjs/XR/webXRTypes";
  73295. export * from "babylonjs/XR/webXRSessionManager";
  73296. export * from "babylonjs/XR/webXRDefaultExperience";
  73297. export * from "babylonjs/XR/webXRFeaturesManager";
  73298. export * from "babylonjs/XR/features/index";
  73299. export * from "babylonjs/XR/motionController/index";
  73300. }
  73301. declare module "babylonjs/index" {
  73302. export * from "babylonjs/abstractScene";
  73303. export * from "babylonjs/Actions/index";
  73304. export * from "babylonjs/Animations/index";
  73305. export * from "babylonjs/assetContainer";
  73306. export * from "babylonjs/Audio/index";
  73307. export * from "babylonjs/Behaviors/index";
  73308. export * from "babylonjs/Bones/index";
  73309. export * from "babylonjs/Cameras/index";
  73310. export * from "babylonjs/Collisions/index";
  73311. export * from "babylonjs/Culling/index";
  73312. export * from "babylonjs/Debug/index";
  73313. export * from "babylonjs/Engines/index";
  73314. export * from "babylonjs/Events/index";
  73315. export * from "babylonjs/Gamepads/index";
  73316. export * from "babylonjs/Gizmos/index";
  73317. export * from "babylonjs/Helpers/index";
  73318. export * from "babylonjs/Instrumentation/index";
  73319. export * from "babylonjs/Layers/index";
  73320. export * from "babylonjs/LensFlares/index";
  73321. export * from "babylonjs/Lights/index";
  73322. export * from "babylonjs/Loading/index";
  73323. export * from "babylonjs/Materials/index";
  73324. export * from "babylonjs/Maths/index";
  73325. export * from "babylonjs/Meshes/index";
  73326. export * from "babylonjs/Morph/index";
  73327. export * from "babylonjs/Navigation/index";
  73328. export * from "babylonjs/node";
  73329. export * from "babylonjs/Offline/index";
  73330. export * from "babylonjs/Particles/index";
  73331. export * from "babylonjs/Physics/index";
  73332. export * from "babylonjs/PostProcesses/index";
  73333. export * from "babylonjs/Probes/index";
  73334. export * from "babylonjs/Rendering/index";
  73335. export * from "babylonjs/scene";
  73336. export * from "babylonjs/sceneComponent";
  73337. export * from "babylonjs/Sprites/index";
  73338. export * from "babylonjs/States/index";
  73339. export * from "babylonjs/Misc/index";
  73340. export * from "babylonjs/XR/index";
  73341. export * from "babylonjs/types";
  73342. }
  73343. declare module "babylonjs/Animations/pathCursor" {
  73344. import { Vector3 } from "babylonjs/Maths/math.vector";
  73345. import { Path2 } from "babylonjs/Maths/math.path";
  73346. /**
  73347. * A cursor which tracks a point on a path
  73348. */
  73349. export class PathCursor {
  73350. private path;
  73351. /**
  73352. * Stores path cursor callbacks for when an onchange event is triggered
  73353. */
  73354. private _onchange;
  73355. /**
  73356. * The value of the path cursor
  73357. */
  73358. value: number;
  73359. /**
  73360. * The animation array of the path cursor
  73361. */
  73362. animations: Animation[];
  73363. /**
  73364. * Initializes the path cursor
  73365. * @param path The path to track
  73366. */
  73367. constructor(path: Path2);
  73368. /**
  73369. * Gets the cursor point on the path
  73370. * @returns A point on the path cursor at the cursor location
  73371. */
  73372. getPoint(): Vector3;
  73373. /**
  73374. * Moves the cursor ahead by the step amount
  73375. * @param step The amount to move the cursor forward
  73376. * @returns This path cursor
  73377. */
  73378. moveAhead(step?: number): PathCursor;
  73379. /**
  73380. * Moves the cursor behind by the step amount
  73381. * @param step The amount to move the cursor back
  73382. * @returns This path cursor
  73383. */
  73384. moveBack(step?: number): PathCursor;
  73385. /**
  73386. * Moves the cursor by the step amount
  73387. * If the step amount is greater than one, an exception is thrown
  73388. * @param step The amount to move the cursor
  73389. * @returns This path cursor
  73390. */
  73391. move(step: number): PathCursor;
  73392. /**
  73393. * Ensures that the value is limited between zero and one
  73394. * @returns This path cursor
  73395. */
  73396. private ensureLimits;
  73397. /**
  73398. * Runs onchange callbacks on change (used by the animation engine)
  73399. * @returns This path cursor
  73400. */
  73401. private raiseOnChange;
  73402. /**
  73403. * Executes a function on change
  73404. * @param f A path cursor onchange callback
  73405. * @returns This path cursor
  73406. */
  73407. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73408. }
  73409. }
  73410. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73411. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73412. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73413. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73414. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73415. }
  73416. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73417. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73418. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73419. }
  73420. declare module "babylonjs/Engines/Processors/index" {
  73421. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73422. export * from "babylonjs/Engines/Processors/Expressions/index";
  73423. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73424. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73425. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73426. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73427. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73428. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73429. }
  73430. declare module "babylonjs/Legacy/legacy" {
  73431. import * as Babylon from "babylonjs/index";
  73432. export * from "babylonjs/index";
  73433. }
  73434. declare module "babylonjs/Shaders/blur.fragment" {
  73435. /** @hidden */
  73436. export var blurPixelShader: {
  73437. name: string;
  73438. shader: string;
  73439. };
  73440. }
  73441. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73442. /** @hidden */
  73443. export var pointCloudVertexDeclaration: {
  73444. name: string;
  73445. shader: string;
  73446. };
  73447. }
  73448. declare module "babylonjs" {
  73449. export * from "babylonjs/Legacy/legacy";
  73450. }
  73451. declare module BABYLON {
  73452. /** Alias type for value that can be null */
  73453. export type Nullable<T> = T | null;
  73454. /**
  73455. * Alias type for number that are floats
  73456. * @ignorenaming
  73457. */
  73458. export type float = number;
  73459. /**
  73460. * Alias type for number that are doubles.
  73461. * @ignorenaming
  73462. */
  73463. export type double = number;
  73464. /**
  73465. * Alias type for number that are integer
  73466. * @ignorenaming
  73467. */
  73468. export type int = number;
  73469. /** Alias type for number array or Float32Array */
  73470. export type FloatArray = number[] | Float32Array;
  73471. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73472. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73473. /**
  73474. * Alias for types that can be used by a Buffer or VertexBuffer.
  73475. */
  73476. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73477. /**
  73478. * Alias type for primitive types
  73479. * @ignorenaming
  73480. */
  73481. type Primitive = undefined | null | boolean | string | number | Function;
  73482. /**
  73483. * Type modifier to make all the properties of an object Readonly
  73484. */
  73485. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73486. /**
  73487. * Type modifier to make all the properties of an object Readonly recursively
  73488. */
  73489. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73490. /**
  73491. * Type modifier to make object properties readonly.
  73492. */
  73493. export type DeepImmutableObject<T> = {
  73494. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73495. };
  73496. /** @hidden */
  73497. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73498. }
  73499. }
  73500. declare module BABYLON {
  73501. /**
  73502. * A class serves as a medium between the observable and its observers
  73503. */
  73504. export class EventState {
  73505. /**
  73506. * Create a new EventState
  73507. * @param mask defines the mask associated with this state
  73508. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73509. * @param target defines the original target of the state
  73510. * @param currentTarget defines the current target of the state
  73511. */
  73512. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73513. /**
  73514. * Initialize the current event state
  73515. * @param mask defines the mask associated with this state
  73516. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73517. * @param target defines the original target of the state
  73518. * @param currentTarget defines the current target of the state
  73519. * @returns the current event state
  73520. */
  73521. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73522. /**
  73523. * An Observer can set this property to true to prevent subsequent observers of being notified
  73524. */
  73525. skipNextObservers: boolean;
  73526. /**
  73527. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73528. */
  73529. mask: number;
  73530. /**
  73531. * The object that originally notified the event
  73532. */
  73533. target?: any;
  73534. /**
  73535. * The current object in the bubbling phase
  73536. */
  73537. currentTarget?: any;
  73538. /**
  73539. * This will be populated with the return value of the last function that was executed.
  73540. * If it is the first function in the callback chain it will be the event data.
  73541. */
  73542. lastReturnValue?: any;
  73543. }
  73544. /**
  73545. * Represent an Observer registered to a given Observable object.
  73546. */
  73547. export class Observer<T> {
  73548. /**
  73549. * Defines the callback to call when the observer is notified
  73550. */
  73551. callback: (eventData: T, eventState: EventState) => void;
  73552. /**
  73553. * Defines the mask of the observer (used to filter notifications)
  73554. */
  73555. mask: number;
  73556. /**
  73557. * Defines the current scope used to restore the JS context
  73558. */
  73559. scope: any;
  73560. /** @hidden */
  73561. _willBeUnregistered: boolean;
  73562. /**
  73563. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73564. */
  73565. unregisterOnNextCall: boolean;
  73566. /**
  73567. * Creates a new observer
  73568. * @param callback defines the callback to call when the observer is notified
  73569. * @param mask defines the mask of the observer (used to filter notifications)
  73570. * @param scope defines the current scope used to restore the JS context
  73571. */
  73572. constructor(
  73573. /**
  73574. * Defines the callback to call when the observer is notified
  73575. */
  73576. callback: (eventData: T, eventState: EventState) => void,
  73577. /**
  73578. * Defines the mask of the observer (used to filter notifications)
  73579. */
  73580. mask: number,
  73581. /**
  73582. * Defines the current scope used to restore the JS context
  73583. */
  73584. scope?: any);
  73585. }
  73586. /**
  73587. * Represent a list of observers registered to multiple Observables object.
  73588. */
  73589. export class MultiObserver<T> {
  73590. private _observers;
  73591. private _observables;
  73592. /**
  73593. * Release associated resources
  73594. */
  73595. dispose(): void;
  73596. /**
  73597. * Raise a callback when one of the observable will notify
  73598. * @param observables defines a list of observables to watch
  73599. * @param callback defines the callback to call on notification
  73600. * @param mask defines the mask used to filter notifications
  73601. * @param scope defines the current scope used to restore the JS context
  73602. * @returns the new MultiObserver
  73603. */
  73604. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73605. }
  73606. /**
  73607. * The Observable class is a simple implementation of the Observable pattern.
  73608. *
  73609. * 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.
  73610. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73611. * 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).
  73612. * 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.
  73613. */
  73614. export class Observable<T> {
  73615. private _observers;
  73616. private _eventState;
  73617. private _onObserverAdded;
  73618. /**
  73619. * Gets the list of observers
  73620. */
  73621. get observers(): Array<Observer<T>>;
  73622. /**
  73623. * Creates a new observable
  73624. * @param onObserverAdded defines a callback to call when a new observer is added
  73625. */
  73626. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73627. /**
  73628. * Create a new Observer with the specified callback
  73629. * @param callback the callback that will be executed for that Observer
  73630. * @param mask the mask used to filter observers
  73631. * @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.
  73632. * @param scope optional scope for the callback to be called from
  73633. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73634. * @returns the new observer created for the callback
  73635. */
  73636. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73637. /**
  73638. * Create a new Observer with the specified callback and unregisters after the next notification
  73639. * @param callback the callback that will be executed for that Observer
  73640. * @returns the new observer created for the callback
  73641. */
  73642. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73643. /**
  73644. * Remove an Observer from the Observable object
  73645. * @param observer the instance of the Observer to remove
  73646. * @returns false if it doesn't belong to this Observable
  73647. */
  73648. remove(observer: Nullable<Observer<T>>): boolean;
  73649. /**
  73650. * Remove a callback from the Observable object
  73651. * @param callback the callback to remove
  73652. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73653. * @returns false if it doesn't belong to this Observable
  73654. */
  73655. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73656. private _deferUnregister;
  73657. private _remove;
  73658. /**
  73659. * Moves the observable to the top of the observer list making it get called first when notified
  73660. * @param observer the observer to move
  73661. */
  73662. makeObserverTopPriority(observer: Observer<T>): void;
  73663. /**
  73664. * Moves the observable to the bottom of the observer list making it get called last when notified
  73665. * @param observer the observer to move
  73666. */
  73667. makeObserverBottomPriority(observer: Observer<T>): void;
  73668. /**
  73669. * Notify all Observers by calling their respective callback with the given data
  73670. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73671. * @param eventData defines the data to send to all observers
  73672. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73673. * @param target defines the original target of the state
  73674. * @param currentTarget defines the current target of the state
  73675. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73676. */
  73677. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73678. /**
  73679. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73680. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73681. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73682. * and it is crucial that all callbacks will be executed.
  73683. * The order of the callbacks is kept, callbacks are not executed parallel.
  73684. *
  73685. * @param eventData The data to be sent to each callback
  73686. * @param mask is used to filter observers defaults to -1
  73687. * @param target defines the callback target (see EventState)
  73688. * @param currentTarget defines he current object in the bubbling phase
  73689. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73690. */
  73691. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73692. /**
  73693. * Notify a specific observer
  73694. * @param observer defines the observer to notify
  73695. * @param eventData defines the data to be sent to each callback
  73696. * @param mask is used to filter observers defaults to -1
  73697. */
  73698. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73699. /**
  73700. * Gets a boolean indicating if the observable has at least one observer
  73701. * @returns true is the Observable has at least one Observer registered
  73702. */
  73703. hasObservers(): boolean;
  73704. /**
  73705. * Clear the list of observers
  73706. */
  73707. clear(): void;
  73708. /**
  73709. * Clone the current observable
  73710. * @returns a new observable
  73711. */
  73712. clone(): Observable<T>;
  73713. /**
  73714. * Does this observable handles observer registered with a given mask
  73715. * @param mask defines the mask to be tested
  73716. * @return whether or not one observer registered with the given mask is handeled
  73717. **/
  73718. hasSpecificMask(mask?: number): boolean;
  73719. }
  73720. }
  73721. declare module BABYLON {
  73722. /**
  73723. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73724. * Babylon.js
  73725. */
  73726. export class DomManagement {
  73727. /**
  73728. * Checks if the window object exists
  73729. * @returns true if the window object exists
  73730. */
  73731. static IsWindowObjectExist(): boolean;
  73732. /**
  73733. * Checks if the navigator object exists
  73734. * @returns true if the navigator object exists
  73735. */
  73736. static IsNavigatorAvailable(): boolean;
  73737. /**
  73738. * Extracts text content from a DOM element hierarchy
  73739. * @param element defines the root element
  73740. * @returns a string
  73741. */
  73742. static GetDOMTextContent(element: HTMLElement): string;
  73743. }
  73744. }
  73745. declare module BABYLON {
  73746. /**
  73747. * Logger used througouht the application to allow configuration of
  73748. * the log level required for the messages.
  73749. */
  73750. export class Logger {
  73751. /**
  73752. * No log
  73753. */
  73754. static readonly NoneLogLevel: number;
  73755. /**
  73756. * Only message logs
  73757. */
  73758. static readonly MessageLogLevel: number;
  73759. /**
  73760. * Only warning logs
  73761. */
  73762. static readonly WarningLogLevel: number;
  73763. /**
  73764. * Only error logs
  73765. */
  73766. static readonly ErrorLogLevel: number;
  73767. /**
  73768. * All logs
  73769. */
  73770. static readonly AllLogLevel: number;
  73771. private static _LogCache;
  73772. /**
  73773. * Gets a value indicating the number of loading errors
  73774. * @ignorenaming
  73775. */
  73776. static errorsCount: number;
  73777. /**
  73778. * Callback called when a new log is added
  73779. */
  73780. static OnNewCacheEntry: (entry: string) => void;
  73781. private static _AddLogEntry;
  73782. private static _FormatMessage;
  73783. private static _LogDisabled;
  73784. private static _LogEnabled;
  73785. private static _WarnDisabled;
  73786. private static _WarnEnabled;
  73787. private static _ErrorDisabled;
  73788. private static _ErrorEnabled;
  73789. /**
  73790. * Log a message to the console
  73791. */
  73792. static Log: (message: string) => void;
  73793. /**
  73794. * Write a warning message to the console
  73795. */
  73796. static Warn: (message: string) => void;
  73797. /**
  73798. * Write an error message to the console
  73799. */
  73800. static Error: (message: string) => void;
  73801. /**
  73802. * Gets current log cache (list of logs)
  73803. */
  73804. static get LogCache(): string;
  73805. /**
  73806. * Clears the log cache
  73807. */
  73808. static ClearLogCache(): void;
  73809. /**
  73810. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73811. */
  73812. static set LogLevels(level: number);
  73813. }
  73814. }
  73815. declare module BABYLON {
  73816. /** @hidden */
  73817. export class _TypeStore {
  73818. /** @hidden */
  73819. static RegisteredTypes: {
  73820. [key: string]: Object;
  73821. };
  73822. /** @hidden */
  73823. static GetClass(fqdn: string): any;
  73824. }
  73825. }
  73826. declare module BABYLON {
  73827. /**
  73828. * Helper to manipulate strings
  73829. */
  73830. export class StringTools {
  73831. /**
  73832. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73833. * @param str Source string
  73834. * @param suffix Suffix to search for in the source string
  73835. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73836. */
  73837. static EndsWith(str: string, suffix: string): boolean;
  73838. /**
  73839. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73840. * @param str Source string
  73841. * @param suffix Suffix to search for in the source string
  73842. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73843. */
  73844. static StartsWith(str: string, suffix: string): boolean;
  73845. /**
  73846. * Decodes a buffer into a string
  73847. * @param buffer The buffer to decode
  73848. * @returns The decoded string
  73849. */
  73850. static Decode(buffer: Uint8Array | Uint16Array): string;
  73851. /**
  73852. * Encode a buffer to a base64 string
  73853. * @param buffer defines the buffer to encode
  73854. * @returns the encoded string
  73855. */
  73856. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73857. /**
  73858. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  73859. * @param num the number to convert and pad
  73860. * @param length the expected length of the string
  73861. * @returns the padded string
  73862. */
  73863. static PadNumber(num: number, length: number): string;
  73864. }
  73865. }
  73866. declare module BABYLON {
  73867. /**
  73868. * Class containing a set of static utilities functions for deep copy.
  73869. */
  73870. export class DeepCopier {
  73871. /**
  73872. * Tries to copy an object by duplicating every property
  73873. * @param source defines the source object
  73874. * @param destination defines the target object
  73875. * @param doNotCopyList defines a list of properties to avoid
  73876. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73877. */
  73878. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73879. }
  73880. }
  73881. declare module BABYLON {
  73882. /**
  73883. * Class containing a set of static utilities functions for precision date
  73884. */
  73885. export class PrecisionDate {
  73886. /**
  73887. * Gets either window.performance.now() if supported or Date.now() else
  73888. */
  73889. static get Now(): number;
  73890. }
  73891. }
  73892. declare module BABYLON {
  73893. /** @hidden */
  73894. export class _DevTools {
  73895. static WarnImport(name: string): string;
  73896. }
  73897. }
  73898. declare module BABYLON {
  73899. /**
  73900. * Interface used to define the mechanism to get data from the network
  73901. */
  73902. export interface IWebRequest {
  73903. /**
  73904. * Returns client's response url
  73905. */
  73906. responseURL: string;
  73907. /**
  73908. * Returns client's status
  73909. */
  73910. status: number;
  73911. /**
  73912. * Returns client's status as a text
  73913. */
  73914. statusText: string;
  73915. }
  73916. }
  73917. declare module BABYLON {
  73918. /**
  73919. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73920. */
  73921. export class WebRequest implements IWebRequest {
  73922. private _xhr;
  73923. /**
  73924. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73925. * i.e. when loading files, where the server/service expects an Authorization header
  73926. */
  73927. static CustomRequestHeaders: {
  73928. [key: string]: string;
  73929. };
  73930. /**
  73931. * Add callback functions in this array to update all the requests before they get sent to the network
  73932. */
  73933. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73934. private _injectCustomRequestHeaders;
  73935. /**
  73936. * Gets or sets a function to be called when loading progress changes
  73937. */
  73938. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73939. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73940. /**
  73941. * Returns client's state
  73942. */
  73943. get readyState(): number;
  73944. /**
  73945. * Returns client's status
  73946. */
  73947. get status(): number;
  73948. /**
  73949. * Returns client's status as a text
  73950. */
  73951. get statusText(): string;
  73952. /**
  73953. * Returns client's response
  73954. */
  73955. get response(): any;
  73956. /**
  73957. * Returns client's response url
  73958. */
  73959. get responseURL(): string;
  73960. /**
  73961. * Returns client's response as text
  73962. */
  73963. get responseText(): string;
  73964. /**
  73965. * Gets or sets the expected response type
  73966. */
  73967. get responseType(): XMLHttpRequestResponseType;
  73968. set responseType(value: XMLHttpRequestResponseType);
  73969. /** @hidden */
  73970. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73971. /** @hidden */
  73972. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73973. /**
  73974. * Cancels any network activity
  73975. */
  73976. abort(): void;
  73977. /**
  73978. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73979. * @param body defines an optional request body
  73980. */
  73981. send(body?: Document | BodyInit | null): void;
  73982. /**
  73983. * Sets the request method, request URL
  73984. * @param method defines the method to use (GET, POST, etc..)
  73985. * @param url defines the url to connect with
  73986. */
  73987. open(method: string, url: string): void;
  73988. /**
  73989. * Sets the value of a request header.
  73990. * @param name The name of the header whose value is to be set
  73991. * @param value The value to set as the body of the header
  73992. */
  73993. setRequestHeader(name: string, value: string): void;
  73994. /**
  73995. * Get the string containing the text of a particular header's value.
  73996. * @param name The name of the header
  73997. * @returns The string containing the text of the given header name
  73998. */
  73999. getResponseHeader(name: string): Nullable<string>;
  74000. }
  74001. }
  74002. declare module BABYLON {
  74003. /**
  74004. * File request interface
  74005. */
  74006. export interface IFileRequest {
  74007. /**
  74008. * Raised when the request is complete (success or error).
  74009. */
  74010. onCompleteObservable: Observable<IFileRequest>;
  74011. /**
  74012. * Aborts the request for a file.
  74013. */
  74014. abort: () => void;
  74015. }
  74016. }
  74017. declare module BABYLON {
  74018. /**
  74019. * Define options used to create a render target texture
  74020. */
  74021. export class RenderTargetCreationOptions {
  74022. /**
  74023. * Specifies is mipmaps must be generated
  74024. */
  74025. generateMipMaps?: boolean;
  74026. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  74027. generateDepthBuffer?: boolean;
  74028. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  74029. generateStencilBuffer?: boolean;
  74030. /** Defines texture type (int by default) */
  74031. type?: number;
  74032. /** Defines sampling mode (trilinear by default) */
  74033. samplingMode?: number;
  74034. /** Defines format (RGBA by default) */
  74035. format?: number;
  74036. }
  74037. }
  74038. declare module BABYLON {
  74039. /** Defines the cross module used constants to avoid circular dependncies */
  74040. export class Constants {
  74041. /** Defines that alpha blending is disabled */
  74042. static readonly ALPHA_DISABLE: number;
  74043. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  74044. static readonly ALPHA_ADD: number;
  74045. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  74046. static readonly ALPHA_COMBINE: number;
  74047. /** Defines that alpha blending is DEST - SRC * DEST */
  74048. static readonly ALPHA_SUBTRACT: number;
  74049. /** Defines that alpha blending is SRC * DEST */
  74050. static readonly ALPHA_MULTIPLY: number;
  74051. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  74052. static readonly ALPHA_MAXIMIZED: number;
  74053. /** Defines that alpha blending is SRC + DEST */
  74054. static readonly ALPHA_ONEONE: number;
  74055. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  74056. static readonly ALPHA_PREMULTIPLIED: number;
  74057. /**
  74058. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  74059. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  74060. */
  74061. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  74062. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  74063. static readonly ALPHA_INTERPOLATE: number;
  74064. /**
  74065. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  74066. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  74067. */
  74068. static readonly ALPHA_SCREENMODE: number;
  74069. /**
  74070. * Defines that alpha blending is SRC + DST
  74071. * Alpha will be set to SRC ALPHA + DST ALPHA
  74072. */
  74073. static readonly ALPHA_ONEONE_ONEONE: number;
  74074. /**
  74075. * Defines that alpha blending is SRC * DST ALPHA + DST
  74076. * Alpha will be set to 0
  74077. */
  74078. static readonly ALPHA_ALPHATOCOLOR: number;
  74079. /**
  74080. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74081. */
  74082. static readonly ALPHA_REVERSEONEMINUS: number;
  74083. /**
  74084. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  74085. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  74086. */
  74087. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  74088. /**
  74089. * Defines that alpha blending is SRC + DST
  74090. * Alpha will be set to SRC ALPHA
  74091. */
  74092. static readonly ALPHA_ONEONE_ONEZERO: number;
  74093. /**
  74094. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74095. * Alpha will be set to DST ALPHA
  74096. */
  74097. static readonly ALPHA_EXCLUSION: number;
  74098. /** Defines that alpha blending equation a SUM */
  74099. static readonly ALPHA_EQUATION_ADD: number;
  74100. /** Defines that alpha blending equation a SUBSTRACTION */
  74101. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  74102. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  74103. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  74104. /** Defines that alpha blending equation a MAX operation */
  74105. static readonly ALPHA_EQUATION_MAX: number;
  74106. /** Defines that alpha blending equation a MIN operation */
  74107. static readonly ALPHA_EQUATION_MIN: number;
  74108. /**
  74109. * Defines that alpha blending equation a DARKEN operation:
  74110. * It takes the min of the src and sums the alpha channels.
  74111. */
  74112. static readonly ALPHA_EQUATION_DARKEN: number;
  74113. /** Defines that the ressource is not delayed*/
  74114. static readonly DELAYLOADSTATE_NONE: number;
  74115. /** Defines that the ressource was successfully delay loaded */
  74116. static readonly DELAYLOADSTATE_LOADED: number;
  74117. /** Defines that the ressource is currently delay loading */
  74118. static readonly DELAYLOADSTATE_LOADING: number;
  74119. /** Defines that the ressource is delayed and has not started loading */
  74120. static readonly DELAYLOADSTATE_NOTLOADED: number;
  74121. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  74122. static readonly NEVER: number;
  74123. /** 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 */
  74124. static readonly ALWAYS: number;
  74125. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  74126. static readonly LESS: number;
  74127. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  74128. static readonly EQUAL: number;
  74129. /** 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 */
  74130. static readonly LEQUAL: number;
  74131. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  74132. static readonly GREATER: number;
  74133. /** 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 */
  74134. static readonly GEQUAL: number;
  74135. /** 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 */
  74136. static readonly NOTEQUAL: number;
  74137. /** Passed to stencilOperation to specify that stencil value must be kept */
  74138. static readonly KEEP: number;
  74139. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74140. static readonly REPLACE: number;
  74141. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74142. static readonly INCR: number;
  74143. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74144. static readonly DECR: number;
  74145. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74146. static readonly INVERT: number;
  74147. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74148. static readonly INCR_WRAP: number;
  74149. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74150. static readonly DECR_WRAP: number;
  74151. /** Texture is not repeating outside of 0..1 UVs */
  74152. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74153. /** Texture is repeating outside of 0..1 UVs */
  74154. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  74155. /** Texture is repeating and mirrored */
  74156. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  74157. /** ALPHA */
  74158. static readonly TEXTUREFORMAT_ALPHA: number;
  74159. /** LUMINANCE */
  74160. static readonly TEXTUREFORMAT_LUMINANCE: number;
  74161. /** LUMINANCE_ALPHA */
  74162. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  74163. /** RGB */
  74164. static readonly TEXTUREFORMAT_RGB: number;
  74165. /** RGBA */
  74166. static readonly TEXTUREFORMAT_RGBA: number;
  74167. /** RED */
  74168. static readonly TEXTUREFORMAT_RED: number;
  74169. /** RED (2nd reference) */
  74170. static readonly TEXTUREFORMAT_R: number;
  74171. /** RG */
  74172. static readonly TEXTUREFORMAT_RG: number;
  74173. /** RED_INTEGER */
  74174. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  74175. /** RED_INTEGER (2nd reference) */
  74176. static readonly TEXTUREFORMAT_R_INTEGER: number;
  74177. /** RG_INTEGER */
  74178. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  74179. /** RGB_INTEGER */
  74180. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  74181. /** RGBA_INTEGER */
  74182. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  74183. /** UNSIGNED_BYTE */
  74184. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  74185. /** UNSIGNED_BYTE (2nd reference) */
  74186. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  74187. /** FLOAT */
  74188. static readonly TEXTURETYPE_FLOAT: number;
  74189. /** HALF_FLOAT */
  74190. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74191. /** BYTE */
  74192. static readonly TEXTURETYPE_BYTE: number;
  74193. /** SHORT */
  74194. static readonly TEXTURETYPE_SHORT: number;
  74195. /** UNSIGNED_SHORT */
  74196. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74197. /** INT */
  74198. static readonly TEXTURETYPE_INT: number;
  74199. /** UNSIGNED_INT */
  74200. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74201. /** UNSIGNED_SHORT_4_4_4_4 */
  74202. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74203. /** UNSIGNED_SHORT_5_5_5_1 */
  74204. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74205. /** UNSIGNED_SHORT_5_6_5 */
  74206. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74207. /** UNSIGNED_INT_2_10_10_10_REV */
  74208. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74209. /** UNSIGNED_INT_24_8 */
  74210. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74211. /** UNSIGNED_INT_10F_11F_11F_REV */
  74212. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74213. /** UNSIGNED_INT_5_9_9_9_REV */
  74214. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74215. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74216. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74217. /** nearest is mag = nearest and min = nearest and no mip */
  74218. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74219. /** mag = nearest and min = nearest and mip = none */
  74220. static readonly TEXTURE_NEAREST_NEAREST: number;
  74221. /** Bilinear is mag = linear and min = linear and no mip */
  74222. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74223. /** mag = linear and min = linear and mip = none */
  74224. static readonly TEXTURE_LINEAR_LINEAR: number;
  74225. /** Trilinear is mag = linear and min = linear and mip = linear */
  74226. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74227. /** Trilinear is mag = linear and min = linear and mip = linear */
  74228. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74229. /** mag = nearest and min = nearest and mip = nearest */
  74230. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74231. /** mag = nearest and min = linear and mip = nearest */
  74232. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74233. /** mag = nearest and min = linear and mip = linear */
  74234. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74235. /** mag = nearest and min = linear and mip = none */
  74236. static readonly TEXTURE_NEAREST_LINEAR: number;
  74237. /** nearest is mag = nearest and min = nearest and mip = linear */
  74238. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74239. /** mag = linear and min = nearest and mip = nearest */
  74240. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74241. /** mag = linear and min = nearest and mip = linear */
  74242. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74243. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74244. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74245. /** mag = linear and min = nearest and mip = none */
  74246. static readonly TEXTURE_LINEAR_NEAREST: number;
  74247. /** Explicit coordinates mode */
  74248. static readonly TEXTURE_EXPLICIT_MODE: number;
  74249. /** Spherical coordinates mode */
  74250. static readonly TEXTURE_SPHERICAL_MODE: number;
  74251. /** Planar coordinates mode */
  74252. static readonly TEXTURE_PLANAR_MODE: number;
  74253. /** Cubic coordinates mode */
  74254. static readonly TEXTURE_CUBIC_MODE: number;
  74255. /** Projection coordinates mode */
  74256. static readonly TEXTURE_PROJECTION_MODE: number;
  74257. /** Skybox coordinates mode */
  74258. static readonly TEXTURE_SKYBOX_MODE: number;
  74259. /** Inverse Cubic coordinates mode */
  74260. static readonly TEXTURE_INVCUBIC_MODE: number;
  74261. /** Equirectangular coordinates mode */
  74262. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74263. /** Equirectangular Fixed coordinates mode */
  74264. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74265. /** Equirectangular Fixed Mirrored coordinates mode */
  74266. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74267. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74268. static readonly SCALEMODE_FLOOR: number;
  74269. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74270. static readonly SCALEMODE_NEAREST: number;
  74271. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74272. static readonly SCALEMODE_CEILING: number;
  74273. /**
  74274. * The dirty texture flag value
  74275. */
  74276. static readonly MATERIAL_TextureDirtyFlag: number;
  74277. /**
  74278. * The dirty light flag value
  74279. */
  74280. static readonly MATERIAL_LightDirtyFlag: number;
  74281. /**
  74282. * The dirty fresnel flag value
  74283. */
  74284. static readonly MATERIAL_FresnelDirtyFlag: number;
  74285. /**
  74286. * The dirty attribute flag value
  74287. */
  74288. static readonly MATERIAL_AttributesDirtyFlag: number;
  74289. /**
  74290. * The dirty misc flag value
  74291. */
  74292. static readonly MATERIAL_MiscDirtyFlag: number;
  74293. /**
  74294. * The all dirty flag value
  74295. */
  74296. static readonly MATERIAL_AllDirtyFlag: number;
  74297. /**
  74298. * Returns the triangle fill mode
  74299. */
  74300. static readonly MATERIAL_TriangleFillMode: number;
  74301. /**
  74302. * Returns the wireframe mode
  74303. */
  74304. static readonly MATERIAL_WireFrameFillMode: number;
  74305. /**
  74306. * Returns the point fill mode
  74307. */
  74308. static readonly MATERIAL_PointFillMode: number;
  74309. /**
  74310. * Returns the point list draw mode
  74311. */
  74312. static readonly MATERIAL_PointListDrawMode: number;
  74313. /**
  74314. * Returns the line list draw mode
  74315. */
  74316. static readonly MATERIAL_LineListDrawMode: number;
  74317. /**
  74318. * Returns the line loop draw mode
  74319. */
  74320. static readonly MATERIAL_LineLoopDrawMode: number;
  74321. /**
  74322. * Returns the line strip draw mode
  74323. */
  74324. static readonly MATERIAL_LineStripDrawMode: number;
  74325. /**
  74326. * Returns the triangle strip draw mode
  74327. */
  74328. static readonly MATERIAL_TriangleStripDrawMode: number;
  74329. /**
  74330. * Returns the triangle fan draw mode
  74331. */
  74332. static readonly MATERIAL_TriangleFanDrawMode: number;
  74333. /**
  74334. * Stores the clock-wise side orientation
  74335. */
  74336. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74337. /**
  74338. * Stores the counter clock-wise side orientation
  74339. */
  74340. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74341. /**
  74342. * Nothing
  74343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74344. */
  74345. static readonly ACTION_NothingTrigger: number;
  74346. /**
  74347. * On pick
  74348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74349. */
  74350. static readonly ACTION_OnPickTrigger: number;
  74351. /**
  74352. * On left pick
  74353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74354. */
  74355. static readonly ACTION_OnLeftPickTrigger: number;
  74356. /**
  74357. * On right pick
  74358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74359. */
  74360. static readonly ACTION_OnRightPickTrigger: number;
  74361. /**
  74362. * On center pick
  74363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74364. */
  74365. static readonly ACTION_OnCenterPickTrigger: number;
  74366. /**
  74367. * On pick down
  74368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74369. */
  74370. static readonly ACTION_OnPickDownTrigger: number;
  74371. /**
  74372. * On double pick
  74373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74374. */
  74375. static readonly ACTION_OnDoublePickTrigger: number;
  74376. /**
  74377. * On pick up
  74378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74379. */
  74380. static readonly ACTION_OnPickUpTrigger: number;
  74381. /**
  74382. * On pick out.
  74383. * This trigger will only be raised if you also declared a OnPickDown
  74384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74385. */
  74386. static readonly ACTION_OnPickOutTrigger: number;
  74387. /**
  74388. * On long press
  74389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74390. */
  74391. static readonly ACTION_OnLongPressTrigger: number;
  74392. /**
  74393. * On pointer over
  74394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74395. */
  74396. static readonly ACTION_OnPointerOverTrigger: number;
  74397. /**
  74398. * On pointer out
  74399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74400. */
  74401. static readonly ACTION_OnPointerOutTrigger: number;
  74402. /**
  74403. * On every frame
  74404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74405. */
  74406. static readonly ACTION_OnEveryFrameTrigger: number;
  74407. /**
  74408. * On intersection enter
  74409. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74410. */
  74411. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74412. /**
  74413. * On intersection exit
  74414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74415. */
  74416. static readonly ACTION_OnIntersectionExitTrigger: number;
  74417. /**
  74418. * On key down
  74419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74420. */
  74421. static readonly ACTION_OnKeyDownTrigger: number;
  74422. /**
  74423. * On key up
  74424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74425. */
  74426. static readonly ACTION_OnKeyUpTrigger: number;
  74427. /**
  74428. * Billboard mode will only apply to Y axis
  74429. */
  74430. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74431. /**
  74432. * Billboard mode will apply to all axes
  74433. */
  74434. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74435. /**
  74436. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74437. */
  74438. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74439. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74440. * Test order :
  74441. * Is the bounding sphere outside the frustum ?
  74442. * If not, are the bounding box vertices outside the frustum ?
  74443. * It not, then the cullable object is in the frustum.
  74444. */
  74445. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74446. /** Culling strategy : Bounding Sphere Only.
  74447. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74448. * It's also less accurate than the standard because some not visible objects can still be selected.
  74449. * Test : is the bounding sphere outside the frustum ?
  74450. * If not, then the cullable object is in the frustum.
  74451. */
  74452. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74453. /** Culling strategy : Optimistic Inclusion.
  74454. * This in an inclusion test first, then the standard exclusion test.
  74455. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74456. * 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.
  74457. * Anyway, it's as accurate as the standard strategy.
  74458. * Test :
  74459. * Is the cullable object bounding sphere center in the frustum ?
  74460. * If not, apply the default culling strategy.
  74461. */
  74462. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74463. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74464. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74465. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74466. * 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.
  74467. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74468. * Test :
  74469. * Is the cullable object bounding sphere center in the frustum ?
  74470. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74471. */
  74472. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74473. /**
  74474. * No logging while loading
  74475. */
  74476. static readonly SCENELOADER_NO_LOGGING: number;
  74477. /**
  74478. * Minimal logging while loading
  74479. */
  74480. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74481. /**
  74482. * Summary logging while loading
  74483. */
  74484. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74485. /**
  74486. * Detailled logging while loading
  74487. */
  74488. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74489. }
  74490. }
  74491. declare module BABYLON {
  74492. /**
  74493. * This represents the required contract to create a new type of texture loader.
  74494. */
  74495. export interface IInternalTextureLoader {
  74496. /**
  74497. * Defines wether the loader supports cascade loading the different faces.
  74498. */
  74499. supportCascades: boolean;
  74500. /**
  74501. * This returns if the loader support the current file information.
  74502. * @param extension defines the file extension of the file being loaded
  74503. * @returns true if the loader can load the specified file
  74504. */
  74505. canLoad(extension: string): boolean;
  74506. /**
  74507. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  74508. * @param data contains the texture data
  74509. * @param texture defines the BabylonJS internal texture
  74510. * @param createPolynomials will be true if polynomials have been requested
  74511. * @param onLoad defines the callback to trigger once the texture is ready
  74512. * @param onError defines the callback to trigger in case of error
  74513. */
  74514. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74515. /**
  74516. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  74517. * @param data contains the texture data
  74518. * @param texture defines the BabylonJS internal texture
  74519. * @param callback defines the method to call once ready to upload
  74520. */
  74521. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74522. }
  74523. }
  74524. declare module BABYLON {
  74525. /**
  74526. * Class used to store and describe the pipeline context associated with an effect
  74527. */
  74528. export interface IPipelineContext {
  74529. /**
  74530. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74531. */
  74532. isAsync: boolean;
  74533. /**
  74534. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74535. */
  74536. isReady: boolean;
  74537. /** @hidden */
  74538. _getVertexShaderCode(): string | null;
  74539. /** @hidden */
  74540. _getFragmentShaderCode(): string | null;
  74541. /** @hidden */
  74542. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74543. }
  74544. }
  74545. declare module BABYLON {
  74546. /**
  74547. * Class used to store gfx data (like WebGLBuffer)
  74548. */
  74549. export class DataBuffer {
  74550. /**
  74551. * Gets or sets the number of objects referencing this buffer
  74552. */
  74553. references: number;
  74554. /** Gets or sets the size of the underlying buffer */
  74555. capacity: number;
  74556. /**
  74557. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74558. */
  74559. is32Bits: boolean;
  74560. /**
  74561. * Gets the underlying buffer
  74562. */
  74563. get underlyingResource(): any;
  74564. }
  74565. }
  74566. declare module BABYLON {
  74567. /** @hidden */
  74568. export interface IShaderProcessor {
  74569. attributeProcessor?: (attribute: string) => string;
  74570. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74571. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74572. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74573. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74574. lineProcessor?: (line: string, isFragment: boolean) => string;
  74575. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74576. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74577. }
  74578. }
  74579. declare module BABYLON {
  74580. /** @hidden */
  74581. export interface ProcessingOptions {
  74582. defines: string[];
  74583. indexParameters: any;
  74584. isFragment: boolean;
  74585. shouldUseHighPrecisionShader: boolean;
  74586. supportsUniformBuffers: boolean;
  74587. shadersRepository: string;
  74588. includesShadersStore: {
  74589. [key: string]: string;
  74590. };
  74591. processor?: IShaderProcessor;
  74592. version: string;
  74593. platformName: string;
  74594. lookForClosingBracketForUniformBuffer?: boolean;
  74595. }
  74596. }
  74597. declare module BABYLON {
  74598. /** @hidden */
  74599. export class ShaderCodeNode {
  74600. line: string;
  74601. children: ShaderCodeNode[];
  74602. additionalDefineKey?: string;
  74603. additionalDefineValue?: string;
  74604. isValid(preprocessors: {
  74605. [key: string]: string;
  74606. }): boolean;
  74607. process(preprocessors: {
  74608. [key: string]: string;
  74609. }, options: ProcessingOptions): string;
  74610. }
  74611. }
  74612. declare module BABYLON {
  74613. /** @hidden */
  74614. export class ShaderCodeCursor {
  74615. private _lines;
  74616. lineIndex: number;
  74617. get currentLine(): string;
  74618. get canRead(): boolean;
  74619. set lines(value: string[]);
  74620. }
  74621. }
  74622. declare module BABYLON {
  74623. /** @hidden */
  74624. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74625. process(preprocessors: {
  74626. [key: string]: string;
  74627. }, options: ProcessingOptions): string;
  74628. }
  74629. }
  74630. declare module BABYLON {
  74631. /** @hidden */
  74632. export class ShaderDefineExpression {
  74633. isTrue(preprocessors: {
  74634. [key: string]: string;
  74635. }): boolean;
  74636. }
  74637. }
  74638. declare module BABYLON {
  74639. /** @hidden */
  74640. export class ShaderCodeTestNode extends ShaderCodeNode {
  74641. testExpression: ShaderDefineExpression;
  74642. isValid(preprocessors: {
  74643. [key: string]: string;
  74644. }): boolean;
  74645. }
  74646. }
  74647. declare module BABYLON {
  74648. /** @hidden */
  74649. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74650. define: string;
  74651. not: boolean;
  74652. constructor(define: string, not?: boolean);
  74653. isTrue(preprocessors: {
  74654. [key: string]: string;
  74655. }): boolean;
  74656. }
  74657. }
  74658. declare module BABYLON {
  74659. /** @hidden */
  74660. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74661. leftOperand: ShaderDefineExpression;
  74662. rightOperand: ShaderDefineExpression;
  74663. isTrue(preprocessors: {
  74664. [key: string]: string;
  74665. }): boolean;
  74666. }
  74667. }
  74668. declare module BABYLON {
  74669. /** @hidden */
  74670. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74671. leftOperand: ShaderDefineExpression;
  74672. rightOperand: ShaderDefineExpression;
  74673. isTrue(preprocessors: {
  74674. [key: string]: string;
  74675. }): boolean;
  74676. }
  74677. }
  74678. declare module BABYLON {
  74679. /** @hidden */
  74680. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74681. define: string;
  74682. operand: string;
  74683. testValue: string;
  74684. constructor(define: string, operand: string, testValue: string);
  74685. isTrue(preprocessors: {
  74686. [key: string]: string;
  74687. }): boolean;
  74688. }
  74689. }
  74690. declare module BABYLON {
  74691. /**
  74692. * Class used to enable access to offline support
  74693. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74694. */
  74695. export interface IOfflineProvider {
  74696. /**
  74697. * Gets a boolean indicating if scene must be saved in the database
  74698. */
  74699. enableSceneOffline: boolean;
  74700. /**
  74701. * Gets a boolean indicating if textures must be saved in the database
  74702. */
  74703. enableTexturesOffline: boolean;
  74704. /**
  74705. * Open the offline support and make it available
  74706. * @param successCallback defines the callback to call on success
  74707. * @param errorCallback defines the callback to call on error
  74708. */
  74709. open(successCallback: () => void, errorCallback: () => void): void;
  74710. /**
  74711. * Loads an image from the offline support
  74712. * @param url defines the url to load from
  74713. * @param image defines the target DOM image
  74714. */
  74715. loadImage(url: string, image: HTMLImageElement): void;
  74716. /**
  74717. * Loads a file from offline support
  74718. * @param url defines the URL to load from
  74719. * @param sceneLoaded defines a callback to call on success
  74720. * @param progressCallBack defines a callback to call when progress changed
  74721. * @param errorCallback defines a callback to call on error
  74722. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74723. */
  74724. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74725. }
  74726. }
  74727. declare module BABYLON {
  74728. /**
  74729. * Class used to help managing file picking and drag'n'drop
  74730. * File Storage
  74731. */
  74732. export class FilesInputStore {
  74733. /**
  74734. * List of files ready to be loaded
  74735. */
  74736. static FilesToLoad: {
  74737. [key: string]: File;
  74738. };
  74739. }
  74740. }
  74741. declare module BABYLON {
  74742. /**
  74743. * Class used to define a retry strategy when error happens while loading assets
  74744. */
  74745. export class RetryStrategy {
  74746. /**
  74747. * Function used to defines an exponential back off strategy
  74748. * @param maxRetries defines the maximum number of retries (3 by default)
  74749. * @param baseInterval defines the interval between retries
  74750. * @returns the strategy function to use
  74751. */
  74752. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74753. }
  74754. }
  74755. declare module BABYLON {
  74756. /**
  74757. * @ignore
  74758. * Application error to support additional information when loading a file
  74759. */
  74760. export abstract class BaseError extends Error {
  74761. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74762. }
  74763. }
  74764. declare module BABYLON {
  74765. /** @ignore */
  74766. export class LoadFileError extends BaseError {
  74767. request?: WebRequest;
  74768. file?: File;
  74769. /**
  74770. * Creates a new LoadFileError
  74771. * @param message defines the message of the error
  74772. * @param request defines the optional web request
  74773. * @param file defines the optional file
  74774. */
  74775. constructor(message: string, object?: WebRequest | File);
  74776. }
  74777. /** @ignore */
  74778. export class RequestFileError extends BaseError {
  74779. request: WebRequest;
  74780. /**
  74781. * Creates a new LoadFileError
  74782. * @param message defines the message of the error
  74783. * @param request defines the optional web request
  74784. */
  74785. constructor(message: string, request: WebRequest);
  74786. }
  74787. /** @ignore */
  74788. export class ReadFileError extends BaseError {
  74789. file: File;
  74790. /**
  74791. * Creates a new ReadFileError
  74792. * @param message defines the message of the error
  74793. * @param file defines the optional file
  74794. */
  74795. constructor(message: string, file: File);
  74796. }
  74797. /**
  74798. * @hidden
  74799. */
  74800. export class FileTools {
  74801. /**
  74802. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74803. */
  74804. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74805. /**
  74806. * Gets or sets the base URL to use to load assets
  74807. */
  74808. static BaseUrl: string;
  74809. /**
  74810. * Default behaviour for cors in the application.
  74811. * It can be a string if the expected behavior is identical in the entire app.
  74812. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74813. */
  74814. static CorsBehavior: string | ((url: string | string[]) => string);
  74815. /**
  74816. * Gets or sets a function used to pre-process url before using them to load assets
  74817. */
  74818. static PreprocessUrl: (url: string) => string;
  74819. /**
  74820. * Removes unwanted characters from an url
  74821. * @param url defines the url to clean
  74822. * @returns the cleaned url
  74823. */
  74824. private static _CleanUrl;
  74825. /**
  74826. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74827. * @param url define the url we are trying
  74828. * @param element define the dom element where to configure the cors policy
  74829. */
  74830. static SetCorsBehavior(url: string | string[], element: {
  74831. crossOrigin: string | null;
  74832. }): void;
  74833. /**
  74834. * Loads an image as an HTMLImageElement.
  74835. * @param input url string, ArrayBuffer, or Blob to load
  74836. * @param onLoad callback called when the image successfully loads
  74837. * @param onError callback called when the image fails to load
  74838. * @param offlineProvider offline provider for caching
  74839. * @param mimeType optional mime type
  74840. * @returns the HTMLImageElement of the loaded image
  74841. */
  74842. 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>;
  74843. /**
  74844. * Reads a file from a File object
  74845. * @param file defines the file to load
  74846. * @param onSuccess defines the callback to call when data is loaded
  74847. * @param onProgress defines the callback to call during loading process
  74848. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74849. * @param onError defines the callback to call when an error occurs
  74850. * @returns a file request object
  74851. */
  74852. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74853. /**
  74854. * Loads a file from a url
  74855. * @param url url to load
  74856. * @param onSuccess callback called when the file successfully loads
  74857. * @param onProgress callback called while file is loading (if the server supports this mode)
  74858. * @param offlineProvider defines the offline provider for caching
  74859. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74860. * @param onError callback called when the file fails to load
  74861. * @returns a file request object
  74862. */
  74863. 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;
  74864. /**
  74865. * Loads a file
  74866. * @param url url to load
  74867. * @param onSuccess callback called when the file successfully loads
  74868. * @param onProgress callback called while file is loading (if the server supports this mode)
  74869. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74870. * @param onError callback called when the file fails to load
  74871. * @param onOpened callback called when the web request is opened
  74872. * @returns a file request object
  74873. */
  74874. 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;
  74875. /**
  74876. * Checks if the loaded document was accessed via `file:`-Protocol.
  74877. * @returns boolean
  74878. */
  74879. static IsFileURL(): boolean;
  74880. }
  74881. }
  74882. declare module BABYLON {
  74883. /** @hidden */
  74884. export class ShaderProcessor {
  74885. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74886. private static _ProcessPrecision;
  74887. private static _ExtractOperation;
  74888. private static _BuildSubExpression;
  74889. private static _BuildExpression;
  74890. private static _MoveCursorWithinIf;
  74891. private static _MoveCursor;
  74892. private static _EvaluatePreProcessors;
  74893. private static _PreparePreProcessors;
  74894. private static _ProcessShaderConversion;
  74895. private static _ProcessIncludes;
  74896. /**
  74897. * Loads a file from a url
  74898. * @param url url to load
  74899. * @param onSuccess callback called when the file successfully loads
  74900. * @param onProgress callback called while file is loading (if the server supports this mode)
  74901. * @param offlineProvider defines the offline provider for caching
  74902. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74903. * @param onError callback called when the file fails to load
  74904. * @returns a file request object
  74905. * @hidden
  74906. */
  74907. 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;
  74908. }
  74909. }
  74910. declare module BABYLON {
  74911. /**
  74912. * @hidden
  74913. */
  74914. export interface IColor4Like {
  74915. r: float;
  74916. g: float;
  74917. b: float;
  74918. a: float;
  74919. }
  74920. /**
  74921. * @hidden
  74922. */
  74923. export interface IColor3Like {
  74924. r: float;
  74925. g: float;
  74926. b: float;
  74927. }
  74928. /**
  74929. * @hidden
  74930. */
  74931. export interface IVector4Like {
  74932. x: float;
  74933. y: float;
  74934. z: float;
  74935. w: float;
  74936. }
  74937. /**
  74938. * @hidden
  74939. */
  74940. export interface IVector3Like {
  74941. x: float;
  74942. y: float;
  74943. z: float;
  74944. }
  74945. /**
  74946. * @hidden
  74947. */
  74948. export interface IVector2Like {
  74949. x: float;
  74950. y: float;
  74951. }
  74952. /**
  74953. * @hidden
  74954. */
  74955. export interface IMatrixLike {
  74956. toArray(): DeepImmutable<Float32Array>;
  74957. updateFlag: int;
  74958. }
  74959. /**
  74960. * @hidden
  74961. */
  74962. export interface IViewportLike {
  74963. x: float;
  74964. y: float;
  74965. width: float;
  74966. height: float;
  74967. }
  74968. /**
  74969. * @hidden
  74970. */
  74971. export interface IPlaneLike {
  74972. normal: IVector3Like;
  74973. d: float;
  74974. normalize(): void;
  74975. }
  74976. }
  74977. declare module BABYLON {
  74978. /**
  74979. * Interface used to define common properties for effect fallbacks
  74980. */
  74981. export interface IEffectFallbacks {
  74982. /**
  74983. * Removes the defines that should be removed when falling back.
  74984. * @param currentDefines defines the current define statements for the shader.
  74985. * @param effect defines the current effect we try to compile
  74986. * @returns The resulting defines with defines of the current rank removed.
  74987. */
  74988. reduce(currentDefines: string, effect: Effect): string;
  74989. /**
  74990. * Removes the fallback from the bound mesh.
  74991. */
  74992. unBindMesh(): void;
  74993. /**
  74994. * Checks to see if more fallbacks are still availible.
  74995. */
  74996. hasMoreFallbacks: boolean;
  74997. }
  74998. }
  74999. declare module BABYLON {
  75000. /**
  75001. * Class used to evalaute queries containing `and` and `or` operators
  75002. */
  75003. export class AndOrNotEvaluator {
  75004. /**
  75005. * Evaluate a query
  75006. * @param query defines the query to evaluate
  75007. * @param evaluateCallback defines the callback used to filter result
  75008. * @returns true if the query matches
  75009. */
  75010. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  75011. private static _HandleParenthesisContent;
  75012. private static _SimplifyNegation;
  75013. }
  75014. }
  75015. declare module BABYLON {
  75016. /**
  75017. * Class used to store custom tags
  75018. */
  75019. export class Tags {
  75020. /**
  75021. * Adds support for tags on the given object
  75022. * @param obj defines the object to use
  75023. */
  75024. static EnableFor(obj: any): void;
  75025. /**
  75026. * Removes tags support
  75027. * @param obj defines the object to use
  75028. */
  75029. static DisableFor(obj: any): void;
  75030. /**
  75031. * Gets a boolean indicating if the given object has tags
  75032. * @param obj defines the object to use
  75033. * @returns a boolean
  75034. */
  75035. static HasTags(obj: any): boolean;
  75036. /**
  75037. * Gets the tags available on a given object
  75038. * @param obj defines the object to use
  75039. * @param asString defines if the tags must be returned as a string instead of an array of strings
  75040. * @returns the tags
  75041. */
  75042. static GetTags(obj: any, asString?: boolean): any;
  75043. /**
  75044. * Adds tags to an object
  75045. * @param obj defines the object to use
  75046. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  75047. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  75048. */
  75049. static AddTagsTo(obj: any, tagsString: string): void;
  75050. /**
  75051. * @hidden
  75052. */
  75053. static _AddTagTo(obj: any, tag: string): void;
  75054. /**
  75055. * Removes specific tags from a specific object
  75056. * @param obj defines the object to use
  75057. * @param tagsString defines the tags to remove
  75058. */
  75059. static RemoveTagsFrom(obj: any, tagsString: string): void;
  75060. /**
  75061. * @hidden
  75062. */
  75063. static _RemoveTagFrom(obj: any, tag: string): void;
  75064. /**
  75065. * Defines if tags hosted on an object match a given query
  75066. * @param obj defines the object to use
  75067. * @param tagsQuery defines the tag query
  75068. * @returns a boolean
  75069. */
  75070. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  75071. }
  75072. }
  75073. declare module BABYLON {
  75074. /**
  75075. * Scalar computation library
  75076. */
  75077. export class Scalar {
  75078. /**
  75079. * Two pi constants convenient for computation.
  75080. */
  75081. static TwoPi: number;
  75082. /**
  75083. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75084. * @param a number
  75085. * @param b number
  75086. * @param epsilon (default = 1.401298E-45)
  75087. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75088. */
  75089. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  75090. /**
  75091. * Returns a string : the upper case translation of the number i to hexadecimal.
  75092. * @param i number
  75093. * @returns the upper case translation of the number i to hexadecimal.
  75094. */
  75095. static ToHex(i: number): string;
  75096. /**
  75097. * Returns -1 if value is negative and +1 is value is positive.
  75098. * @param value the value
  75099. * @returns the value itself if it's equal to zero.
  75100. */
  75101. static Sign(value: number): number;
  75102. /**
  75103. * Returns the value itself if it's between min and max.
  75104. * Returns min if the value is lower than min.
  75105. * Returns max if the value is greater than max.
  75106. * @param value the value to clmap
  75107. * @param min the min value to clamp to (default: 0)
  75108. * @param max the max value to clamp to (default: 1)
  75109. * @returns the clamped value
  75110. */
  75111. static Clamp(value: number, min?: number, max?: number): number;
  75112. /**
  75113. * the log2 of value.
  75114. * @param value the value to compute log2 of
  75115. * @returns the log2 of value.
  75116. */
  75117. static Log2(value: number): number;
  75118. /**
  75119. * Loops the value, so that it is never larger than length and never smaller than 0.
  75120. *
  75121. * This is similar to the modulo operator but it works with floating point numbers.
  75122. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75123. * With t = 5 and length = 2.5, the result would be 0.0.
  75124. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75125. * @param value the value
  75126. * @param length the length
  75127. * @returns the looped value
  75128. */
  75129. static Repeat(value: number, length: number): number;
  75130. /**
  75131. * Normalize the value between 0.0 and 1.0 using min and max values
  75132. * @param value value to normalize
  75133. * @param min max to normalize between
  75134. * @param max min to normalize between
  75135. * @returns the normalized value
  75136. */
  75137. static Normalize(value: number, min: number, max: number): number;
  75138. /**
  75139. * Denormalize the value from 0.0 and 1.0 using min and max values
  75140. * @param normalized value to denormalize
  75141. * @param min max to denormalize between
  75142. * @param max min to denormalize between
  75143. * @returns the denormalized value
  75144. */
  75145. static Denormalize(normalized: number, min: number, max: number): number;
  75146. /**
  75147. * Calculates the shortest difference between two given angles given in degrees.
  75148. * @param current current angle in degrees
  75149. * @param target target angle in degrees
  75150. * @returns the delta
  75151. */
  75152. static DeltaAngle(current: number, target: number): number;
  75153. /**
  75154. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  75155. * @param tx value
  75156. * @param length length
  75157. * @returns The returned value will move back and forth between 0 and length
  75158. */
  75159. static PingPong(tx: number, length: number): number;
  75160. /**
  75161. * Interpolates between min and max with smoothing at the limits.
  75162. *
  75163. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  75164. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  75165. * @param from from
  75166. * @param to to
  75167. * @param tx value
  75168. * @returns the smooth stepped value
  75169. */
  75170. static SmoothStep(from: number, to: number, tx: number): number;
  75171. /**
  75172. * Moves a value current towards target.
  75173. *
  75174. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  75175. * Negative values of maxDelta pushes the value away from target.
  75176. * @param current current value
  75177. * @param target target value
  75178. * @param maxDelta max distance to move
  75179. * @returns resulting value
  75180. */
  75181. static MoveTowards(current: number, target: number, maxDelta: number): number;
  75182. /**
  75183. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75184. *
  75185. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  75186. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  75187. * @param current current value
  75188. * @param target target value
  75189. * @param maxDelta max distance to move
  75190. * @returns resulting angle
  75191. */
  75192. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75193. /**
  75194. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75195. * @param start start value
  75196. * @param end target value
  75197. * @param amount amount to lerp between
  75198. * @returns the lerped value
  75199. */
  75200. static Lerp(start: number, end: number, amount: number): number;
  75201. /**
  75202. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75203. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75204. * @param start start value
  75205. * @param end target value
  75206. * @param amount amount to lerp between
  75207. * @returns the lerped value
  75208. */
  75209. static LerpAngle(start: number, end: number, amount: number): number;
  75210. /**
  75211. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75212. * @param a start value
  75213. * @param b target value
  75214. * @param value value between a and b
  75215. * @returns the inverseLerp value
  75216. */
  75217. static InverseLerp(a: number, b: number, value: number): number;
  75218. /**
  75219. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75220. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75221. * @param value1 spline value
  75222. * @param tangent1 spline value
  75223. * @param value2 spline value
  75224. * @param tangent2 spline value
  75225. * @param amount input value
  75226. * @returns hermite result
  75227. */
  75228. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75229. /**
  75230. * Returns a random float number between and min and max values
  75231. * @param min min value of random
  75232. * @param max max value of random
  75233. * @returns random value
  75234. */
  75235. static RandomRange(min: number, max: number): number;
  75236. /**
  75237. * This function returns percentage of a number in a given range.
  75238. *
  75239. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75240. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75241. * @param number to convert to percentage
  75242. * @param min min range
  75243. * @param max max range
  75244. * @returns the percentage
  75245. */
  75246. static RangeToPercent(number: number, min: number, max: number): number;
  75247. /**
  75248. * This function returns number that corresponds to the percentage in a given range.
  75249. *
  75250. * PercentToRange(0.34,0,100) will return 34.
  75251. * @param percent to convert to number
  75252. * @param min min range
  75253. * @param max max range
  75254. * @returns the number
  75255. */
  75256. static PercentToRange(percent: number, min: number, max: number): number;
  75257. /**
  75258. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75259. * @param angle The angle to normalize in radian.
  75260. * @return The converted angle.
  75261. */
  75262. static NormalizeRadians(angle: number): number;
  75263. }
  75264. }
  75265. declare module BABYLON {
  75266. /**
  75267. * Constant used to convert a value to gamma space
  75268. * @ignorenaming
  75269. */
  75270. export const ToGammaSpace: number;
  75271. /**
  75272. * Constant used to convert a value to linear space
  75273. * @ignorenaming
  75274. */
  75275. export const ToLinearSpace = 2.2;
  75276. /**
  75277. * Constant used to define the minimal number value in Babylon.js
  75278. * @ignorenaming
  75279. */
  75280. let Epsilon: number;
  75281. }
  75282. declare module BABYLON {
  75283. /**
  75284. * Class used to represent a viewport on screen
  75285. */
  75286. export class Viewport {
  75287. /** viewport left coordinate */
  75288. x: number;
  75289. /** viewport top coordinate */
  75290. y: number;
  75291. /**viewport width */
  75292. width: number;
  75293. /** viewport height */
  75294. height: number;
  75295. /**
  75296. * Creates a Viewport object located at (x, y) and sized (width, height)
  75297. * @param x defines viewport left coordinate
  75298. * @param y defines viewport top coordinate
  75299. * @param width defines the viewport width
  75300. * @param height defines the viewport height
  75301. */
  75302. constructor(
  75303. /** viewport left coordinate */
  75304. x: number,
  75305. /** viewport top coordinate */
  75306. y: number,
  75307. /**viewport width */
  75308. width: number,
  75309. /** viewport height */
  75310. height: number);
  75311. /**
  75312. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75313. * @param renderWidth defines the rendering width
  75314. * @param renderHeight defines the rendering height
  75315. * @returns a new Viewport
  75316. */
  75317. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75318. /**
  75319. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75320. * @param renderWidth defines the rendering width
  75321. * @param renderHeight defines the rendering height
  75322. * @param ref defines the target viewport
  75323. * @returns the current viewport
  75324. */
  75325. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75326. /**
  75327. * Returns a new Viewport copied from the current one
  75328. * @returns a new Viewport
  75329. */
  75330. clone(): Viewport;
  75331. }
  75332. }
  75333. declare module BABYLON {
  75334. /**
  75335. * Class containing a set of static utilities functions for arrays.
  75336. */
  75337. export class ArrayTools {
  75338. /**
  75339. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75340. * @param size the number of element to construct and put in the array
  75341. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75342. * @returns a new array filled with new objects
  75343. */
  75344. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75345. }
  75346. }
  75347. declare module BABYLON {
  75348. /**
  75349. * Class representing a vector containing 2 coordinates
  75350. */
  75351. export class Vector2 {
  75352. /** defines the first coordinate */
  75353. x: number;
  75354. /** defines the second coordinate */
  75355. y: number;
  75356. /**
  75357. * Creates a new Vector2 from the given x and y coordinates
  75358. * @param x defines the first coordinate
  75359. * @param y defines the second coordinate
  75360. */
  75361. constructor(
  75362. /** defines the first coordinate */
  75363. x?: number,
  75364. /** defines the second coordinate */
  75365. y?: number);
  75366. /**
  75367. * Gets a string with the Vector2 coordinates
  75368. * @returns a string with the Vector2 coordinates
  75369. */
  75370. toString(): string;
  75371. /**
  75372. * Gets class name
  75373. * @returns the string "Vector2"
  75374. */
  75375. getClassName(): string;
  75376. /**
  75377. * Gets current vector hash code
  75378. * @returns the Vector2 hash code as a number
  75379. */
  75380. getHashCode(): number;
  75381. /**
  75382. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75383. * @param array defines the source array
  75384. * @param index defines the offset in source array
  75385. * @returns the current Vector2
  75386. */
  75387. toArray(array: FloatArray, index?: number): Vector2;
  75388. /**
  75389. * Copy the current vector to an array
  75390. * @returns a new array with 2 elements: the Vector2 coordinates.
  75391. */
  75392. asArray(): number[];
  75393. /**
  75394. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75395. * @param source defines the source Vector2
  75396. * @returns the current updated Vector2
  75397. */
  75398. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75399. /**
  75400. * Sets the Vector2 coordinates with the given floats
  75401. * @param x defines the first coordinate
  75402. * @param y defines the second coordinate
  75403. * @returns the current updated Vector2
  75404. */
  75405. copyFromFloats(x: number, y: number): Vector2;
  75406. /**
  75407. * Sets the Vector2 coordinates with the given floats
  75408. * @param x defines the first coordinate
  75409. * @param y defines the second coordinate
  75410. * @returns the current updated Vector2
  75411. */
  75412. set(x: number, y: number): Vector2;
  75413. /**
  75414. * Add another vector with the current one
  75415. * @param otherVector defines the other vector
  75416. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75417. */
  75418. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75419. /**
  75420. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75421. * @param otherVector defines the other vector
  75422. * @param result defines the target vector
  75423. * @returns the unmodified current Vector2
  75424. */
  75425. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75426. /**
  75427. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75428. * @param otherVector defines the other vector
  75429. * @returns the current updated Vector2
  75430. */
  75431. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75432. /**
  75433. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75434. * @param otherVector defines the other vector
  75435. * @returns a new Vector2
  75436. */
  75437. addVector3(otherVector: Vector3): Vector2;
  75438. /**
  75439. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75440. * @param otherVector defines the other vector
  75441. * @returns a new Vector2
  75442. */
  75443. subtract(otherVector: Vector2): Vector2;
  75444. /**
  75445. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75446. * @param otherVector defines the other vector
  75447. * @param result defines the target vector
  75448. * @returns the unmodified current Vector2
  75449. */
  75450. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75451. /**
  75452. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75453. * @param otherVector defines the other vector
  75454. * @returns the current updated Vector2
  75455. */
  75456. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75457. /**
  75458. * Multiplies in place the current Vector2 coordinates by the given ones
  75459. * @param otherVector defines the other vector
  75460. * @returns the current updated Vector2
  75461. */
  75462. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75463. /**
  75464. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75465. * @param otherVector defines the other vector
  75466. * @returns a new Vector2
  75467. */
  75468. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75469. /**
  75470. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75471. * @param otherVector defines the other vector
  75472. * @param result defines the target vector
  75473. * @returns the unmodified current Vector2
  75474. */
  75475. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75476. /**
  75477. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75478. * @param x defines the first coordinate
  75479. * @param y defines the second coordinate
  75480. * @returns a new Vector2
  75481. */
  75482. multiplyByFloats(x: number, y: number): Vector2;
  75483. /**
  75484. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75485. * @param otherVector defines the other vector
  75486. * @returns a new Vector2
  75487. */
  75488. divide(otherVector: Vector2): Vector2;
  75489. /**
  75490. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75491. * @param otherVector defines the other vector
  75492. * @param result defines the target vector
  75493. * @returns the unmodified current Vector2
  75494. */
  75495. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75496. /**
  75497. * Divides the current Vector2 coordinates by the given ones
  75498. * @param otherVector defines the other vector
  75499. * @returns the current updated Vector2
  75500. */
  75501. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75502. /**
  75503. * Gets a new Vector2 with current Vector2 negated coordinates
  75504. * @returns a new Vector2
  75505. */
  75506. negate(): Vector2;
  75507. /**
  75508. * Negate this vector in place
  75509. * @returns this
  75510. */
  75511. negateInPlace(): Vector2;
  75512. /**
  75513. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75514. * @param result defines the Vector3 object where to store the result
  75515. * @returns the current Vector2
  75516. */
  75517. negateToRef(result: Vector2): Vector2;
  75518. /**
  75519. * Multiply the Vector2 coordinates by scale
  75520. * @param scale defines the scaling factor
  75521. * @returns the current updated Vector2
  75522. */
  75523. scaleInPlace(scale: number): Vector2;
  75524. /**
  75525. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75526. * @param scale defines the scaling factor
  75527. * @returns a new Vector2
  75528. */
  75529. scale(scale: number): Vector2;
  75530. /**
  75531. * Scale the current Vector2 values by a factor to a given Vector2
  75532. * @param scale defines the scale factor
  75533. * @param result defines the Vector2 object where to store the result
  75534. * @returns the unmodified current Vector2
  75535. */
  75536. scaleToRef(scale: number, result: Vector2): Vector2;
  75537. /**
  75538. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75539. * @param scale defines the scale factor
  75540. * @param result defines the Vector2 object where to store the result
  75541. * @returns the unmodified current Vector2
  75542. */
  75543. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75544. /**
  75545. * Gets a boolean if two vectors are equals
  75546. * @param otherVector defines the other vector
  75547. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75548. */
  75549. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75550. /**
  75551. * Gets a boolean if two vectors are equals (using an epsilon value)
  75552. * @param otherVector defines the other vector
  75553. * @param epsilon defines the minimal distance to consider equality
  75554. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75555. */
  75556. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75557. /**
  75558. * Gets a new Vector2 from current Vector2 floored values
  75559. * @returns a new Vector2
  75560. */
  75561. floor(): Vector2;
  75562. /**
  75563. * Gets a new Vector2 from current Vector2 floored values
  75564. * @returns a new Vector2
  75565. */
  75566. fract(): Vector2;
  75567. /**
  75568. * Gets the length of the vector
  75569. * @returns the vector length (float)
  75570. */
  75571. length(): number;
  75572. /**
  75573. * Gets the vector squared length
  75574. * @returns the vector squared length (float)
  75575. */
  75576. lengthSquared(): number;
  75577. /**
  75578. * Normalize the vector
  75579. * @returns the current updated Vector2
  75580. */
  75581. normalize(): Vector2;
  75582. /**
  75583. * Gets a new Vector2 copied from the Vector2
  75584. * @returns a new Vector2
  75585. */
  75586. clone(): Vector2;
  75587. /**
  75588. * Gets a new Vector2(0, 0)
  75589. * @returns a new Vector2
  75590. */
  75591. static Zero(): Vector2;
  75592. /**
  75593. * Gets a new Vector2(1, 1)
  75594. * @returns a new Vector2
  75595. */
  75596. static One(): Vector2;
  75597. /**
  75598. * Gets a new Vector2 set from the given index element of the given array
  75599. * @param array defines the data source
  75600. * @param offset defines the offset in the data source
  75601. * @returns a new Vector2
  75602. */
  75603. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75604. /**
  75605. * Sets "result" from the given index element of the given array
  75606. * @param array defines the data source
  75607. * @param offset defines the offset in the data source
  75608. * @param result defines the target vector
  75609. */
  75610. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75611. /**
  75612. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75613. * @param value1 defines 1st point of control
  75614. * @param value2 defines 2nd point of control
  75615. * @param value3 defines 3rd point of control
  75616. * @param value4 defines 4th point of control
  75617. * @param amount defines the interpolation factor
  75618. * @returns a new Vector2
  75619. */
  75620. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75621. /**
  75622. * 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".
  75623. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75624. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75625. * @param value defines the value to clamp
  75626. * @param min defines the lower limit
  75627. * @param max defines the upper limit
  75628. * @returns a new Vector2
  75629. */
  75630. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75631. /**
  75632. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75633. * @param value1 defines the 1st control point
  75634. * @param tangent1 defines the outgoing tangent
  75635. * @param value2 defines the 2nd control point
  75636. * @param tangent2 defines the incoming tangent
  75637. * @param amount defines the interpolation factor
  75638. * @returns a new Vector2
  75639. */
  75640. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75641. /**
  75642. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75643. * @param start defines the start vector
  75644. * @param end defines the end vector
  75645. * @param amount defines the interpolation factor
  75646. * @returns a new Vector2
  75647. */
  75648. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75649. /**
  75650. * Gets the dot product of the vector "left" and the vector "right"
  75651. * @param left defines first vector
  75652. * @param right defines second vector
  75653. * @returns the dot product (float)
  75654. */
  75655. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75656. /**
  75657. * Returns a new Vector2 equal to the normalized given vector
  75658. * @param vector defines the vector to normalize
  75659. * @returns a new Vector2
  75660. */
  75661. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75662. /**
  75663. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75664. * @param left defines 1st vector
  75665. * @param right defines 2nd vector
  75666. * @returns a new Vector2
  75667. */
  75668. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75669. /**
  75670. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75671. * @param left defines 1st vector
  75672. * @param right defines 2nd vector
  75673. * @returns a new Vector2
  75674. */
  75675. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75676. /**
  75677. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75678. * @param vector defines the vector to transform
  75679. * @param transformation defines the matrix to apply
  75680. * @returns a new Vector2
  75681. */
  75682. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75683. /**
  75684. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75685. * @param vector defines the vector to transform
  75686. * @param transformation defines the matrix to apply
  75687. * @param result defines the target vector
  75688. */
  75689. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75690. /**
  75691. * Determines if a given vector is included in a triangle
  75692. * @param p defines the vector to test
  75693. * @param p0 defines 1st triangle point
  75694. * @param p1 defines 2nd triangle point
  75695. * @param p2 defines 3rd triangle point
  75696. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75697. */
  75698. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75699. /**
  75700. * Gets the distance between the vectors "value1" and "value2"
  75701. * @param value1 defines first vector
  75702. * @param value2 defines second vector
  75703. * @returns the distance between vectors
  75704. */
  75705. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75706. /**
  75707. * Returns the squared distance between the vectors "value1" and "value2"
  75708. * @param value1 defines first vector
  75709. * @param value2 defines second vector
  75710. * @returns the squared distance between vectors
  75711. */
  75712. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75713. /**
  75714. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75715. * @param value1 defines first vector
  75716. * @param value2 defines second vector
  75717. * @returns a new Vector2
  75718. */
  75719. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75720. /**
  75721. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75722. * @param p defines the middle point
  75723. * @param segA defines one point of the segment
  75724. * @param segB defines the other point of the segment
  75725. * @returns the shortest distance
  75726. */
  75727. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75728. }
  75729. /**
  75730. * Class used to store (x,y,z) vector representation
  75731. * A Vector3 is the main object used in 3D geometry
  75732. * It can represent etiher the coordinates of a point the space, either a direction
  75733. * Reminder: js uses a left handed forward facing system
  75734. */
  75735. export class Vector3 {
  75736. /**
  75737. * Defines the first coordinates (on X axis)
  75738. */
  75739. x: number;
  75740. /**
  75741. * Defines the second coordinates (on Y axis)
  75742. */
  75743. y: number;
  75744. /**
  75745. * Defines the third coordinates (on Z axis)
  75746. */
  75747. z: number;
  75748. private static _UpReadOnly;
  75749. private static _ZeroReadOnly;
  75750. /**
  75751. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75752. * @param x defines the first coordinates (on X axis)
  75753. * @param y defines the second coordinates (on Y axis)
  75754. * @param z defines the third coordinates (on Z axis)
  75755. */
  75756. constructor(
  75757. /**
  75758. * Defines the first coordinates (on X axis)
  75759. */
  75760. x?: number,
  75761. /**
  75762. * Defines the second coordinates (on Y axis)
  75763. */
  75764. y?: number,
  75765. /**
  75766. * Defines the third coordinates (on Z axis)
  75767. */
  75768. z?: number);
  75769. /**
  75770. * Creates a string representation of the Vector3
  75771. * @returns a string with the Vector3 coordinates.
  75772. */
  75773. toString(): string;
  75774. /**
  75775. * Gets the class name
  75776. * @returns the string "Vector3"
  75777. */
  75778. getClassName(): string;
  75779. /**
  75780. * Creates the Vector3 hash code
  75781. * @returns a number which tends to be unique between Vector3 instances
  75782. */
  75783. getHashCode(): number;
  75784. /**
  75785. * Creates an array containing three elements : the coordinates of the Vector3
  75786. * @returns a new array of numbers
  75787. */
  75788. asArray(): number[];
  75789. /**
  75790. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75791. * @param array defines the destination array
  75792. * @param index defines the offset in the destination array
  75793. * @returns the current Vector3
  75794. */
  75795. toArray(array: FloatArray, index?: number): Vector3;
  75796. /**
  75797. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75798. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75799. */
  75800. toQuaternion(): Quaternion;
  75801. /**
  75802. * Adds the given vector to the current Vector3
  75803. * @param otherVector defines the second operand
  75804. * @returns the current updated Vector3
  75805. */
  75806. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75807. /**
  75808. * Adds the given coordinates to the current Vector3
  75809. * @param x defines the x coordinate of the operand
  75810. * @param y defines the y coordinate of the operand
  75811. * @param z defines the z coordinate of the operand
  75812. * @returns the current updated Vector3
  75813. */
  75814. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75815. /**
  75816. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75817. * @param otherVector defines the second operand
  75818. * @returns the resulting Vector3
  75819. */
  75820. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75821. /**
  75822. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75823. * @param otherVector defines the second operand
  75824. * @param result defines the Vector3 object where to store the result
  75825. * @returns the current Vector3
  75826. */
  75827. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75828. /**
  75829. * Subtract the given vector from the current Vector3
  75830. * @param otherVector defines the second operand
  75831. * @returns the current updated Vector3
  75832. */
  75833. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75834. /**
  75835. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75836. * @param otherVector defines the second operand
  75837. * @returns the resulting Vector3
  75838. */
  75839. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75840. /**
  75841. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75842. * @param otherVector defines the second operand
  75843. * @param result defines the Vector3 object where to store the result
  75844. * @returns the current Vector3
  75845. */
  75846. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75847. /**
  75848. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75849. * @param x defines the x coordinate of the operand
  75850. * @param y defines the y coordinate of the operand
  75851. * @param z defines the z coordinate of the operand
  75852. * @returns the resulting Vector3
  75853. */
  75854. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75855. /**
  75856. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75857. * @param x defines the x coordinate of the operand
  75858. * @param y defines the y coordinate of the operand
  75859. * @param z defines the z coordinate of the operand
  75860. * @param result defines the Vector3 object where to store the result
  75861. * @returns the current Vector3
  75862. */
  75863. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75864. /**
  75865. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75866. * @returns a new Vector3
  75867. */
  75868. negate(): Vector3;
  75869. /**
  75870. * Negate this vector in place
  75871. * @returns this
  75872. */
  75873. negateInPlace(): Vector3;
  75874. /**
  75875. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75876. * @param result defines the Vector3 object where to store the result
  75877. * @returns the current Vector3
  75878. */
  75879. negateToRef(result: Vector3): Vector3;
  75880. /**
  75881. * Multiplies the Vector3 coordinates by the float "scale"
  75882. * @param scale defines the multiplier factor
  75883. * @returns the current updated Vector3
  75884. */
  75885. scaleInPlace(scale: number): Vector3;
  75886. /**
  75887. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75888. * @param scale defines the multiplier factor
  75889. * @returns a new Vector3
  75890. */
  75891. scale(scale: number): Vector3;
  75892. /**
  75893. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75894. * @param scale defines the multiplier factor
  75895. * @param result defines the Vector3 object where to store the result
  75896. * @returns the current Vector3
  75897. */
  75898. scaleToRef(scale: number, result: Vector3): Vector3;
  75899. /**
  75900. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75901. * @param scale defines the scale factor
  75902. * @param result defines the Vector3 object where to store the result
  75903. * @returns the unmodified current Vector3
  75904. */
  75905. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75906. /**
  75907. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75908. * @param otherVector defines the second operand
  75909. * @returns true if both vectors are equals
  75910. */
  75911. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75912. /**
  75913. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75914. * @param otherVector defines the second operand
  75915. * @param epsilon defines the minimal distance to define values as equals
  75916. * @returns true if both vectors are distant less than epsilon
  75917. */
  75918. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75919. /**
  75920. * Returns true if the current Vector3 coordinates equals the given floats
  75921. * @param x defines the x coordinate of the operand
  75922. * @param y defines the y coordinate of the operand
  75923. * @param z defines the z coordinate of the operand
  75924. * @returns true if both vectors are equals
  75925. */
  75926. equalsToFloats(x: number, y: number, z: number): boolean;
  75927. /**
  75928. * Multiplies the current Vector3 coordinates by the given ones
  75929. * @param otherVector defines the second operand
  75930. * @returns the current updated Vector3
  75931. */
  75932. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75933. /**
  75934. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75935. * @param otherVector defines the second operand
  75936. * @returns the new Vector3
  75937. */
  75938. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75939. /**
  75940. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75941. * @param otherVector defines the second operand
  75942. * @param result defines the Vector3 object where to store the result
  75943. * @returns the current Vector3
  75944. */
  75945. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75946. /**
  75947. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75948. * @param x defines the x coordinate of the operand
  75949. * @param y defines the y coordinate of the operand
  75950. * @param z defines the z coordinate of the operand
  75951. * @returns the new Vector3
  75952. */
  75953. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75954. /**
  75955. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75956. * @param otherVector defines the second operand
  75957. * @returns the new Vector3
  75958. */
  75959. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75960. /**
  75961. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75962. * @param otherVector defines the second operand
  75963. * @param result defines the Vector3 object where to store the result
  75964. * @returns the current Vector3
  75965. */
  75966. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75967. /**
  75968. * Divides the current Vector3 coordinates by the given ones.
  75969. * @param otherVector defines the second operand
  75970. * @returns the current updated Vector3
  75971. */
  75972. divideInPlace(otherVector: Vector3): Vector3;
  75973. /**
  75974. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75975. * @param other defines the second operand
  75976. * @returns the current updated Vector3
  75977. */
  75978. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75979. /**
  75980. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75981. * @param other defines the second operand
  75982. * @returns the current updated Vector3
  75983. */
  75984. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75985. /**
  75986. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75987. * @param x defines the x coordinate of the operand
  75988. * @param y defines the y coordinate of the operand
  75989. * @param z defines the z coordinate of the operand
  75990. * @returns the current updated Vector3
  75991. */
  75992. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75993. /**
  75994. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75995. * @param x defines the x coordinate of the operand
  75996. * @param y defines the y coordinate of the operand
  75997. * @param z defines the z coordinate of the operand
  75998. * @returns the current updated Vector3
  75999. */
  76000. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76001. /**
  76002. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  76003. * Check if is non uniform within a certain amount of decimal places to account for this
  76004. * @param epsilon the amount the values can differ
  76005. * @returns if the the vector is non uniform to a certain number of decimal places
  76006. */
  76007. isNonUniformWithinEpsilon(epsilon: number): boolean;
  76008. /**
  76009. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  76010. */
  76011. get isNonUniform(): boolean;
  76012. /**
  76013. * Gets a new Vector3 from current Vector3 floored values
  76014. * @returns a new Vector3
  76015. */
  76016. floor(): Vector3;
  76017. /**
  76018. * Gets a new Vector3 from current Vector3 floored values
  76019. * @returns a new Vector3
  76020. */
  76021. fract(): Vector3;
  76022. /**
  76023. * Gets the length of the Vector3
  76024. * @returns the length of the Vector3
  76025. */
  76026. length(): number;
  76027. /**
  76028. * Gets the squared length of the Vector3
  76029. * @returns squared length of the Vector3
  76030. */
  76031. lengthSquared(): number;
  76032. /**
  76033. * Normalize the current Vector3.
  76034. * Please note that this is an in place operation.
  76035. * @returns the current updated Vector3
  76036. */
  76037. normalize(): Vector3;
  76038. /**
  76039. * Reorders the x y z properties of the vector in place
  76040. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  76041. * @returns the current updated vector
  76042. */
  76043. reorderInPlace(order: string): this;
  76044. /**
  76045. * Rotates the vector around 0,0,0 by a quaternion
  76046. * @param quaternion the rotation quaternion
  76047. * @param result vector to store the result
  76048. * @returns the resulting vector
  76049. */
  76050. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  76051. /**
  76052. * Rotates a vector around a given point
  76053. * @param quaternion the rotation quaternion
  76054. * @param point the point to rotate around
  76055. * @param result vector to store the result
  76056. * @returns the resulting vector
  76057. */
  76058. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  76059. /**
  76060. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  76061. * The cross product is then orthogonal to both current and "other"
  76062. * @param other defines the right operand
  76063. * @returns the cross product
  76064. */
  76065. cross(other: Vector3): Vector3;
  76066. /**
  76067. * Normalize the current Vector3 with the given input length.
  76068. * Please note that this is an in place operation.
  76069. * @param len the length of the vector
  76070. * @returns the current updated Vector3
  76071. */
  76072. normalizeFromLength(len: number): Vector3;
  76073. /**
  76074. * Normalize the current Vector3 to a new vector
  76075. * @returns the new Vector3
  76076. */
  76077. normalizeToNew(): Vector3;
  76078. /**
  76079. * Normalize the current Vector3 to the reference
  76080. * @param reference define the Vector3 to update
  76081. * @returns the updated Vector3
  76082. */
  76083. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  76084. /**
  76085. * Creates a new Vector3 copied from the current Vector3
  76086. * @returns the new Vector3
  76087. */
  76088. clone(): Vector3;
  76089. /**
  76090. * Copies the given vector coordinates to the current Vector3 ones
  76091. * @param source defines the source Vector3
  76092. * @returns the current updated Vector3
  76093. */
  76094. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  76095. /**
  76096. * Copies the given floats to the current Vector3 coordinates
  76097. * @param x defines the x coordinate of the operand
  76098. * @param y defines the y coordinate of the operand
  76099. * @param z defines the z coordinate of the operand
  76100. * @returns the current updated Vector3
  76101. */
  76102. copyFromFloats(x: number, y: number, z: number): Vector3;
  76103. /**
  76104. * Copies the given floats to the current Vector3 coordinates
  76105. * @param x defines the x coordinate of the operand
  76106. * @param y defines the y coordinate of the operand
  76107. * @param z defines the z coordinate of the operand
  76108. * @returns the current updated Vector3
  76109. */
  76110. set(x: number, y: number, z: number): Vector3;
  76111. /**
  76112. * Copies the given float to the current Vector3 coordinates
  76113. * @param v defines the x, y and z coordinates of the operand
  76114. * @returns the current updated Vector3
  76115. */
  76116. setAll(v: number): Vector3;
  76117. /**
  76118. * Get the clip factor between two vectors
  76119. * @param vector0 defines the first operand
  76120. * @param vector1 defines the second operand
  76121. * @param axis defines the axis to use
  76122. * @param size defines the size along the axis
  76123. * @returns the clip factor
  76124. */
  76125. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76126. /**
  76127. * Get angle between two vectors
  76128. * @param vector0 angle between vector0 and vector1
  76129. * @param vector1 angle between vector0 and vector1
  76130. * @param normal direction of the normal
  76131. * @return the angle between vector0 and vector1
  76132. */
  76133. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76134. /**
  76135. * Returns a new Vector3 set from the index "offset" of the given array
  76136. * @param array defines the source array
  76137. * @param offset defines the offset in the source array
  76138. * @returns the new Vector3
  76139. */
  76140. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76141. /**
  76142. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76143. * @param array defines the source array
  76144. * @param offset defines the offset in the source array
  76145. * @returns the new Vector3
  76146. * @deprecated Please use FromArray instead.
  76147. */
  76148. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76149. /**
  76150. * Sets the given vector "result" with the element values from the index "offset" of the given array
  76151. * @param array defines the source array
  76152. * @param offset defines the offset in the source array
  76153. * @param result defines the Vector3 where to store the result
  76154. */
  76155. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  76156. /**
  76157. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  76158. * @param array defines the source array
  76159. * @param offset defines the offset in the source array
  76160. * @param result defines the Vector3 where to store the result
  76161. * @deprecated Please use FromArrayToRef instead.
  76162. */
  76163. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  76164. /**
  76165. * Sets the given vector "result" with the given floats.
  76166. * @param x defines the x coordinate of the source
  76167. * @param y defines the y coordinate of the source
  76168. * @param z defines the z coordinate of the source
  76169. * @param result defines the Vector3 where to store the result
  76170. */
  76171. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  76172. /**
  76173. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  76174. * @returns a new empty Vector3
  76175. */
  76176. static Zero(): Vector3;
  76177. /**
  76178. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  76179. * @returns a new unit Vector3
  76180. */
  76181. static One(): Vector3;
  76182. /**
  76183. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  76184. * @returns a new up Vector3
  76185. */
  76186. static Up(): Vector3;
  76187. /**
  76188. * Gets a up Vector3 that must not be updated
  76189. */
  76190. static get UpReadOnly(): DeepImmutable<Vector3>;
  76191. /**
  76192. * Gets a zero Vector3 that must not be updated
  76193. */
  76194. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76195. /**
  76196. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76197. * @returns a new down Vector3
  76198. */
  76199. static Down(): Vector3;
  76200. /**
  76201. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76202. * @returns a new forward Vector3
  76203. */
  76204. static Forward(): Vector3;
  76205. /**
  76206. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76207. * @returns a new forward Vector3
  76208. */
  76209. static Backward(): Vector3;
  76210. /**
  76211. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76212. * @returns a new right Vector3
  76213. */
  76214. static Right(): Vector3;
  76215. /**
  76216. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76217. * @returns a new left Vector3
  76218. */
  76219. static Left(): Vector3;
  76220. /**
  76221. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76222. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76223. * @param vector defines the Vector3 to transform
  76224. * @param transformation defines the transformation matrix
  76225. * @returns the transformed Vector3
  76226. */
  76227. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76228. /**
  76229. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76230. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76231. * @param vector defines the Vector3 to transform
  76232. * @param transformation defines the transformation matrix
  76233. * @param result defines the Vector3 where to store the result
  76234. */
  76235. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76236. /**
  76237. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76238. * This method computes tranformed coordinates only, not transformed direction vectors
  76239. * @param x define the x coordinate of the source vector
  76240. * @param y define the y coordinate of the source vector
  76241. * @param z define the z coordinate of the source vector
  76242. * @param transformation defines the transformation matrix
  76243. * @param result defines the Vector3 where to store the result
  76244. */
  76245. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76246. /**
  76247. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76248. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76249. * @param vector defines the Vector3 to transform
  76250. * @param transformation defines the transformation matrix
  76251. * @returns the new Vector3
  76252. */
  76253. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76254. /**
  76255. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76256. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76257. * @param vector defines the Vector3 to transform
  76258. * @param transformation defines the transformation matrix
  76259. * @param result defines the Vector3 where to store the result
  76260. */
  76261. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76262. /**
  76263. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76264. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76265. * @param x define the x coordinate of the source vector
  76266. * @param y define the y coordinate of the source vector
  76267. * @param z define the z coordinate of the source vector
  76268. * @param transformation defines the transformation matrix
  76269. * @param result defines the Vector3 where to store the result
  76270. */
  76271. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76272. /**
  76273. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76274. * @param value1 defines the first control point
  76275. * @param value2 defines the second control point
  76276. * @param value3 defines the third control point
  76277. * @param value4 defines the fourth control point
  76278. * @param amount defines the amount on the spline to use
  76279. * @returns the new Vector3
  76280. */
  76281. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76282. /**
  76283. * 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"
  76284. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76285. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76286. * @param value defines the current value
  76287. * @param min defines the lower range value
  76288. * @param max defines the upper range value
  76289. * @returns the new Vector3
  76290. */
  76291. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76292. /**
  76293. * 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"
  76294. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76295. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76296. * @param value defines the current value
  76297. * @param min defines the lower range value
  76298. * @param max defines the upper range value
  76299. * @param result defines the Vector3 where to store the result
  76300. */
  76301. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76302. /**
  76303. * Checks if a given vector is inside a specific range
  76304. * @param v defines the vector to test
  76305. * @param min defines the minimum range
  76306. * @param max defines the maximum range
  76307. */
  76308. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76309. /**
  76310. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76311. * @param value1 defines the first control point
  76312. * @param tangent1 defines the first tangent vector
  76313. * @param value2 defines the second control point
  76314. * @param tangent2 defines the second tangent vector
  76315. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76316. * @returns the new Vector3
  76317. */
  76318. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76319. /**
  76320. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76321. * @param start defines the start value
  76322. * @param end defines the end value
  76323. * @param amount max defines amount between both (between 0 and 1)
  76324. * @returns the new Vector3
  76325. */
  76326. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76327. /**
  76328. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76329. * @param start defines the start value
  76330. * @param end defines the end value
  76331. * @param amount max defines amount between both (between 0 and 1)
  76332. * @param result defines the Vector3 where to store the result
  76333. */
  76334. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76335. /**
  76336. * Returns the dot product (float) between the vectors "left" and "right"
  76337. * @param left defines the left operand
  76338. * @param right defines the right operand
  76339. * @returns the dot product
  76340. */
  76341. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76342. /**
  76343. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76344. * The cross product is then orthogonal to both "left" and "right"
  76345. * @param left defines the left operand
  76346. * @param right defines the right operand
  76347. * @returns the cross product
  76348. */
  76349. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76350. /**
  76351. * Sets the given vector "result" with the cross product of "left" and "right"
  76352. * The cross product is then orthogonal to both "left" and "right"
  76353. * @param left defines the left operand
  76354. * @param right defines the right operand
  76355. * @param result defines the Vector3 where to store the result
  76356. */
  76357. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76358. /**
  76359. * Returns a new Vector3 as the normalization of the given vector
  76360. * @param vector defines the Vector3 to normalize
  76361. * @returns the new Vector3
  76362. */
  76363. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76364. /**
  76365. * Sets the given vector "result" with the normalization of the given first vector
  76366. * @param vector defines the Vector3 to normalize
  76367. * @param result defines the Vector3 where to store the result
  76368. */
  76369. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76370. /**
  76371. * Project a Vector3 onto screen space
  76372. * @param vector defines the Vector3 to project
  76373. * @param world defines the world matrix to use
  76374. * @param transform defines the transform (view x projection) matrix to use
  76375. * @param viewport defines the screen viewport to use
  76376. * @returns the new Vector3
  76377. */
  76378. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76379. /** @hidden */
  76380. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76381. /**
  76382. * Unproject from screen space to object space
  76383. * @param source defines the screen space Vector3 to use
  76384. * @param viewportWidth defines the current width of the viewport
  76385. * @param viewportHeight defines the current height of the viewport
  76386. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76387. * @param transform defines the transform (view x projection) matrix to use
  76388. * @returns the new Vector3
  76389. */
  76390. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76391. /**
  76392. * Unproject from screen space to object space
  76393. * @param source defines the screen space Vector3 to use
  76394. * @param viewportWidth defines the current width of the viewport
  76395. * @param viewportHeight defines the current height of the viewport
  76396. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76397. * @param view defines the view matrix to use
  76398. * @param projection defines the projection matrix to use
  76399. * @returns the new Vector3
  76400. */
  76401. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76402. /**
  76403. * Unproject from screen space to object space
  76404. * @param source defines the screen space Vector3 to use
  76405. * @param viewportWidth defines the current width of the viewport
  76406. * @param viewportHeight defines the current height of the viewport
  76407. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76408. * @param view defines the view matrix to use
  76409. * @param projection defines the projection matrix to use
  76410. * @param result defines the Vector3 where to store the result
  76411. */
  76412. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76413. /**
  76414. * Unproject from screen space to object space
  76415. * @param sourceX defines the screen space x coordinate to use
  76416. * @param sourceY defines the screen space y coordinate to use
  76417. * @param sourceZ defines the screen space z coordinate to use
  76418. * @param viewportWidth defines the current width of the viewport
  76419. * @param viewportHeight defines the current height of the viewport
  76420. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76421. * @param view defines the view matrix to use
  76422. * @param projection defines the projection matrix to use
  76423. * @param result defines the Vector3 where to store the result
  76424. */
  76425. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76426. /**
  76427. * Gets the minimal coordinate values between two Vector3
  76428. * @param left defines the first operand
  76429. * @param right defines the second operand
  76430. * @returns the new Vector3
  76431. */
  76432. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76433. /**
  76434. * Gets the maximal coordinate values between two Vector3
  76435. * @param left defines the first operand
  76436. * @param right defines the second operand
  76437. * @returns the new Vector3
  76438. */
  76439. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76440. /**
  76441. * Returns the distance between the vectors "value1" and "value2"
  76442. * @param value1 defines the first operand
  76443. * @param value2 defines the second operand
  76444. * @returns the distance
  76445. */
  76446. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76447. /**
  76448. * Returns the squared distance between the vectors "value1" and "value2"
  76449. * @param value1 defines the first operand
  76450. * @param value2 defines the second operand
  76451. * @returns the squared distance
  76452. */
  76453. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76454. /**
  76455. * Returns a new Vector3 located at the center between "value1" and "value2"
  76456. * @param value1 defines the first operand
  76457. * @param value2 defines the second operand
  76458. * @returns the new Vector3
  76459. */
  76460. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76461. /**
  76462. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76463. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76464. * to something in order to rotate it from its local system to the given target system
  76465. * Note: axis1, axis2 and axis3 are normalized during this operation
  76466. * @param axis1 defines the first axis
  76467. * @param axis2 defines the second axis
  76468. * @param axis3 defines the third axis
  76469. * @returns a new Vector3
  76470. */
  76471. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76472. /**
  76473. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76474. * @param axis1 defines the first axis
  76475. * @param axis2 defines the second axis
  76476. * @param axis3 defines the third axis
  76477. * @param ref defines the Vector3 where to store the result
  76478. */
  76479. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76480. }
  76481. /**
  76482. * Vector4 class created for EulerAngle class conversion to Quaternion
  76483. */
  76484. export class Vector4 {
  76485. /** x value of the vector */
  76486. x: number;
  76487. /** y value of the vector */
  76488. y: number;
  76489. /** z value of the vector */
  76490. z: number;
  76491. /** w value of the vector */
  76492. w: number;
  76493. /**
  76494. * Creates a Vector4 object from the given floats.
  76495. * @param x x value of the vector
  76496. * @param y y value of the vector
  76497. * @param z z value of the vector
  76498. * @param w w value of the vector
  76499. */
  76500. constructor(
  76501. /** x value of the vector */
  76502. x: number,
  76503. /** y value of the vector */
  76504. y: number,
  76505. /** z value of the vector */
  76506. z: number,
  76507. /** w value of the vector */
  76508. w: number);
  76509. /**
  76510. * Returns the string with the Vector4 coordinates.
  76511. * @returns a string containing all the vector values
  76512. */
  76513. toString(): string;
  76514. /**
  76515. * Returns the string "Vector4".
  76516. * @returns "Vector4"
  76517. */
  76518. getClassName(): string;
  76519. /**
  76520. * Returns the Vector4 hash code.
  76521. * @returns a unique hash code
  76522. */
  76523. getHashCode(): number;
  76524. /**
  76525. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76526. * @returns the resulting array
  76527. */
  76528. asArray(): number[];
  76529. /**
  76530. * Populates the given array from the given index with the Vector4 coordinates.
  76531. * @param array array to populate
  76532. * @param index index of the array to start at (default: 0)
  76533. * @returns the Vector4.
  76534. */
  76535. toArray(array: FloatArray, index?: number): Vector4;
  76536. /**
  76537. * Adds the given vector to the current Vector4.
  76538. * @param otherVector the vector to add
  76539. * @returns the updated Vector4.
  76540. */
  76541. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76542. /**
  76543. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76544. * @param otherVector the vector to add
  76545. * @returns the resulting vector
  76546. */
  76547. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76548. /**
  76549. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76550. * @param otherVector the vector to add
  76551. * @param result the vector to store the result
  76552. * @returns the current Vector4.
  76553. */
  76554. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76555. /**
  76556. * Subtract in place the given vector from the current Vector4.
  76557. * @param otherVector the vector to subtract
  76558. * @returns the updated Vector4.
  76559. */
  76560. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76561. /**
  76562. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76563. * @param otherVector the vector to add
  76564. * @returns the new vector with the result
  76565. */
  76566. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76567. /**
  76568. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76569. * @param otherVector the vector to subtract
  76570. * @param result the vector to store the result
  76571. * @returns the current Vector4.
  76572. */
  76573. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76574. /**
  76575. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76576. */
  76577. /**
  76578. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76579. * @param x value to subtract
  76580. * @param y value to subtract
  76581. * @param z value to subtract
  76582. * @param w value to subtract
  76583. * @returns new vector containing the result
  76584. */
  76585. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76586. /**
  76587. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76588. * @param x value to subtract
  76589. * @param y value to subtract
  76590. * @param z value to subtract
  76591. * @param w value to subtract
  76592. * @param result the vector to store the result in
  76593. * @returns the current Vector4.
  76594. */
  76595. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76596. /**
  76597. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76598. * @returns a new vector with the negated values
  76599. */
  76600. negate(): Vector4;
  76601. /**
  76602. * Negate this vector in place
  76603. * @returns this
  76604. */
  76605. negateInPlace(): Vector4;
  76606. /**
  76607. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76608. * @param result defines the Vector3 object where to store the result
  76609. * @returns the current Vector4
  76610. */
  76611. negateToRef(result: Vector4): Vector4;
  76612. /**
  76613. * Multiplies the current Vector4 coordinates by scale (float).
  76614. * @param scale the number to scale with
  76615. * @returns the updated Vector4.
  76616. */
  76617. scaleInPlace(scale: number): Vector4;
  76618. /**
  76619. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76620. * @param scale the number to scale with
  76621. * @returns a new vector with the result
  76622. */
  76623. scale(scale: number): Vector4;
  76624. /**
  76625. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76626. * @param scale the number to scale with
  76627. * @param result a vector to store the result in
  76628. * @returns the current Vector4.
  76629. */
  76630. scaleToRef(scale: number, result: Vector4): Vector4;
  76631. /**
  76632. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76633. * @param scale defines the scale factor
  76634. * @param result defines the Vector4 object where to store the result
  76635. * @returns the unmodified current Vector4
  76636. */
  76637. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76638. /**
  76639. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76640. * @param otherVector the vector to compare against
  76641. * @returns true if they are equal
  76642. */
  76643. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76644. /**
  76645. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76646. * @param otherVector vector to compare against
  76647. * @param epsilon (Default: very small number)
  76648. * @returns true if they are equal
  76649. */
  76650. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76651. /**
  76652. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76653. * @param x x value to compare against
  76654. * @param y y value to compare against
  76655. * @param z z value to compare against
  76656. * @param w w value to compare against
  76657. * @returns true if equal
  76658. */
  76659. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76660. /**
  76661. * Multiplies in place the current Vector4 by the given one.
  76662. * @param otherVector vector to multiple with
  76663. * @returns the updated Vector4.
  76664. */
  76665. multiplyInPlace(otherVector: Vector4): Vector4;
  76666. /**
  76667. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76668. * @param otherVector vector to multiple with
  76669. * @returns resulting new vector
  76670. */
  76671. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76672. /**
  76673. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76674. * @param otherVector vector to multiple with
  76675. * @param result vector to store the result
  76676. * @returns the current Vector4.
  76677. */
  76678. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76679. /**
  76680. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76681. * @param x x value multiply with
  76682. * @param y y value multiply with
  76683. * @param z z value multiply with
  76684. * @param w w value multiply with
  76685. * @returns resulting new vector
  76686. */
  76687. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76688. /**
  76689. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76690. * @param otherVector vector to devide with
  76691. * @returns resulting new vector
  76692. */
  76693. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76694. /**
  76695. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76696. * @param otherVector vector to devide with
  76697. * @param result vector to store the result
  76698. * @returns the current Vector4.
  76699. */
  76700. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76701. /**
  76702. * Divides the current Vector3 coordinates by the given ones.
  76703. * @param otherVector vector to devide with
  76704. * @returns the updated Vector3.
  76705. */
  76706. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76707. /**
  76708. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76709. * @param other defines the second operand
  76710. * @returns the current updated Vector4
  76711. */
  76712. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76713. /**
  76714. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76715. * @param other defines the second operand
  76716. * @returns the current updated Vector4
  76717. */
  76718. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76719. /**
  76720. * Gets a new Vector4 from current Vector4 floored values
  76721. * @returns a new Vector4
  76722. */
  76723. floor(): Vector4;
  76724. /**
  76725. * Gets a new Vector4 from current Vector3 floored values
  76726. * @returns a new Vector4
  76727. */
  76728. fract(): Vector4;
  76729. /**
  76730. * Returns the Vector4 length (float).
  76731. * @returns the length
  76732. */
  76733. length(): number;
  76734. /**
  76735. * Returns the Vector4 squared length (float).
  76736. * @returns the length squared
  76737. */
  76738. lengthSquared(): number;
  76739. /**
  76740. * Normalizes in place the Vector4.
  76741. * @returns the updated Vector4.
  76742. */
  76743. normalize(): Vector4;
  76744. /**
  76745. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76746. * @returns this converted to a new vector3
  76747. */
  76748. toVector3(): Vector3;
  76749. /**
  76750. * Returns a new Vector4 copied from the current one.
  76751. * @returns the new cloned vector
  76752. */
  76753. clone(): Vector4;
  76754. /**
  76755. * Updates the current Vector4 with the given one coordinates.
  76756. * @param source the source vector to copy from
  76757. * @returns the updated Vector4.
  76758. */
  76759. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76760. /**
  76761. * Updates the current Vector4 coordinates with the given floats.
  76762. * @param x float to copy from
  76763. * @param y float to copy from
  76764. * @param z float to copy from
  76765. * @param w float to copy from
  76766. * @returns the updated Vector4.
  76767. */
  76768. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76769. /**
  76770. * Updates the current Vector4 coordinates with the given floats.
  76771. * @param x float to set from
  76772. * @param y float to set from
  76773. * @param z float to set from
  76774. * @param w float to set from
  76775. * @returns the updated Vector4.
  76776. */
  76777. set(x: number, y: number, z: number, w: number): Vector4;
  76778. /**
  76779. * Copies the given float to the current Vector3 coordinates
  76780. * @param v defines the x, y, z and w coordinates of the operand
  76781. * @returns the current updated Vector3
  76782. */
  76783. setAll(v: number): Vector4;
  76784. /**
  76785. * Returns a new Vector4 set from the starting index of the given array.
  76786. * @param array the array to pull values from
  76787. * @param offset the offset into the array to start at
  76788. * @returns the new vector
  76789. */
  76790. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76791. /**
  76792. * Updates the given vector "result" from the starting index of the given array.
  76793. * @param array the array to pull values from
  76794. * @param offset the offset into the array to start at
  76795. * @param result the vector to store the result in
  76796. */
  76797. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76798. /**
  76799. * Updates the given vector "result" from the starting index of the given Float32Array.
  76800. * @param array the array to pull values from
  76801. * @param offset the offset into the array to start at
  76802. * @param result the vector to store the result in
  76803. */
  76804. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76805. /**
  76806. * Updates the given vector "result" coordinates from the given floats.
  76807. * @param x float to set from
  76808. * @param y float to set from
  76809. * @param z float to set from
  76810. * @param w float to set from
  76811. * @param result the vector to the floats in
  76812. */
  76813. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76814. /**
  76815. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76816. * @returns the new vector
  76817. */
  76818. static Zero(): Vector4;
  76819. /**
  76820. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76821. * @returns the new vector
  76822. */
  76823. static One(): Vector4;
  76824. /**
  76825. * Returns a new normalized Vector4 from the given one.
  76826. * @param vector the vector to normalize
  76827. * @returns the vector
  76828. */
  76829. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76830. /**
  76831. * Updates the given vector "result" from the normalization of the given one.
  76832. * @param vector the vector to normalize
  76833. * @param result the vector to store the result in
  76834. */
  76835. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76836. /**
  76837. * Returns a vector with the minimum values from the left and right vectors
  76838. * @param left left vector to minimize
  76839. * @param right right vector to minimize
  76840. * @returns a new vector with the minimum of the left and right vector values
  76841. */
  76842. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76843. /**
  76844. * Returns a vector with the maximum values from the left and right vectors
  76845. * @param left left vector to maximize
  76846. * @param right right vector to maximize
  76847. * @returns a new vector with the maximum of the left and right vector values
  76848. */
  76849. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76850. /**
  76851. * Returns the distance (float) between the vectors "value1" and "value2".
  76852. * @param value1 value to calulate the distance between
  76853. * @param value2 value to calulate the distance between
  76854. * @return the distance between the two vectors
  76855. */
  76856. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76857. /**
  76858. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76859. * @param value1 value to calulate the distance between
  76860. * @param value2 value to calulate the distance between
  76861. * @return the distance between the two vectors squared
  76862. */
  76863. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76864. /**
  76865. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76866. * @param value1 value to calulate the center between
  76867. * @param value2 value to calulate the center between
  76868. * @return the center between the two vectors
  76869. */
  76870. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76871. /**
  76872. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76873. * This methods computes transformed normalized direction vectors only.
  76874. * @param vector the vector to transform
  76875. * @param transformation the transformation matrix to apply
  76876. * @returns the new vector
  76877. */
  76878. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76879. /**
  76880. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76881. * This methods computes transformed normalized direction vectors only.
  76882. * @param vector the vector to transform
  76883. * @param transformation the transformation matrix to apply
  76884. * @param result the vector to store the result in
  76885. */
  76886. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76887. /**
  76888. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76889. * This methods computes transformed normalized direction vectors only.
  76890. * @param x value to transform
  76891. * @param y value to transform
  76892. * @param z value to transform
  76893. * @param w value to transform
  76894. * @param transformation the transformation matrix to apply
  76895. * @param result the vector to store the results in
  76896. */
  76897. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76898. /**
  76899. * Creates a new Vector4 from a Vector3
  76900. * @param source defines the source data
  76901. * @param w defines the 4th component (default is 0)
  76902. * @returns a new Vector4
  76903. */
  76904. static FromVector3(source: Vector3, w?: number): Vector4;
  76905. }
  76906. /**
  76907. * Class used to store quaternion data
  76908. * @see https://en.wikipedia.org/wiki/Quaternion
  76909. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76910. */
  76911. export class Quaternion {
  76912. /** defines the first component (0 by default) */
  76913. x: number;
  76914. /** defines the second component (0 by default) */
  76915. y: number;
  76916. /** defines the third component (0 by default) */
  76917. z: number;
  76918. /** defines the fourth component (1.0 by default) */
  76919. w: number;
  76920. /**
  76921. * Creates a new Quaternion from the given floats
  76922. * @param x defines the first component (0 by default)
  76923. * @param y defines the second component (0 by default)
  76924. * @param z defines the third component (0 by default)
  76925. * @param w defines the fourth component (1.0 by default)
  76926. */
  76927. constructor(
  76928. /** defines the first component (0 by default) */
  76929. x?: number,
  76930. /** defines the second component (0 by default) */
  76931. y?: number,
  76932. /** defines the third component (0 by default) */
  76933. z?: number,
  76934. /** defines the fourth component (1.0 by default) */
  76935. w?: number);
  76936. /**
  76937. * Gets a string representation for the current quaternion
  76938. * @returns a string with the Quaternion coordinates
  76939. */
  76940. toString(): string;
  76941. /**
  76942. * Gets the class name of the quaternion
  76943. * @returns the string "Quaternion"
  76944. */
  76945. getClassName(): string;
  76946. /**
  76947. * Gets a hash code for this quaternion
  76948. * @returns the quaternion hash code
  76949. */
  76950. getHashCode(): number;
  76951. /**
  76952. * Copy the quaternion to an array
  76953. * @returns a new array populated with 4 elements from the quaternion coordinates
  76954. */
  76955. asArray(): number[];
  76956. /**
  76957. * Check if two quaternions are equals
  76958. * @param otherQuaternion defines the second operand
  76959. * @return true if the current quaternion and the given one coordinates are strictly equals
  76960. */
  76961. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76962. /**
  76963. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76964. * @param otherQuaternion defines the other quaternion
  76965. * @param epsilon defines the minimal distance to consider equality
  76966. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76967. */
  76968. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76969. /**
  76970. * Clone the current quaternion
  76971. * @returns a new quaternion copied from the current one
  76972. */
  76973. clone(): Quaternion;
  76974. /**
  76975. * Copy a quaternion to the current one
  76976. * @param other defines the other quaternion
  76977. * @returns the updated current quaternion
  76978. */
  76979. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76980. /**
  76981. * Updates the current quaternion with the given float coordinates
  76982. * @param x defines the x coordinate
  76983. * @param y defines the y coordinate
  76984. * @param z defines the z coordinate
  76985. * @param w defines the w coordinate
  76986. * @returns the updated current quaternion
  76987. */
  76988. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76989. /**
  76990. * Updates the current quaternion from the given float coordinates
  76991. * @param x defines the x coordinate
  76992. * @param y defines the y coordinate
  76993. * @param z defines the z coordinate
  76994. * @param w defines the w coordinate
  76995. * @returns the updated current quaternion
  76996. */
  76997. set(x: number, y: number, z: number, w: number): Quaternion;
  76998. /**
  76999. * Adds two quaternions
  77000. * @param other defines the second operand
  77001. * @returns a new quaternion as the addition result of the given one and the current quaternion
  77002. */
  77003. add(other: DeepImmutable<Quaternion>): Quaternion;
  77004. /**
  77005. * Add a quaternion to the current one
  77006. * @param other defines the quaternion to add
  77007. * @returns the current quaternion
  77008. */
  77009. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  77010. /**
  77011. * Subtract two quaternions
  77012. * @param other defines the second operand
  77013. * @returns a new quaternion as the subtraction result of the given one from the current one
  77014. */
  77015. subtract(other: Quaternion): Quaternion;
  77016. /**
  77017. * Multiplies the current quaternion by a scale factor
  77018. * @param value defines the scale factor
  77019. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  77020. */
  77021. scale(value: number): Quaternion;
  77022. /**
  77023. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  77024. * @param scale defines the scale factor
  77025. * @param result defines the Quaternion object where to store the result
  77026. * @returns the unmodified current quaternion
  77027. */
  77028. scaleToRef(scale: number, result: Quaternion): Quaternion;
  77029. /**
  77030. * Multiplies in place the current quaternion by a scale factor
  77031. * @param value defines the scale factor
  77032. * @returns the current modified quaternion
  77033. */
  77034. scaleInPlace(value: number): Quaternion;
  77035. /**
  77036. * Scale the current quaternion values by a factor and add the result to a given quaternion
  77037. * @param scale defines the scale factor
  77038. * @param result defines the Quaternion object where to store the result
  77039. * @returns the unmodified current quaternion
  77040. */
  77041. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  77042. /**
  77043. * Multiplies two quaternions
  77044. * @param q1 defines the second operand
  77045. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  77046. */
  77047. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  77048. /**
  77049. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  77050. * @param q1 defines the second operand
  77051. * @param result defines the target quaternion
  77052. * @returns the current quaternion
  77053. */
  77054. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  77055. /**
  77056. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  77057. * @param q1 defines the second operand
  77058. * @returns the currentupdated quaternion
  77059. */
  77060. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  77061. /**
  77062. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  77063. * @param ref defines the target quaternion
  77064. * @returns the current quaternion
  77065. */
  77066. conjugateToRef(ref: Quaternion): Quaternion;
  77067. /**
  77068. * Conjugates in place (1-q) the current quaternion
  77069. * @returns the current updated quaternion
  77070. */
  77071. conjugateInPlace(): Quaternion;
  77072. /**
  77073. * Conjugates in place (1-q) the current quaternion
  77074. * @returns a new quaternion
  77075. */
  77076. conjugate(): Quaternion;
  77077. /**
  77078. * Gets length of current quaternion
  77079. * @returns the quaternion length (float)
  77080. */
  77081. length(): number;
  77082. /**
  77083. * Normalize in place the current quaternion
  77084. * @returns the current updated quaternion
  77085. */
  77086. normalize(): Quaternion;
  77087. /**
  77088. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  77089. * @param order is a reserved parameter and is ignore for now
  77090. * @returns a new Vector3 containing the Euler angles
  77091. */
  77092. toEulerAngles(order?: string): Vector3;
  77093. /**
  77094. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  77095. * @param result defines the vector which will be filled with the Euler angles
  77096. * @param order is a reserved parameter and is ignore for now
  77097. * @returns the current unchanged quaternion
  77098. */
  77099. toEulerAnglesToRef(result: Vector3): Quaternion;
  77100. /**
  77101. * Updates the given rotation matrix with the current quaternion values
  77102. * @param result defines the target matrix
  77103. * @returns the current unchanged quaternion
  77104. */
  77105. toRotationMatrix(result: Matrix): Quaternion;
  77106. /**
  77107. * Updates the current quaternion from the given rotation matrix values
  77108. * @param matrix defines the source matrix
  77109. * @returns the current updated quaternion
  77110. */
  77111. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77112. /**
  77113. * Creates a new quaternion from a rotation matrix
  77114. * @param matrix defines the source matrix
  77115. * @returns a new quaternion created from the given rotation matrix values
  77116. */
  77117. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77118. /**
  77119. * Updates the given quaternion with the given rotation matrix values
  77120. * @param matrix defines the source matrix
  77121. * @param result defines the target quaternion
  77122. */
  77123. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77124. /**
  77125. * Returns the dot product (float) between the quaternions "left" and "right"
  77126. * @param left defines the left operand
  77127. * @param right defines the right operand
  77128. * @returns the dot product
  77129. */
  77130. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77131. /**
  77132. * Checks if the two quaternions are close to each other
  77133. * @param quat0 defines the first quaternion to check
  77134. * @param quat1 defines the second quaternion to check
  77135. * @returns true if the two quaternions are close to each other
  77136. */
  77137. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77138. /**
  77139. * Creates an empty quaternion
  77140. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77141. */
  77142. static Zero(): Quaternion;
  77143. /**
  77144. * Inverse a given quaternion
  77145. * @param q defines the source quaternion
  77146. * @returns a new quaternion as the inverted current quaternion
  77147. */
  77148. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77149. /**
  77150. * Inverse a given quaternion
  77151. * @param q defines the source quaternion
  77152. * @param result the quaternion the result will be stored in
  77153. * @returns the result quaternion
  77154. */
  77155. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  77156. /**
  77157. * Creates an identity quaternion
  77158. * @returns the identity quaternion
  77159. */
  77160. static Identity(): Quaternion;
  77161. /**
  77162. * Gets a boolean indicating if the given quaternion is identity
  77163. * @param quaternion defines the quaternion to check
  77164. * @returns true if the quaternion is identity
  77165. */
  77166. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  77167. /**
  77168. * Creates a quaternion from a rotation around an axis
  77169. * @param axis defines the axis to use
  77170. * @param angle defines the angle to use
  77171. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  77172. */
  77173. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  77174. /**
  77175. * Creates a rotation around an axis and stores it into the given quaternion
  77176. * @param axis defines the axis to use
  77177. * @param angle defines the angle to use
  77178. * @param result defines the target quaternion
  77179. * @returns the target quaternion
  77180. */
  77181. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  77182. /**
  77183. * Creates a new quaternion from data stored into an array
  77184. * @param array defines the data source
  77185. * @param offset defines the offset in the source array where the data starts
  77186. * @returns a new quaternion
  77187. */
  77188. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  77189. /**
  77190. * Updates the given quaternion "result" from the starting index of the given array.
  77191. * @param array the array to pull values from
  77192. * @param offset the offset into the array to start at
  77193. * @param result the quaternion to store the result in
  77194. */
  77195. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  77196. /**
  77197. * Create a quaternion from Euler rotation angles
  77198. * @param x Pitch
  77199. * @param y Yaw
  77200. * @param z Roll
  77201. * @returns the new Quaternion
  77202. */
  77203. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77204. /**
  77205. * Updates a quaternion from Euler rotation angles
  77206. * @param x Pitch
  77207. * @param y Yaw
  77208. * @param z Roll
  77209. * @param result the quaternion to store the result
  77210. * @returns the updated quaternion
  77211. */
  77212. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77213. /**
  77214. * Create a quaternion from Euler rotation vector
  77215. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77216. * @returns the new Quaternion
  77217. */
  77218. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77219. /**
  77220. * Updates a quaternion from Euler rotation vector
  77221. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77222. * @param result the quaternion to store the result
  77223. * @returns the updated quaternion
  77224. */
  77225. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77226. /**
  77227. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77228. * @param yaw defines the rotation around Y axis
  77229. * @param pitch defines the rotation around X axis
  77230. * @param roll defines the rotation around Z axis
  77231. * @returns the new quaternion
  77232. */
  77233. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77234. /**
  77235. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77236. * @param yaw defines the rotation around Y axis
  77237. * @param pitch defines the rotation around X axis
  77238. * @param roll defines the rotation around Z axis
  77239. * @param result defines the target quaternion
  77240. */
  77241. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77242. /**
  77243. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77244. * @param alpha defines the rotation around first axis
  77245. * @param beta defines the rotation around second axis
  77246. * @param gamma defines the rotation around third axis
  77247. * @returns the new quaternion
  77248. */
  77249. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77250. /**
  77251. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77252. * @param alpha defines the rotation around first axis
  77253. * @param beta defines the rotation around second axis
  77254. * @param gamma defines the rotation around third axis
  77255. * @param result defines the target quaternion
  77256. */
  77257. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77258. /**
  77259. * 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)
  77260. * @param axis1 defines the first axis
  77261. * @param axis2 defines the second axis
  77262. * @param axis3 defines the third axis
  77263. * @returns the new quaternion
  77264. */
  77265. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77266. /**
  77267. * 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
  77268. * @param axis1 defines the first axis
  77269. * @param axis2 defines the second axis
  77270. * @param axis3 defines the third axis
  77271. * @param ref defines the target quaternion
  77272. */
  77273. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77274. /**
  77275. * Interpolates between two quaternions
  77276. * @param left defines first quaternion
  77277. * @param right defines second quaternion
  77278. * @param amount defines the gradient to use
  77279. * @returns the new interpolated quaternion
  77280. */
  77281. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77282. /**
  77283. * Interpolates between two quaternions and stores it into a target quaternion
  77284. * @param left defines first quaternion
  77285. * @param right defines second quaternion
  77286. * @param amount defines the gradient to use
  77287. * @param result defines the target quaternion
  77288. */
  77289. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77290. /**
  77291. * Interpolate between two quaternions using Hermite interpolation
  77292. * @param value1 defines first quaternion
  77293. * @param tangent1 defines the incoming tangent
  77294. * @param value2 defines second quaternion
  77295. * @param tangent2 defines the outgoing tangent
  77296. * @param amount defines the target quaternion
  77297. * @returns the new interpolated quaternion
  77298. */
  77299. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77300. }
  77301. /**
  77302. * Class used to store matrix data (4x4)
  77303. */
  77304. export class Matrix {
  77305. private static _updateFlagSeed;
  77306. private static _identityReadOnly;
  77307. private _isIdentity;
  77308. private _isIdentityDirty;
  77309. private _isIdentity3x2;
  77310. private _isIdentity3x2Dirty;
  77311. /**
  77312. * Gets the update flag of the matrix which is an unique number for the matrix.
  77313. * It will be incremented every time the matrix data change.
  77314. * You can use it to speed the comparison between two versions of the same matrix.
  77315. */
  77316. updateFlag: number;
  77317. private readonly _m;
  77318. /**
  77319. * Gets the internal data of the matrix
  77320. */
  77321. get m(): DeepImmutable<Float32Array>;
  77322. /** @hidden */
  77323. _markAsUpdated(): void;
  77324. /** @hidden */
  77325. private _updateIdentityStatus;
  77326. /**
  77327. * Creates an empty matrix (filled with zeros)
  77328. */
  77329. constructor();
  77330. /**
  77331. * Check if the current matrix is identity
  77332. * @returns true is the matrix is the identity matrix
  77333. */
  77334. isIdentity(): boolean;
  77335. /**
  77336. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77337. * @returns true is the matrix is the identity matrix
  77338. */
  77339. isIdentityAs3x2(): boolean;
  77340. /**
  77341. * Gets the determinant of the matrix
  77342. * @returns the matrix determinant
  77343. */
  77344. determinant(): number;
  77345. /**
  77346. * Returns the matrix as a Float32Array
  77347. * @returns the matrix underlying array
  77348. */
  77349. toArray(): DeepImmutable<Float32Array>;
  77350. /**
  77351. * Returns the matrix as a Float32Array
  77352. * @returns the matrix underlying array.
  77353. */
  77354. asArray(): DeepImmutable<Float32Array>;
  77355. /**
  77356. * Inverts the current matrix in place
  77357. * @returns the current inverted matrix
  77358. */
  77359. invert(): Matrix;
  77360. /**
  77361. * Sets all the matrix elements to zero
  77362. * @returns the current matrix
  77363. */
  77364. reset(): Matrix;
  77365. /**
  77366. * Adds the current matrix with a second one
  77367. * @param other defines the matrix to add
  77368. * @returns a new matrix as the addition of the current matrix and the given one
  77369. */
  77370. add(other: DeepImmutable<Matrix>): Matrix;
  77371. /**
  77372. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77373. * @param other defines the matrix to add
  77374. * @param result defines the target matrix
  77375. * @returns the current matrix
  77376. */
  77377. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77378. /**
  77379. * Adds in place the given matrix to the current matrix
  77380. * @param other defines the second operand
  77381. * @returns the current updated matrix
  77382. */
  77383. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77384. /**
  77385. * Sets the given matrix to the current inverted Matrix
  77386. * @param other defines the target matrix
  77387. * @returns the unmodified current matrix
  77388. */
  77389. invertToRef(other: Matrix): Matrix;
  77390. /**
  77391. * add a value at the specified position in the current Matrix
  77392. * @param index the index of the value within the matrix. between 0 and 15.
  77393. * @param value the value to be added
  77394. * @returns the current updated matrix
  77395. */
  77396. addAtIndex(index: number, value: number): Matrix;
  77397. /**
  77398. * mutiply the specified position in the current Matrix by a value
  77399. * @param index the index of the value within the matrix. between 0 and 15.
  77400. * @param value the value to be added
  77401. * @returns the current updated matrix
  77402. */
  77403. multiplyAtIndex(index: number, value: number): Matrix;
  77404. /**
  77405. * Inserts the translation vector (using 3 floats) in the current matrix
  77406. * @param x defines the 1st component of the translation
  77407. * @param y defines the 2nd component of the translation
  77408. * @param z defines the 3rd component of the translation
  77409. * @returns the current updated matrix
  77410. */
  77411. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77412. /**
  77413. * Adds the translation vector (using 3 floats) in the current matrix
  77414. * @param x defines the 1st component of the translation
  77415. * @param y defines the 2nd component of the translation
  77416. * @param z defines the 3rd component of the translation
  77417. * @returns the current updated matrix
  77418. */
  77419. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77420. /**
  77421. * Inserts the translation vector in the current matrix
  77422. * @param vector3 defines the translation to insert
  77423. * @returns the current updated matrix
  77424. */
  77425. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77426. /**
  77427. * Gets the translation value of the current matrix
  77428. * @returns a new Vector3 as the extracted translation from the matrix
  77429. */
  77430. getTranslation(): Vector3;
  77431. /**
  77432. * Fill a Vector3 with the extracted translation from the matrix
  77433. * @param result defines the Vector3 where to store the translation
  77434. * @returns the current matrix
  77435. */
  77436. getTranslationToRef(result: Vector3): Matrix;
  77437. /**
  77438. * Remove rotation and scaling part from the matrix
  77439. * @returns the updated matrix
  77440. */
  77441. removeRotationAndScaling(): Matrix;
  77442. /**
  77443. * Multiply two matrices
  77444. * @param other defines the second operand
  77445. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77446. */
  77447. multiply(other: DeepImmutable<Matrix>): Matrix;
  77448. /**
  77449. * Copy the current matrix from the given one
  77450. * @param other defines the source matrix
  77451. * @returns the current updated matrix
  77452. */
  77453. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77454. /**
  77455. * Populates the given array from the starting index with the current matrix values
  77456. * @param array defines the target array
  77457. * @param offset defines the offset in the target array where to start storing values
  77458. * @returns the current matrix
  77459. */
  77460. copyToArray(array: Float32Array, offset?: number): Matrix;
  77461. /**
  77462. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77463. * @param other defines the second operand
  77464. * @param result defines the matrix where to store the multiplication
  77465. * @returns the current matrix
  77466. */
  77467. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77468. /**
  77469. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77470. * @param other defines the second operand
  77471. * @param result defines the array where to store the multiplication
  77472. * @param offset defines the offset in the target array where to start storing values
  77473. * @returns the current matrix
  77474. */
  77475. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77476. /**
  77477. * Check equality between this matrix and a second one
  77478. * @param value defines the second matrix to compare
  77479. * @returns true is the current matrix and the given one values are strictly equal
  77480. */
  77481. equals(value: DeepImmutable<Matrix>): boolean;
  77482. /**
  77483. * Clone the current matrix
  77484. * @returns a new matrix from the current matrix
  77485. */
  77486. clone(): Matrix;
  77487. /**
  77488. * Returns the name of the current matrix class
  77489. * @returns the string "Matrix"
  77490. */
  77491. getClassName(): string;
  77492. /**
  77493. * Gets the hash code of the current matrix
  77494. * @returns the hash code
  77495. */
  77496. getHashCode(): number;
  77497. /**
  77498. * Decomposes the current Matrix into a translation, rotation and scaling components
  77499. * @param scale defines the scale vector3 given as a reference to update
  77500. * @param rotation defines the rotation quaternion given as a reference to update
  77501. * @param translation defines the translation vector3 given as a reference to update
  77502. * @returns true if operation was successful
  77503. */
  77504. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77505. /**
  77506. * Gets specific row of the matrix
  77507. * @param index defines the number of the row to get
  77508. * @returns the index-th row of the current matrix as a new Vector4
  77509. */
  77510. getRow(index: number): Nullable<Vector4>;
  77511. /**
  77512. * Sets the index-th row of the current matrix to the vector4 values
  77513. * @param index defines the number of the row to set
  77514. * @param row defines the target vector4
  77515. * @returns the updated current matrix
  77516. */
  77517. setRow(index: number, row: Vector4): Matrix;
  77518. /**
  77519. * Compute the transpose of the matrix
  77520. * @returns the new transposed matrix
  77521. */
  77522. transpose(): Matrix;
  77523. /**
  77524. * Compute the transpose of the matrix and store it in a given matrix
  77525. * @param result defines the target matrix
  77526. * @returns the current matrix
  77527. */
  77528. transposeToRef(result: Matrix): Matrix;
  77529. /**
  77530. * Sets the index-th row of the current matrix with the given 4 x float values
  77531. * @param index defines the row index
  77532. * @param x defines the x component to set
  77533. * @param y defines the y component to set
  77534. * @param z defines the z component to set
  77535. * @param w defines the w component to set
  77536. * @returns the updated current matrix
  77537. */
  77538. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77539. /**
  77540. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77541. * @param scale defines the scale factor
  77542. * @returns a new matrix
  77543. */
  77544. scale(scale: number): Matrix;
  77545. /**
  77546. * Scale the current matrix values by a factor to a given result matrix
  77547. * @param scale defines the scale factor
  77548. * @param result defines the matrix to store the result
  77549. * @returns the current matrix
  77550. */
  77551. scaleToRef(scale: number, result: Matrix): Matrix;
  77552. /**
  77553. * Scale the current matrix values by a factor and add the result to a given matrix
  77554. * @param scale defines the scale factor
  77555. * @param result defines the Matrix to store the result
  77556. * @returns the current matrix
  77557. */
  77558. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77559. /**
  77560. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77561. * @param ref matrix to store the result
  77562. */
  77563. toNormalMatrix(ref: Matrix): void;
  77564. /**
  77565. * Gets only rotation part of the current matrix
  77566. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77567. */
  77568. getRotationMatrix(): Matrix;
  77569. /**
  77570. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77571. * @param result defines the target matrix to store data to
  77572. * @returns the current matrix
  77573. */
  77574. getRotationMatrixToRef(result: Matrix): Matrix;
  77575. /**
  77576. * Toggles model matrix from being right handed to left handed in place and vice versa
  77577. */
  77578. toggleModelMatrixHandInPlace(): void;
  77579. /**
  77580. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77581. */
  77582. toggleProjectionMatrixHandInPlace(): void;
  77583. /**
  77584. * Creates a matrix from an array
  77585. * @param array defines the source array
  77586. * @param offset defines an offset in the source array
  77587. * @returns a new Matrix set from the starting index of the given array
  77588. */
  77589. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77590. /**
  77591. * Copy the content of an array into a given matrix
  77592. * @param array defines the source array
  77593. * @param offset defines an offset in the source array
  77594. * @param result defines the target matrix
  77595. */
  77596. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77597. /**
  77598. * Stores an array into a matrix after having multiplied each component by a given factor
  77599. * @param array defines the source array
  77600. * @param offset defines the offset in the source array
  77601. * @param scale defines the scaling factor
  77602. * @param result defines the target matrix
  77603. */
  77604. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77605. /**
  77606. * Gets an identity matrix that must not be updated
  77607. */
  77608. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77609. /**
  77610. * Stores a list of values (16) inside a given matrix
  77611. * @param initialM11 defines 1st value of 1st row
  77612. * @param initialM12 defines 2nd value of 1st row
  77613. * @param initialM13 defines 3rd value of 1st row
  77614. * @param initialM14 defines 4th value of 1st row
  77615. * @param initialM21 defines 1st value of 2nd row
  77616. * @param initialM22 defines 2nd value of 2nd row
  77617. * @param initialM23 defines 3rd value of 2nd row
  77618. * @param initialM24 defines 4th value of 2nd row
  77619. * @param initialM31 defines 1st value of 3rd row
  77620. * @param initialM32 defines 2nd value of 3rd row
  77621. * @param initialM33 defines 3rd value of 3rd row
  77622. * @param initialM34 defines 4th value of 3rd row
  77623. * @param initialM41 defines 1st value of 4th row
  77624. * @param initialM42 defines 2nd value of 4th row
  77625. * @param initialM43 defines 3rd value of 4th row
  77626. * @param initialM44 defines 4th value of 4th row
  77627. * @param result defines the target matrix
  77628. */
  77629. 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;
  77630. /**
  77631. * Creates new matrix from a list of values (16)
  77632. * @param initialM11 defines 1st value of 1st row
  77633. * @param initialM12 defines 2nd value of 1st row
  77634. * @param initialM13 defines 3rd value of 1st row
  77635. * @param initialM14 defines 4th value of 1st row
  77636. * @param initialM21 defines 1st value of 2nd row
  77637. * @param initialM22 defines 2nd value of 2nd row
  77638. * @param initialM23 defines 3rd value of 2nd row
  77639. * @param initialM24 defines 4th value of 2nd row
  77640. * @param initialM31 defines 1st value of 3rd row
  77641. * @param initialM32 defines 2nd value of 3rd row
  77642. * @param initialM33 defines 3rd value of 3rd row
  77643. * @param initialM34 defines 4th value of 3rd row
  77644. * @param initialM41 defines 1st value of 4th row
  77645. * @param initialM42 defines 2nd value of 4th row
  77646. * @param initialM43 defines 3rd value of 4th row
  77647. * @param initialM44 defines 4th value of 4th row
  77648. * @returns the new matrix
  77649. */
  77650. 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;
  77651. /**
  77652. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77653. * @param scale defines the scale vector3
  77654. * @param rotation defines the rotation quaternion
  77655. * @param translation defines the translation vector3
  77656. * @returns a new matrix
  77657. */
  77658. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77659. /**
  77660. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77661. * @param scale defines the scale vector3
  77662. * @param rotation defines the rotation quaternion
  77663. * @param translation defines the translation vector3
  77664. * @param result defines the target matrix
  77665. */
  77666. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77667. /**
  77668. * Creates a new identity matrix
  77669. * @returns a new identity matrix
  77670. */
  77671. static Identity(): Matrix;
  77672. /**
  77673. * Creates a new identity matrix and stores the result in a given matrix
  77674. * @param result defines the target matrix
  77675. */
  77676. static IdentityToRef(result: Matrix): void;
  77677. /**
  77678. * Creates a new zero matrix
  77679. * @returns a new zero matrix
  77680. */
  77681. static Zero(): Matrix;
  77682. /**
  77683. * Creates a new rotation matrix for "angle" radians around the X axis
  77684. * @param angle defines the angle (in radians) to use
  77685. * @return the new matrix
  77686. */
  77687. static RotationX(angle: number): Matrix;
  77688. /**
  77689. * Creates a new matrix as the invert of a given matrix
  77690. * @param source defines the source matrix
  77691. * @returns the new matrix
  77692. */
  77693. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77694. /**
  77695. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77696. * @param angle defines the angle (in radians) to use
  77697. * @param result defines the target matrix
  77698. */
  77699. static RotationXToRef(angle: number, result: Matrix): void;
  77700. /**
  77701. * Creates a new rotation matrix for "angle" radians around the Y axis
  77702. * @param angle defines the angle (in radians) to use
  77703. * @return the new matrix
  77704. */
  77705. static RotationY(angle: number): Matrix;
  77706. /**
  77707. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77708. * @param angle defines the angle (in radians) to use
  77709. * @param result defines the target matrix
  77710. */
  77711. static RotationYToRef(angle: number, result: Matrix): void;
  77712. /**
  77713. * Creates a new rotation matrix for "angle" radians around the Z axis
  77714. * @param angle defines the angle (in radians) to use
  77715. * @return the new matrix
  77716. */
  77717. static RotationZ(angle: number): Matrix;
  77718. /**
  77719. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77720. * @param angle defines the angle (in radians) to use
  77721. * @param result defines the target matrix
  77722. */
  77723. static RotationZToRef(angle: number, result: Matrix): void;
  77724. /**
  77725. * Creates a new rotation matrix for "angle" radians around the given axis
  77726. * @param axis defines the axis to use
  77727. * @param angle defines the angle (in radians) to use
  77728. * @return the new matrix
  77729. */
  77730. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77731. /**
  77732. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77733. * @param axis defines the axis to use
  77734. * @param angle defines the angle (in radians) to use
  77735. * @param result defines the target matrix
  77736. */
  77737. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77738. /**
  77739. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77740. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77741. * @param from defines the vector to align
  77742. * @param to defines the vector to align to
  77743. * @param result defines the target matrix
  77744. */
  77745. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77746. /**
  77747. * Creates a rotation matrix
  77748. * @param yaw defines the yaw angle in radians (Y axis)
  77749. * @param pitch defines the pitch angle in radians (X axis)
  77750. * @param roll defines the roll angle in radians (X axis)
  77751. * @returns the new rotation matrix
  77752. */
  77753. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77754. /**
  77755. * Creates a rotation matrix and stores it in a given matrix
  77756. * @param yaw defines the yaw angle in radians (Y axis)
  77757. * @param pitch defines the pitch angle in radians (X axis)
  77758. * @param roll defines the roll angle in radians (X axis)
  77759. * @param result defines the target matrix
  77760. */
  77761. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77762. /**
  77763. * Creates a scaling matrix
  77764. * @param x defines the scale factor on X axis
  77765. * @param y defines the scale factor on Y axis
  77766. * @param z defines the scale factor on Z axis
  77767. * @returns the new matrix
  77768. */
  77769. static Scaling(x: number, y: number, z: number): Matrix;
  77770. /**
  77771. * Creates a scaling matrix and stores it in a given matrix
  77772. * @param x defines the scale factor on X axis
  77773. * @param y defines the scale factor on Y axis
  77774. * @param z defines the scale factor on Z axis
  77775. * @param result defines the target matrix
  77776. */
  77777. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77778. /**
  77779. * Creates a translation matrix
  77780. * @param x defines the translation on X axis
  77781. * @param y defines the translation on Y axis
  77782. * @param z defines the translationon Z axis
  77783. * @returns the new matrix
  77784. */
  77785. static Translation(x: number, y: number, z: number): Matrix;
  77786. /**
  77787. * Creates a translation matrix and stores it in a given matrix
  77788. * @param x defines the translation on X axis
  77789. * @param y defines the translation on Y axis
  77790. * @param z defines the translationon Z axis
  77791. * @param result defines the target matrix
  77792. */
  77793. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77794. /**
  77795. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77796. * @param startValue defines the start value
  77797. * @param endValue defines the end value
  77798. * @param gradient defines the gradient factor
  77799. * @returns the new matrix
  77800. */
  77801. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77802. /**
  77803. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77804. * @param startValue defines the start value
  77805. * @param endValue defines the end value
  77806. * @param gradient defines the gradient factor
  77807. * @param result defines the Matrix object where to store data
  77808. */
  77809. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77810. /**
  77811. * Builds a new matrix whose values are computed by:
  77812. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77813. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77814. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77815. * @param startValue defines the first matrix
  77816. * @param endValue defines the second matrix
  77817. * @param gradient defines the gradient between the two matrices
  77818. * @returns the new matrix
  77819. */
  77820. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77821. /**
  77822. * Update a matrix to values which are computed by:
  77823. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77824. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77825. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77826. * @param startValue defines the first matrix
  77827. * @param endValue defines the second matrix
  77828. * @param gradient defines the gradient between the two matrices
  77829. * @param result defines the target matrix
  77830. */
  77831. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77832. /**
  77833. * 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"
  77834. * This function works in left handed mode
  77835. * @param eye defines the final position of the entity
  77836. * @param target defines where the entity should look at
  77837. * @param up defines the up vector for the entity
  77838. * @returns the new matrix
  77839. */
  77840. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77841. /**
  77842. * 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".
  77843. * This function works in left handed mode
  77844. * @param eye defines the final position of the entity
  77845. * @param target defines where the entity should look at
  77846. * @param up defines the up vector for the entity
  77847. * @param result defines the target matrix
  77848. */
  77849. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77850. /**
  77851. * 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"
  77852. * This function works in right handed mode
  77853. * @param eye defines the final position of the entity
  77854. * @param target defines where the entity should look at
  77855. * @param up defines the up vector for the entity
  77856. * @returns the new matrix
  77857. */
  77858. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77859. /**
  77860. * 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".
  77861. * This function works in right handed mode
  77862. * @param eye defines the final position of the entity
  77863. * @param target defines where the entity should look at
  77864. * @param up defines the up vector for the entity
  77865. * @param result defines the target matrix
  77866. */
  77867. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77868. /**
  77869. * Create a left-handed orthographic projection matrix
  77870. * @param width defines the viewport width
  77871. * @param height defines the viewport height
  77872. * @param znear defines the near clip plane
  77873. * @param zfar defines the far clip plane
  77874. * @returns a new matrix as a left-handed orthographic projection matrix
  77875. */
  77876. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77877. /**
  77878. * Store a left-handed orthographic projection to a given matrix
  77879. * @param width defines the viewport width
  77880. * @param height defines the viewport height
  77881. * @param znear defines the near clip plane
  77882. * @param zfar defines the far clip plane
  77883. * @param result defines the target matrix
  77884. */
  77885. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77886. /**
  77887. * Create a left-handed orthographic projection matrix
  77888. * @param left defines the viewport left coordinate
  77889. * @param right defines the viewport right coordinate
  77890. * @param bottom defines the viewport bottom coordinate
  77891. * @param top defines the viewport top coordinate
  77892. * @param znear defines the near clip plane
  77893. * @param zfar defines the far clip plane
  77894. * @returns a new matrix as a left-handed orthographic projection matrix
  77895. */
  77896. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77897. /**
  77898. * Stores a left-handed orthographic projection into a given matrix
  77899. * @param left defines the viewport left coordinate
  77900. * @param right defines the viewport right coordinate
  77901. * @param bottom defines the viewport bottom coordinate
  77902. * @param top defines the viewport top coordinate
  77903. * @param znear defines the near clip plane
  77904. * @param zfar defines the far clip plane
  77905. * @param result defines the target matrix
  77906. */
  77907. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77908. /**
  77909. * Creates a right-handed orthographic projection matrix
  77910. * @param left defines the viewport left coordinate
  77911. * @param right defines the viewport right coordinate
  77912. * @param bottom defines the viewport bottom coordinate
  77913. * @param top defines the viewport top coordinate
  77914. * @param znear defines the near clip plane
  77915. * @param zfar defines the far clip plane
  77916. * @returns a new matrix as a right-handed orthographic projection matrix
  77917. */
  77918. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77919. /**
  77920. * Stores a right-handed orthographic projection into a given matrix
  77921. * @param left defines the viewport left coordinate
  77922. * @param right defines the viewport right coordinate
  77923. * @param bottom defines the viewport bottom coordinate
  77924. * @param top defines the viewport top coordinate
  77925. * @param znear defines the near clip plane
  77926. * @param zfar defines the far clip plane
  77927. * @param result defines the target matrix
  77928. */
  77929. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77930. /**
  77931. * Creates a left-handed perspective projection matrix
  77932. * @param width defines the viewport width
  77933. * @param height defines the viewport height
  77934. * @param znear defines the near clip plane
  77935. * @param zfar defines the far clip plane
  77936. * @returns a new matrix as a left-handed perspective projection matrix
  77937. */
  77938. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77939. /**
  77940. * Creates a left-handed perspective projection matrix
  77941. * @param fov defines the horizontal field of view
  77942. * @param aspect defines the aspect ratio
  77943. * @param znear defines the near clip plane
  77944. * @param zfar defines the far clip plane
  77945. * @returns a new matrix as a left-handed perspective projection matrix
  77946. */
  77947. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77948. /**
  77949. * Stores a left-handed perspective projection into a given matrix
  77950. * @param fov defines the horizontal field of view
  77951. * @param aspect defines the aspect ratio
  77952. * @param znear defines the near clip plane
  77953. * @param zfar defines the far clip plane
  77954. * @param result defines the target matrix
  77955. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77956. */
  77957. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77958. /**
  77959. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77960. * @param fov defines the horizontal field of view
  77961. * @param aspect defines the aspect ratio
  77962. * @param znear defines the near clip plane
  77963. * @param zfar not used as infinity is used as far clip
  77964. * @param result defines the target matrix
  77965. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77966. */
  77967. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77968. /**
  77969. * Creates a right-handed perspective projection matrix
  77970. * @param fov defines the horizontal field of view
  77971. * @param aspect defines the aspect ratio
  77972. * @param znear defines the near clip plane
  77973. * @param zfar defines the far clip plane
  77974. * @returns a new matrix as a right-handed perspective projection matrix
  77975. */
  77976. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77977. /**
  77978. * Stores a right-handed perspective projection into a given matrix
  77979. * @param fov defines the horizontal field of view
  77980. * @param aspect defines the aspect ratio
  77981. * @param znear defines the near clip plane
  77982. * @param zfar defines the far clip plane
  77983. * @param result defines the target matrix
  77984. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77985. */
  77986. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77987. /**
  77988. * Stores a right-handed perspective projection into a given matrix
  77989. * @param fov defines the horizontal field of view
  77990. * @param aspect defines the aspect ratio
  77991. * @param znear defines the near clip plane
  77992. * @param zfar not used as infinity is used as far clip
  77993. * @param result defines the target matrix
  77994. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77995. */
  77996. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77997. /**
  77998. * Stores a perspective projection for WebVR info a given matrix
  77999. * @param fov defines the field of view
  78000. * @param znear defines the near clip plane
  78001. * @param zfar defines the far clip plane
  78002. * @param result defines the target matrix
  78003. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  78004. */
  78005. static PerspectiveFovWebVRToRef(fov: {
  78006. upDegrees: number;
  78007. downDegrees: number;
  78008. leftDegrees: number;
  78009. rightDegrees: number;
  78010. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  78011. /**
  78012. * Computes a complete transformation matrix
  78013. * @param viewport defines the viewport to use
  78014. * @param world defines the world matrix
  78015. * @param view defines the view matrix
  78016. * @param projection defines the projection matrix
  78017. * @param zmin defines the near clip plane
  78018. * @param zmax defines the far clip plane
  78019. * @returns the transformation matrix
  78020. */
  78021. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  78022. /**
  78023. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  78024. * @param matrix defines the matrix to use
  78025. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  78026. */
  78027. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  78028. /**
  78029. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  78030. * @param matrix defines the matrix to use
  78031. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  78032. */
  78033. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  78034. /**
  78035. * Compute the transpose of a given matrix
  78036. * @param matrix defines the matrix to transpose
  78037. * @returns the new matrix
  78038. */
  78039. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  78040. /**
  78041. * Compute the transpose of a matrix and store it in a target matrix
  78042. * @param matrix defines the matrix to transpose
  78043. * @param result defines the target matrix
  78044. */
  78045. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  78046. /**
  78047. * Computes a reflection matrix from a plane
  78048. * @param plane defines the reflection plane
  78049. * @returns a new matrix
  78050. */
  78051. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  78052. /**
  78053. * Computes a reflection matrix from a plane
  78054. * @param plane defines the reflection plane
  78055. * @param result defines the target matrix
  78056. */
  78057. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  78058. /**
  78059. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  78060. * @param xaxis defines the value of the 1st axis
  78061. * @param yaxis defines the value of the 2nd axis
  78062. * @param zaxis defines the value of the 3rd axis
  78063. * @param result defines the target matrix
  78064. */
  78065. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  78066. /**
  78067. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  78068. * @param quat defines the quaternion to use
  78069. * @param result defines the target matrix
  78070. */
  78071. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  78072. }
  78073. /**
  78074. * @hidden
  78075. */
  78076. export class TmpVectors {
  78077. static Vector2: Vector2[];
  78078. static Vector3: Vector3[];
  78079. static Vector4: Vector4[];
  78080. static Quaternion: Quaternion[];
  78081. static Matrix: Matrix[];
  78082. }
  78083. }
  78084. declare module BABYLON {
  78085. /**
  78086. * Defines potential orientation for back face culling
  78087. */
  78088. export enum Orientation {
  78089. /**
  78090. * Clockwise
  78091. */
  78092. CW = 0,
  78093. /** Counter clockwise */
  78094. CCW = 1
  78095. }
  78096. /** Class used to represent a Bezier curve */
  78097. export class BezierCurve {
  78098. /**
  78099. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  78100. * @param t defines the time
  78101. * @param x1 defines the left coordinate on X axis
  78102. * @param y1 defines the left coordinate on Y axis
  78103. * @param x2 defines the right coordinate on X axis
  78104. * @param y2 defines the right coordinate on Y axis
  78105. * @returns the interpolated value
  78106. */
  78107. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  78108. }
  78109. /**
  78110. * Defines angle representation
  78111. */
  78112. export class Angle {
  78113. private _radians;
  78114. /**
  78115. * Creates an Angle object of "radians" radians (float).
  78116. * @param radians the angle in radians
  78117. */
  78118. constructor(radians: number);
  78119. /**
  78120. * Get value in degrees
  78121. * @returns the Angle value in degrees (float)
  78122. */
  78123. degrees(): number;
  78124. /**
  78125. * Get value in radians
  78126. * @returns the Angle value in radians (float)
  78127. */
  78128. radians(): number;
  78129. /**
  78130. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78131. * @param a defines first vector
  78132. * @param b defines second vector
  78133. * @returns a new Angle
  78134. */
  78135. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78136. /**
  78137. * Gets a new Angle object from the given float in radians
  78138. * @param radians defines the angle value in radians
  78139. * @returns a new Angle
  78140. */
  78141. static FromRadians(radians: number): Angle;
  78142. /**
  78143. * Gets a new Angle object from the given float in degrees
  78144. * @param degrees defines the angle value in degrees
  78145. * @returns a new Angle
  78146. */
  78147. static FromDegrees(degrees: number): Angle;
  78148. }
  78149. /**
  78150. * This represents an arc in a 2d space.
  78151. */
  78152. export class Arc2 {
  78153. /** Defines the start point of the arc */
  78154. startPoint: Vector2;
  78155. /** Defines the mid point of the arc */
  78156. midPoint: Vector2;
  78157. /** Defines the end point of the arc */
  78158. endPoint: Vector2;
  78159. /**
  78160. * Defines the center point of the arc.
  78161. */
  78162. centerPoint: Vector2;
  78163. /**
  78164. * Defines the radius of the arc.
  78165. */
  78166. radius: number;
  78167. /**
  78168. * Defines the angle of the arc (from mid point to end point).
  78169. */
  78170. angle: Angle;
  78171. /**
  78172. * Defines the start angle of the arc (from start point to middle point).
  78173. */
  78174. startAngle: Angle;
  78175. /**
  78176. * Defines the orientation of the arc (clock wise/counter clock wise).
  78177. */
  78178. orientation: Orientation;
  78179. /**
  78180. * Creates an Arc object from the three given points : start, middle and end.
  78181. * @param startPoint Defines the start point of the arc
  78182. * @param midPoint Defines the midlle point of the arc
  78183. * @param endPoint Defines the end point of the arc
  78184. */
  78185. constructor(
  78186. /** Defines the start point of the arc */
  78187. startPoint: Vector2,
  78188. /** Defines the mid point of the arc */
  78189. midPoint: Vector2,
  78190. /** Defines the end point of the arc */
  78191. endPoint: Vector2);
  78192. }
  78193. /**
  78194. * Represents a 2D path made up of multiple 2D points
  78195. */
  78196. export class Path2 {
  78197. private _points;
  78198. private _length;
  78199. /**
  78200. * If the path start and end point are the same
  78201. */
  78202. closed: boolean;
  78203. /**
  78204. * Creates a Path2 object from the starting 2D coordinates x and y.
  78205. * @param x the starting points x value
  78206. * @param y the starting points y value
  78207. */
  78208. constructor(x: number, y: number);
  78209. /**
  78210. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78211. * @param x the added points x value
  78212. * @param y the added points y value
  78213. * @returns the updated Path2.
  78214. */
  78215. addLineTo(x: number, y: number): Path2;
  78216. /**
  78217. * 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.
  78218. * @param midX middle point x value
  78219. * @param midY middle point y value
  78220. * @param endX end point x value
  78221. * @param endY end point y value
  78222. * @param numberOfSegments (default: 36)
  78223. * @returns the updated Path2.
  78224. */
  78225. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78226. /**
  78227. * Closes the Path2.
  78228. * @returns the Path2.
  78229. */
  78230. close(): Path2;
  78231. /**
  78232. * Gets the sum of the distance between each sequential point in the path
  78233. * @returns the Path2 total length (float).
  78234. */
  78235. length(): number;
  78236. /**
  78237. * Gets the points which construct the path
  78238. * @returns the Path2 internal array of points.
  78239. */
  78240. getPoints(): Vector2[];
  78241. /**
  78242. * Retreives the point at the distance aways from the starting point
  78243. * @param normalizedLengthPosition the length along the path to retreive the point from
  78244. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78245. */
  78246. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78247. /**
  78248. * Creates a new path starting from an x and y position
  78249. * @param x starting x value
  78250. * @param y starting y value
  78251. * @returns a new Path2 starting at the coordinates (x, y).
  78252. */
  78253. static StartingAt(x: number, y: number): Path2;
  78254. }
  78255. /**
  78256. * Represents a 3D path made up of multiple 3D points
  78257. */
  78258. export class Path3D {
  78259. /**
  78260. * an array of Vector3, the curve axis of the Path3D
  78261. */
  78262. path: Vector3[];
  78263. private _curve;
  78264. private _distances;
  78265. private _tangents;
  78266. private _normals;
  78267. private _binormals;
  78268. private _raw;
  78269. private _alignTangentsWithPath;
  78270. private readonly _pointAtData;
  78271. /**
  78272. * new Path3D(path, normal, raw)
  78273. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78274. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78275. * @param path an array of Vector3, the curve axis of the Path3D
  78276. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78277. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78278. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78279. */
  78280. constructor(
  78281. /**
  78282. * an array of Vector3, the curve axis of the Path3D
  78283. */
  78284. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78285. /**
  78286. * Returns the Path3D array of successive Vector3 designing its curve.
  78287. * @returns the Path3D array of successive Vector3 designing its curve.
  78288. */
  78289. getCurve(): Vector3[];
  78290. /**
  78291. * Returns the Path3D array of successive Vector3 designing its curve.
  78292. * @returns the Path3D array of successive Vector3 designing its curve.
  78293. */
  78294. getPoints(): Vector3[];
  78295. /**
  78296. * @returns the computed length (float) of the path.
  78297. */
  78298. length(): number;
  78299. /**
  78300. * Returns an array populated with tangent vectors on each Path3D curve point.
  78301. * @returns an array populated with tangent vectors on each Path3D curve point.
  78302. */
  78303. getTangents(): Vector3[];
  78304. /**
  78305. * Returns an array populated with normal vectors on each Path3D curve point.
  78306. * @returns an array populated with normal vectors on each Path3D curve point.
  78307. */
  78308. getNormals(): Vector3[];
  78309. /**
  78310. * Returns an array populated with binormal vectors on each Path3D curve point.
  78311. * @returns an array populated with binormal vectors on each Path3D curve point.
  78312. */
  78313. getBinormals(): Vector3[];
  78314. /**
  78315. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78316. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78317. */
  78318. getDistances(): number[];
  78319. /**
  78320. * Returns an interpolated point along this path
  78321. * @param position the position of the point along this path, from 0.0 to 1.0
  78322. * @returns a new Vector3 as the point
  78323. */
  78324. getPointAt(position: number): Vector3;
  78325. /**
  78326. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78327. * @param position the position of the point along this path, from 0.0 to 1.0
  78328. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78329. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78330. */
  78331. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78332. /**
  78333. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78334. * @param position the position of the point along this path, from 0.0 to 1.0
  78335. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78336. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78337. */
  78338. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78339. /**
  78340. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78341. * @param position the position of the point along this path, from 0.0 to 1.0
  78342. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78343. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78344. */
  78345. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78346. /**
  78347. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78348. * @param position the position of the point along this path, from 0.0 to 1.0
  78349. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78350. */
  78351. getDistanceAt(position: number): number;
  78352. /**
  78353. * Returns the array index of the previous point of an interpolated point along this path
  78354. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78355. * @returns the array index
  78356. */
  78357. getPreviousPointIndexAt(position: number): number;
  78358. /**
  78359. * 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)
  78360. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78361. * @returns the sub position
  78362. */
  78363. getSubPositionAt(position: number): number;
  78364. /**
  78365. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78366. * @param target the vector of which to get the closest position to
  78367. * @returns the position of the closest virtual point on this path to the target vector
  78368. */
  78369. getClosestPositionTo(target: Vector3): number;
  78370. /**
  78371. * Returns a sub path (slice) of this path
  78372. * @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
  78373. * @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
  78374. * @returns a sub path (slice) of this path
  78375. */
  78376. slice(start?: number, end?: number): Path3D;
  78377. /**
  78378. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78379. * @param path path which all values are copied into the curves points
  78380. * @param firstNormal which should be projected onto the curve
  78381. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78382. * @returns the same object updated.
  78383. */
  78384. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78385. private _compute;
  78386. private _getFirstNonNullVector;
  78387. private _getLastNonNullVector;
  78388. private _normalVector;
  78389. /**
  78390. * Updates the point at data for an interpolated point along this curve
  78391. * @param position the position of the point along this curve, from 0.0 to 1.0
  78392. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78393. * @returns the (updated) point at data
  78394. */
  78395. private _updatePointAtData;
  78396. /**
  78397. * Updates the point at data from the specified parameters
  78398. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78399. * @param point the interpolated point
  78400. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78401. */
  78402. private _setPointAtData;
  78403. /**
  78404. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78405. */
  78406. private _updateInterpolationMatrix;
  78407. }
  78408. /**
  78409. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78410. * A Curve3 is designed from a series of successive Vector3.
  78411. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78412. */
  78413. export class Curve3 {
  78414. private _points;
  78415. private _length;
  78416. /**
  78417. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78418. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78419. * @param v1 (Vector3) the control point
  78420. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78421. * @param nbPoints (integer) the wanted number of points in the curve
  78422. * @returns the created Curve3
  78423. */
  78424. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78425. /**
  78426. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78427. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78428. * @param v1 (Vector3) the first control point
  78429. * @param v2 (Vector3) the second control point
  78430. * @param v3 (Vector3) the end point of the Cubic Bezier
  78431. * @param nbPoints (integer) the wanted number of points in the curve
  78432. * @returns the created Curve3
  78433. */
  78434. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78435. /**
  78436. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78437. * @param p1 (Vector3) the origin point of the Hermite Spline
  78438. * @param t1 (Vector3) the tangent vector at the origin point
  78439. * @param p2 (Vector3) the end point of the Hermite Spline
  78440. * @param t2 (Vector3) the tangent vector at the end point
  78441. * @param nbPoints (integer) the wanted number of points in the curve
  78442. * @returns the created Curve3
  78443. */
  78444. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78445. /**
  78446. * Returns a Curve3 object along a CatmullRom Spline curve :
  78447. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78448. * @param nbPoints (integer) the wanted number of points between each curve control points
  78449. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78450. * @returns the created Curve3
  78451. */
  78452. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78453. /**
  78454. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78455. * A Curve3 is designed from a series of successive Vector3.
  78456. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78457. * @param points points which make up the curve
  78458. */
  78459. constructor(points: Vector3[]);
  78460. /**
  78461. * @returns the Curve3 stored array of successive Vector3
  78462. */
  78463. getPoints(): Vector3[];
  78464. /**
  78465. * @returns the computed length (float) of the curve.
  78466. */
  78467. length(): number;
  78468. /**
  78469. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78470. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78471. * curveA and curveB keep unchanged.
  78472. * @param curve the curve to continue from this curve
  78473. * @returns the newly constructed curve
  78474. */
  78475. continue(curve: DeepImmutable<Curve3>): Curve3;
  78476. private _computeLength;
  78477. }
  78478. }
  78479. declare module BABYLON {
  78480. /**
  78481. * This represents the main contract an easing function should follow.
  78482. * Easing functions are used throughout the animation system.
  78483. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78484. */
  78485. export interface IEasingFunction {
  78486. /**
  78487. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78488. * of the easing function.
  78489. * The link below provides some of the most common examples of easing functions.
  78490. * @see https://easings.net/
  78491. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78492. * @returns the corresponding value on the curve defined by the easing function
  78493. */
  78494. ease(gradient: number): number;
  78495. }
  78496. /**
  78497. * Base class used for every default easing function.
  78498. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78499. */
  78500. export class EasingFunction implements IEasingFunction {
  78501. /**
  78502. * Interpolation follows the mathematical formula associated with the easing function.
  78503. */
  78504. static readonly EASINGMODE_EASEIN: number;
  78505. /**
  78506. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78507. */
  78508. static readonly EASINGMODE_EASEOUT: number;
  78509. /**
  78510. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78511. */
  78512. static readonly EASINGMODE_EASEINOUT: number;
  78513. private _easingMode;
  78514. /**
  78515. * Sets the easing mode of the current function.
  78516. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78517. */
  78518. setEasingMode(easingMode: number): void;
  78519. /**
  78520. * Gets the current easing mode.
  78521. * @returns the easing mode
  78522. */
  78523. getEasingMode(): number;
  78524. /**
  78525. * @hidden
  78526. */
  78527. easeInCore(gradient: number): number;
  78528. /**
  78529. * Given an input gradient between 0 and 1, this returns the corresponding value
  78530. * of the easing function.
  78531. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78532. * @returns the corresponding value on the curve defined by the easing function
  78533. */
  78534. ease(gradient: number): number;
  78535. }
  78536. /**
  78537. * Easing function with a circle shape (see link below).
  78538. * @see https://easings.net/#easeInCirc
  78539. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78540. */
  78541. export class CircleEase extends EasingFunction implements IEasingFunction {
  78542. /** @hidden */
  78543. easeInCore(gradient: number): number;
  78544. }
  78545. /**
  78546. * Easing function with a ease back shape (see link below).
  78547. * @see https://easings.net/#easeInBack
  78548. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78549. */
  78550. export class BackEase extends EasingFunction implements IEasingFunction {
  78551. /** Defines the amplitude of the function */
  78552. amplitude: number;
  78553. /**
  78554. * Instantiates a back ease easing
  78555. * @see https://easings.net/#easeInBack
  78556. * @param amplitude Defines the amplitude of the function
  78557. */
  78558. constructor(
  78559. /** Defines the amplitude of the function */
  78560. amplitude?: number);
  78561. /** @hidden */
  78562. easeInCore(gradient: number): number;
  78563. }
  78564. /**
  78565. * Easing function with a bouncing shape (see link below).
  78566. * @see https://easings.net/#easeInBounce
  78567. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78568. */
  78569. export class BounceEase extends EasingFunction implements IEasingFunction {
  78570. /** Defines the number of bounces */
  78571. bounces: number;
  78572. /** Defines the amplitude of the bounce */
  78573. bounciness: number;
  78574. /**
  78575. * Instantiates a bounce easing
  78576. * @see https://easings.net/#easeInBounce
  78577. * @param bounces Defines the number of bounces
  78578. * @param bounciness Defines the amplitude of the bounce
  78579. */
  78580. constructor(
  78581. /** Defines the number of bounces */
  78582. bounces?: number,
  78583. /** Defines the amplitude of the bounce */
  78584. bounciness?: number);
  78585. /** @hidden */
  78586. easeInCore(gradient: number): number;
  78587. }
  78588. /**
  78589. * Easing function with a power of 3 shape (see link below).
  78590. * @see https://easings.net/#easeInCubic
  78591. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78592. */
  78593. export class CubicEase extends EasingFunction implements IEasingFunction {
  78594. /** @hidden */
  78595. easeInCore(gradient: number): number;
  78596. }
  78597. /**
  78598. * Easing function with an elastic shape (see link below).
  78599. * @see https://easings.net/#easeInElastic
  78600. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78601. */
  78602. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78603. /** Defines the number of oscillations*/
  78604. oscillations: number;
  78605. /** Defines the amplitude of the oscillations*/
  78606. springiness: number;
  78607. /**
  78608. * Instantiates an elastic easing function
  78609. * @see https://easings.net/#easeInElastic
  78610. * @param oscillations Defines the number of oscillations
  78611. * @param springiness Defines the amplitude of the oscillations
  78612. */
  78613. constructor(
  78614. /** Defines the number of oscillations*/
  78615. oscillations?: number,
  78616. /** Defines the amplitude of the oscillations*/
  78617. springiness?: number);
  78618. /** @hidden */
  78619. easeInCore(gradient: number): number;
  78620. }
  78621. /**
  78622. * Easing function with an exponential shape (see link below).
  78623. * @see https://easings.net/#easeInExpo
  78624. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78625. */
  78626. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78627. /** Defines the exponent of the function */
  78628. exponent: number;
  78629. /**
  78630. * Instantiates an exponential easing function
  78631. * @see https://easings.net/#easeInExpo
  78632. * @param exponent Defines the exponent of the function
  78633. */
  78634. constructor(
  78635. /** Defines the exponent of the function */
  78636. exponent?: number);
  78637. /** @hidden */
  78638. easeInCore(gradient: number): number;
  78639. }
  78640. /**
  78641. * Easing function with a power shape (see link below).
  78642. * @see https://easings.net/#easeInQuad
  78643. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78644. */
  78645. export class PowerEase extends EasingFunction implements IEasingFunction {
  78646. /** Defines the power of the function */
  78647. power: number;
  78648. /**
  78649. * Instantiates an power base easing function
  78650. * @see https://easings.net/#easeInQuad
  78651. * @param power Defines the power of the function
  78652. */
  78653. constructor(
  78654. /** Defines the power of the function */
  78655. power?: number);
  78656. /** @hidden */
  78657. easeInCore(gradient: number): number;
  78658. }
  78659. /**
  78660. * Easing function with a power of 2 shape (see link below).
  78661. * @see https://easings.net/#easeInQuad
  78662. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78663. */
  78664. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78665. /** @hidden */
  78666. easeInCore(gradient: number): number;
  78667. }
  78668. /**
  78669. * Easing function with a power of 4 shape (see link below).
  78670. * @see https://easings.net/#easeInQuart
  78671. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78672. */
  78673. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78674. /** @hidden */
  78675. easeInCore(gradient: number): number;
  78676. }
  78677. /**
  78678. * Easing function with a power of 5 shape (see link below).
  78679. * @see https://easings.net/#easeInQuint
  78680. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78681. */
  78682. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78683. /** @hidden */
  78684. easeInCore(gradient: number): number;
  78685. }
  78686. /**
  78687. * Easing function with a sin shape (see link below).
  78688. * @see https://easings.net/#easeInSine
  78689. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78690. */
  78691. export class SineEase extends EasingFunction implements IEasingFunction {
  78692. /** @hidden */
  78693. easeInCore(gradient: number): number;
  78694. }
  78695. /**
  78696. * Easing function with a bezier shape (see link below).
  78697. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78698. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78699. */
  78700. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78701. /** Defines the x component of the start tangent in the bezier curve */
  78702. x1: number;
  78703. /** Defines the y component of the start tangent in the bezier curve */
  78704. y1: number;
  78705. /** Defines the x component of the end tangent in the bezier curve */
  78706. x2: number;
  78707. /** Defines the y component of the end tangent in the bezier curve */
  78708. y2: number;
  78709. /**
  78710. * Instantiates a bezier function
  78711. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78712. * @param x1 Defines the x component of the start tangent in the bezier curve
  78713. * @param y1 Defines the y component of the start tangent in the bezier curve
  78714. * @param x2 Defines the x component of the end tangent in the bezier curve
  78715. * @param y2 Defines the y component of the end tangent in the bezier curve
  78716. */
  78717. constructor(
  78718. /** Defines the x component of the start tangent in the bezier curve */
  78719. x1?: number,
  78720. /** Defines the y component of the start tangent in the bezier curve */
  78721. y1?: number,
  78722. /** Defines the x component of the end tangent in the bezier curve */
  78723. x2?: number,
  78724. /** Defines the y component of the end tangent in the bezier curve */
  78725. y2?: number);
  78726. /** @hidden */
  78727. easeInCore(gradient: number): number;
  78728. }
  78729. }
  78730. declare module BABYLON {
  78731. /**
  78732. * Class used to hold a RBG color
  78733. */
  78734. export class Color3 {
  78735. /**
  78736. * Defines the red component (between 0 and 1, default is 0)
  78737. */
  78738. r: number;
  78739. /**
  78740. * Defines the green component (between 0 and 1, default is 0)
  78741. */
  78742. g: number;
  78743. /**
  78744. * Defines the blue component (between 0 and 1, default is 0)
  78745. */
  78746. b: number;
  78747. /**
  78748. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78749. * @param r defines the red component (between 0 and 1, default is 0)
  78750. * @param g defines the green component (between 0 and 1, default is 0)
  78751. * @param b defines the blue component (between 0 and 1, default is 0)
  78752. */
  78753. constructor(
  78754. /**
  78755. * Defines the red component (between 0 and 1, default is 0)
  78756. */
  78757. r?: number,
  78758. /**
  78759. * Defines the green component (between 0 and 1, default is 0)
  78760. */
  78761. g?: number,
  78762. /**
  78763. * Defines the blue component (between 0 and 1, default is 0)
  78764. */
  78765. b?: number);
  78766. /**
  78767. * Creates a string with the Color3 current values
  78768. * @returns the string representation of the Color3 object
  78769. */
  78770. toString(): string;
  78771. /**
  78772. * Returns the string "Color3"
  78773. * @returns "Color3"
  78774. */
  78775. getClassName(): string;
  78776. /**
  78777. * Compute the Color3 hash code
  78778. * @returns an unique number that can be used to hash Color3 objects
  78779. */
  78780. getHashCode(): number;
  78781. /**
  78782. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78783. * @param array defines the array where to store the r,g,b components
  78784. * @param index defines an optional index in the target array to define where to start storing values
  78785. * @returns the current Color3 object
  78786. */
  78787. toArray(array: FloatArray, index?: number): Color3;
  78788. /**
  78789. * Returns a new Color4 object from the current Color3 and the given alpha
  78790. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78791. * @returns a new Color4 object
  78792. */
  78793. toColor4(alpha?: number): Color4;
  78794. /**
  78795. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78796. * @returns the new array
  78797. */
  78798. asArray(): number[];
  78799. /**
  78800. * Returns the luminance value
  78801. * @returns a float value
  78802. */
  78803. toLuminance(): number;
  78804. /**
  78805. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78806. * @param otherColor defines the second operand
  78807. * @returns the new Color3 object
  78808. */
  78809. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78810. /**
  78811. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78812. * @param otherColor defines the second operand
  78813. * @param result defines the Color3 object where to store the result
  78814. * @returns the current Color3
  78815. */
  78816. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78817. /**
  78818. * Determines equality between Color3 objects
  78819. * @param otherColor defines the second operand
  78820. * @returns true if the rgb values are equal to the given ones
  78821. */
  78822. equals(otherColor: DeepImmutable<Color3>): boolean;
  78823. /**
  78824. * Determines equality between the current Color3 object and a set of r,b,g values
  78825. * @param r defines the red component to check
  78826. * @param g defines the green component to check
  78827. * @param b defines the blue component to check
  78828. * @returns true if the rgb values are equal to the given ones
  78829. */
  78830. equalsFloats(r: number, g: number, b: number): boolean;
  78831. /**
  78832. * Multiplies in place each rgb value by scale
  78833. * @param scale defines the scaling factor
  78834. * @returns the updated Color3
  78835. */
  78836. scale(scale: number): Color3;
  78837. /**
  78838. * Multiplies the rgb values by scale and stores the result into "result"
  78839. * @param scale defines the scaling factor
  78840. * @param result defines the Color3 object where to store the result
  78841. * @returns the unmodified current Color3
  78842. */
  78843. scaleToRef(scale: number, result: Color3): Color3;
  78844. /**
  78845. * Scale the current Color3 values by a factor and add the result to a given Color3
  78846. * @param scale defines the scale factor
  78847. * @param result defines color to store the result into
  78848. * @returns the unmodified current Color3
  78849. */
  78850. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78851. /**
  78852. * Clamps the rgb values by the min and max values and stores the result into "result"
  78853. * @param min defines minimum clamping value (default is 0)
  78854. * @param max defines maximum clamping value (default is 1)
  78855. * @param result defines color to store the result into
  78856. * @returns the original Color3
  78857. */
  78858. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78859. /**
  78860. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78861. * @param otherColor defines the second operand
  78862. * @returns the new Color3
  78863. */
  78864. add(otherColor: DeepImmutable<Color3>): Color3;
  78865. /**
  78866. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78867. * @param otherColor defines the second operand
  78868. * @param result defines Color3 object to store the result into
  78869. * @returns the unmodified current Color3
  78870. */
  78871. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78872. /**
  78873. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78874. * @param otherColor defines the second operand
  78875. * @returns the new Color3
  78876. */
  78877. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78878. /**
  78879. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78880. * @param otherColor defines the second operand
  78881. * @param result defines Color3 object to store the result into
  78882. * @returns the unmodified current Color3
  78883. */
  78884. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78885. /**
  78886. * Copy the current object
  78887. * @returns a new Color3 copied the current one
  78888. */
  78889. clone(): Color3;
  78890. /**
  78891. * Copies the rgb values from the source in the current Color3
  78892. * @param source defines the source Color3 object
  78893. * @returns the updated Color3 object
  78894. */
  78895. copyFrom(source: DeepImmutable<Color3>): Color3;
  78896. /**
  78897. * Updates the Color3 rgb values from the given floats
  78898. * @param r defines the red component to read from
  78899. * @param g defines the green component to read from
  78900. * @param b defines the blue component to read from
  78901. * @returns the current Color3 object
  78902. */
  78903. copyFromFloats(r: number, g: number, b: number): Color3;
  78904. /**
  78905. * Updates the Color3 rgb values from the given floats
  78906. * @param r defines the red component to read from
  78907. * @param g defines the green component to read from
  78908. * @param b defines the blue component to read from
  78909. * @returns the current Color3 object
  78910. */
  78911. set(r: number, g: number, b: number): Color3;
  78912. /**
  78913. * Compute the Color3 hexadecimal code as a string
  78914. * @returns a string containing the hexadecimal representation of the Color3 object
  78915. */
  78916. toHexString(): string;
  78917. /**
  78918. * Computes a new Color3 converted from the current one to linear space
  78919. * @returns a new Color3 object
  78920. */
  78921. toLinearSpace(): Color3;
  78922. /**
  78923. * Converts current color in rgb space to HSV values
  78924. * @returns a new color3 representing the HSV values
  78925. */
  78926. toHSV(): Color3;
  78927. /**
  78928. * Converts current color in rgb space to HSV values
  78929. * @param result defines the Color3 where to store the HSV values
  78930. */
  78931. toHSVToRef(result: Color3): void;
  78932. /**
  78933. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78934. * @param convertedColor defines the Color3 object where to store the linear space version
  78935. * @returns the unmodified Color3
  78936. */
  78937. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78938. /**
  78939. * Computes a new Color3 converted from the current one to gamma space
  78940. * @returns a new Color3 object
  78941. */
  78942. toGammaSpace(): Color3;
  78943. /**
  78944. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78945. * @param convertedColor defines the Color3 object where to store the gamma space version
  78946. * @returns the unmodified Color3
  78947. */
  78948. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78949. private static _BlackReadOnly;
  78950. /**
  78951. * Convert Hue, saturation and value to a Color3 (RGB)
  78952. * @param hue defines the hue
  78953. * @param saturation defines the saturation
  78954. * @param value defines the value
  78955. * @param result defines the Color3 where to store the RGB values
  78956. */
  78957. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78958. /**
  78959. * Creates a new Color3 from the string containing valid hexadecimal values
  78960. * @param hex defines a string containing valid hexadecimal values
  78961. * @returns a new Color3 object
  78962. */
  78963. static FromHexString(hex: string): Color3;
  78964. /**
  78965. * Creates a new Color3 from the starting index of the given array
  78966. * @param array defines the source array
  78967. * @param offset defines an offset in the source array
  78968. * @returns a new Color3 object
  78969. */
  78970. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78971. /**
  78972. * Creates a new Color3 from integer values (< 256)
  78973. * @param r defines the red component to read from (value between 0 and 255)
  78974. * @param g defines the green component to read from (value between 0 and 255)
  78975. * @param b defines the blue component to read from (value between 0 and 255)
  78976. * @returns a new Color3 object
  78977. */
  78978. static FromInts(r: number, g: number, b: number): Color3;
  78979. /**
  78980. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78981. * @param start defines the start Color3 value
  78982. * @param end defines the end Color3 value
  78983. * @param amount defines the gradient value between start and end
  78984. * @returns a new Color3 object
  78985. */
  78986. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78987. /**
  78988. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78989. * @param left defines the start value
  78990. * @param right defines the end value
  78991. * @param amount defines the gradient factor
  78992. * @param result defines the Color3 object where to store the result
  78993. */
  78994. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78995. /**
  78996. * Returns a Color3 value containing a red color
  78997. * @returns a new Color3 object
  78998. */
  78999. static Red(): Color3;
  79000. /**
  79001. * Returns a Color3 value containing a green color
  79002. * @returns a new Color3 object
  79003. */
  79004. static Green(): Color3;
  79005. /**
  79006. * Returns a Color3 value containing a blue color
  79007. * @returns a new Color3 object
  79008. */
  79009. static Blue(): Color3;
  79010. /**
  79011. * Returns a Color3 value containing a black color
  79012. * @returns a new Color3 object
  79013. */
  79014. static Black(): Color3;
  79015. /**
  79016. * Gets a Color3 value containing a black color that must not be updated
  79017. */
  79018. static get BlackReadOnly(): DeepImmutable<Color3>;
  79019. /**
  79020. * Returns a Color3 value containing a white color
  79021. * @returns a new Color3 object
  79022. */
  79023. static White(): Color3;
  79024. /**
  79025. * Returns a Color3 value containing a purple color
  79026. * @returns a new Color3 object
  79027. */
  79028. static Purple(): Color3;
  79029. /**
  79030. * Returns a Color3 value containing a magenta color
  79031. * @returns a new Color3 object
  79032. */
  79033. static Magenta(): Color3;
  79034. /**
  79035. * Returns a Color3 value containing a yellow color
  79036. * @returns a new Color3 object
  79037. */
  79038. static Yellow(): Color3;
  79039. /**
  79040. * Returns a Color3 value containing a gray color
  79041. * @returns a new Color3 object
  79042. */
  79043. static Gray(): Color3;
  79044. /**
  79045. * Returns a Color3 value containing a teal color
  79046. * @returns a new Color3 object
  79047. */
  79048. static Teal(): Color3;
  79049. /**
  79050. * Returns a Color3 value containing a random color
  79051. * @returns a new Color3 object
  79052. */
  79053. static Random(): Color3;
  79054. }
  79055. /**
  79056. * Class used to hold a RBGA color
  79057. */
  79058. export class Color4 {
  79059. /**
  79060. * Defines the red component (between 0 and 1, default is 0)
  79061. */
  79062. r: number;
  79063. /**
  79064. * Defines the green component (between 0 and 1, default is 0)
  79065. */
  79066. g: number;
  79067. /**
  79068. * Defines the blue component (between 0 and 1, default is 0)
  79069. */
  79070. b: number;
  79071. /**
  79072. * Defines the alpha component (between 0 and 1, default is 1)
  79073. */
  79074. a: number;
  79075. /**
  79076. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  79077. * @param r defines the red component (between 0 and 1, default is 0)
  79078. * @param g defines the green component (between 0 and 1, default is 0)
  79079. * @param b defines the blue component (between 0 and 1, default is 0)
  79080. * @param a defines the alpha component (between 0 and 1, default is 1)
  79081. */
  79082. constructor(
  79083. /**
  79084. * Defines the red component (between 0 and 1, default is 0)
  79085. */
  79086. r?: number,
  79087. /**
  79088. * Defines the green component (between 0 and 1, default is 0)
  79089. */
  79090. g?: number,
  79091. /**
  79092. * Defines the blue component (between 0 and 1, default is 0)
  79093. */
  79094. b?: number,
  79095. /**
  79096. * Defines the alpha component (between 0 and 1, default is 1)
  79097. */
  79098. a?: number);
  79099. /**
  79100. * Adds in place the given Color4 values to the current Color4 object
  79101. * @param right defines the second operand
  79102. * @returns the current updated Color4 object
  79103. */
  79104. addInPlace(right: DeepImmutable<Color4>): Color4;
  79105. /**
  79106. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  79107. * @returns the new array
  79108. */
  79109. asArray(): number[];
  79110. /**
  79111. * Stores from the starting index in the given array the Color4 successive values
  79112. * @param array defines the array where to store the r,g,b components
  79113. * @param index defines an optional index in the target array to define where to start storing values
  79114. * @returns the current Color4 object
  79115. */
  79116. toArray(array: number[], index?: number): Color4;
  79117. /**
  79118. * Determines equality between Color4 objects
  79119. * @param otherColor defines the second operand
  79120. * @returns true if the rgba values are equal to the given ones
  79121. */
  79122. equals(otherColor: DeepImmutable<Color4>): boolean;
  79123. /**
  79124. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  79125. * @param right defines the second operand
  79126. * @returns a new Color4 object
  79127. */
  79128. add(right: DeepImmutable<Color4>): Color4;
  79129. /**
  79130. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79131. * @param right defines the second operand
  79132. * @returns a new Color4 object
  79133. */
  79134. subtract(right: DeepImmutable<Color4>): Color4;
  79135. /**
  79136. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79137. * @param right defines the second operand
  79138. * @param result defines the Color4 object where to store the result
  79139. * @returns the current Color4 object
  79140. */
  79141. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79142. /**
  79143. * Creates a new Color4 with the current Color4 values multiplied by scale
  79144. * @param scale defines the scaling factor to apply
  79145. * @returns a new Color4 object
  79146. */
  79147. scale(scale: number): Color4;
  79148. /**
  79149. * Multiplies the current Color4 values by scale and stores the result in "result"
  79150. * @param scale defines the scaling factor to apply
  79151. * @param result defines the Color4 object where to store the result
  79152. * @returns the current unmodified Color4
  79153. */
  79154. scaleToRef(scale: number, result: Color4): Color4;
  79155. /**
  79156. * Scale the current Color4 values by a factor and add the result to a given Color4
  79157. * @param scale defines the scale factor
  79158. * @param result defines the Color4 object where to store the result
  79159. * @returns the unmodified current Color4
  79160. */
  79161. scaleAndAddToRef(scale: number, result: Color4): Color4;
  79162. /**
  79163. * Clamps the rgb values by the min and max values and stores the result into "result"
  79164. * @param min defines minimum clamping value (default is 0)
  79165. * @param max defines maximum clamping value (default is 1)
  79166. * @param result defines color to store the result into.
  79167. * @returns the cuurent Color4
  79168. */
  79169. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  79170. /**
  79171. * Multipy an Color4 value by another and return a new Color4 object
  79172. * @param color defines the Color4 value to multiply by
  79173. * @returns a new Color4 object
  79174. */
  79175. multiply(color: Color4): Color4;
  79176. /**
  79177. * Multipy a Color4 value by another and push the result in a reference value
  79178. * @param color defines the Color4 value to multiply by
  79179. * @param result defines the Color4 to fill the result in
  79180. * @returns the result Color4
  79181. */
  79182. multiplyToRef(color: Color4, result: Color4): Color4;
  79183. /**
  79184. * Creates a string with the Color4 current values
  79185. * @returns the string representation of the Color4 object
  79186. */
  79187. toString(): string;
  79188. /**
  79189. * Returns the string "Color4"
  79190. * @returns "Color4"
  79191. */
  79192. getClassName(): string;
  79193. /**
  79194. * Compute the Color4 hash code
  79195. * @returns an unique number that can be used to hash Color4 objects
  79196. */
  79197. getHashCode(): number;
  79198. /**
  79199. * Creates a new Color4 copied from the current one
  79200. * @returns a new Color4 object
  79201. */
  79202. clone(): Color4;
  79203. /**
  79204. * Copies the given Color4 values into the current one
  79205. * @param source defines the source Color4 object
  79206. * @returns the current updated Color4 object
  79207. */
  79208. copyFrom(source: Color4): Color4;
  79209. /**
  79210. * Copies the given float values into the current one
  79211. * @param r defines the red component to read from
  79212. * @param g defines the green component to read from
  79213. * @param b defines the blue component to read from
  79214. * @param a defines the alpha component to read from
  79215. * @returns the current updated Color4 object
  79216. */
  79217. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79218. /**
  79219. * Copies the given float values into the current one
  79220. * @param r defines the red component to read from
  79221. * @param g defines the green component to read from
  79222. * @param b defines the blue component to read from
  79223. * @param a defines the alpha component to read from
  79224. * @returns the current updated Color4 object
  79225. */
  79226. set(r: number, g: number, b: number, a: number): Color4;
  79227. /**
  79228. * Compute the Color4 hexadecimal code as a string
  79229. * @returns a string containing the hexadecimal representation of the Color4 object
  79230. */
  79231. toHexString(): string;
  79232. /**
  79233. * Computes a new Color4 converted from the current one to linear space
  79234. * @returns a new Color4 object
  79235. */
  79236. toLinearSpace(): Color4;
  79237. /**
  79238. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79239. * @param convertedColor defines the Color4 object where to store the linear space version
  79240. * @returns the unmodified Color4
  79241. */
  79242. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79243. /**
  79244. * Computes a new Color4 converted from the current one to gamma space
  79245. * @returns a new Color4 object
  79246. */
  79247. toGammaSpace(): Color4;
  79248. /**
  79249. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79250. * @param convertedColor defines the Color4 object where to store the gamma space version
  79251. * @returns the unmodified Color4
  79252. */
  79253. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79254. /**
  79255. * Creates a new Color4 from the string containing valid hexadecimal values
  79256. * @param hex defines a string containing valid hexadecimal values
  79257. * @returns a new Color4 object
  79258. */
  79259. static FromHexString(hex: string): Color4;
  79260. /**
  79261. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79262. * @param left defines the start value
  79263. * @param right defines the end value
  79264. * @param amount defines the gradient factor
  79265. * @returns a new Color4 object
  79266. */
  79267. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79268. /**
  79269. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79270. * @param left defines the start value
  79271. * @param right defines the end value
  79272. * @param amount defines the gradient factor
  79273. * @param result defines the Color4 object where to store data
  79274. */
  79275. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79276. /**
  79277. * Creates a new Color4 from a Color3 and an alpha value
  79278. * @param color3 defines the source Color3 to read from
  79279. * @param alpha defines the alpha component (1.0 by default)
  79280. * @returns a new Color4 object
  79281. */
  79282. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79283. /**
  79284. * Creates a new Color4 from the starting index element of the given array
  79285. * @param array defines the source array to read from
  79286. * @param offset defines the offset in the source array
  79287. * @returns a new Color4 object
  79288. */
  79289. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79290. /**
  79291. * Creates a new Color3 from integer values (< 256)
  79292. * @param r defines the red component to read from (value between 0 and 255)
  79293. * @param g defines the green component to read from (value between 0 and 255)
  79294. * @param b defines the blue component to read from (value between 0 and 255)
  79295. * @param a defines the alpha component to read from (value between 0 and 255)
  79296. * @returns a new Color3 object
  79297. */
  79298. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79299. /**
  79300. * Check the content of a given array and convert it to an array containing RGBA data
  79301. * If the original array was already containing count * 4 values then it is returned directly
  79302. * @param colors defines the array to check
  79303. * @param count defines the number of RGBA data to expect
  79304. * @returns an array containing count * 4 values (RGBA)
  79305. */
  79306. static CheckColors4(colors: number[], count: number): number[];
  79307. }
  79308. /**
  79309. * @hidden
  79310. */
  79311. export class TmpColors {
  79312. static Color3: Color3[];
  79313. static Color4: Color4[];
  79314. }
  79315. }
  79316. declare module BABYLON {
  79317. /**
  79318. * Defines an interface which represents an animation key frame
  79319. */
  79320. export interface IAnimationKey {
  79321. /**
  79322. * Frame of the key frame
  79323. */
  79324. frame: number;
  79325. /**
  79326. * Value at the specifies key frame
  79327. */
  79328. value: any;
  79329. /**
  79330. * The input tangent for the cubic hermite spline
  79331. */
  79332. inTangent?: any;
  79333. /**
  79334. * The output tangent for the cubic hermite spline
  79335. */
  79336. outTangent?: any;
  79337. /**
  79338. * The animation interpolation type
  79339. */
  79340. interpolation?: AnimationKeyInterpolation;
  79341. }
  79342. /**
  79343. * Enum for the animation key frame interpolation type
  79344. */
  79345. export enum AnimationKeyInterpolation {
  79346. /**
  79347. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79348. */
  79349. STEP = 1
  79350. }
  79351. }
  79352. declare module BABYLON {
  79353. /**
  79354. * Represents the range of an animation
  79355. */
  79356. export class AnimationRange {
  79357. /**The name of the animation range**/
  79358. name: string;
  79359. /**The starting frame of the animation */
  79360. from: number;
  79361. /**The ending frame of the animation*/
  79362. to: number;
  79363. /**
  79364. * Initializes the range of an animation
  79365. * @param name The name of the animation range
  79366. * @param from The starting frame of the animation
  79367. * @param to The ending frame of the animation
  79368. */
  79369. constructor(
  79370. /**The name of the animation range**/
  79371. name: string,
  79372. /**The starting frame of the animation */
  79373. from: number,
  79374. /**The ending frame of the animation*/
  79375. to: number);
  79376. /**
  79377. * Makes a copy of the animation range
  79378. * @returns A copy of the animation range
  79379. */
  79380. clone(): AnimationRange;
  79381. }
  79382. }
  79383. declare module BABYLON {
  79384. /**
  79385. * Composed of a frame, and an action function
  79386. */
  79387. export class AnimationEvent {
  79388. /** The frame for which the event is triggered **/
  79389. frame: number;
  79390. /** The event to perform when triggered **/
  79391. action: (currentFrame: number) => void;
  79392. /** Specifies if the event should be triggered only once**/
  79393. onlyOnce?: boolean | undefined;
  79394. /**
  79395. * Specifies if the animation event is done
  79396. */
  79397. isDone: boolean;
  79398. /**
  79399. * Initializes the animation event
  79400. * @param frame The frame for which the event is triggered
  79401. * @param action The event to perform when triggered
  79402. * @param onlyOnce Specifies if the event should be triggered only once
  79403. */
  79404. constructor(
  79405. /** The frame for which the event is triggered **/
  79406. frame: number,
  79407. /** The event to perform when triggered **/
  79408. action: (currentFrame: number) => void,
  79409. /** Specifies if the event should be triggered only once**/
  79410. onlyOnce?: boolean | undefined);
  79411. /** @hidden */
  79412. _clone(): AnimationEvent;
  79413. }
  79414. }
  79415. declare module BABYLON {
  79416. /**
  79417. * Interface used to define a behavior
  79418. */
  79419. export interface Behavior<T> {
  79420. /** gets or sets behavior's name */
  79421. name: string;
  79422. /**
  79423. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79424. */
  79425. init(): void;
  79426. /**
  79427. * Called when the behavior is attached to a target
  79428. * @param target defines the target where the behavior is attached to
  79429. */
  79430. attach(target: T): void;
  79431. /**
  79432. * Called when the behavior is detached from its target
  79433. */
  79434. detach(): void;
  79435. }
  79436. /**
  79437. * Interface implemented by classes supporting behaviors
  79438. */
  79439. export interface IBehaviorAware<T> {
  79440. /**
  79441. * Attach a behavior
  79442. * @param behavior defines the behavior to attach
  79443. * @returns the current host
  79444. */
  79445. addBehavior(behavior: Behavior<T>): T;
  79446. /**
  79447. * Remove a behavior from the current object
  79448. * @param behavior defines the behavior to detach
  79449. * @returns the current host
  79450. */
  79451. removeBehavior(behavior: Behavior<T>): T;
  79452. /**
  79453. * Gets a behavior using its name to search
  79454. * @param name defines the name to search
  79455. * @returns the behavior or null if not found
  79456. */
  79457. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79458. }
  79459. }
  79460. declare module BABYLON {
  79461. /**
  79462. * Defines an array and its length.
  79463. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79464. */
  79465. export interface ISmartArrayLike<T> {
  79466. /**
  79467. * The data of the array.
  79468. */
  79469. data: Array<T>;
  79470. /**
  79471. * The active length of the array.
  79472. */
  79473. length: number;
  79474. }
  79475. /**
  79476. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79477. */
  79478. export class SmartArray<T> implements ISmartArrayLike<T> {
  79479. /**
  79480. * The full set of data from the array.
  79481. */
  79482. data: Array<T>;
  79483. /**
  79484. * The active length of the array.
  79485. */
  79486. length: number;
  79487. protected _id: number;
  79488. /**
  79489. * Instantiates a Smart Array.
  79490. * @param capacity defines the default capacity of the array.
  79491. */
  79492. constructor(capacity: number);
  79493. /**
  79494. * Pushes a value at the end of the active data.
  79495. * @param value defines the object to push in the array.
  79496. */
  79497. push(value: T): void;
  79498. /**
  79499. * Iterates over the active data and apply the lambda to them.
  79500. * @param func defines the action to apply on each value.
  79501. */
  79502. forEach(func: (content: T) => void): void;
  79503. /**
  79504. * Sorts the full sets of data.
  79505. * @param compareFn defines the comparison function to apply.
  79506. */
  79507. sort(compareFn: (a: T, b: T) => number): void;
  79508. /**
  79509. * Resets the active data to an empty array.
  79510. */
  79511. reset(): void;
  79512. /**
  79513. * Releases all the data from the array as well as the array.
  79514. */
  79515. dispose(): void;
  79516. /**
  79517. * Concats the active data with a given array.
  79518. * @param array defines the data to concatenate with.
  79519. */
  79520. concat(array: any): void;
  79521. /**
  79522. * Returns the position of a value in the active data.
  79523. * @param value defines the value to find the index for
  79524. * @returns the index if found in the active data otherwise -1
  79525. */
  79526. indexOf(value: T): number;
  79527. /**
  79528. * Returns whether an element is part of the active data.
  79529. * @param value defines the value to look for
  79530. * @returns true if found in the active data otherwise false
  79531. */
  79532. contains(value: T): boolean;
  79533. private static _GlobalId;
  79534. }
  79535. /**
  79536. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79537. * The data in this array can only be present once
  79538. */
  79539. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79540. private _duplicateId;
  79541. /**
  79542. * Pushes a value at the end of the active data.
  79543. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79544. * @param value defines the object to push in the array.
  79545. */
  79546. push(value: T): void;
  79547. /**
  79548. * Pushes a value at the end of the active data.
  79549. * If the data is already present, it won t be added again
  79550. * @param value defines the object to push in the array.
  79551. * @returns true if added false if it was already present
  79552. */
  79553. pushNoDuplicate(value: T): boolean;
  79554. /**
  79555. * Resets the active data to an empty array.
  79556. */
  79557. reset(): void;
  79558. /**
  79559. * Concats the active data with a given array.
  79560. * This ensures no dupplicate will be present in the result.
  79561. * @param array defines the data to concatenate with.
  79562. */
  79563. concatWithNoDuplicate(array: any): void;
  79564. }
  79565. }
  79566. declare module BABYLON {
  79567. /**
  79568. * @ignore
  79569. * This is a list of all the different input types that are available in the application.
  79570. * Fo instance: ArcRotateCameraGamepadInput...
  79571. */
  79572. export var CameraInputTypes: {};
  79573. /**
  79574. * This is the contract to implement in order to create a new input class.
  79575. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79576. */
  79577. export interface ICameraInput<TCamera extends Camera> {
  79578. /**
  79579. * Defines the camera the input is attached to.
  79580. */
  79581. camera: Nullable<TCamera>;
  79582. /**
  79583. * Gets the class name of the current intput.
  79584. * @returns the class name
  79585. */
  79586. getClassName(): string;
  79587. /**
  79588. * Get the friendly name associated with the input class.
  79589. * @returns the input friendly name
  79590. */
  79591. getSimpleName(): string;
  79592. /**
  79593. * Attach the input controls to a specific dom element to get the input from.
  79594. * @param element Defines the element the controls should be listened from
  79595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79596. */
  79597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79598. /**
  79599. * Detach the current controls from the specified dom element.
  79600. * @param element Defines the element to stop listening the inputs from
  79601. */
  79602. detachControl(element: Nullable<HTMLElement>): void;
  79603. /**
  79604. * Update the current camera state depending on the inputs that have been used this frame.
  79605. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79606. */
  79607. checkInputs?: () => void;
  79608. }
  79609. /**
  79610. * Represents a map of input types to input instance or input index to input instance.
  79611. */
  79612. export interface CameraInputsMap<TCamera extends Camera> {
  79613. /**
  79614. * Accessor to the input by input type.
  79615. */
  79616. [name: string]: ICameraInput<TCamera>;
  79617. /**
  79618. * Accessor to the input by input index.
  79619. */
  79620. [idx: number]: ICameraInput<TCamera>;
  79621. }
  79622. /**
  79623. * This represents the input manager used within a camera.
  79624. * It helps dealing with all the different kind of input attached to a camera.
  79625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79626. */
  79627. export class CameraInputsManager<TCamera extends Camera> {
  79628. /**
  79629. * Defines the list of inputs attahed to the camera.
  79630. */
  79631. attached: CameraInputsMap<TCamera>;
  79632. /**
  79633. * Defines the dom element the camera is collecting inputs from.
  79634. * This is null if the controls have not been attached.
  79635. */
  79636. attachedElement: Nullable<HTMLElement>;
  79637. /**
  79638. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79639. */
  79640. noPreventDefault: boolean;
  79641. /**
  79642. * Defined the camera the input manager belongs to.
  79643. */
  79644. camera: TCamera;
  79645. /**
  79646. * Update the current camera state depending on the inputs that have been used this frame.
  79647. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79648. */
  79649. checkInputs: () => void;
  79650. /**
  79651. * Instantiate a new Camera Input Manager.
  79652. * @param camera Defines the camera the input manager blongs to
  79653. */
  79654. constructor(camera: TCamera);
  79655. /**
  79656. * Add an input method to a camera
  79657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79658. * @param input camera input method
  79659. */
  79660. add(input: ICameraInput<TCamera>): void;
  79661. /**
  79662. * Remove a specific input method from a camera
  79663. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79664. * @param inputToRemove camera input method
  79665. */
  79666. remove(inputToRemove: ICameraInput<TCamera>): void;
  79667. /**
  79668. * Remove a specific input type from a camera
  79669. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79670. * @param inputType the type of the input to remove
  79671. */
  79672. removeByType(inputType: string): void;
  79673. private _addCheckInputs;
  79674. /**
  79675. * Attach the input controls to the currently attached dom element to listen the events from.
  79676. * @param input Defines the input to attach
  79677. */
  79678. attachInput(input: ICameraInput<TCamera>): void;
  79679. /**
  79680. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79681. * @param element Defines the dom element to collect the events from
  79682. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79683. */
  79684. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79685. /**
  79686. * Detach the current manager inputs controls from a specific dom element.
  79687. * @param element Defines the dom element to collect the events from
  79688. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79689. */
  79690. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79691. /**
  79692. * Rebuild the dynamic inputCheck function from the current list of
  79693. * defined inputs in the manager.
  79694. */
  79695. rebuildInputCheck(): void;
  79696. /**
  79697. * Remove all attached input methods from a camera
  79698. */
  79699. clear(): void;
  79700. /**
  79701. * Serialize the current input manager attached to a camera.
  79702. * This ensures than once parsed,
  79703. * the input associated to the camera will be identical to the current ones
  79704. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79705. */
  79706. serialize(serializedCamera: any): void;
  79707. /**
  79708. * Parses an input manager serialized JSON to restore the previous list of inputs
  79709. * and states associated to a camera.
  79710. * @param parsedCamera Defines the JSON to parse
  79711. */
  79712. parse(parsedCamera: any): void;
  79713. }
  79714. }
  79715. declare module BABYLON {
  79716. /**
  79717. * Class used to store data that will be store in GPU memory
  79718. */
  79719. export class Buffer {
  79720. private _engine;
  79721. private _buffer;
  79722. /** @hidden */
  79723. _data: Nullable<DataArray>;
  79724. private _updatable;
  79725. private _instanced;
  79726. private _divisor;
  79727. /**
  79728. * Gets the byte stride.
  79729. */
  79730. readonly byteStride: number;
  79731. /**
  79732. * Constructor
  79733. * @param engine the engine
  79734. * @param data the data to use for this buffer
  79735. * @param updatable whether the data is updatable
  79736. * @param stride the stride (optional)
  79737. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79738. * @param instanced whether the buffer is instanced (optional)
  79739. * @param useBytes set to true if the stride in in bytes (optional)
  79740. * @param divisor sets an optional divisor for instances (1 by default)
  79741. */
  79742. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79743. /**
  79744. * Create a new VertexBuffer based on the current buffer
  79745. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79746. * @param offset defines offset in the buffer (0 by default)
  79747. * @param size defines the size in floats of attributes (position is 3 for instance)
  79748. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79749. * @param instanced defines if the vertex buffer contains indexed data
  79750. * @param useBytes defines if the offset and stride are in bytes *
  79751. * @param divisor sets an optional divisor for instances (1 by default)
  79752. * @returns the new vertex buffer
  79753. */
  79754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79755. /**
  79756. * Gets a boolean indicating if the Buffer is updatable?
  79757. * @returns true if the buffer is updatable
  79758. */
  79759. isUpdatable(): boolean;
  79760. /**
  79761. * Gets current buffer's data
  79762. * @returns a DataArray or null
  79763. */
  79764. getData(): Nullable<DataArray>;
  79765. /**
  79766. * Gets underlying native buffer
  79767. * @returns underlying native buffer
  79768. */
  79769. getBuffer(): Nullable<DataBuffer>;
  79770. /**
  79771. * Gets the stride in float32 units (i.e. byte stride / 4).
  79772. * May not be an integer if the byte stride is not divisible by 4.
  79773. * @returns the stride in float32 units
  79774. * @deprecated Please use byteStride instead.
  79775. */
  79776. getStrideSize(): number;
  79777. /**
  79778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79779. * @param data defines the data to store
  79780. */
  79781. create(data?: Nullable<DataArray>): void;
  79782. /** @hidden */
  79783. _rebuild(): void;
  79784. /**
  79785. * Update current buffer data
  79786. * @param data defines the data to store
  79787. */
  79788. update(data: DataArray): void;
  79789. /**
  79790. * Updates the data directly.
  79791. * @param data the new data
  79792. * @param offset the new offset
  79793. * @param vertexCount the vertex count (optional)
  79794. * @param useBytes set to true if the offset is in bytes
  79795. */
  79796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79797. /**
  79798. * Release all resources
  79799. */
  79800. dispose(): void;
  79801. }
  79802. /**
  79803. * Specialized buffer used to store vertex data
  79804. */
  79805. export class VertexBuffer {
  79806. /** @hidden */
  79807. _buffer: Buffer;
  79808. private _kind;
  79809. private _size;
  79810. private _ownsBuffer;
  79811. private _instanced;
  79812. private _instanceDivisor;
  79813. /**
  79814. * The byte type.
  79815. */
  79816. static readonly BYTE: number;
  79817. /**
  79818. * The unsigned byte type.
  79819. */
  79820. static readonly UNSIGNED_BYTE: number;
  79821. /**
  79822. * The short type.
  79823. */
  79824. static readonly SHORT: number;
  79825. /**
  79826. * The unsigned short type.
  79827. */
  79828. static readonly UNSIGNED_SHORT: number;
  79829. /**
  79830. * The integer type.
  79831. */
  79832. static readonly INT: number;
  79833. /**
  79834. * The unsigned integer type.
  79835. */
  79836. static readonly UNSIGNED_INT: number;
  79837. /**
  79838. * The float type.
  79839. */
  79840. static readonly FLOAT: number;
  79841. /**
  79842. * Gets or sets the instance divisor when in instanced mode
  79843. */
  79844. get instanceDivisor(): number;
  79845. set instanceDivisor(value: number);
  79846. /**
  79847. * Gets the byte stride.
  79848. */
  79849. readonly byteStride: number;
  79850. /**
  79851. * Gets the byte offset.
  79852. */
  79853. readonly byteOffset: number;
  79854. /**
  79855. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79856. */
  79857. readonly normalized: boolean;
  79858. /**
  79859. * Gets the data type of each component in the array.
  79860. */
  79861. readonly type: number;
  79862. /**
  79863. * Constructor
  79864. * @param engine the engine
  79865. * @param data the data to use for this vertex buffer
  79866. * @param kind the vertex buffer kind
  79867. * @param updatable whether the data is updatable
  79868. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79869. * @param stride the stride (optional)
  79870. * @param instanced whether the buffer is instanced (optional)
  79871. * @param offset the offset of the data (optional)
  79872. * @param size the number of components (optional)
  79873. * @param type the type of the component (optional)
  79874. * @param normalized whether the data contains normalized data (optional)
  79875. * @param useBytes set to true if stride and offset are in bytes (optional)
  79876. * @param divisor defines the instance divisor to use (1 by default)
  79877. */
  79878. 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);
  79879. /** @hidden */
  79880. _rebuild(): void;
  79881. /**
  79882. * Returns the kind of the VertexBuffer (string)
  79883. * @returns a string
  79884. */
  79885. getKind(): string;
  79886. /**
  79887. * Gets a boolean indicating if the VertexBuffer is updatable?
  79888. * @returns true if the buffer is updatable
  79889. */
  79890. isUpdatable(): boolean;
  79891. /**
  79892. * Gets current buffer's data
  79893. * @returns a DataArray or null
  79894. */
  79895. getData(): Nullable<DataArray>;
  79896. /**
  79897. * Gets underlying native buffer
  79898. * @returns underlying native buffer
  79899. */
  79900. getBuffer(): Nullable<DataBuffer>;
  79901. /**
  79902. * Gets the stride in float32 units (i.e. byte stride / 4).
  79903. * May not be an integer if the byte stride is not divisible by 4.
  79904. * @returns the stride in float32 units
  79905. * @deprecated Please use byteStride instead.
  79906. */
  79907. getStrideSize(): number;
  79908. /**
  79909. * Returns the offset as a multiple of the type byte length.
  79910. * @returns the offset in bytes
  79911. * @deprecated Please use byteOffset instead.
  79912. */
  79913. getOffset(): number;
  79914. /**
  79915. * Returns the number of components per vertex attribute (integer)
  79916. * @returns the size in float
  79917. */
  79918. getSize(): number;
  79919. /**
  79920. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79921. * @returns true if this buffer is instanced
  79922. */
  79923. getIsInstanced(): boolean;
  79924. /**
  79925. * Returns the instancing divisor, zero for non-instanced (integer).
  79926. * @returns a number
  79927. */
  79928. getInstanceDivisor(): number;
  79929. /**
  79930. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79931. * @param data defines the data to store
  79932. */
  79933. create(data?: DataArray): void;
  79934. /**
  79935. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79936. * This function will create a new buffer if the current one is not updatable
  79937. * @param data defines the data to store
  79938. */
  79939. update(data: DataArray): void;
  79940. /**
  79941. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79942. * Returns the directly updated WebGLBuffer.
  79943. * @param data the new data
  79944. * @param offset the new offset
  79945. * @param useBytes set to true if the offset is in bytes
  79946. */
  79947. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79948. /**
  79949. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79950. */
  79951. dispose(): void;
  79952. /**
  79953. * Enumerates each value of this vertex buffer as numbers.
  79954. * @param count the number of values to enumerate
  79955. * @param callback the callback function called for each value
  79956. */
  79957. forEach(count: number, callback: (value: number, index: number) => void): void;
  79958. /**
  79959. * Positions
  79960. */
  79961. static readonly PositionKind: string;
  79962. /**
  79963. * Normals
  79964. */
  79965. static readonly NormalKind: string;
  79966. /**
  79967. * Tangents
  79968. */
  79969. static readonly TangentKind: string;
  79970. /**
  79971. * Texture coordinates
  79972. */
  79973. static readonly UVKind: string;
  79974. /**
  79975. * Texture coordinates 2
  79976. */
  79977. static readonly UV2Kind: string;
  79978. /**
  79979. * Texture coordinates 3
  79980. */
  79981. static readonly UV3Kind: string;
  79982. /**
  79983. * Texture coordinates 4
  79984. */
  79985. static readonly UV4Kind: string;
  79986. /**
  79987. * Texture coordinates 5
  79988. */
  79989. static readonly UV5Kind: string;
  79990. /**
  79991. * Texture coordinates 6
  79992. */
  79993. static readonly UV6Kind: string;
  79994. /**
  79995. * Colors
  79996. */
  79997. static readonly ColorKind: string;
  79998. /**
  79999. * Matrix indices (for bones)
  80000. */
  80001. static readonly MatricesIndicesKind: string;
  80002. /**
  80003. * Matrix weights (for bones)
  80004. */
  80005. static readonly MatricesWeightsKind: string;
  80006. /**
  80007. * Additional matrix indices (for bones)
  80008. */
  80009. static readonly MatricesIndicesExtraKind: string;
  80010. /**
  80011. * Additional matrix weights (for bones)
  80012. */
  80013. static readonly MatricesWeightsExtraKind: string;
  80014. /**
  80015. * Deduces the stride given a kind.
  80016. * @param kind The kind string to deduce
  80017. * @returns The deduced stride
  80018. */
  80019. static DeduceStride(kind: string): number;
  80020. /**
  80021. * Gets the byte length of the given type.
  80022. * @param type the type
  80023. * @returns the number of bytes
  80024. */
  80025. static GetTypeByteLength(type: number): number;
  80026. /**
  80027. * Enumerates each value of the given parameters as numbers.
  80028. * @param data the data to enumerate
  80029. * @param byteOffset the byte offset of the data
  80030. * @param byteStride the byte stride of the data
  80031. * @param componentCount the number of components per element
  80032. * @param componentType the type of the component
  80033. * @param count the number of values to enumerate
  80034. * @param normalized whether the data is normalized
  80035. * @param callback the callback function called for each value
  80036. */
  80037. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  80038. private static _GetFloatValue;
  80039. }
  80040. }
  80041. declare module BABYLON {
  80042. /**
  80043. * @hidden
  80044. */
  80045. export class IntersectionInfo {
  80046. bu: Nullable<number>;
  80047. bv: Nullable<number>;
  80048. distance: number;
  80049. faceId: number;
  80050. subMeshId: number;
  80051. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  80052. }
  80053. }
  80054. declare module BABYLON {
  80055. /**
  80056. * Represens a plane by the equation ax + by + cz + d = 0
  80057. */
  80058. export class Plane {
  80059. private static _TmpMatrix;
  80060. /**
  80061. * Normal of the plane (a,b,c)
  80062. */
  80063. normal: Vector3;
  80064. /**
  80065. * d component of the plane
  80066. */
  80067. d: number;
  80068. /**
  80069. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80070. * @param a a component of the plane
  80071. * @param b b component of the plane
  80072. * @param c c component of the plane
  80073. * @param d d component of the plane
  80074. */
  80075. constructor(a: number, b: number, c: number, d: number);
  80076. /**
  80077. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80078. */
  80079. asArray(): number[];
  80080. /**
  80081. * @returns a new plane copied from the current Plane.
  80082. */
  80083. clone(): Plane;
  80084. /**
  80085. * @returns the string "Plane".
  80086. */
  80087. getClassName(): string;
  80088. /**
  80089. * @returns the Plane hash code.
  80090. */
  80091. getHashCode(): number;
  80092. /**
  80093. * Normalize the current Plane in place.
  80094. * @returns the updated Plane.
  80095. */
  80096. normalize(): Plane;
  80097. /**
  80098. * Applies a transformation the plane and returns the result
  80099. * @param transformation the transformation matrix to be applied to the plane
  80100. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80101. */
  80102. transform(transformation: DeepImmutable<Matrix>): Plane;
  80103. /**
  80104. * Calcualtte the dot product between the point and the plane normal
  80105. * @param point point to calculate the dot product with
  80106. * @returns the dot product (float) of the point coordinates and the plane normal.
  80107. */
  80108. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80109. /**
  80110. * Updates the current Plane from the plane defined by the three given points.
  80111. * @param point1 one of the points used to contruct the plane
  80112. * @param point2 one of the points used to contruct the plane
  80113. * @param point3 one of the points used to contruct the plane
  80114. * @returns the updated Plane.
  80115. */
  80116. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80117. /**
  80118. * Checks if the plane is facing a given direction
  80119. * @param direction the direction to check if the plane is facing
  80120. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80121. * @returns True is the vector "direction" is the same side than the plane normal.
  80122. */
  80123. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80124. /**
  80125. * Calculates the distance to a point
  80126. * @param point point to calculate distance to
  80127. * @returns the signed distance (float) from the given point to the Plane.
  80128. */
  80129. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80130. /**
  80131. * Creates a plane from an array
  80132. * @param array the array to create a plane from
  80133. * @returns a new Plane from the given array.
  80134. */
  80135. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80136. /**
  80137. * Creates a plane from three points
  80138. * @param point1 point used to create the plane
  80139. * @param point2 point used to create the plane
  80140. * @param point3 point used to create the plane
  80141. * @returns a new Plane defined by the three given points.
  80142. */
  80143. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80144. /**
  80145. * Creates a plane from an origin point and a normal
  80146. * @param origin origin of the plane to be constructed
  80147. * @param normal normal of the plane to be constructed
  80148. * @returns a new Plane the normal vector to this plane at the given origin point.
  80149. * Note : the vector "normal" is updated because normalized.
  80150. */
  80151. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  80152. /**
  80153. * Calculates the distance from a plane and a point
  80154. * @param origin origin of the plane to be constructed
  80155. * @param normal normal of the plane to be constructed
  80156. * @param point point to calculate distance to
  80157. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80158. */
  80159. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80160. }
  80161. }
  80162. declare module BABYLON {
  80163. /**
  80164. * Class used to store bounding sphere information
  80165. */
  80166. export class BoundingSphere {
  80167. /**
  80168. * Gets the center of the bounding sphere in local space
  80169. */
  80170. readonly center: Vector3;
  80171. /**
  80172. * Radius of the bounding sphere in local space
  80173. */
  80174. radius: number;
  80175. /**
  80176. * Gets the center of the bounding sphere in world space
  80177. */
  80178. readonly centerWorld: Vector3;
  80179. /**
  80180. * Radius of the bounding sphere in world space
  80181. */
  80182. radiusWorld: number;
  80183. /**
  80184. * Gets the minimum vector in local space
  80185. */
  80186. readonly minimum: Vector3;
  80187. /**
  80188. * Gets the maximum vector in local space
  80189. */
  80190. readonly maximum: Vector3;
  80191. private _worldMatrix;
  80192. private static readonly TmpVector3;
  80193. /**
  80194. * Creates a new bounding sphere
  80195. * @param min defines the minimum vector (in local space)
  80196. * @param max defines the maximum vector (in local space)
  80197. * @param worldMatrix defines the new world matrix
  80198. */
  80199. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80200. /**
  80201. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80202. * @param min defines the new minimum vector (in local space)
  80203. * @param max defines the new maximum vector (in local space)
  80204. * @param worldMatrix defines the new world matrix
  80205. */
  80206. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80207. /**
  80208. * Scale the current bounding sphere by applying a scale factor
  80209. * @param factor defines the scale factor to apply
  80210. * @returns the current bounding box
  80211. */
  80212. scale(factor: number): BoundingSphere;
  80213. /**
  80214. * Gets the world matrix of the bounding box
  80215. * @returns a matrix
  80216. */
  80217. getWorldMatrix(): DeepImmutable<Matrix>;
  80218. /** @hidden */
  80219. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80220. /**
  80221. * Tests if the bounding sphere is intersecting the frustum planes
  80222. * @param frustumPlanes defines the frustum planes to test
  80223. * @returns true if there is an intersection
  80224. */
  80225. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80226. /**
  80227. * Tests if the bounding sphere center is in between the frustum planes.
  80228. * Used for optimistic fast inclusion.
  80229. * @param frustumPlanes defines the frustum planes to test
  80230. * @returns true if the sphere center is in between the frustum planes
  80231. */
  80232. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80233. /**
  80234. * Tests if a point is inside the bounding sphere
  80235. * @param point defines the point to test
  80236. * @returns true if the point is inside the bounding sphere
  80237. */
  80238. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80239. /**
  80240. * Checks if two sphere intersct
  80241. * @param sphere0 sphere 0
  80242. * @param sphere1 sphere 1
  80243. * @returns true if the speres intersect
  80244. */
  80245. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80246. }
  80247. }
  80248. declare module BABYLON {
  80249. /**
  80250. * Class used to store bounding box information
  80251. */
  80252. export class BoundingBox implements ICullable {
  80253. /**
  80254. * Gets the 8 vectors representing the bounding box in local space
  80255. */
  80256. readonly vectors: Vector3[];
  80257. /**
  80258. * Gets the center of the bounding box in local space
  80259. */
  80260. readonly center: Vector3;
  80261. /**
  80262. * Gets the center of the bounding box in world space
  80263. */
  80264. readonly centerWorld: Vector3;
  80265. /**
  80266. * Gets the extend size in local space
  80267. */
  80268. readonly extendSize: Vector3;
  80269. /**
  80270. * Gets the extend size in world space
  80271. */
  80272. readonly extendSizeWorld: Vector3;
  80273. /**
  80274. * Gets the OBB (object bounding box) directions
  80275. */
  80276. readonly directions: Vector3[];
  80277. /**
  80278. * Gets the 8 vectors representing the bounding box in world space
  80279. */
  80280. readonly vectorsWorld: Vector3[];
  80281. /**
  80282. * Gets the minimum vector in world space
  80283. */
  80284. readonly minimumWorld: Vector3;
  80285. /**
  80286. * Gets the maximum vector in world space
  80287. */
  80288. readonly maximumWorld: Vector3;
  80289. /**
  80290. * Gets the minimum vector in local space
  80291. */
  80292. readonly minimum: Vector3;
  80293. /**
  80294. * Gets the maximum vector in local space
  80295. */
  80296. readonly maximum: Vector3;
  80297. private _worldMatrix;
  80298. private static readonly TmpVector3;
  80299. /**
  80300. * @hidden
  80301. */
  80302. _tag: number;
  80303. /**
  80304. * Creates a new bounding box
  80305. * @param min defines the minimum vector (in local space)
  80306. * @param max defines the maximum vector (in local space)
  80307. * @param worldMatrix defines the new world matrix
  80308. */
  80309. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80310. /**
  80311. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80312. * @param min defines the new minimum vector (in local space)
  80313. * @param max defines the new maximum vector (in local space)
  80314. * @param worldMatrix defines the new world matrix
  80315. */
  80316. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80317. /**
  80318. * Scale the current bounding box by applying a scale factor
  80319. * @param factor defines the scale factor to apply
  80320. * @returns the current bounding box
  80321. */
  80322. scale(factor: number): BoundingBox;
  80323. /**
  80324. * Gets the world matrix of the bounding box
  80325. * @returns a matrix
  80326. */
  80327. getWorldMatrix(): DeepImmutable<Matrix>;
  80328. /** @hidden */
  80329. _update(world: DeepImmutable<Matrix>): void;
  80330. /**
  80331. * Tests if the bounding box is intersecting the frustum planes
  80332. * @param frustumPlanes defines the frustum planes to test
  80333. * @returns true if there is an intersection
  80334. */
  80335. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80336. /**
  80337. * Tests if the bounding box is entirely inside the frustum planes
  80338. * @param frustumPlanes defines the frustum planes to test
  80339. * @returns true if there is an inclusion
  80340. */
  80341. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80342. /**
  80343. * Tests if a point is inside the bounding box
  80344. * @param point defines the point to test
  80345. * @returns true if the point is inside the bounding box
  80346. */
  80347. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80348. /**
  80349. * Tests if the bounding box intersects with a bounding sphere
  80350. * @param sphere defines the sphere to test
  80351. * @returns true if there is an intersection
  80352. */
  80353. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80354. /**
  80355. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80356. * @param min defines the min vector to use
  80357. * @param max defines the max vector to use
  80358. * @returns true if there is an intersection
  80359. */
  80360. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80361. /**
  80362. * Tests if two bounding boxes are intersections
  80363. * @param box0 defines the first box to test
  80364. * @param box1 defines the second box to test
  80365. * @returns true if there is an intersection
  80366. */
  80367. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80368. /**
  80369. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80370. * @param minPoint defines the minimum vector of the bounding box
  80371. * @param maxPoint defines the maximum vector of the bounding box
  80372. * @param sphereCenter defines the sphere center
  80373. * @param sphereRadius defines the sphere radius
  80374. * @returns true if there is an intersection
  80375. */
  80376. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80377. /**
  80378. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80379. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80380. * @param frustumPlanes defines the frustum planes to test
  80381. * @return true if there is an inclusion
  80382. */
  80383. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80384. /**
  80385. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80386. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80387. * @param frustumPlanes defines the frustum planes to test
  80388. * @return true if there is an intersection
  80389. */
  80390. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80391. }
  80392. }
  80393. declare module BABYLON {
  80394. /** @hidden */
  80395. export class Collider {
  80396. /** Define if a collision was found */
  80397. collisionFound: boolean;
  80398. /**
  80399. * Define last intersection point in local space
  80400. */
  80401. intersectionPoint: Vector3;
  80402. /**
  80403. * Define last collided mesh
  80404. */
  80405. collidedMesh: Nullable<AbstractMesh>;
  80406. private _collisionPoint;
  80407. private _planeIntersectionPoint;
  80408. private _tempVector;
  80409. private _tempVector2;
  80410. private _tempVector3;
  80411. private _tempVector4;
  80412. private _edge;
  80413. private _baseToVertex;
  80414. private _destinationPoint;
  80415. private _slidePlaneNormal;
  80416. private _displacementVector;
  80417. /** @hidden */
  80418. _radius: Vector3;
  80419. /** @hidden */
  80420. _retry: number;
  80421. private _velocity;
  80422. private _basePoint;
  80423. private _epsilon;
  80424. /** @hidden */
  80425. _velocityWorldLength: number;
  80426. /** @hidden */
  80427. _basePointWorld: Vector3;
  80428. private _velocityWorld;
  80429. private _normalizedVelocity;
  80430. /** @hidden */
  80431. _initialVelocity: Vector3;
  80432. /** @hidden */
  80433. _initialPosition: Vector3;
  80434. private _nearestDistance;
  80435. private _collisionMask;
  80436. get collisionMask(): number;
  80437. set collisionMask(mask: number);
  80438. /**
  80439. * Gets the plane normal used to compute the sliding response (in local space)
  80440. */
  80441. get slidePlaneNormal(): Vector3;
  80442. /** @hidden */
  80443. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80444. /** @hidden */
  80445. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80446. /** @hidden */
  80447. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80448. /** @hidden */
  80449. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80450. /** @hidden */
  80451. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80452. /** @hidden */
  80453. _getResponse(pos: Vector3, vel: Vector3): void;
  80454. }
  80455. }
  80456. declare module BABYLON {
  80457. /**
  80458. * Interface for cullable objects
  80459. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80460. */
  80461. export interface ICullable {
  80462. /**
  80463. * Checks if the object or part of the object is in the frustum
  80464. * @param frustumPlanes Camera near/planes
  80465. * @returns true if the object is in frustum otherwise false
  80466. */
  80467. isInFrustum(frustumPlanes: Plane[]): boolean;
  80468. /**
  80469. * Checks if a cullable object (mesh...) is in the camera frustum
  80470. * Unlike isInFrustum this cheks the full bounding box
  80471. * @param frustumPlanes Camera near/planes
  80472. * @returns true if the object is in frustum otherwise false
  80473. */
  80474. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80475. }
  80476. /**
  80477. * Info for a bounding data of a mesh
  80478. */
  80479. export class BoundingInfo implements ICullable {
  80480. /**
  80481. * Bounding box for the mesh
  80482. */
  80483. readonly boundingBox: BoundingBox;
  80484. /**
  80485. * Bounding sphere for the mesh
  80486. */
  80487. readonly boundingSphere: BoundingSphere;
  80488. private _isLocked;
  80489. private static readonly TmpVector3;
  80490. /**
  80491. * Constructs bounding info
  80492. * @param minimum min vector of the bounding box/sphere
  80493. * @param maximum max vector of the bounding box/sphere
  80494. * @param worldMatrix defines the new world matrix
  80495. */
  80496. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80497. /**
  80498. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80499. * @param min defines the new minimum vector (in local space)
  80500. * @param max defines the new maximum vector (in local space)
  80501. * @param worldMatrix defines the new world matrix
  80502. */
  80503. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80504. /**
  80505. * min vector of the bounding box/sphere
  80506. */
  80507. get minimum(): Vector3;
  80508. /**
  80509. * max vector of the bounding box/sphere
  80510. */
  80511. get maximum(): Vector3;
  80512. /**
  80513. * If the info is locked and won't be updated to avoid perf overhead
  80514. */
  80515. get isLocked(): boolean;
  80516. set isLocked(value: boolean);
  80517. /**
  80518. * Updates the bounding sphere and box
  80519. * @param world world matrix to be used to update
  80520. */
  80521. update(world: DeepImmutable<Matrix>): void;
  80522. /**
  80523. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80524. * @param center New center of the bounding info
  80525. * @param extend New extend of the bounding info
  80526. * @returns the current bounding info
  80527. */
  80528. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80529. /**
  80530. * Scale the current bounding info by applying a scale factor
  80531. * @param factor defines the scale factor to apply
  80532. * @returns the current bounding info
  80533. */
  80534. scale(factor: number): BoundingInfo;
  80535. /**
  80536. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80537. * @param frustumPlanes defines the frustum to test
  80538. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80539. * @returns true if the bounding info is in the frustum planes
  80540. */
  80541. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80542. /**
  80543. * Gets the world distance between the min and max points of the bounding box
  80544. */
  80545. get diagonalLength(): number;
  80546. /**
  80547. * Checks if a cullable object (mesh...) is in the camera frustum
  80548. * Unlike isInFrustum this cheks the full bounding box
  80549. * @param frustumPlanes Camera near/planes
  80550. * @returns true if the object is in frustum otherwise false
  80551. */
  80552. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80553. /** @hidden */
  80554. _checkCollision(collider: Collider): boolean;
  80555. /**
  80556. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80557. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80558. * @param point the point to check intersection with
  80559. * @returns if the point intersects
  80560. */
  80561. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80562. /**
  80563. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80564. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80565. * @param boundingInfo the bounding info to check intersection with
  80566. * @param precise if the intersection should be done using OBB
  80567. * @returns if the bounding info intersects
  80568. */
  80569. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80570. }
  80571. }
  80572. declare module BABYLON {
  80573. /**
  80574. * Extracts minimum and maximum values from a list of indexed positions
  80575. * @param positions defines the positions to use
  80576. * @param indices defines the indices to the positions
  80577. * @param indexStart defines the start index
  80578. * @param indexCount defines the end index
  80579. * @param bias defines bias value to add to the result
  80580. * @return minimum and maximum values
  80581. */
  80582. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80583. minimum: Vector3;
  80584. maximum: Vector3;
  80585. };
  80586. /**
  80587. * Extracts minimum and maximum values from a list of positions
  80588. * @param positions defines the positions to use
  80589. * @param start defines the start index in the positions array
  80590. * @param count defines the number of positions to handle
  80591. * @param bias defines bias value to add to the result
  80592. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80593. * @return minimum and maximum values
  80594. */
  80595. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80596. minimum: Vector3;
  80597. maximum: Vector3;
  80598. };
  80599. }
  80600. declare module BABYLON {
  80601. /** @hidden */
  80602. export class WebGLDataBuffer extends DataBuffer {
  80603. private _buffer;
  80604. constructor(resource: WebGLBuffer);
  80605. get underlyingResource(): any;
  80606. }
  80607. }
  80608. declare module BABYLON {
  80609. /** @hidden */
  80610. export class WebGLPipelineContext implements IPipelineContext {
  80611. engine: ThinEngine;
  80612. program: Nullable<WebGLProgram>;
  80613. context?: WebGLRenderingContext;
  80614. vertexShader?: WebGLShader;
  80615. fragmentShader?: WebGLShader;
  80616. isParallelCompiled: boolean;
  80617. onCompiled?: () => void;
  80618. transformFeedback?: WebGLTransformFeedback | null;
  80619. vertexCompilationError: Nullable<string>;
  80620. fragmentCompilationError: Nullable<string>;
  80621. programLinkError: Nullable<string>;
  80622. programValidationError: Nullable<string>;
  80623. get isAsync(): boolean;
  80624. get isReady(): boolean;
  80625. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80626. _getVertexShaderCode(): string | null;
  80627. _getFragmentShaderCode(): string | null;
  80628. }
  80629. }
  80630. declare module BABYLON {
  80631. interface ThinEngine {
  80632. /**
  80633. * Create an uniform buffer
  80634. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80635. * @param elements defines the content of the uniform buffer
  80636. * @returns the webGL uniform buffer
  80637. */
  80638. createUniformBuffer(elements: FloatArray): DataBuffer;
  80639. /**
  80640. * Create a dynamic uniform buffer
  80641. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80642. * @param elements defines the content of the uniform buffer
  80643. * @returns the webGL uniform buffer
  80644. */
  80645. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80646. /**
  80647. * Update an existing uniform buffer
  80648. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80649. * @param uniformBuffer defines the target uniform buffer
  80650. * @param elements defines the content to update
  80651. * @param offset defines the offset in the uniform buffer where update should start
  80652. * @param count defines the size of the data to update
  80653. */
  80654. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80655. /**
  80656. * Bind an uniform buffer to the current webGL context
  80657. * @param buffer defines the buffer to bind
  80658. */
  80659. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80660. /**
  80661. * Bind a buffer to the current webGL context at a given location
  80662. * @param buffer defines the buffer to bind
  80663. * @param location defines the index where to bind the buffer
  80664. */
  80665. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80666. /**
  80667. * Bind a specific block at a given index in a specific shader program
  80668. * @param pipelineContext defines the pipeline context to use
  80669. * @param blockName defines the block name
  80670. * @param index defines the index where to bind the block
  80671. */
  80672. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80673. }
  80674. }
  80675. declare module BABYLON {
  80676. /**
  80677. * Uniform buffer objects.
  80678. *
  80679. * Handles blocks of uniform on the GPU.
  80680. *
  80681. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80682. *
  80683. * For more information, please refer to :
  80684. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80685. */
  80686. export class UniformBuffer {
  80687. private _engine;
  80688. private _buffer;
  80689. private _data;
  80690. private _bufferData;
  80691. private _dynamic?;
  80692. private _uniformLocations;
  80693. private _uniformSizes;
  80694. private _uniformLocationPointer;
  80695. private _needSync;
  80696. private _noUBO;
  80697. private _currentEffect;
  80698. /** @hidden */
  80699. _alreadyBound: boolean;
  80700. private static _MAX_UNIFORM_SIZE;
  80701. private static _tempBuffer;
  80702. /**
  80703. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80704. * This is dynamic to allow compat with webgl 1 and 2.
  80705. * You will need to pass the name of the uniform as well as the value.
  80706. */
  80707. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80708. /**
  80709. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80710. * This is dynamic to allow compat with webgl 1 and 2.
  80711. * You will need to pass the name of the uniform as well as the value.
  80712. */
  80713. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80714. /**
  80715. * Lambda to Update a single float in a uniform buffer.
  80716. * This is dynamic to allow compat with webgl 1 and 2.
  80717. * You will need to pass the name of the uniform as well as the value.
  80718. */
  80719. updateFloat: (name: string, x: number) => void;
  80720. /**
  80721. * Lambda to Update a vec2 of float in a uniform buffer.
  80722. * This is dynamic to allow compat with webgl 1 and 2.
  80723. * You will need to pass the name of the uniform as well as the value.
  80724. */
  80725. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80726. /**
  80727. * Lambda to Update a vec3 of float in a uniform buffer.
  80728. * This is dynamic to allow compat with webgl 1 and 2.
  80729. * You will need to pass the name of the uniform as well as the value.
  80730. */
  80731. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80732. /**
  80733. * Lambda to Update a vec4 of float in a uniform buffer.
  80734. * This is dynamic to allow compat with webgl 1 and 2.
  80735. * You will need to pass the name of the uniform as well as the value.
  80736. */
  80737. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80738. /**
  80739. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80740. * This is dynamic to allow compat with webgl 1 and 2.
  80741. * You will need to pass the name of the uniform as well as the value.
  80742. */
  80743. updateMatrix: (name: string, mat: Matrix) => void;
  80744. /**
  80745. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80746. * This is dynamic to allow compat with webgl 1 and 2.
  80747. * You will need to pass the name of the uniform as well as the value.
  80748. */
  80749. updateVector3: (name: string, vector: Vector3) => void;
  80750. /**
  80751. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80752. * This is dynamic to allow compat with webgl 1 and 2.
  80753. * You will need to pass the name of the uniform as well as the value.
  80754. */
  80755. updateVector4: (name: string, vector: Vector4) => void;
  80756. /**
  80757. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80758. * This is dynamic to allow compat with webgl 1 and 2.
  80759. * You will need to pass the name of the uniform as well as the value.
  80760. */
  80761. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80762. /**
  80763. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80764. * This is dynamic to allow compat with webgl 1 and 2.
  80765. * You will need to pass the name of the uniform as well as the value.
  80766. */
  80767. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80768. /**
  80769. * Instantiates a new Uniform buffer objects.
  80770. *
  80771. * Handles blocks of uniform on the GPU.
  80772. *
  80773. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80774. *
  80775. * For more information, please refer to :
  80776. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80777. * @param engine Define the engine the buffer is associated with
  80778. * @param data Define the data contained in the buffer
  80779. * @param dynamic Define if the buffer is updatable
  80780. */
  80781. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80782. /**
  80783. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80784. * or just falling back on setUniformXXX calls.
  80785. */
  80786. get useUbo(): boolean;
  80787. /**
  80788. * Indicates if the WebGL underlying uniform buffer is in sync
  80789. * with the javascript cache data.
  80790. */
  80791. get isSync(): boolean;
  80792. /**
  80793. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80794. * Also, a dynamic UniformBuffer will disable cache verification and always
  80795. * update the underlying WebGL uniform buffer to the GPU.
  80796. * @returns if Dynamic, otherwise false
  80797. */
  80798. isDynamic(): boolean;
  80799. /**
  80800. * The data cache on JS side.
  80801. * @returns the underlying data as a float array
  80802. */
  80803. getData(): Float32Array;
  80804. /**
  80805. * The underlying WebGL Uniform buffer.
  80806. * @returns the webgl buffer
  80807. */
  80808. getBuffer(): Nullable<DataBuffer>;
  80809. /**
  80810. * std140 layout specifies how to align data within an UBO structure.
  80811. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80812. * for specs.
  80813. */
  80814. private _fillAlignment;
  80815. /**
  80816. * Adds an uniform in the buffer.
  80817. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80818. * for the layout to be correct !
  80819. * @param name Name of the uniform, as used in the uniform block in the shader.
  80820. * @param size Data size, or data directly.
  80821. */
  80822. addUniform(name: string, size: number | number[]): void;
  80823. /**
  80824. * Adds a Matrix 4x4 to the uniform buffer.
  80825. * @param name Name of the uniform, as used in the uniform block in the shader.
  80826. * @param mat A 4x4 matrix.
  80827. */
  80828. addMatrix(name: string, mat: Matrix): void;
  80829. /**
  80830. * Adds a vec2 to the uniform buffer.
  80831. * @param name Name of the uniform, as used in the uniform block in the shader.
  80832. * @param x Define the x component value of the vec2
  80833. * @param y Define the y component value of the vec2
  80834. */
  80835. addFloat2(name: string, x: number, y: number): void;
  80836. /**
  80837. * Adds a vec3 to the uniform buffer.
  80838. * @param name Name of the uniform, as used in the uniform block in the shader.
  80839. * @param x Define the x component value of the vec3
  80840. * @param y Define the y component value of the vec3
  80841. * @param z Define the z component value of the vec3
  80842. */
  80843. addFloat3(name: string, x: number, y: number, z: number): void;
  80844. /**
  80845. * Adds a vec3 to the uniform buffer.
  80846. * @param name Name of the uniform, as used in the uniform block in the shader.
  80847. * @param color Define the vec3 from a Color
  80848. */
  80849. addColor3(name: string, color: Color3): void;
  80850. /**
  80851. * Adds a vec4 to the uniform buffer.
  80852. * @param name Name of the uniform, as used in the uniform block in the shader.
  80853. * @param color Define the rgb components from a Color
  80854. * @param alpha Define the a component of the vec4
  80855. */
  80856. addColor4(name: string, color: Color3, alpha: number): void;
  80857. /**
  80858. * Adds a vec3 to the uniform buffer.
  80859. * @param name Name of the uniform, as used in the uniform block in the shader.
  80860. * @param vector Define the vec3 components from a Vector
  80861. */
  80862. addVector3(name: string, vector: Vector3): void;
  80863. /**
  80864. * Adds a Matrix 3x3 to the uniform buffer.
  80865. * @param name Name of the uniform, as used in the uniform block in the shader.
  80866. */
  80867. addMatrix3x3(name: string): void;
  80868. /**
  80869. * Adds a Matrix 2x2 to the uniform buffer.
  80870. * @param name Name of the uniform, as used in the uniform block in the shader.
  80871. */
  80872. addMatrix2x2(name: string): void;
  80873. /**
  80874. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80875. */
  80876. create(): void;
  80877. /** @hidden */
  80878. _rebuild(): void;
  80879. /**
  80880. * Updates the WebGL Uniform Buffer on the GPU.
  80881. * If the `dynamic` flag is set to true, no cache comparison is done.
  80882. * Otherwise, the buffer will be updated only if the cache differs.
  80883. */
  80884. update(): void;
  80885. /**
  80886. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80887. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80888. * @param data Define the flattened data
  80889. * @param size Define the size of the data.
  80890. */
  80891. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80892. private _valueCache;
  80893. private _cacheMatrix;
  80894. private _updateMatrix3x3ForUniform;
  80895. private _updateMatrix3x3ForEffect;
  80896. private _updateMatrix2x2ForEffect;
  80897. private _updateMatrix2x2ForUniform;
  80898. private _updateFloatForEffect;
  80899. private _updateFloatForUniform;
  80900. private _updateFloat2ForEffect;
  80901. private _updateFloat2ForUniform;
  80902. private _updateFloat3ForEffect;
  80903. private _updateFloat3ForUniform;
  80904. private _updateFloat4ForEffect;
  80905. private _updateFloat4ForUniform;
  80906. private _updateMatrixForEffect;
  80907. private _updateMatrixForUniform;
  80908. private _updateVector3ForEffect;
  80909. private _updateVector3ForUniform;
  80910. private _updateVector4ForEffect;
  80911. private _updateVector4ForUniform;
  80912. private _updateColor3ForEffect;
  80913. private _updateColor3ForUniform;
  80914. private _updateColor4ForEffect;
  80915. private _updateColor4ForUniform;
  80916. /**
  80917. * Sets a sampler uniform on the effect.
  80918. * @param name Define the name of the sampler.
  80919. * @param texture Define the texture to set in the sampler
  80920. */
  80921. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80922. /**
  80923. * Directly updates the value of the uniform in the cache AND on the GPU.
  80924. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80925. * @param data Define the flattened data
  80926. */
  80927. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80928. /**
  80929. * Binds this uniform buffer to an effect.
  80930. * @param effect Define the effect to bind the buffer to
  80931. * @param name Name of the uniform block in the shader.
  80932. */
  80933. bindToEffect(effect: Effect, name: string): void;
  80934. /**
  80935. * Disposes the uniform buffer.
  80936. */
  80937. dispose(): void;
  80938. }
  80939. }
  80940. declare module BABYLON {
  80941. /**
  80942. * Enum that determines the text-wrapping mode to use.
  80943. */
  80944. export enum InspectableType {
  80945. /**
  80946. * Checkbox for booleans
  80947. */
  80948. Checkbox = 0,
  80949. /**
  80950. * Sliders for numbers
  80951. */
  80952. Slider = 1,
  80953. /**
  80954. * Vector3
  80955. */
  80956. Vector3 = 2,
  80957. /**
  80958. * Quaternions
  80959. */
  80960. Quaternion = 3,
  80961. /**
  80962. * Color3
  80963. */
  80964. Color3 = 4,
  80965. /**
  80966. * String
  80967. */
  80968. String = 5
  80969. }
  80970. /**
  80971. * Interface used to define custom inspectable properties.
  80972. * This interface is used by the inspector to display custom property grids
  80973. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80974. */
  80975. export interface IInspectable {
  80976. /**
  80977. * Gets the label to display
  80978. */
  80979. label: string;
  80980. /**
  80981. * Gets the name of the property to edit
  80982. */
  80983. propertyName: string;
  80984. /**
  80985. * Gets the type of the editor to use
  80986. */
  80987. type: InspectableType;
  80988. /**
  80989. * Gets the minimum value of the property when using in "slider" mode
  80990. */
  80991. min?: number;
  80992. /**
  80993. * Gets the maximum value of the property when using in "slider" mode
  80994. */
  80995. max?: number;
  80996. /**
  80997. * Gets the setp to use when using in "slider" mode
  80998. */
  80999. step?: number;
  81000. }
  81001. }
  81002. declare module BABYLON {
  81003. /**
  81004. * Class used to provide helper for timing
  81005. */
  81006. export class TimingTools {
  81007. /**
  81008. * Polyfill for setImmediate
  81009. * @param action defines the action to execute after the current execution block
  81010. */
  81011. static SetImmediate(action: () => void): void;
  81012. }
  81013. }
  81014. declare module BABYLON {
  81015. /**
  81016. * Class used to enable instatition of objects by class name
  81017. */
  81018. export class InstantiationTools {
  81019. /**
  81020. * Use this object to register external classes like custom textures or material
  81021. * to allow the laoders to instantiate them
  81022. */
  81023. static RegisteredExternalClasses: {
  81024. [key: string]: Object;
  81025. };
  81026. /**
  81027. * Tries to instantiate a new object from a given class name
  81028. * @param className defines the class name to instantiate
  81029. * @returns the new object or null if the system was not able to do the instantiation
  81030. */
  81031. static Instantiate(className: string): any;
  81032. }
  81033. }
  81034. declare module BABYLON {
  81035. /**
  81036. * Define options used to create a depth texture
  81037. */
  81038. export class DepthTextureCreationOptions {
  81039. /** Specifies whether or not a stencil should be allocated in the texture */
  81040. generateStencil?: boolean;
  81041. /** Specifies whether or not bilinear filtering is enable on the texture */
  81042. bilinearFiltering?: boolean;
  81043. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  81044. comparisonFunction?: number;
  81045. /** Specifies if the created texture is a cube texture */
  81046. isCube?: boolean;
  81047. }
  81048. }
  81049. declare module BABYLON {
  81050. interface ThinEngine {
  81051. /**
  81052. * Creates a depth stencil cube texture.
  81053. * This is only available in WebGL 2.
  81054. * @param size The size of face edge in the cube texture.
  81055. * @param options The options defining the cube texture.
  81056. * @returns The cube texture
  81057. */
  81058. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  81059. /**
  81060. * Creates a cube texture
  81061. * @param rootUrl defines the url where the files to load is located
  81062. * @param scene defines the current scene
  81063. * @param files defines the list of files to load (1 per face)
  81064. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81065. * @param onLoad defines an optional callback raised when the texture is loaded
  81066. * @param onError defines an optional callback raised if there is an issue to load the texture
  81067. * @param format defines the format of the data
  81068. * @param forcedExtension defines the extension to use to pick the right loader
  81069. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81070. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81071. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81072. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  81073. * @returns the cube texture as an InternalTexture
  81074. */
  81075. 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>): InternalTexture;
  81076. /**
  81077. * Creates a cube texture
  81078. * @param rootUrl defines the url where the files to load is located
  81079. * @param scene defines the current scene
  81080. * @param files defines the list of files to load (1 per face)
  81081. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81082. * @param onLoad defines an optional callback raised when the texture is loaded
  81083. * @param onError defines an optional callback raised if there is an issue to load the texture
  81084. * @param format defines the format of the data
  81085. * @param forcedExtension defines the extension to use to pick the right loader
  81086. * @returns the cube texture as an InternalTexture
  81087. */
  81088. 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;
  81089. /**
  81090. * Creates a cube texture
  81091. * @param rootUrl defines the url where the files to load is located
  81092. * @param scene defines the current scene
  81093. * @param files defines the list of files to load (1 per face)
  81094. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81095. * @param onLoad defines an optional callback raised when the texture is loaded
  81096. * @param onError defines an optional callback raised if there is an issue to load the texture
  81097. * @param format defines the format of the data
  81098. * @param forcedExtension defines the extension to use to pick the right loader
  81099. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81100. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81101. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81102. * @returns the cube texture as an InternalTexture
  81103. */
  81104. 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;
  81105. /** @hidden */
  81106. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  81107. /** @hidden */
  81108. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  81109. /** @hidden */
  81110. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81111. /** @hidden */
  81112. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81113. /**
  81114. * @hidden
  81115. */
  81116. _setCubeMapTextureParams(loadMipmap: boolean): void;
  81117. }
  81118. }
  81119. declare module BABYLON {
  81120. /**
  81121. * Class for creating a cube texture
  81122. */
  81123. export class CubeTexture extends BaseTexture {
  81124. private _delayedOnLoad;
  81125. /**
  81126. * Observable triggered once the texture has been loaded.
  81127. */
  81128. onLoadObservable: Observable<CubeTexture>;
  81129. /**
  81130. * The url of the texture
  81131. */
  81132. url: string;
  81133. /**
  81134. * Gets or sets the center of the bounding box associated with the cube texture.
  81135. * It must define where the camera used to render the texture was set
  81136. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81137. */
  81138. boundingBoxPosition: Vector3;
  81139. private _boundingBoxSize;
  81140. /**
  81141. * Gets or sets the size of the bounding box associated with the cube texture
  81142. * When defined, the cubemap will switch to local mode
  81143. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81144. * @example https://www.babylonjs-playground.com/#RNASML
  81145. */
  81146. set boundingBoxSize(value: Vector3);
  81147. /**
  81148. * Returns the bounding box size
  81149. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81150. */
  81151. get boundingBoxSize(): Vector3;
  81152. protected _rotationY: number;
  81153. /**
  81154. * Sets texture matrix rotation angle around Y axis in radians.
  81155. */
  81156. set rotationY(value: number);
  81157. /**
  81158. * Gets texture matrix rotation angle around Y axis radians.
  81159. */
  81160. get rotationY(): number;
  81161. /**
  81162. * Are mip maps generated for this texture or not.
  81163. */
  81164. get noMipmap(): boolean;
  81165. private _noMipmap;
  81166. private _files;
  81167. protected _forcedExtension: Nullable<string>;
  81168. private _extensions;
  81169. private _textureMatrix;
  81170. private _format;
  81171. private _createPolynomials;
  81172. /** @hidden */
  81173. _prefiltered: boolean;
  81174. /**
  81175. * Creates a cube texture from an array of image urls
  81176. * @param files defines an array of image urls
  81177. * @param scene defines the hosting scene
  81178. * @param noMipmap specifies if mip maps are not used
  81179. * @returns a cube texture
  81180. */
  81181. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  81182. /**
  81183. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  81184. * @param url defines the url of the prefiltered texture
  81185. * @param scene defines the scene the texture is attached to
  81186. * @param forcedExtension defines the extension of the file if different from the url
  81187. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81188. * @return the prefiltered texture
  81189. */
  81190. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  81191. /**
  81192. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  81193. * as prefiltered data.
  81194. * @param rootUrl defines the url of the texture or the root name of the six images
  81195. * @param scene defines the scene the texture is attached to
  81196. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  81197. * @param noMipmap defines if mipmaps should be created or not
  81198. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  81199. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  81200. * @param onError defines a callback triggered in case of error during load
  81201. * @param format defines the internal format to use for the texture once loaded
  81202. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81203. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81204. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81205. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81206. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81207. * @return the cube texture
  81208. */
  81209. 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);
  81210. /**
  81211. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81212. */
  81213. get isPrefiltered(): boolean;
  81214. /**
  81215. * Get the current class name of the texture useful for serialization or dynamic coding.
  81216. * @returns "CubeTexture"
  81217. */
  81218. getClassName(): string;
  81219. /**
  81220. * Update the url (and optional buffer) of this texture if url was null during construction.
  81221. * @param url the url of the texture
  81222. * @param forcedExtension defines the extension to use
  81223. * @param onLoad callback called when the texture is loaded (defaults to null)
  81224. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81225. */
  81226. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81227. /**
  81228. * Delays loading of the cube texture
  81229. * @param forcedExtension defines the extension to use
  81230. */
  81231. delayLoad(forcedExtension?: string): void;
  81232. /**
  81233. * Returns the reflection texture matrix
  81234. * @returns the reflection texture matrix
  81235. */
  81236. getReflectionTextureMatrix(): Matrix;
  81237. /**
  81238. * Sets the reflection texture matrix
  81239. * @param value Reflection texture matrix
  81240. */
  81241. setReflectionTextureMatrix(value: Matrix): void;
  81242. /**
  81243. * Parses text to create a cube texture
  81244. * @param parsedTexture define the serialized text to read from
  81245. * @param scene defines the hosting scene
  81246. * @param rootUrl defines the root url of the cube texture
  81247. * @returns a cube texture
  81248. */
  81249. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81250. /**
  81251. * Makes a clone, or deep copy, of the cube texture
  81252. * @returns a new cube texture
  81253. */
  81254. clone(): CubeTexture;
  81255. }
  81256. }
  81257. declare module BABYLON {
  81258. /**
  81259. * Manages the defines for the Material
  81260. */
  81261. export class MaterialDefines {
  81262. /** @hidden */
  81263. protected _keys: string[];
  81264. private _isDirty;
  81265. /** @hidden */
  81266. _renderId: number;
  81267. /** @hidden */
  81268. _areLightsDirty: boolean;
  81269. /** @hidden */
  81270. _areLightsDisposed: boolean;
  81271. /** @hidden */
  81272. _areAttributesDirty: boolean;
  81273. /** @hidden */
  81274. _areTexturesDirty: boolean;
  81275. /** @hidden */
  81276. _areFresnelDirty: boolean;
  81277. /** @hidden */
  81278. _areMiscDirty: boolean;
  81279. /** @hidden */
  81280. _areImageProcessingDirty: boolean;
  81281. /** @hidden */
  81282. _normals: boolean;
  81283. /** @hidden */
  81284. _uvs: boolean;
  81285. /** @hidden */
  81286. _needNormals: boolean;
  81287. /** @hidden */
  81288. _needUVs: boolean;
  81289. [id: string]: any;
  81290. /**
  81291. * Specifies if the material needs to be re-calculated
  81292. */
  81293. get isDirty(): boolean;
  81294. /**
  81295. * Marks the material to indicate that it has been re-calculated
  81296. */
  81297. markAsProcessed(): void;
  81298. /**
  81299. * Marks the material to indicate that it needs to be re-calculated
  81300. */
  81301. markAsUnprocessed(): void;
  81302. /**
  81303. * Marks the material to indicate all of its defines need to be re-calculated
  81304. */
  81305. markAllAsDirty(): void;
  81306. /**
  81307. * Marks the material to indicate that image processing needs to be re-calculated
  81308. */
  81309. markAsImageProcessingDirty(): void;
  81310. /**
  81311. * Marks the material to indicate the lights need to be re-calculated
  81312. * @param disposed Defines whether the light is dirty due to dispose or not
  81313. */
  81314. markAsLightDirty(disposed?: boolean): void;
  81315. /**
  81316. * Marks the attribute state as changed
  81317. */
  81318. markAsAttributesDirty(): void;
  81319. /**
  81320. * Marks the texture state as changed
  81321. */
  81322. markAsTexturesDirty(): void;
  81323. /**
  81324. * Marks the fresnel state as changed
  81325. */
  81326. markAsFresnelDirty(): void;
  81327. /**
  81328. * Marks the misc state as changed
  81329. */
  81330. markAsMiscDirty(): void;
  81331. /**
  81332. * Rebuilds the material defines
  81333. */
  81334. rebuild(): void;
  81335. /**
  81336. * Specifies if two material defines are equal
  81337. * @param other - A material define instance to compare to
  81338. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81339. */
  81340. isEqual(other: MaterialDefines): boolean;
  81341. /**
  81342. * Clones this instance's defines to another instance
  81343. * @param other - material defines to clone values to
  81344. */
  81345. cloneTo(other: MaterialDefines): void;
  81346. /**
  81347. * Resets the material define values
  81348. */
  81349. reset(): void;
  81350. /**
  81351. * Converts the material define values to a string
  81352. * @returns - String of material define information
  81353. */
  81354. toString(): string;
  81355. }
  81356. }
  81357. declare module BABYLON {
  81358. /**
  81359. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81360. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81361. * 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;
  81362. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81363. */
  81364. export class ColorCurves {
  81365. private _dirty;
  81366. private _tempColor;
  81367. private _globalCurve;
  81368. private _highlightsCurve;
  81369. private _midtonesCurve;
  81370. private _shadowsCurve;
  81371. private _positiveCurve;
  81372. private _negativeCurve;
  81373. private _globalHue;
  81374. private _globalDensity;
  81375. private _globalSaturation;
  81376. private _globalExposure;
  81377. /**
  81378. * Gets the global Hue value.
  81379. * 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).
  81380. */
  81381. get globalHue(): number;
  81382. /**
  81383. * Sets the global Hue value.
  81384. * 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).
  81385. */
  81386. set globalHue(value: number);
  81387. /**
  81388. * Gets the global Density value.
  81389. * 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.
  81390. * Values less than zero provide a filter of opposite hue.
  81391. */
  81392. get globalDensity(): number;
  81393. /**
  81394. * Sets the global Density value.
  81395. * 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.
  81396. * Values less than zero provide a filter of opposite hue.
  81397. */
  81398. set globalDensity(value: number);
  81399. /**
  81400. * Gets the global Saturation value.
  81401. * 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.
  81402. */
  81403. get globalSaturation(): number;
  81404. /**
  81405. * Sets the global Saturation value.
  81406. * 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.
  81407. */
  81408. set globalSaturation(value: number);
  81409. /**
  81410. * Gets the global Exposure value.
  81411. * 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.
  81412. */
  81413. get globalExposure(): number;
  81414. /**
  81415. * Sets the global Exposure value.
  81416. * 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.
  81417. */
  81418. set globalExposure(value: number);
  81419. private _highlightsHue;
  81420. private _highlightsDensity;
  81421. private _highlightsSaturation;
  81422. private _highlightsExposure;
  81423. /**
  81424. * Gets the highlights Hue value.
  81425. * 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).
  81426. */
  81427. get highlightsHue(): number;
  81428. /**
  81429. * Sets the highlights Hue value.
  81430. * 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).
  81431. */
  81432. set highlightsHue(value: number);
  81433. /**
  81434. * Gets the highlights Density value.
  81435. * 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.
  81436. * Values less than zero provide a filter of opposite hue.
  81437. */
  81438. get highlightsDensity(): number;
  81439. /**
  81440. * Sets the highlights Density value.
  81441. * 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.
  81442. * Values less than zero provide a filter of opposite hue.
  81443. */
  81444. set highlightsDensity(value: number);
  81445. /**
  81446. * Gets the highlights Saturation value.
  81447. * 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.
  81448. */
  81449. get highlightsSaturation(): number;
  81450. /**
  81451. * Sets the highlights Saturation value.
  81452. * 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.
  81453. */
  81454. set highlightsSaturation(value: number);
  81455. /**
  81456. * Gets the highlights Exposure value.
  81457. * 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.
  81458. */
  81459. get highlightsExposure(): number;
  81460. /**
  81461. * Sets the highlights Exposure value.
  81462. * 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.
  81463. */
  81464. set highlightsExposure(value: number);
  81465. private _midtonesHue;
  81466. private _midtonesDensity;
  81467. private _midtonesSaturation;
  81468. private _midtonesExposure;
  81469. /**
  81470. * Gets the midtones Hue value.
  81471. * 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).
  81472. */
  81473. get midtonesHue(): number;
  81474. /**
  81475. * Sets the midtones Hue value.
  81476. * 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).
  81477. */
  81478. set midtonesHue(value: number);
  81479. /**
  81480. * Gets the midtones Density value.
  81481. * 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.
  81482. * Values less than zero provide a filter of opposite hue.
  81483. */
  81484. get midtonesDensity(): number;
  81485. /**
  81486. * Sets the midtones Density value.
  81487. * 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.
  81488. * Values less than zero provide a filter of opposite hue.
  81489. */
  81490. set midtonesDensity(value: number);
  81491. /**
  81492. * Gets the midtones Saturation value.
  81493. * 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.
  81494. */
  81495. get midtonesSaturation(): number;
  81496. /**
  81497. * Sets the midtones Saturation value.
  81498. * 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.
  81499. */
  81500. set midtonesSaturation(value: number);
  81501. /**
  81502. * Gets the midtones Exposure value.
  81503. * 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.
  81504. */
  81505. get midtonesExposure(): number;
  81506. /**
  81507. * Sets the midtones Exposure value.
  81508. * 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.
  81509. */
  81510. set midtonesExposure(value: number);
  81511. private _shadowsHue;
  81512. private _shadowsDensity;
  81513. private _shadowsSaturation;
  81514. private _shadowsExposure;
  81515. /**
  81516. * Gets the shadows Hue value.
  81517. * 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).
  81518. */
  81519. get shadowsHue(): number;
  81520. /**
  81521. * Sets the shadows Hue value.
  81522. * 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).
  81523. */
  81524. set shadowsHue(value: number);
  81525. /**
  81526. * Gets the shadows Density value.
  81527. * 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.
  81528. * Values less than zero provide a filter of opposite hue.
  81529. */
  81530. get shadowsDensity(): number;
  81531. /**
  81532. * Sets the shadows Density value.
  81533. * 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.
  81534. * Values less than zero provide a filter of opposite hue.
  81535. */
  81536. set shadowsDensity(value: number);
  81537. /**
  81538. * Gets the shadows Saturation value.
  81539. * 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.
  81540. */
  81541. get shadowsSaturation(): number;
  81542. /**
  81543. * Sets the shadows Saturation value.
  81544. * 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.
  81545. */
  81546. set shadowsSaturation(value: number);
  81547. /**
  81548. * Gets the shadows Exposure value.
  81549. * 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.
  81550. */
  81551. get shadowsExposure(): number;
  81552. /**
  81553. * Sets the shadows Exposure value.
  81554. * 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.
  81555. */
  81556. set shadowsExposure(value: number);
  81557. /**
  81558. * Returns the class name
  81559. * @returns The class name
  81560. */
  81561. getClassName(): string;
  81562. /**
  81563. * Binds the color curves to the shader.
  81564. * @param colorCurves The color curve to bind
  81565. * @param effect The effect to bind to
  81566. * @param positiveUniform The positive uniform shader parameter
  81567. * @param neutralUniform The neutral uniform shader parameter
  81568. * @param negativeUniform The negative uniform shader parameter
  81569. */
  81570. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81571. /**
  81572. * Prepare the list of uniforms associated with the ColorCurves effects.
  81573. * @param uniformsList The list of uniforms used in the effect
  81574. */
  81575. static PrepareUniforms(uniformsList: string[]): void;
  81576. /**
  81577. * Returns color grading data based on a hue, density, saturation and exposure value.
  81578. * @param filterHue The hue of the color filter.
  81579. * @param filterDensity The density of the color filter.
  81580. * @param saturation The saturation.
  81581. * @param exposure The exposure.
  81582. * @param result The result data container.
  81583. */
  81584. private getColorGradingDataToRef;
  81585. /**
  81586. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81587. * @param value The input slider value in range [-100,100].
  81588. * @returns Adjusted value.
  81589. */
  81590. private static applyColorGradingSliderNonlinear;
  81591. /**
  81592. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81593. * @param hue The hue (H) input.
  81594. * @param saturation The saturation (S) input.
  81595. * @param brightness The brightness (B) input.
  81596. * @result An RGBA color represented as Vector4.
  81597. */
  81598. private static fromHSBToRef;
  81599. /**
  81600. * Returns a value clamped between min and max
  81601. * @param value The value to clamp
  81602. * @param min The minimum of value
  81603. * @param max The maximum of value
  81604. * @returns The clamped value.
  81605. */
  81606. private static clamp;
  81607. /**
  81608. * Clones the current color curve instance.
  81609. * @return The cloned curves
  81610. */
  81611. clone(): ColorCurves;
  81612. /**
  81613. * Serializes the current color curve instance to a json representation.
  81614. * @return a JSON representation
  81615. */
  81616. serialize(): any;
  81617. /**
  81618. * Parses the color curve from a json representation.
  81619. * @param source the JSON source to parse
  81620. * @return The parsed curves
  81621. */
  81622. static Parse(source: any): ColorCurves;
  81623. }
  81624. }
  81625. declare module BABYLON {
  81626. /**
  81627. * Interface to follow in your material defines to integrate easily the
  81628. * Image proccessing functions.
  81629. * @hidden
  81630. */
  81631. export interface IImageProcessingConfigurationDefines {
  81632. IMAGEPROCESSING: boolean;
  81633. VIGNETTE: boolean;
  81634. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81635. VIGNETTEBLENDMODEOPAQUE: boolean;
  81636. TONEMAPPING: boolean;
  81637. TONEMAPPING_ACES: boolean;
  81638. CONTRAST: boolean;
  81639. EXPOSURE: boolean;
  81640. COLORCURVES: boolean;
  81641. COLORGRADING: boolean;
  81642. COLORGRADING3D: boolean;
  81643. SAMPLER3DGREENDEPTH: boolean;
  81644. SAMPLER3DBGRMAP: boolean;
  81645. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81646. }
  81647. /**
  81648. * @hidden
  81649. */
  81650. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81651. IMAGEPROCESSING: boolean;
  81652. VIGNETTE: boolean;
  81653. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81654. VIGNETTEBLENDMODEOPAQUE: boolean;
  81655. TONEMAPPING: boolean;
  81656. TONEMAPPING_ACES: boolean;
  81657. CONTRAST: boolean;
  81658. COLORCURVES: boolean;
  81659. COLORGRADING: boolean;
  81660. COLORGRADING3D: boolean;
  81661. SAMPLER3DGREENDEPTH: boolean;
  81662. SAMPLER3DBGRMAP: boolean;
  81663. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81664. EXPOSURE: boolean;
  81665. constructor();
  81666. }
  81667. /**
  81668. * This groups together the common properties used for image processing either in direct forward pass
  81669. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81670. * or not.
  81671. */
  81672. export class ImageProcessingConfiguration {
  81673. /**
  81674. * Default tone mapping applied in BabylonJS.
  81675. */
  81676. static readonly TONEMAPPING_STANDARD: number;
  81677. /**
  81678. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81679. * to other engines rendering to increase portability.
  81680. */
  81681. static readonly TONEMAPPING_ACES: number;
  81682. /**
  81683. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81684. */
  81685. colorCurves: Nullable<ColorCurves>;
  81686. private _colorCurvesEnabled;
  81687. /**
  81688. * Gets wether the color curves effect is enabled.
  81689. */
  81690. get colorCurvesEnabled(): boolean;
  81691. /**
  81692. * Sets wether the color curves effect is enabled.
  81693. */
  81694. set colorCurvesEnabled(value: boolean);
  81695. private _colorGradingTexture;
  81696. /**
  81697. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81698. */
  81699. get colorGradingTexture(): Nullable<BaseTexture>;
  81700. /**
  81701. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81702. */
  81703. set colorGradingTexture(value: Nullable<BaseTexture>);
  81704. private _colorGradingEnabled;
  81705. /**
  81706. * Gets wether the color grading effect is enabled.
  81707. */
  81708. get colorGradingEnabled(): boolean;
  81709. /**
  81710. * Sets wether the color grading effect is enabled.
  81711. */
  81712. set colorGradingEnabled(value: boolean);
  81713. private _colorGradingWithGreenDepth;
  81714. /**
  81715. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81716. */
  81717. get colorGradingWithGreenDepth(): boolean;
  81718. /**
  81719. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81720. */
  81721. set colorGradingWithGreenDepth(value: boolean);
  81722. private _colorGradingBGR;
  81723. /**
  81724. * Gets wether the color grading texture contains BGR values.
  81725. */
  81726. get colorGradingBGR(): boolean;
  81727. /**
  81728. * Sets wether the color grading texture contains BGR values.
  81729. */
  81730. set colorGradingBGR(value: boolean);
  81731. /** @hidden */
  81732. _exposure: number;
  81733. /**
  81734. * Gets the Exposure used in the effect.
  81735. */
  81736. get exposure(): number;
  81737. /**
  81738. * Sets the Exposure used in the effect.
  81739. */
  81740. set exposure(value: number);
  81741. private _toneMappingEnabled;
  81742. /**
  81743. * Gets wether the tone mapping effect is enabled.
  81744. */
  81745. get toneMappingEnabled(): boolean;
  81746. /**
  81747. * Sets wether the tone mapping effect is enabled.
  81748. */
  81749. set toneMappingEnabled(value: boolean);
  81750. private _toneMappingType;
  81751. /**
  81752. * Gets the type of tone mapping effect.
  81753. */
  81754. get toneMappingType(): number;
  81755. /**
  81756. * Sets the type of tone mapping effect used in BabylonJS.
  81757. */
  81758. set toneMappingType(value: number);
  81759. protected _contrast: number;
  81760. /**
  81761. * Gets the contrast used in the effect.
  81762. */
  81763. get contrast(): number;
  81764. /**
  81765. * Sets the contrast used in the effect.
  81766. */
  81767. set contrast(value: number);
  81768. /**
  81769. * Vignette stretch size.
  81770. */
  81771. vignetteStretch: number;
  81772. /**
  81773. * Vignette centre X Offset.
  81774. */
  81775. vignetteCentreX: number;
  81776. /**
  81777. * Vignette centre Y Offset.
  81778. */
  81779. vignetteCentreY: number;
  81780. /**
  81781. * Vignette weight or intensity of the vignette effect.
  81782. */
  81783. vignetteWeight: number;
  81784. /**
  81785. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81786. * if vignetteEnabled is set to true.
  81787. */
  81788. vignetteColor: Color4;
  81789. /**
  81790. * Camera field of view used by the Vignette effect.
  81791. */
  81792. vignetteCameraFov: number;
  81793. private _vignetteBlendMode;
  81794. /**
  81795. * Gets the vignette blend mode allowing different kind of effect.
  81796. */
  81797. get vignetteBlendMode(): number;
  81798. /**
  81799. * Sets the vignette blend mode allowing different kind of effect.
  81800. */
  81801. set vignetteBlendMode(value: number);
  81802. private _vignetteEnabled;
  81803. /**
  81804. * Gets wether the vignette effect is enabled.
  81805. */
  81806. get vignetteEnabled(): boolean;
  81807. /**
  81808. * Sets wether the vignette effect is enabled.
  81809. */
  81810. set vignetteEnabled(value: boolean);
  81811. private _applyByPostProcess;
  81812. /**
  81813. * Gets wether the image processing is applied through a post process or not.
  81814. */
  81815. get applyByPostProcess(): boolean;
  81816. /**
  81817. * Sets wether the image processing is applied through a post process or not.
  81818. */
  81819. set applyByPostProcess(value: boolean);
  81820. private _isEnabled;
  81821. /**
  81822. * Gets wether the image processing is enabled or not.
  81823. */
  81824. get isEnabled(): boolean;
  81825. /**
  81826. * Sets wether the image processing is enabled or not.
  81827. */
  81828. set isEnabled(value: boolean);
  81829. /**
  81830. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81831. */
  81832. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81833. /**
  81834. * Method called each time the image processing information changes requires to recompile the effect.
  81835. */
  81836. protected _updateParameters(): void;
  81837. /**
  81838. * Gets the current class name.
  81839. * @return "ImageProcessingConfiguration"
  81840. */
  81841. getClassName(): string;
  81842. /**
  81843. * Prepare the list of uniforms associated with the Image Processing effects.
  81844. * @param uniforms The list of uniforms used in the effect
  81845. * @param defines the list of defines currently in use
  81846. */
  81847. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81848. /**
  81849. * Prepare the list of samplers associated with the Image Processing effects.
  81850. * @param samplersList The list of uniforms used in the effect
  81851. * @param defines the list of defines currently in use
  81852. */
  81853. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81854. /**
  81855. * Prepare the list of defines associated to the shader.
  81856. * @param defines the list of defines to complete
  81857. * @param forPostProcess Define if we are currently in post process mode or not
  81858. */
  81859. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81860. /**
  81861. * Returns true if all the image processing information are ready.
  81862. * @returns True if ready, otherwise, false
  81863. */
  81864. isReady(): boolean;
  81865. /**
  81866. * Binds the image processing to the shader.
  81867. * @param effect The effect to bind to
  81868. * @param overrideAspectRatio Override the aspect ratio of the effect
  81869. */
  81870. bind(effect: Effect, overrideAspectRatio?: number): void;
  81871. /**
  81872. * Clones the current image processing instance.
  81873. * @return The cloned image processing
  81874. */
  81875. clone(): ImageProcessingConfiguration;
  81876. /**
  81877. * Serializes the current image processing instance to a json representation.
  81878. * @return a JSON representation
  81879. */
  81880. serialize(): any;
  81881. /**
  81882. * Parses the image processing from a json representation.
  81883. * @param source the JSON source to parse
  81884. * @return The parsed image processing
  81885. */
  81886. static Parse(source: any): ImageProcessingConfiguration;
  81887. private static _VIGNETTEMODE_MULTIPLY;
  81888. private static _VIGNETTEMODE_OPAQUE;
  81889. /**
  81890. * Used to apply the vignette as a mix with the pixel color.
  81891. */
  81892. static get VIGNETTEMODE_MULTIPLY(): number;
  81893. /**
  81894. * Used to apply the vignette as a replacement of the pixel color.
  81895. */
  81896. static get VIGNETTEMODE_OPAQUE(): number;
  81897. }
  81898. }
  81899. declare module BABYLON {
  81900. /** @hidden */
  81901. export var postprocessVertexShader: {
  81902. name: string;
  81903. shader: string;
  81904. };
  81905. }
  81906. declare module BABYLON {
  81907. interface ThinEngine {
  81908. /**
  81909. * Creates a new render target texture
  81910. * @param size defines the size of the texture
  81911. * @param options defines the options used to create the texture
  81912. * @returns a new render target texture stored in an InternalTexture
  81913. */
  81914. createRenderTargetTexture(size: number | {
  81915. width: number;
  81916. height: number;
  81917. layers?: number;
  81918. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81919. /**
  81920. * Creates a depth stencil texture.
  81921. * This is only available in WebGL 2 or with the depth texture extension available.
  81922. * @param size The size of face edge in the texture.
  81923. * @param options The options defining the texture.
  81924. * @returns The texture
  81925. */
  81926. createDepthStencilTexture(size: number | {
  81927. width: number;
  81928. height: number;
  81929. layers?: number;
  81930. }, options: DepthTextureCreationOptions): InternalTexture;
  81931. /** @hidden */
  81932. _createDepthStencilTexture(size: number | {
  81933. width: number;
  81934. height: number;
  81935. layers?: number;
  81936. }, options: DepthTextureCreationOptions): InternalTexture;
  81937. }
  81938. }
  81939. declare module BABYLON {
  81940. /** Defines supported spaces */
  81941. export enum Space {
  81942. /** Local (object) space */
  81943. LOCAL = 0,
  81944. /** World space */
  81945. WORLD = 1,
  81946. /** Bone space */
  81947. BONE = 2
  81948. }
  81949. /** Defines the 3 main axes */
  81950. export class Axis {
  81951. /** X axis */
  81952. static X: Vector3;
  81953. /** Y axis */
  81954. static Y: Vector3;
  81955. /** Z axis */
  81956. static Z: Vector3;
  81957. }
  81958. }
  81959. declare module BABYLON {
  81960. /**
  81961. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81962. * This is the base of the follow, arc rotate cameras and Free camera
  81963. * @see http://doc.babylonjs.com/features/cameras
  81964. */
  81965. export class TargetCamera extends Camera {
  81966. private static _RigCamTransformMatrix;
  81967. private static _TargetTransformMatrix;
  81968. private static _TargetFocalPoint;
  81969. /**
  81970. * Define the current direction the camera is moving to
  81971. */
  81972. cameraDirection: Vector3;
  81973. /**
  81974. * Define the current rotation the camera is rotating to
  81975. */
  81976. cameraRotation: Vector2;
  81977. /**
  81978. * When set, the up vector of the camera will be updated by the rotation of the camera
  81979. */
  81980. updateUpVectorFromRotation: boolean;
  81981. private _tmpQuaternion;
  81982. /**
  81983. * Define the current rotation of the camera
  81984. */
  81985. rotation: Vector3;
  81986. /**
  81987. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81988. */
  81989. rotationQuaternion: Quaternion;
  81990. /**
  81991. * Define the current speed of the camera
  81992. */
  81993. speed: number;
  81994. /**
  81995. * Add constraint to the camera to prevent it to move freely in all directions and
  81996. * around all axis.
  81997. */
  81998. noRotationConstraint: boolean;
  81999. /**
  82000. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  82001. * panning
  82002. */
  82003. invertRotation: boolean;
  82004. /**
  82005. * Speed multiplier for inverse camera panning
  82006. */
  82007. inverseRotationSpeed: number;
  82008. /**
  82009. * Define the current target of the camera as an object or a position.
  82010. */
  82011. lockedTarget: any;
  82012. /** @hidden */
  82013. _currentTarget: Vector3;
  82014. /** @hidden */
  82015. _initialFocalDistance: number;
  82016. /** @hidden */
  82017. _viewMatrix: Matrix;
  82018. /** @hidden */
  82019. _camMatrix: Matrix;
  82020. /** @hidden */
  82021. _cameraTransformMatrix: Matrix;
  82022. /** @hidden */
  82023. _cameraRotationMatrix: Matrix;
  82024. /** @hidden */
  82025. _referencePoint: Vector3;
  82026. /** @hidden */
  82027. _transformedReferencePoint: Vector3;
  82028. protected _globalCurrentTarget: Vector3;
  82029. protected _globalCurrentUpVector: Vector3;
  82030. /** @hidden */
  82031. _reset: () => void;
  82032. private _defaultUp;
  82033. /**
  82034. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  82035. * This is the base of the follow, arc rotate cameras and Free camera
  82036. * @see http://doc.babylonjs.com/features/cameras
  82037. * @param name Defines the name of the camera in the scene
  82038. * @param position Defines the start position of the camera in the scene
  82039. * @param scene Defines the scene the camera belongs to
  82040. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82041. */
  82042. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82043. /**
  82044. * Gets the position in front of the camera at a given distance.
  82045. * @param distance The distance from the camera we want the position to be
  82046. * @returns the position
  82047. */
  82048. getFrontPosition(distance: number): Vector3;
  82049. /** @hidden */
  82050. _getLockedTargetPosition(): Nullable<Vector3>;
  82051. private _storedPosition;
  82052. private _storedRotation;
  82053. private _storedRotationQuaternion;
  82054. /**
  82055. * Store current camera state of the camera (fov, position, rotation, etc..)
  82056. * @returns the camera
  82057. */
  82058. storeState(): Camera;
  82059. /**
  82060. * Restored camera state. You must call storeState() first
  82061. * @returns whether it was successful or not
  82062. * @hidden
  82063. */
  82064. _restoreStateValues(): boolean;
  82065. /** @hidden */
  82066. _initCache(): void;
  82067. /** @hidden */
  82068. _updateCache(ignoreParentClass?: boolean): void;
  82069. /** @hidden */
  82070. _isSynchronizedViewMatrix(): boolean;
  82071. /** @hidden */
  82072. _computeLocalCameraSpeed(): number;
  82073. /**
  82074. * Defines the target the camera should look at.
  82075. * @param target Defines the new target as a Vector or a mesh
  82076. */
  82077. setTarget(target: Vector3): void;
  82078. /**
  82079. * Return the current target position of the camera. This value is expressed in local space.
  82080. * @returns the target position
  82081. */
  82082. getTarget(): Vector3;
  82083. /** @hidden */
  82084. _decideIfNeedsToMove(): boolean;
  82085. /** @hidden */
  82086. _updatePosition(): void;
  82087. /** @hidden */
  82088. _checkInputs(): void;
  82089. protected _updateCameraRotationMatrix(): void;
  82090. /**
  82091. * 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)
  82092. * @returns the current camera
  82093. */
  82094. private _rotateUpVectorWithCameraRotationMatrix;
  82095. private _cachedRotationZ;
  82096. private _cachedQuaternionRotationZ;
  82097. /** @hidden */
  82098. _getViewMatrix(): Matrix;
  82099. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  82100. /**
  82101. * @hidden
  82102. */
  82103. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  82104. /**
  82105. * @hidden
  82106. */
  82107. _updateRigCameras(): void;
  82108. private _getRigCamPositionAndTarget;
  82109. /**
  82110. * Gets the current object class name.
  82111. * @return the class name
  82112. */
  82113. getClassName(): string;
  82114. }
  82115. }
  82116. declare module BABYLON {
  82117. /**
  82118. * Gather the list of keyboard event types as constants.
  82119. */
  82120. export class KeyboardEventTypes {
  82121. /**
  82122. * The keydown event is fired when a key becomes active (pressed).
  82123. */
  82124. static readonly KEYDOWN: number;
  82125. /**
  82126. * The keyup event is fired when a key has been released.
  82127. */
  82128. static readonly KEYUP: number;
  82129. }
  82130. /**
  82131. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82132. */
  82133. export class KeyboardInfo {
  82134. /**
  82135. * Defines the type of event (KeyboardEventTypes)
  82136. */
  82137. type: number;
  82138. /**
  82139. * Defines the related dom event
  82140. */
  82141. event: KeyboardEvent;
  82142. /**
  82143. * Instantiates a new keyboard info.
  82144. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82145. * @param type Defines the type of event (KeyboardEventTypes)
  82146. * @param event Defines the related dom event
  82147. */
  82148. constructor(
  82149. /**
  82150. * Defines the type of event (KeyboardEventTypes)
  82151. */
  82152. type: number,
  82153. /**
  82154. * Defines the related dom event
  82155. */
  82156. event: KeyboardEvent);
  82157. }
  82158. /**
  82159. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82160. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  82161. */
  82162. export class KeyboardInfoPre extends KeyboardInfo {
  82163. /**
  82164. * Defines the type of event (KeyboardEventTypes)
  82165. */
  82166. type: number;
  82167. /**
  82168. * Defines the related dom event
  82169. */
  82170. event: KeyboardEvent;
  82171. /**
  82172. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  82173. */
  82174. skipOnPointerObservable: boolean;
  82175. /**
  82176. * Instantiates a new keyboard pre info.
  82177. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82178. * @param type Defines the type of event (KeyboardEventTypes)
  82179. * @param event Defines the related dom event
  82180. */
  82181. constructor(
  82182. /**
  82183. * Defines the type of event (KeyboardEventTypes)
  82184. */
  82185. type: number,
  82186. /**
  82187. * Defines the related dom event
  82188. */
  82189. event: KeyboardEvent);
  82190. }
  82191. }
  82192. declare module BABYLON {
  82193. /**
  82194. * Manage the keyboard inputs to control the movement of a free camera.
  82195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82196. */
  82197. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  82198. /**
  82199. * Defines the camera the input is attached to.
  82200. */
  82201. camera: FreeCamera;
  82202. /**
  82203. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82204. */
  82205. keysUp: number[];
  82206. /**
  82207. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82208. */
  82209. keysDown: number[];
  82210. /**
  82211. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82212. */
  82213. keysLeft: number[];
  82214. /**
  82215. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82216. */
  82217. keysRight: number[];
  82218. private _keys;
  82219. private _onCanvasBlurObserver;
  82220. private _onKeyboardObserver;
  82221. private _engine;
  82222. private _scene;
  82223. /**
  82224. * Attach the input controls to a specific dom element to get the input from.
  82225. * @param element Defines the element the controls should be listened from
  82226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82227. */
  82228. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82229. /**
  82230. * Detach the current controls from the specified dom element.
  82231. * @param element Defines the element to stop listening the inputs from
  82232. */
  82233. detachControl(element: Nullable<HTMLElement>): void;
  82234. /**
  82235. * Update the current camera state depending on the inputs that have been used this frame.
  82236. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82237. */
  82238. checkInputs(): void;
  82239. /**
  82240. * Gets the class name of the current intput.
  82241. * @returns the class name
  82242. */
  82243. getClassName(): string;
  82244. /** @hidden */
  82245. _onLostFocus(): void;
  82246. /**
  82247. * Get the friendly name associated with the input class.
  82248. * @returns the input friendly name
  82249. */
  82250. getSimpleName(): string;
  82251. }
  82252. }
  82253. declare module BABYLON {
  82254. /**
  82255. * Interface describing all the common properties and methods a shadow light needs to implement.
  82256. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82257. * as well as binding the different shadow properties to the effects.
  82258. */
  82259. export interface IShadowLight extends Light {
  82260. /**
  82261. * The light id in the scene (used in scene.findLighById for instance)
  82262. */
  82263. id: string;
  82264. /**
  82265. * The position the shdow will be casted from.
  82266. */
  82267. position: Vector3;
  82268. /**
  82269. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82270. */
  82271. direction: Vector3;
  82272. /**
  82273. * The transformed position. Position of the light in world space taking parenting in account.
  82274. */
  82275. transformedPosition: Vector3;
  82276. /**
  82277. * The transformed direction. Direction of the light in world space taking parenting in account.
  82278. */
  82279. transformedDirection: Vector3;
  82280. /**
  82281. * The friendly name of the light in the scene.
  82282. */
  82283. name: string;
  82284. /**
  82285. * Defines the shadow projection clipping minimum z value.
  82286. */
  82287. shadowMinZ: number;
  82288. /**
  82289. * Defines the shadow projection clipping maximum z value.
  82290. */
  82291. shadowMaxZ: number;
  82292. /**
  82293. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82294. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82295. */
  82296. computeTransformedInformation(): boolean;
  82297. /**
  82298. * Gets the scene the light belongs to.
  82299. * @returns The scene
  82300. */
  82301. getScene(): Scene;
  82302. /**
  82303. * Callback defining a custom Projection Matrix Builder.
  82304. * This can be used to override the default projection matrix computation.
  82305. */
  82306. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82307. /**
  82308. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82309. * @param matrix The materix to updated with the projection information
  82310. * @param viewMatrix The transform matrix of the light
  82311. * @param renderList The list of mesh to render in the map
  82312. * @returns The current light
  82313. */
  82314. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82315. /**
  82316. * Gets the current depth scale used in ESM.
  82317. * @returns The scale
  82318. */
  82319. getDepthScale(): number;
  82320. /**
  82321. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82322. * @returns true if a cube texture needs to be use
  82323. */
  82324. needCube(): boolean;
  82325. /**
  82326. * Detects if the projection matrix requires to be recomputed this frame.
  82327. * @returns true if it requires to be recomputed otherwise, false.
  82328. */
  82329. needProjectionMatrixCompute(): boolean;
  82330. /**
  82331. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82332. */
  82333. forceProjectionMatrixCompute(): void;
  82334. /**
  82335. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82336. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82337. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82338. */
  82339. getShadowDirection(faceIndex?: number): Vector3;
  82340. /**
  82341. * Gets the minZ used for shadow according to both the scene and the light.
  82342. * @param activeCamera The camera we are returning the min for
  82343. * @returns the depth min z
  82344. */
  82345. getDepthMinZ(activeCamera: Camera): number;
  82346. /**
  82347. * Gets the maxZ used for shadow according to both the scene and the light.
  82348. * @param activeCamera The camera we are returning the max for
  82349. * @returns the depth max z
  82350. */
  82351. getDepthMaxZ(activeCamera: Camera): number;
  82352. }
  82353. /**
  82354. * Base implementation IShadowLight
  82355. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82356. */
  82357. export abstract class ShadowLight extends Light implements IShadowLight {
  82358. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82359. protected _position: Vector3;
  82360. protected _setPosition(value: Vector3): void;
  82361. /**
  82362. * Sets the position the shadow will be casted from. Also use as the light position for both
  82363. * point and spot lights.
  82364. */
  82365. get position(): Vector3;
  82366. /**
  82367. * Sets the position the shadow will be casted from. Also use as the light position for both
  82368. * point and spot lights.
  82369. */
  82370. set position(value: Vector3);
  82371. protected _direction: Vector3;
  82372. protected _setDirection(value: Vector3): void;
  82373. /**
  82374. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82375. * Also use as the light direction on spot and directional lights.
  82376. */
  82377. get direction(): Vector3;
  82378. /**
  82379. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82380. * Also use as the light direction on spot and directional lights.
  82381. */
  82382. set direction(value: Vector3);
  82383. protected _shadowMinZ: number;
  82384. /**
  82385. * Gets the shadow projection clipping minimum z value.
  82386. */
  82387. get shadowMinZ(): number;
  82388. /**
  82389. * Sets the shadow projection clipping minimum z value.
  82390. */
  82391. set shadowMinZ(value: number);
  82392. protected _shadowMaxZ: number;
  82393. /**
  82394. * Sets the shadow projection clipping maximum z value.
  82395. */
  82396. get shadowMaxZ(): number;
  82397. /**
  82398. * Gets the shadow projection clipping maximum z value.
  82399. */
  82400. set shadowMaxZ(value: number);
  82401. /**
  82402. * Callback defining a custom Projection Matrix Builder.
  82403. * This can be used to override the default projection matrix computation.
  82404. */
  82405. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82406. /**
  82407. * The transformed position. Position of the light in world space taking parenting in account.
  82408. */
  82409. transformedPosition: Vector3;
  82410. /**
  82411. * The transformed direction. Direction of the light in world space taking parenting in account.
  82412. */
  82413. transformedDirection: Vector3;
  82414. private _needProjectionMatrixCompute;
  82415. /**
  82416. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82417. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82418. */
  82419. computeTransformedInformation(): boolean;
  82420. /**
  82421. * Return the depth scale used for the shadow map.
  82422. * @returns the depth scale.
  82423. */
  82424. getDepthScale(): number;
  82425. /**
  82426. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82427. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82428. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82429. */
  82430. getShadowDirection(faceIndex?: number): Vector3;
  82431. /**
  82432. * Returns the ShadowLight absolute position in the World.
  82433. * @returns the position vector in world space
  82434. */
  82435. getAbsolutePosition(): Vector3;
  82436. /**
  82437. * Sets the ShadowLight direction toward the passed target.
  82438. * @param target The point to target in local space
  82439. * @returns the updated ShadowLight direction
  82440. */
  82441. setDirectionToTarget(target: Vector3): Vector3;
  82442. /**
  82443. * Returns the light rotation in euler definition.
  82444. * @returns the x y z rotation in local space.
  82445. */
  82446. getRotation(): Vector3;
  82447. /**
  82448. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82449. * @returns true if a cube texture needs to be use
  82450. */
  82451. needCube(): boolean;
  82452. /**
  82453. * Detects if the projection matrix requires to be recomputed this frame.
  82454. * @returns true if it requires to be recomputed otherwise, false.
  82455. */
  82456. needProjectionMatrixCompute(): boolean;
  82457. /**
  82458. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82459. */
  82460. forceProjectionMatrixCompute(): void;
  82461. /** @hidden */
  82462. _initCache(): void;
  82463. /** @hidden */
  82464. _isSynchronized(): boolean;
  82465. /**
  82466. * Computes the world matrix of the node
  82467. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82468. * @returns the world matrix
  82469. */
  82470. computeWorldMatrix(force?: boolean): Matrix;
  82471. /**
  82472. * Gets the minZ used for shadow according to both the scene and the light.
  82473. * @param activeCamera The camera we are returning the min for
  82474. * @returns the depth min z
  82475. */
  82476. getDepthMinZ(activeCamera: Camera): number;
  82477. /**
  82478. * Gets the maxZ used for shadow according to both the scene and the light.
  82479. * @param activeCamera The camera we are returning the max for
  82480. * @returns the depth max z
  82481. */
  82482. getDepthMaxZ(activeCamera: Camera): number;
  82483. /**
  82484. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82485. * @param matrix The materix to updated with the projection information
  82486. * @param viewMatrix The transform matrix of the light
  82487. * @param renderList The list of mesh to render in the map
  82488. * @returns The current light
  82489. */
  82490. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82491. }
  82492. }
  82493. declare module BABYLON {
  82494. /**
  82495. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82496. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82497. */
  82498. export class EffectFallbacks implements IEffectFallbacks {
  82499. private _defines;
  82500. private _currentRank;
  82501. private _maxRank;
  82502. private _mesh;
  82503. /**
  82504. * Removes the fallback from the bound mesh.
  82505. */
  82506. unBindMesh(): void;
  82507. /**
  82508. * Adds a fallback on the specified property.
  82509. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82510. * @param define The name of the define in the shader
  82511. */
  82512. addFallback(rank: number, define: string): void;
  82513. /**
  82514. * Sets the mesh to use CPU skinning when needing to fallback.
  82515. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82516. * @param mesh The mesh to use the fallbacks.
  82517. */
  82518. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82519. /**
  82520. * Checks to see if more fallbacks are still availible.
  82521. */
  82522. get hasMoreFallbacks(): boolean;
  82523. /**
  82524. * Removes the defines that should be removed when falling back.
  82525. * @param currentDefines defines the current define statements for the shader.
  82526. * @param effect defines the current effect we try to compile
  82527. * @returns The resulting defines with defines of the current rank removed.
  82528. */
  82529. reduce(currentDefines: string, effect: Effect): string;
  82530. }
  82531. }
  82532. declare module BABYLON {
  82533. /**
  82534. * "Static Class" containing the most commonly used helper while dealing with material for
  82535. * rendering purpose.
  82536. *
  82537. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82538. *
  82539. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82540. */
  82541. export class MaterialHelper {
  82542. /**
  82543. * Bind the current view position to an effect.
  82544. * @param effect The effect to be bound
  82545. * @param scene The scene the eyes position is used from
  82546. */
  82547. static BindEyePosition(effect: Effect, scene: Scene): void;
  82548. /**
  82549. * Helps preparing the defines values about the UVs in used in the effect.
  82550. * UVs are shared as much as we can accross channels in the shaders.
  82551. * @param texture The texture we are preparing the UVs for
  82552. * @param defines The defines to update
  82553. * @param key The channel key "diffuse", "specular"... used in the shader
  82554. */
  82555. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82556. /**
  82557. * Binds a texture matrix value to its corrsponding uniform
  82558. * @param texture The texture to bind the matrix for
  82559. * @param uniformBuffer The uniform buffer receivin the data
  82560. * @param key The channel key "diffuse", "specular"... used in the shader
  82561. */
  82562. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82563. /**
  82564. * Gets the current status of the fog (should it be enabled?)
  82565. * @param mesh defines the mesh to evaluate for fog support
  82566. * @param scene defines the hosting scene
  82567. * @returns true if fog must be enabled
  82568. */
  82569. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82570. /**
  82571. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82572. * @param mesh defines the current mesh
  82573. * @param scene defines the current scene
  82574. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82575. * @param pointsCloud defines if point cloud rendering has to be turned on
  82576. * @param fogEnabled defines if fog has to be turned on
  82577. * @param alphaTest defines if alpha testing has to be turned on
  82578. * @param defines defines the current list of defines
  82579. */
  82580. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82581. /**
  82582. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82583. * @param scene defines the current scene
  82584. * @param engine defines the current engine
  82585. * @param defines specifies the list of active defines
  82586. * @param useInstances defines if instances have to be turned on
  82587. * @param useClipPlane defines if clip plane have to be turned on
  82588. */
  82589. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82590. /**
  82591. * Prepares the defines for bones
  82592. * @param mesh The mesh containing the geometry data we will draw
  82593. * @param defines The defines to update
  82594. */
  82595. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82596. /**
  82597. * Prepares the defines for morph targets
  82598. * @param mesh The mesh containing the geometry data we will draw
  82599. * @param defines The defines to update
  82600. */
  82601. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82602. /**
  82603. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82604. * @param mesh The mesh containing the geometry data we will draw
  82605. * @param defines The defines to update
  82606. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82607. * @param useBones Precise whether bones should be used or not (override mesh info)
  82608. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82609. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82610. * @returns false if defines are considered not dirty and have not been checked
  82611. */
  82612. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82613. /**
  82614. * Prepares the defines related to multiview
  82615. * @param scene The scene we are intending to draw
  82616. * @param defines The defines to update
  82617. */
  82618. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82619. /**
  82620. * Prepares the defines related to the light information passed in parameter
  82621. * @param scene The scene we are intending to draw
  82622. * @param mesh The mesh the effect is compiling for
  82623. * @param light The light the effect is compiling for
  82624. * @param lightIndex The index of the light
  82625. * @param defines The defines to update
  82626. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82627. * @param state Defines the current state regarding what is needed (normals, etc...)
  82628. */
  82629. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82630. needNormals: boolean;
  82631. needRebuild: boolean;
  82632. shadowEnabled: boolean;
  82633. specularEnabled: boolean;
  82634. lightmapMode: boolean;
  82635. }): void;
  82636. /**
  82637. * Prepares the defines related to the light information passed in parameter
  82638. * @param scene The scene we are intending to draw
  82639. * @param mesh The mesh the effect is compiling for
  82640. * @param defines The defines to update
  82641. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82642. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82643. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82644. * @returns true if normals will be required for the rest of the effect
  82645. */
  82646. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82647. /**
  82648. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82649. * @param lightIndex defines the light index
  82650. * @param uniformsList The uniform list
  82651. * @param samplersList The sampler list
  82652. * @param projectedLightTexture defines if projected texture must be used
  82653. * @param uniformBuffersList defines an optional list of uniform buffers
  82654. */
  82655. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82656. /**
  82657. * Prepares the uniforms and samplers list to be used in the effect
  82658. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82659. * @param samplersList The sampler list
  82660. * @param defines The defines helping in the list generation
  82661. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82662. */
  82663. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82664. /**
  82665. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82666. * @param defines The defines to update while falling back
  82667. * @param fallbacks The authorized effect fallbacks
  82668. * @param maxSimultaneousLights The maximum number of lights allowed
  82669. * @param rank the current rank of the Effect
  82670. * @returns The newly affected rank
  82671. */
  82672. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82673. private static _TmpMorphInfluencers;
  82674. /**
  82675. * Prepares the list of attributes required for morph targets according to the effect defines.
  82676. * @param attribs The current list of supported attribs
  82677. * @param mesh The mesh to prepare the morph targets attributes for
  82678. * @param influencers The number of influencers
  82679. */
  82680. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82681. /**
  82682. * Prepares the list of attributes required for morph targets according to the effect defines.
  82683. * @param attribs The current list of supported attribs
  82684. * @param mesh The mesh to prepare the morph targets attributes for
  82685. * @param defines The current Defines of the effect
  82686. */
  82687. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82688. /**
  82689. * Prepares the list of attributes required for bones according to the effect defines.
  82690. * @param attribs The current list of supported attribs
  82691. * @param mesh The mesh to prepare the bones attributes for
  82692. * @param defines The current Defines of the effect
  82693. * @param fallbacks The current efffect fallback strategy
  82694. */
  82695. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82696. /**
  82697. * Check and prepare the list of attributes required for instances according to the effect defines.
  82698. * @param attribs The current list of supported attribs
  82699. * @param defines The current MaterialDefines of the effect
  82700. */
  82701. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82702. /**
  82703. * Add the list of attributes required for instances to the attribs array.
  82704. * @param attribs The current list of supported attribs
  82705. */
  82706. static PushAttributesForInstances(attribs: string[]): void;
  82707. /**
  82708. * Binds the light information to the effect.
  82709. * @param light The light containing the generator
  82710. * @param effect The effect we are binding the data to
  82711. * @param lightIndex The light index in the effect used to render
  82712. */
  82713. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82714. /**
  82715. * Binds the lights information from the scene to the effect for the given mesh.
  82716. * @param light Light to bind
  82717. * @param lightIndex Light index
  82718. * @param scene The scene where the light belongs to
  82719. * @param effect The effect we are binding the data to
  82720. * @param useSpecular Defines if specular is supported
  82721. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82722. */
  82723. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82724. /**
  82725. * Binds the lights information from the scene to the effect for the given mesh.
  82726. * @param scene The scene the lights belongs to
  82727. * @param mesh The mesh we are binding the information to render
  82728. * @param effect The effect we are binding the data to
  82729. * @param defines The generated defines for the effect
  82730. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82731. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82732. */
  82733. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82734. private static _tempFogColor;
  82735. /**
  82736. * Binds the fog information from the scene to the effect for the given mesh.
  82737. * @param scene The scene the lights belongs to
  82738. * @param mesh The mesh we are binding the information to render
  82739. * @param effect The effect we are binding the data to
  82740. * @param linearSpace Defines if the fog effect is applied in linear space
  82741. */
  82742. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82743. /**
  82744. * Binds the bones information from the mesh to the effect.
  82745. * @param mesh The mesh we are binding the information to render
  82746. * @param effect The effect we are binding the data to
  82747. */
  82748. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82749. /**
  82750. * Binds the morph targets information from the mesh to the effect.
  82751. * @param abstractMesh The mesh we are binding the information to render
  82752. * @param effect The effect we are binding the data to
  82753. */
  82754. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82755. /**
  82756. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82757. * @param defines The generated defines used in the effect
  82758. * @param effect The effect we are binding the data to
  82759. * @param scene The scene we are willing to render with logarithmic scale for
  82760. */
  82761. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82762. /**
  82763. * Binds the clip plane information from the scene to the effect.
  82764. * @param scene The scene the clip plane information are extracted from
  82765. * @param effect The effect we are binding the data to
  82766. */
  82767. static BindClipPlane(effect: Effect, scene: Scene): void;
  82768. }
  82769. }
  82770. declare module BABYLON {
  82771. /** @hidden */
  82772. export var packingFunctions: {
  82773. name: string;
  82774. shader: string;
  82775. };
  82776. }
  82777. declare module BABYLON {
  82778. /** @hidden */
  82779. export var clipPlaneFragmentDeclaration: {
  82780. name: string;
  82781. shader: string;
  82782. };
  82783. }
  82784. declare module BABYLON {
  82785. /** @hidden */
  82786. export var clipPlaneFragment: {
  82787. name: string;
  82788. shader: string;
  82789. };
  82790. }
  82791. declare module BABYLON {
  82792. /** @hidden */
  82793. export var shadowMapPixelShader: {
  82794. name: string;
  82795. shader: string;
  82796. };
  82797. }
  82798. declare module BABYLON {
  82799. /** @hidden */
  82800. export var bonesDeclaration: {
  82801. name: string;
  82802. shader: string;
  82803. };
  82804. }
  82805. declare module BABYLON {
  82806. /** @hidden */
  82807. export var morphTargetsVertexGlobalDeclaration: {
  82808. name: string;
  82809. shader: string;
  82810. };
  82811. }
  82812. declare module BABYLON {
  82813. /** @hidden */
  82814. export var morphTargetsVertexDeclaration: {
  82815. name: string;
  82816. shader: string;
  82817. };
  82818. }
  82819. declare module BABYLON {
  82820. /** @hidden */
  82821. export var instancesDeclaration: {
  82822. name: string;
  82823. shader: string;
  82824. };
  82825. }
  82826. declare module BABYLON {
  82827. /** @hidden */
  82828. export var helperFunctions: {
  82829. name: string;
  82830. shader: string;
  82831. };
  82832. }
  82833. declare module BABYLON {
  82834. /** @hidden */
  82835. export var clipPlaneVertexDeclaration: {
  82836. name: string;
  82837. shader: string;
  82838. };
  82839. }
  82840. declare module BABYLON {
  82841. /** @hidden */
  82842. export var morphTargetsVertex: {
  82843. name: string;
  82844. shader: string;
  82845. };
  82846. }
  82847. declare module BABYLON {
  82848. /** @hidden */
  82849. export var instancesVertex: {
  82850. name: string;
  82851. shader: string;
  82852. };
  82853. }
  82854. declare module BABYLON {
  82855. /** @hidden */
  82856. export var bonesVertex: {
  82857. name: string;
  82858. shader: string;
  82859. };
  82860. }
  82861. declare module BABYLON {
  82862. /** @hidden */
  82863. export var clipPlaneVertex: {
  82864. name: string;
  82865. shader: string;
  82866. };
  82867. }
  82868. declare module BABYLON {
  82869. /** @hidden */
  82870. export var shadowMapVertexShader: {
  82871. name: string;
  82872. shader: string;
  82873. };
  82874. }
  82875. declare module BABYLON {
  82876. /** @hidden */
  82877. export var depthBoxBlurPixelShader: {
  82878. name: string;
  82879. shader: string;
  82880. };
  82881. }
  82882. declare module BABYLON {
  82883. /**
  82884. * Class representing a ray with position and direction
  82885. */
  82886. export class Ray {
  82887. /** origin point */
  82888. origin: Vector3;
  82889. /** direction */
  82890. direction: Vector3;
  82891. /** length of the ray */
  82892. length: number;
  82893. private static readonly TmpVector3;
  82894. private _tmpRay;
  82895. /**
  82896. * Creates a new ray
  82897. * @param origin origin point
  82898. * @param direction direction
  82899. * @param length length of the ray
  82900. */
  82901. constructor(
  82902. /** origin point */
  82903. origin: Vector3,
  82904. /** direction */
  82905. direction: Vector3,
  82906. /** length of the ray */
  82907. length?: number);
  82908. /**
  82909. * Checks if the ray intersects a box
  82910. * @param minimum bound of the box
  82911. * @param maximum bound of the box
  82912. * @param intersectionTreshold extra extend to be added to the box in all direction
  82913. * @returns if the box was hit
  82914. */
  82915. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82916. /**
  82917. * Checks if the ray intersects a box
  82918. * @param box the bounding box to check
  82919. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82920. * @returns if the box was hit
  82921. */
  82922. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82923. /**
  82924. * If the ray hits a sphere
  82925. * @param sphere the bounding sphere to check
  82926. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82927. * @returns true if it hits the sphere
  82928. */
  82929. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82930. /**
  82931. * If the ray hits a triange
  82932. * @param vertex0 triangle vertex
  82933. * @param vertex1 triangle vertex
  82934. * @param vertex2 triangle vertex
  82935. * @returns intersection information if hit
  82936. */
  82937. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82938. /**
  82939. * Checks if ray intersects a plane
  82940. * @param plane the plane to check
  82941. * @returns the distance away it was hit
  82942. */
  82943. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82944. /**
  82945. * Calculate the intercept of a ray on a given axis
  82946. * @param axis to check 'x' | 'y' | 'z'
  82947. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82948. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82949. */
  82950. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82951. /**
  82952. * Checks if ray intersects a mesh
  82953. * @param mesh the mesh to check
  82954. * @param fastCheck if only the bounding box should checked
  82955. * @returns picking info of the intersecton
  82956. */
  82957. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82958. /**
  82959. * Checks if ray intersects a mesh
  82960. * @param meshes the meshes to check
  82961. * @param fastCheck if only the bounding box should checked
  82962. * @param results array to store result in
  82963. * @returns Array of picking infos
  82964. */
  82965. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82966. private _comparePickingInfo;
  82967. private static smallnum;
  82968. private static rayl;
  82969. /**
  82970. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82971. * @param sega the first point of the segment to test the intersection against
  82972. * @param segb the second point of the segment to test the intersection against
  82973. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82974. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82975. */
  82976. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82977. /**
  82978. * Update the ray from viewport position
  82979. * @param x position
  82980. * @param y y position
  82981. * @param viewportWidth viewport width
  82982. * @param viewportHeight viewport height
  82983. * @param world world matrix
  82984. * @param view view matrix
  82985. * @param projection projection matrix
  82986. * @returns this ray updated
  82987. */
  82988. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82989. /**
  82990. * Creates a ray with origin and direction of 0,0,0
  82991. * @returns the new ray
  82992. */
  82993. static Zero(): Ray;
  82994. /**
  82995. * Creates a new ray from screen space and viewport
  82996. * @param x position
  82997. * @param y y position
  82998. * @param viewportWidth viewport width
  82999. * @param viewportHeight viewport height
  83000. * @param world world matrix
  83001. * @param view view matrix
  83002. * @param projection projection matrix
  83003. * @returns new ray
  83004. */
  83005. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83006. /**
  83007. * 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
  83008. * transformed to the given world matrix.
  83009. * @param origin The origin point
  83010. * @param end The end point
  83011. * @param world a matrix to transform the ray to. Default is the identity matrix.
  83012. * @returns the new ray
  83013. */
  83014. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  83015. /**
  83016. * Transforms a ray by a matrix
  83017. * @param ray ray to transform
  83018. * @param matrix matrix to apply
  83019. * @returns the resulting new ray
  83020. */
  83021. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  83022. /**
  83023. * Transforms a ray by a matrix
  83024. * @param ray ray to transform
  83025. * @param matrix matrix to apply
  83026. * @param result ray to store result in
  83027. */
  83028. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  83029. /**
  83030. * Unproject a ray from screen space to object space
  83031. * @param sourceX defines the screen space x coordinate to use
  83032. * @param sourceY defines the screen space y coordinate to use
  83033. * @param viewportWidth defines the current width of the viewport
  83034. * @param viewportHeight defines the current height of the viewport
  83035. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83036. * @param view defines the view matrix to use
  83037. * @param projection defines the projection matrix to use
  83038. */
  83039. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  83040. }
  83041. /**
  83042. * Type used to define predicate used to select faces when a mesh intersection is detected
  83043. */
  83044. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  83045. interface Scene {
  83046. /** @hidden */
  83047. _tempPickingRay: Nullable<Ray>;
  83048. /** @hidden */
  83049. _cachedRayForTransform: Ray;
  83050. /** @hidden */
  83051. _pickWithRayInverseMatrix: Matrix;
  83052. /** @hidden */
  83053. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  83054. /** @hidden */
  83055. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  83056. }
  83057. }
  83058. declare module BABYLON {
  83059. /**
  83060. * Groups all the scene component constants in one place to ease maintenance.
  83061. * @hidden
  83062. */
  83063. export class SceneComponentConstants {
  83064. static readonly NAME_EFFECTLAYER: string;
  83065. static readonly NAME_LAYER: string;
  83066. static readonly NAME_LENSFLARESYSTEM: string;
  83067. static readonly NAME_BOUNDINGBOXRENDERER: string;
  83068. static readonly NAME_PARTICLESYSTEM: string;
  83069. static readonly NAME_GAMEPAD: string;
  83070. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83071. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83072. static readonly NAME_DEPTHRENDERER: string;
  83073. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83074. static readonly NAME_SPRITE: string;
  83075. static readonly NAME_OUTLINERENDERER: string;
  83076. static readonly NAME_PROCEDURALTEXTURE: string;
  83077. static readonly NAME_SHADOWGENERATOR: string;
  83078. static readonly NAME_OCTREE: string;
  83079. static readonly NAME_PHYSICSENGINE: string;
  83080. static readonly NAME_AUDIO: string;
  83081. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83082. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83083. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83084. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83085. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83086. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83087. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83088. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83089. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83090. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83091. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83092. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83093. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83094. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83095. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83096. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83097. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83098. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83099. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83100. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83101. static readonly STEP_AFTERRENDER_AUDIO: number;
  83102. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83103. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83104. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83105. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83106. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83107. static readonly STEP_POINTERMOVE_SPRITE: number;
  83108. static readonly STEP_POINTERDOWN_SPRITE: number;
  83109. static readonly STEP_POINTERUP_SPRITE: number;
  83110. }
  83111. /**
  83112. * This represents a scene component.
  83113. *
  83114. * This is used to decouple the dependency the scene is having on the different workloads like
  83115. * layers, post processes...
  83116. */
  83117. export interface ISceneComponent {
  83118. /**
  83119. * The name of the component. Each component must have a unique name.
  83120. */
  83121. name: string;
  83122. /**
  83123. * The scene the component belongs to.
  83124. */
  83125. scene: Scene;
  83126. /**
  83127. * Register the component to one instance of a scene.
  83128. */
  83129. register(): void;
  83130. /**
  83131. * Rebuilds the elements related to this component in case of
  83132. * context lost for instance.
  83133. */
  83134. rebuild(): void;
  83135. /**
  83136. * Disposes the component and the associated ressources.
  83137. */
  83138. dispose(): void;
  83139. }
  83140. /**
  83141. * This represents a SERIALIZABLE scene component.
  83142. *
  83143. * This extends Scene Component to add Serialization methods on top.
  83144. */
  83145. export interface ISceneSerializableComponent extends ISceneComponent {
  83146. /**
  83147. * Adds all the elements from the container to the scene
  83148. * @param container the container holding the elements
  83149. */
  83150. addFromContainer(container: AbstractScene): void;
  83151. /**
  83152. * Removes all the elements in the container from the scene
  83153. * @param container contains the elements to remove
  83154. * @param dispose if the removed element should be disposed (default: false)
  83155. */
  83156. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  83157. /**
  83158. * Serializes the component data to the specified json object
  83159. * @param serializationObject The object to serialize to
  83160. */
  83161. serialize(serializationObject: any): void;
  83162. }
  83163. /**
  83164. * Strong typing of a Mesh related stage step action
  83165. */
  83166. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  83167. /**
  83168. * Strong typing of a Evaluate Sub Mesh related stage step action
  83169. */
  83170. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  83171. /**
  83172. * Strong typing of a Active Mesh related stage step action
  83173. */
  83174. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  83175. /**
  83176. * Strong typing of a Camera related stage step action
  83177. */
  83178. export type CameraStageAction = (camera: Camera) => void;
  83179. /**
  83180. * Strong typing of a Camera Frame buffer related stage step action
  83181. */
  83182. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  83183. /**
  83184. * Strong typing of a Render Target related stage step action
  83185. */
  83186. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  83187. /**
  83188. * Strong typing of a RenderingGroup related stage step action
  83189. */
  83190. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  83191. /**
  83192. * Strong typing of a Mesh Render related stage step action
  83193. */
  83194. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  83195. /**
  83196. * Strong typing of a simple stage step action
  83197. */
  83198. export type SimpleStageAction = () => void;
  83199. /**
  83200. * Strong typing of a render target action.
  83201. */
  83202. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83203. /**
  83204. * Strong typing of a pointer move action.
  83205. */
  83206. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83207. /**
  83208. * Strong typing of a pointer up/down action.
  83209. */
  83210. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83211. /**
  83212. * Representation of a stage in the scene (Basically a list of ordered steps)
  83213. * @hidden
  83214. */
  83215. export class Stage<T extends Function> extends Array<{
  83216. index: number;
  83217. component: ISceneComponent;
  83218. action: T;
  83219. }> {
  83220. /**
  83221. * Hide ctor from the rest of the world.
  83222. * @param items The items to add.
  83223. */
  83224. private constructor();
  83225. /**
  83226. * Creates a new Stage.
  83227. * @returns A new instance of a Stage
  83228. */
  83229. static Create<T extends Function>(): Stage<T>;
  83230. /**
  83231. * Registers a step in an ordered way in the targeted stage.
  83232. * @param index Defines the position to register the step in
  83233. * @param component Defines the component attached to the step
  83234. * @param action Defines the action to launch during the step
  83235. */
  83236. registerStep(index: number, component: ISceneComponent, action: T): void;
  83237. /**
  83238. * Clears all the steps from the stage.
  83239. */
  83240. clear(): void;
  83241. }
  83242. }
  83243. declare module BABYLON {
  83244. interface Scene {
  83245. /** @hidden */
  83246. _pointerOverSprite: Nullable<Sprite>;
  83247. /** @hidden */
  83248. _pickedDownSprite: Nullable<Sprite>;
  83249. /** @hidden */
  83250. _tempSpritePickingRay: Nullable<Ray>;
  83251. /**
  83252. * All of the sprite managers added to this scene
  83253. * @see http://doc.babylonjs.com/babylon101/sprites
  83254. */
  83255. spriteManagers: Array<ISpriteManager>;
  83256. /**
  83257. * An event triggered when sprites rendering is about to start
  83258. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83259. */
  83260. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83261. /**
  83262. * An event triggered when sprites rendering is done
  83263. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83264. */
  83265. onAfterSpritesRenderingObservable: Observable<Scene>;
  83266. /** @hidden */
  83267. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83268. /** Launch a ray to try to pick a sprite in the scene
  83269. * @param x position on screen
  83270. * @param y position on screen
  83271. * @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
  83272. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83273. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83274. * @returns a PickingInfo
  83275. */
  83276. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83277. /** Use the given ray to pick a sprite in the scene
  83278. * @param ray The ray (in world space) to use to pick meshes
  83279. * @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
  83280. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83281. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83282. * @returns a PickingInfo
  83283. */
  83284. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83285. /** @hidden */
  83286. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83287. /** Launch a ray to try to pick sprites in the scene
  83288. * @param x position on screen
  83289. * @param y position on screen
  83290. * @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
  83291. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83292. * @returns a PickingInfo array
  83293. */
  83294. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83295. /** Use the given ray to pick sprites in the scene
  83296. * @param ray The ray (in world space) to use to pick meshes
  83297. * @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
  83298. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83299. * @returns a PickingInfo array
  83300. */
  83301. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83302. /**
  83303. * Force the sprite under the pointer
  83304. * @param sprite defines the sprite to use
  83305. */
  83306. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83307. /**
  83308. * Gets the sprite under the pointer
  83309. * @returns a Sprite or null if no sprite is under the pointer
  83310. */
  83311. getPointerOverSprite(): Nullable<Sprite>;
  83312. }
  83313. /**
  83314. * Defines the sprite scene component responsible to manage sprites
  83315. * in a given scene.
  83316. */
  83317. export class SpriteSceneComponent implements ISceneComponent {
  83318. /**
  83319. * The component name helpfull to identify the component in the list of scene components.
  83320. */
  83321. readonly name: string;
  83322. /**
  83323. * The scene the component belongs to.
  83324. */
  83325. scene: Scene;
  83326. /** @hidden */
  83327. private _spritePredicate;
  83328. /**
  83329. * Creates a new instance of the component for the given scene
  83330. * @param scene Defines the scene to register the component in
  83331. */
  83332. constructor(scene: Scene);
  83333. /**
  83334. * Registers the component in a given scene
  83335. */
  83336. register(): void;
  83337. /**
  83338. * Rebuilds the elements related to this component in case of
  83339. * context lost for instance.
  83340. */
  83341. rebuild(): void;
  83342. /**
  83343. * Disposes the component and the associated ressources.
  83344. */
  83345. dispose(): void;
  83346. private _pickSpriteButKeepRay;
  83347. private _pointerMove;
  83348. private _pointerDown;
  83349. private _pointerUp;
  83350. }
  83351. }
  83352. declare module BABYLON {
  83353. /** @hidden */
  83354. export var fogFragmentDeclaration: {
  83355. name: string;
  83356. shader: string;
  83357. };
  83358. }
  83359. declare module BABYLON {
  83360. /** @hidden */
  83361. export var fogFragment: {
  83362. name: string;
  83363. shader: string;
  83364. };
  83365. }
  83366. declare module BABYLON {
  83367. /** @hidden */
  83368. export var spritesPixelShader: {
  83369. name: string;
  83370. shader: string;
  83371. };
  83372. }
  83373. declare module BABYLON {
  83374. /** @hidden */
  83375. export var fogVertexDeclaration: {
  83376. name: string;
  83377. shader: string;
  83378. };
  83379. }
  83380. declare module BABYLON {
  83381. /** @hidden */
  83382. export var spritesVertexShader: {
  83383. name: string;
  83384. shader: string;
  83385. };
  83386. }
  83387. declare module BABYLON {
  83388. /**
  83389. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83390. */
  83391. export interface ISpriteManager extends IDisposable {
  83392. /**
  83393. * Restricts the camera to viewing objects with the same layerMask.
  83394. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83395. */
  83396. layerMask: number;
  83397. /**
  83398. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83399. */
  83400. isPickable: boolean;
  83401. /**
  83402. * Specifies the rendering group id for this mesh (0 by default)
  83403. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83404. */
  83405. renderingGroupId: number;
  83406. /**
  83407. * Defines the list of sprites managed by the manager.
  83408. */
  83409. sprites: Array<Sprite>;
  83410. /**
  83411. * Tests the intersection of a sprite with a specific ray.
  83412. * @param ray The ray we are sending to test the collision
  83413. * @param camera The camera space we are sending rays in
  83414. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83415. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83416. * @returns picking info or null.
  83417. */
  83418. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83419. /**
  83420. * Intersects the sprites with a ray
  83421. * @param ray defines the ray to intersect with
  83422. * @param camera defines the current active camera
  83423. * @param predicate defines a predicate used to select candidate sprites
  83424. * @returns null if no hit or a PickingInfo array
  83425. */
  83426. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83427. /**
  83428. * Renders the list of sprites on screen.
  83429. */
  83430. render(): void;
  83431. }
  83432. /**
  83433. * Class used to manage multiple sprites on the same spritesheet
  83434. * @see http://doc.babylonjs.com/babylon101/sprites
  83435. */
  83436. export class SpriteManager implements ISpriteManager {
  83437. /** defines the manager's name */
  83438. name: string;
  83439. /** Gets the list of sprites */
  83440. sprites: Sprite[];
  83441. /** Gets or sets the rendering group id (0 by default) */
  83442. renderingGroupId: number;
  83443. /** Gets or sets camera layer mask */
  83444. layerMask: number;
  83445. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83446. fogEnabled: boolean;
  83447. /** Gets or sets a boolean indicating if the sprites are pickable */
  83448. isPickable: boolean;
  83449. /** Defines the default width of a cell in the spritesheet */
  83450. cellWidth: number;
  83451. /** Defines the default height of a cell in the spritesheet */
  83452. cellHeight: number;
  83453. /** Associative array from JSON sprite data file */
  83454. private _cellData;
  83455. /** Array of sprite names from JSON sprite data file */
  83456. private _spriteMap;
  83457. /** True when packed cell data from JSON file is ready*/
  83458. private _packedAndReady;
  83459. /**
  83460. * An event triggered when the manager is disposed.
  83461. */
  83462. onDisposeObservable: Observable<SpriteManager>;
  83463. private _onDisposeObserver;
  83464. /**
  83465. * Callback called when the manager is disposed
  83466. */
  83467. set onDispose(callback: () => void);
  83468. private _capacity;
  83469. private _fromPacked;
  83470. private _spriteTexture;
  83471. private _epsilon;
  83472. private _scene;
  83473. private _vertexData;
  83474. private _buffer;
  83475. private _vertexBuffers;
  83476. private _indexBuffer;
  83477. private _effectBase;
  83478. private _effectFog;
  83479. /**
  83480. * Gets or sets the spritesheet texture
  83481. */
  83482. get texture(): Texture;
  83483. set texture(value: Texture);
  83484. private _blendMode;
  83485. /**
  83486. * Blend mode use to render the particle, it can be any of
  83487. * the static Constants.ALPHA_x properties provided in this class.
  83488. * Default value is Constants.ALPHA_COMBINE
  83489. */
  83490. get blendMode(): number;
  83491. set blendMode(blendMode: number);
  83492. /** Disables writing to the depth buffer when rendering the sprites.
  83493. * It can be handy to disable depth writing when using textures without alpha channel
  83494. * and setting some specific blend modes.
  83495. */
  83496. disableDepthWrite: boolean;
  83497. /**
  83498. * Creates a new sprite manager
  83499. * @param name defines the manager's name
  83500. * @param imgUrl defines the sprite sheet url
  83501. * @param capacity defines the maximum allowed number of sprites
  83502. * @param cellSize defines the size of a sprite cell
  83503. * @param scene defines the hosting scene
  83504. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83505. * @param samplingMode defines the smapling mode to use with spritesheet
  83506. * @param fromPacked set to false; do not alter
  83507. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83508. */
  83509. constructor(
  83510. /** defines the manager's name */
  83511. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83512. private _makePacked;
  83513. private _appendSpriteVertex;
  83514. /**
  83515. * Intersects the sprites with a ray
  83516. * @param ray defines the ray to intersect with
  83517. * @param camera defines the current active camera
  83518. * @param predicate defines a predicate used to select candidate sprites
  83519. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83520. * @returns null if no hit or a PickingInfo
  83521. */
  83522. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83523. /**
  83524. * Intersects the sprites with a ray
  83525. * @param ray defines the ray to intersect with
  83526. * @param camera defines the current active camera
  83527. * @param predicate defines a predicate used to select candidate sprites
  83528. * @returns null if no hit or a PickingInfo array
  83529. */
  83530. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83531. /**
  83532. * Render all child sprites
  83533. */
  83534. render(): void;
  83535. /**
  83536. * Release associated resources
  83537. */
  83538. dispose(): void;
  83539. }
  83540. }
  83541. declare module BABYLON {
  83542. /** Interface used by value gradients (color, factor, ...) */
  83543. export interface IValueGradient {
  83544. /**
  83545. * Gets or sets the gradient value (between 0 and 1)
  83546. */
  83547. gradient: number;
  83548. }
  83549. /** Class used to store color4 gradient */
  83550. export class ColorGradient implements IValueGradient {
  83551. /**
  83552. * Gets or sets the gradient value (between 0 and 1)
  83553. */
  83554. gradient: number;
  83555. /**
  83556. * Gets or sets first associated color
  83557. */
  83558. color1: Color4;
  83559. /**
  83560. * Gets or sets second associated color
  83561. */
  83562. color2?: Color4;
  83563. /**
  83564. * Will get a color picked randomly between color1 and color2.
  83565. * If color2 is undefined then color1 will be used
  83566. * @param result defines the target Color4 to store the result in
  83567. */
  83568. getColorToRef(result: Color4): void;
  83569. }
  83570. /** Class used to store color 3 gradient */
  83571. export class Color3Gradient implements IValueGradient {
  83572. /**
  83573. * Gets or sets the gradient value (between 0 and 1)
  83574. */
  83575. gradient: number;
  83576. /**
  83577. * Gets or sets the associated color
  83578. */
  83579. color: Color3;
  83580. }
  83581. /** Class used to store factor gradient */
  83582. export class FactorGradient implements IValueGradient {
  83583. /**
  83584. * Gets or sets the gradient value (between 0 and 1)
  83585. */
  83586. gradient: number;
  83587. /**
  83588. * Gets or sets first associated factor
  83589. */
  83590. factor1: number;
  83591. /**
  83592. * Gets or sets second associated factor
  83593. */
  83594. factor2?: number;
  83595. /**
  83596. * Will get a number picked randomly between factor1 and factor2.
  83597. * If factor2 is undefined then factor1 will be used
  83598. * @returns the picked number
  83599. */
  83600. getFactor(): number;
  83601. }
  83602. /**
  83603. * Helper used to simplify some generic gradient tasks
  83604. */
  83605. export class GradientHelper {
  83606. /**
  83607. * Gets the current gradient from an array of IValueGradient
  83608. * @param ratio defines the current ratio to get
  83609. * @param gradients defines the array of IValueGradient
  83610. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83611. */
  83612. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83613. }
  83614. }
  83615. declare module BABYLON {
  83616. /**
  83617. * Interface for the size containing width and height
  83618. */
  83619. export interface ISize {
  83620. /**
  83621. * Width
  83622. */
  83623. width: number;
  83624. /**
  83625. * Heighht
  83626. */
  83627. height: number;
  83628. }
  83629. /**
  83630. * Size containing widht and height
  83631. */
  83632. export class Size implements ISize {
  83633. /**
  83634. * Width
  83635. */
  83636. width: number;
  83637. /**
  83638. * Height
  83639. */
  83640. height: number;
  83641. /**
  83642. * Creates a Size object from the given width and height (floats).
  83643. * @param width width of the new size
  83644. * @param height height of the new size
  83645. */
  83646. constructor(width: number, height: number);
  83647. /**
  83648. * Returns a string with the Size width and height
  83649. * @returns a string with the Size width and height
  83650. */
  83651. toString(): string;
  83652. /**
  83653. * "Size"
  83654. * @returns the string "Size"
  83655. */
  83656. getClassName(): string;
  83657. /**
  83658. * Returns the Size hash code.
  83659. * @returns a hash code for a unique width and height
  83660. */
  83661. getHashCode(): number;
  83662. /**
  83663. * Updates the current size from the given one.
  83664. * @param src the given size
  83665. */
  83666. copyFrom(src: Size): void;
  83667. /**
  83668. * Updates in place the current Size from the given floats.
  83669. * @param width width of the new size
  83670. * @param height height of the new size
  83671. * @returns the updated Size.
  83672. */
  83673. copyFromFloats(width: number, height: number): Size;
  83674. /**
  83675. * Updates in place the current Size from the given floats.
  83676. * @param width width to set
  83677. * @param height height to set
  83678. * @returns the updated Size.
  83679. */
  83680. set(width: number, height: number): Size;
  83681. /**
  83682. * Multiplies the width and height by numbers
  83683. * @param w factor to multiple the width by
  83684. * @param h factor to multiple the height by
  83685. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83686. */
  83687. multiplyByFloats(w: number, h: number): Size;
  83688. /**
  83689. * Clones the size
  83690. * @returns a new Size copied from the given one.
  83691. */
  83692. clone(): Size;
  83693. /**
  83694. * True if the current Size and the given one width and height are strictly equal.
  83695. * @param other the other size to compare against
  83696. * @returns True if the current Size and the given one width and height are strictly equal.
  83697. */
  83698. equals(other: Size): boolean;
  83699. /**
  83700. * The surface of the Size : width * height (float).
  83701. */
  83702. get surface(): number;
  83703. /**
  83704. * Create a new size of zero
  83705. * @returns a new Size set to (0.0, 0.0)
  83706. */
  83707. static Zero(): Size;
  83708. /**
  83709. * Sums the width and height of two sizes
  83710. * @param otherSize size to add to this size
  83711. * @returns a new Size set as the addition result of the current Size and the given one.
  83712. */
  83713. add(otherSize: Size): Size;
  83714. /**
  83715. * Subtracts the width and height of two
  83716. * @param otherSize size to subtract to this size
  83717. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83718. */
  83719. subtract(otherSize: Size): Size;
  83720. /**
  83721. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83722. * @param start starting size to lerp between
  83723. * @param end end size to lerp between
  83724. * @param amount amount to lerp between the start and end values
  83725. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83726. */
  83727. static Lerp(start: Size, end: Size, amount: number): Size;
  83728. }
  83729. }
  83730. declare module BABYLON {
  83731. interface ThinEngine {
  83732. /**
  83733. * Creates a dynamic texture
  83734. * @param width defines the width of the texture
  83735. * @param height defines the height of the texture
  83736. * @param generateMipMaps defines if the engine should generate the mip levels
  83737. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83738. * @returns the dynamic texture inside an InternalTexture
  83739. */
  83740. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83741. /**
  83742. * Update the content of a dynamic texture
  83743. * @param texture defines the texture to update
  83744. * @param canvas defines the canvas containing the source
  83745. * @param invertY defines if data must be stored with Y axis inverted
  83746. * @param premulAlpha defines if alpha is stored as premultiplied
  83747. * @param format defines the format of the data
  83748. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83749. */
  83750. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83751. }
  83752. }
  83753. declare module BABYLON {
  83754. /**
  83755. * Helper class used to generate a canvas to manipulate images
  83756. */
  83757. export class CanvasGenerator {
  83758. /**
  83759. * Create a new canvas (or offscreen canvas depending on the context)
  83760. * @param width defines the expected width
  83761. * @param height defines the expected height
  83762. * @return a new canvas or offscreen canvas
  83763. */
  83764. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83765. }
  83766. }
  83767. declare module BABYLON {
  83768. /**
  83769. * A class extending Texture allowing drawing on a texture
  83770. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83771. */
  83772. export class DynamicTexture extends Texture {
  83773. private _generateMipMaps;
  83774. private _canvas;
  83775. private _context;
  83776. private _engine;
  83777. /**
  83778. * Creates a DynamicTexture
  83779. * @param name defines the name of the texture
  83780. * @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
  83781. * @param scene defines the scene where you want the texture
  83782. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83783. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83784. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83785. */
  83786. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83787. /**
  83788. * Get the current class name of the texture useful for serialization or dynamic coding.
  83789. * @returns "DynamicTexture"
  83790. */
  83791. getClassName(): string;
  83792. /**
  83793. * Gets the current state of canRescale
  83794. */
  83795. get canRescale(): boolean;
  83796. private _recreate;
  83797. /**
  83798. * Scales the texture
  83799. * @param ratio the scale factor to apply to both width and height
  83800. */
  83801. scale(ratio: number): void;
  83802. /**
  83803. * Resizes the texture
  83804. * @param width the new width
  83805. * @param height the new height
  83806. */
  83807. scaleTo(width: number, height: number): void;
  83808. /**
  83809. * Gets the context of the canvas used by the texture
  83810. * @returns the canvas context of the dynamic texture
  83811. */
  83812. getContext(): CanvasRenderingContext2D;
  83813. /**
  83814. * Clears the texture
  83815. */
  83816. clear(): void;
  83817. /**
  83818. * Updates the texture
  83819. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83820. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83821. */
  83822. update(invertY?: boolean, premulAlpha?: boolean): void;
  83823. /**
  83824. * Draws text onto the texture
  83825. * @param text defines the text to be drawn
  83826. * @param x defines the placement of the text from the left
  83827. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83828. * @param font defines the font to be used with font-style, font-size, font-name
  83829. * @param color defines the color used for the text
  83830. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83831. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83832. * @param update defines whether texture is immediately update (default is true)
  83833. */
  83834. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83835. /**
  83836. * Clones the texture
  83837. * @returns the clone of the texture.
  83838. */
  83839. clone(): DynamicTexture;
  83840. /**
  83841. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83842. * @returns a serialized dynamic texture object
  83843. */
  83844. serialize(): any;
  83845. /** @hidden */
  83846. _rebuild(): void;
  83847. }
  83848. }
  83849. declare module BABYLON {
  83850. interface Engine {
  83851. /**
  83852. * Creates a raw texture
  83853. * @param data defines the data to store in the texture
  83854. * @param width defines the width of the texture
  83855. * @param height defines the height of the texture
  83856. * @param format defines the format of the data
  83857. * @param generateMipMaps defines if the engine should generate the mip levels
  83858. * @param invertY defines if data must be stored with Y axis inverted
  83859. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83860. * @param compression defines the compression used (null by default)
  83861. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83862. * @returns the raw texture inside an InternalTexture
  83863. */
  83864. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83865. /**
  83866. * Update a raw texture
  83867. * @param texture defines the texture to update
  83868. * @param data defines the data to store in the texture
  83869. * @param format defines the format of the data
  83870. * @param invertY defines if data must be stored with Y axis inverted
  83871. */
  83872. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83873. /**
  83874. * Update a raw texture
  83875. * @param texture defines the texture to update
  83876. * @param data defines the data to store in the texture
  83877. * @param format defines the format of the data
  83878. * @param invertY defines if data must be stored with Y axis inverted
  83879. * @param compression defines the compression used (null by default)
  83880. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83881. */
  83882. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83883. /**
  83884. * Creates a new raw cube texture
  83885. * @param data defines the array of data to use to create each face
  83886. * @param size defines the size of the textures
  83887. * @param format defines the format of the data
  83888. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83889. * @param generateMipMaps defines if the engine should generate the mip levels
  83890. * @param invertY defines if data must be stored with Y axis inverted
  83891. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83892. * @param compression defines the compression used (null by default)
  83893. * @returns the cube texture as an InternalTexture
  83894. */
  83895. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83896. /**
  83897. * Update a raw cube texture
  83898. * @param texture defines the texture to udpdate
  83899. * @param data defines the data to store
  83900. * @param format defines the data format
  83901. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83902. * @param invertY defines if data must be stored with Y axis inverted
  83903. */
  83904. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83905. /**
  83906. * Update a raw cube texture
  83907. * @param texture defines the texture to udpdate
  83908. * @param data defines the data to store
  83909. * @param format defines the data format
  83910. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83911. * @param invertY defines if data must be stored with Y axis inverted
  83912. * @param compression defines the compression used (null by default)
  83913. */
  83914. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83915. /**
  83916. * Update a raw cube texture
  83917. * @param texture defines the texture to udpdate
  83918. * @param data defines the data to store
  83919. * @param format defines the data format
  83920. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83921. * @param invertY defines if data must be stored with Y axis inverted
  83922. * @param compression defines the compression used (null by default)
  83923. * @param level defines which level of the texture to update
  83924. */
  83925. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83926. /**
  83927. * Creates a new raw cube texture from a specified url
  83928. * @param url defines the url where the data is located
  83929. * @param scene defines the current scene
  83930. * @param size defines the size of the textures
  83931. * @param format defines the format of the data
  83932. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83933. * @param noMipmap defines if the engine should avoid generating the mip levels
  83934. * @param callback defines a callback used to extract texture data from loaded data
  83935. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83936. * @param onLoad defines a callback called when texture is loaded
  83937. * @param onError defines a callback called if there is an error
  83938. * @returns the cube texture as an InternalTexture
  83939. */
  83940. 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;
  83941. /**
  83942. * Creates a new raw cube texture from a specified url
  83943. * @param url defines the url where the data is located
  83944. * @param scene defines the current scene
  83945. * @param size defines the size of the textures
  83946. * @param format defines the format of the data
  83947. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83948. * @param noMipmap defines if the engine should avoid generating the mip levels
  83949. * @param callback defines a callback used to extract texture data from loaded data
  83950. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83951. * @param onLoad defines a callback called when texture is loaded
  83952. * @param onError defines a callback called if there is an error
  83953. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83954. * @param invertY defines if data must be stored with Y axis inverted
  83955. * @returns the cube texture as an InternalTexture
  83956. */
  83957. 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;
  83958. /**
  83959. * Creates a new raw 3D texture
  83960. * @param data defines the data used to create the texture
  83961. * @param width defines the width of the texture
  83962. * @param height defines the height of the texture
  83963. * @param depth defines the depth of the texture
  83964. * @param format defines the format of the texture
  83965. * @param generateMipMaps defines if the engine must generate mip levels
  83966. * @param invertY defines if data must be stored with Y axis inverted
  83967. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83968. * @param compression defines the compressed used (can be null)
  83969. * @param textureType defines the compressed used (can be null)
  83970. * @returns a new raw 3D texture (stored in an InternalTexture)
  83971. */
  83972. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83973. /**
  83974. * Update a raw 3D texture
  83975. * @param texture defines the texture to update
  83976. * @param data defines the data to store
  83977. * @param format defines the data format
  83978. * @param invertY defines if data must be stored with Y axis inverted
  83979. */
  83980. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83981. /**
  83982. * Update a raw 3D texture
  83983. * @param texture defines the texture to update
  83984. * @param data defines the data to store
  83985. * @param format defines the data format
  83986. * @param invertY defines if data must be stored with Y axis inverted
  83987. * @param compression defines the used compression (can be null)
  83988. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83989. */
  83990. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83991. /**
  83992. * Creates a new raw 2D array texture
  83993. * @param data defines the data used to create the texture
  83994. * @param width defines the width of the texture
  83995. * @param height defines the height of the texture
  83996. * @param depth defines the number of layers of the texture
  83997. * @param format defines the format of the texture
  83998. * @param generateMipMaps defines if the engine must generate mip levels
  83999. * @param invertY defines if data must be stored with Y axis inverted
  84000. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84001. * @param compression defines the compressed used (can be null)
  84002. * @param textureType defines the compressed used (can be null)
  84003. * @returns a new raw 2D array texture (stored in an InternalTexture)
  84004. */
  84005. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84006. /**
  84007. * Update a raw 2D array texture
  84008. * @param texture defines the texture to update
  84009. * @param data defines the data to store
  84010. * @param format defines the data format
  84011. * @param invertY defines if data must be stored with Y axis inverted
  84012. */
  84013. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84014. /**
  84015. * Update a raw 2D array texture
  84016. * @param texture defines the texture to update
  84017. * @param data defines the data to store
  84018. * @param format defines the data format
  84019. * @param invertY defines if data must be stored with Y axis inverted
  84020. * @param compression defines the used compression (can be null)
  84021. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84022. */
  84023. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84024. }
  84025. }
  84026. declare module BABYLON {
  84027. /**
  84028. * Raw texture can help creating a texture directly from an array of data.
  84029. * This can be super useful if you either get the data from an uncompressed source or
  84030. * if you wish to create your texture pixel by pixel.
  84031. */
  84032. export class RawTexture extends Texture {
  84033. /**
  84034. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84035. */
  84036. format: number;
  84037. private _engine;
  84038. /**
  84039. * Instantiates a new RawTexture.
  84040. * Raw texture can help creating a texture directly from an array of data.
  84041. * This can be super useful if you either get the data from an uncompressed source or
  84042. * if you wish to create your texture pixel by pixel.
  84043. * @param data define the array of data to use to create the texture
  84044. * @param width define the width of the texture
  84045. * @param height define the height of the texture
  84046. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84047. * @param scene define the scene the texture belongs to
  84048. * @param generateMipMaps define whether mip maps should be generated or not
  84049. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84050. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84051. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84052. */
  84053. constructor(data: ArrayBufferView, width: number, height: number,
  84054. /**
  84055. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84056. */
  84057. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  84058. /**
  84059. * Updates the texture underlying data.
  84060. * @param data Define the new data of the texture
  84061. */
  84062. update(data: ArrayBufferView): void;
  84063. /**
  84064. * Creates a luminance texture from some data.
  84065. * @param data Define the texture data
  84066. * @param width Define the width of the texture
  84067. * @param height Define the height of the texture
  84068. * @param scene Define the scene the texture belongs to
  84069. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84070. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84071. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84072. * @returns the luminance texture
  84073. */
  84074. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84075. /**
  84076. * Creates a luminance alpha texture from some data.
  84077. * @param data Define the texture data
  84078. * @param width Define the width of the texture
  84079. * @param height Define the height of the texture
  84080. * @param scene Define the scene the texture belongs to
  84081. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84082. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84083. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84084. * @returns the luminance alpha texture
  84085. */
  84086. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84087. /**
  84088. * Creates an alpha texture from some data.
  84089. * @param data Define the texture data
  84090. * @param width Define the width of the texture
  84091. * @param height Define the height of the texture
  84092. * @param scene Define the scene the texture belongs to
  84093. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84094. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84095. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84096. * @returns the alpha texture
  84097. */
  84098. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84099. /**
  84100. * Creates a RGB texture from some data.
  84101. * @param data Define the texture data
  84102. * @param width Define the width of the texture
  84103. * @param height Define the height of the texture
  84104. * @param scene Define the scene the texture belongs to
  84105. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84106. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84107. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84108. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84109. * @returns the RGB alpha texture
  84110. */
  84111. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84112. /**
  84113. * Creates a RGBA texture from some data.
  84114. * @param data Define the texture data
  84115. * @param width Define the width of the texture
  84116. * @param height Define the height of the texture
  84117. * @param scene Define the scene the texture belongs to
  84118. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84119. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84120. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84121. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84122. * @returns the RGBA texture
  84123. */
  84124. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84125. /**
  84126. * Creates a R texture from some data.
  84127. * @param data Define the texture data
  84128. * @param width Define the width of the texture
  84129. * @param height Define the height of the texture
  84130. * @param scene Define the scene the texture belongs to
  84131. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84132. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84133. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84134. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84135. * @returns the R texture
  84136. */
  84137. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84138. }
  84139. }
  84140. declare module BABYLON {
  84141. interface AbstractScene {
  84142. /**
  84143. * The list of procedural textures added to the scene
  84144. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84145. */
  84146. proceduralTextures: Array<ProceduralTexture>;
  84147. }
  84148. /**
  84149. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84150. * in a given scene.
  84151. */
  84152. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84153. /**
  84154. * The component name helpfull to identify the component in the list of scene components.
  84155. */
  84156. readonly name: string;
  84157. /**
  84158. * The scene the component belongs to.
  84159. */
  84160. scene: Scene;
  84161. /**
  84162. * Creates a new instance of the component for the given scene
  84163. * @param scene Defines the scene to register the component in
  84164. */
  84165. constructor(scene: Scene);
  84166. /**
  84167. * Registers the component in a given scene
  84168. */
  84169. register(): void;
  84170. /**
  84171. * Rebuilds the elements related to this component in case of
  84172. * context lost for instance.
  84173. */
  84174. rebuild(): void;
  84175. /**
  84176. * Disposes the component and the associated ressources.
  84177. */
  84178. dispose(): void;
  84179. private _beforeClear;
  84180. }
  84181. }
  84182. declare module BABYLON {
  84183. interface ThinEngine {
  84184. /**
  84185. * Creates a new render target cube texture
  84186. * @param size defines the size of the texture
  84187. * @param options defines the options used to create the texture
  84188. * @returns a new render target cube texture stored in an InternalTexture
  84189. */
  84190. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84191. }
  84192. }
  84193. declare module BABYLON {
  84194. /** @hidden */
  84195. export var proceduralVertexShader: {
  84196. name: string;
  84197. shader: string;
  84198. };
  84199. }
  84200. declare module BABYLON {
  84201. /**
  84202. * 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.
  84203. * This is the base class of any Procedural texture and contains most of the shareable code.
  84204. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84205. */
  84206. export class ProceduralTexture extends Texture {
  84207. isCube: boolean;
  84208. /**
  84209. * Define if the texture is enabled or not (disabled texture will not render)
  84210. */
  84211. isEnabled: boolean;
  84212. /**
  84213. * Define if the texture must be cleared before rendering (default is true)
  84214. */
  84215. autoClear: boolean;
  84216. /**
  84217. * Callback called when the texture is generated
  84218. */
  84219. onGenerated: () => void;
  84220. /**
  84221. * Event raised when the texture is generated
  84222. */
  84223. onGeneratedObservable: Observable<ProceduralTexture>;
  84224. /** @hidden */
  84225. _generateMipMaps: boolean;
  84226. /** @hidden **/
  84227. _effect: Effect;
  84228. /** @hidden */
  84229. _textures: {
  84230. [key: string]: Texture;
  84231. };
  84232. private _size;
  84233. private _currentRefreshId;
  84234. private _frameId;
  84235. private _refreshRate;
  84236. private _vertexBuffers;
  84237. private _indexBuffer;
  84238. private _uniforms;
  84239. private _samplers;
  84240. private _fragment;
  84241. private _floats;
  84242. private _ints;
  84243. private _floatsArrays;
  84244. private _colors3;
  84245. private _colors4;
  84246. private _vectors2;
  84247. private _vectors3;
  84248. private _matrices;
  84249. private _fallbackTexture;
  84250. private _fallbackTextureUsed;
  84251. private _engine;
  84252. private _cachedDefines;
  84253. private _contentUpdateId;
  84254. private _contentData;
  84255. /**
  84256. * Instantiates a new procedural texture.
  84257. * 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.
  84258. * This is the base class of any Procedural texture and contains most of the shareable code.
  84259. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84260. * @param name Define the name of the texture
  84261. * @param size Define the size of the texture to create
  84262. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84263. * @param scene Define the scene the texture belongs to
  84264. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84265. * @param generateMipMaps Define if the texture should creates mip maps or not
  84266. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84267. */
  84268. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84269. /**
  84270. * The effect that is created when initializing the post process.
  84271. * @returns The created effect corresponding the the postprocess.
  84272. */
  84273. getEffect(): Effect;
  84274. /**
  84275. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84276. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84277. */
  84278. getContent(): Nullable<ArrayBufferView>;
  84279. private _createIndexBuffer;
  84280. /** @hidden */
  84281. _rebuild(): void;
  84282. /**
  84283. * Resets the texture in order to recreate its associated resources.
  84284. * This can be called in case of context loss
  84285. */
  84286. reset(): void;
  84287. protected _getDefines(): string;
  84288. /**
  84289. * Is the texture ready to be used ? (rendered at least once)
  84290. * @returns true if ready, otherwise, false.
  84291. */
  84292. isReady(): boolean;
  84293. /**
  84294. * Resets the refresh counter of the texture and start bak from scratch.
  84295. * Could be useful to regenerate the texture if it is setup to render only once.
  84296. */
  84297. resetRefreshCounter(): void;
  84298. /**
  84299. * Set the fragment shader to use in order to render the texture.
  84300. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84301. */
  84302. setFragment(fragment: any): void;
  84303. /**
  84304. * Define the refresh rate of the texture or the rendering frequency.
  84305. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84306. */
  84307. get refreshRate(): number;
  84308. set refreshRate(value: number);
  84309. /** @hidden */
  84310. _shouldRender(): boolean;
  84311. /**
  84312. * Get the size the texture is rendering at.
  84313. * @returns the size (texture is always squared)
  84314. */
  84315. getRenderSize(): number;
  84316. /**
  84317. * Resize the texture to new value.
  84318. * @param size Define the new size the texture should have
  84319. * @param generateMipMaps Define whether the new texture should create mip maps
  84320. */
  84321. resize(size: number, generateMipMaps: boolean): void;
  84322. private _checkUniform;
  84323. /**
  84324. * Set a texture in the shader program used to render.
  84325. * @param name Define the name of the uniform samplers as defined in the shader
  84326. * @param texture Define the texture to bind to this sampler
  84327. * @return the texture itself allowing "fluent" like uniform updates
  84328. */
  84329. setTexture(name: string, texture: Texture): ProceduralTexture;
  84330. /**
  84331. * Set a float in the shader.
  84332. * @param name Define the name of the uniform as defined in the shader
  84333. * @param value Define the value to give to the uniform
  84334. * @return the texture itself allowing "fluent" like uniform updates
  84335. */
  84336. setFloat(name: string, value: number): ProceduralTexture;
  84337. /**
  84338. * Set a int in the shader.
  84339. * @param name Define the name of the uniform as defined in the shader
  84340. * @param value Define the value to give to the uniform
  84341. * @return the texture itself allowing "fluent" like uniform updates
  84342. */
  84343. setInt(name: string, value: number): ProceduralTexture;
  84344. /**
  84345. * Set an array of floats in the shader.
  84346. * @param name Define the name of the uniform as defined in the shader
  84347. * @param value Define the value to give to the uniform
  84348. * @return the texture itself allowing "fluent" like uniform updates
  84349. */
  84350. setFloats(name: string, value: number[]): ProceduralTexture;
  84351. /**
  84352. * Set a vec3 in the shader from a Color3.
  84353. * @param name Define the name of the uniform as defined in the shader
  84354. * @param value Define the value to give to the uniform
  84355. * @return the texture itself allowing "fluent" like uniform updates
  84356. */
  84357. setColor3(name: string, value: Color3): ProceduralTexture;
  84358. /**
  84359. * Set a vec4 in the shader from a Color4.
  84360. * @param name Define the name of the uniform as defined in the shader
  84361. * @param value Define the value to give to the uniform
  84362. * @return the texture itself allowing "fluent" like uniform updates
  84363. */
  84364. setColor4(name: string, value: Color4): ProceduralTexture;
  84365. /**
  84366. * Set a vec2 in the shader from a Vector2.
  84367. * @param name Define the name of the uniform as defined in the shader
  84368. * @param value Define the value to give to the uniform
  84369. * @return the texture itself allowing "fluent" like uniform updates
  84370. */
  84371. setVector2(name: string, value: Vector2): ProceduralTexture;
  84372. /**
  84373. * Set a vec3 in the shader from a Vector3.
  84374. * @param name Define the name of the uniform as defined in the shader
  84375. * @param value Define the value to give to the uniform
  84376. * @return the texture itself allowing "fluent" like uniform updates
  84377. */
  84378. setVector3(name: string, value: Vector3): ProceduralTexture;
  84379. /**
  84380. * Set a mat4 in the shader from a MAtrix.
  84381. * @param name Define the name of the uniform as defined in the shader
  84382. * @param value Define the value to give to the uniform
  84383. * @return the texture itself allowing "fluent" like uniform updates
  84384. */
  84385. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84386. /**
  84387. * Render the texture to its associated render target.
  84388. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84389. */
  84390. render(useCameraPostProcess?: boolean): void;
  84391. /**
  84392. * Clone the texture.
  84393. * @returns the cloned texture
  84394. */
  84395. clone(): ProceduralTexture;
  84396. /**
  84397. * Dispose the texture and release its asoociated resources.
  84398. */
  84399. dispose(): void;
  84400. }
  84401. }
  84402. declare module BABYLON {
  84403. /**
  84404. * This represents the base class for particle system in Babylon.
  84405. * 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.
  84406. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84407. * @example https://doc.babylonjs.com/babylon101/particles
  84408. */
  84409. export class BaseParticleSystem {
  84410. /**
  84411. * Source color is added to the destination color without alpha affecting the result
  84412. */
  84413. static BLENDMODE_ONEONE: number;
  84414. /**
  84415. * Blend current color and particle color using particle’s alpha
  84416. */
  84417. static BLENDMODE_STANDARD: number;
  84418. /**
  84419. * Add current color and particle color multiplied by particle’s alpha
  84420. */
  84421. static BLENDMODE_ADD: number;
  84422. /**
  84423. * Multiply current color with particle color
  84424. */
  84425. static BLENDMODE_MULTIPLY: number;
  84426. /**
  84427. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84428. */
  84429. static BLENDMODE_MULTIPLYADD: number;
  84430. /**
  84431. * List of animations used by the particle system.
  84432. */
  84433. animations: Animation[];
  84434. /**
  84435. * The id of the Particle system.
  84436. */
  84437. id: string;
  84438. /**
  84439. * The friendly name of the Particle system.
  84440. */
  84441. name: string;
  84442. /**
  84443. * The rendering group used by the Particle system to chose when to render.
  84444. */
  84445. renderingGroupId: number;
  84446. /**
  84447. * The emitter represents the Mesh or position we are attaching the particle system to.
  84448. */
  84449. emitter: Nullable<AbstractMesh | Vector3>;
  84450. /**
  84451. * The maximum number of particles to emit per frame
  84452. */
  84453. emitRate: number;
  84454. /**
  84455. * If you want to launch only a few particles at once, that can be done, as well.
  84456. */
  84457. manualEmitCount: number;
  84458. /**
  84459. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84460. */
  84461. updateSpeed: number;
  84462. /**
  84463. * The amount of time the particle system is running (depends of the overall update speed).
  84464. */
  84465. targetStopDuration: number;
  84466. /**
  84467. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84468. */
  84469. disposeOnStop: boolean;
  84470. /**
  84471. * Minimum power of emitting particles.
  84472. */
  84473. minEmitPower: number;
  84474. /**
  84475. * Maximum power of emitting particles.
  84476. */
  84477. maxEmitPower: number;
  84478. /**
  84479. * Minimum life time of emitting particles.
  84480. */
  84481. minLifeTime: number;
  84482. /**
  84483. * Maximum life time of emitting particles.
  84484. */
  84485. maxLifeTime: number;
  84486. /**
  84487. * Minimum Size of emitting particles.
  84488. */
  84489. minSize: number;
  84490. /**
  84491. * Maximum Size of emitting particles.
  84492. */
  84493. maxSize: number;
  84494. /**
  84495. * Minimum scale of emitting particles on X axis.
  84496. */
  84497. minScaleX: number;
  84498. /**
  84499. * Maximum scale of emitting particles on X axis.
  84500. */
  84501. maxScaleX: number;
  84502. /**
  84503. * Minimum scale of emitting particles on Y axis.
  84504. */
  84505. minScaleY: number;
  84506. /**
  84507. * Maximum scale of emitting particles on Y axis.
  84508. */
  84509. maxScaleY: number;
  84510. /**
  84511. * Gets or sets the minimal initial rotation in radians.
  84512. */
  84513. minInitialRotation: number;
  84514. /**
  84515. * Gets or sets the maximal initial rotation in radians.
  84516. */
  84517. maxInitialRotation: number;
  84518. /**
  84519. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84520. */
  84521. minAngularSpeed: number;
  84522. /**
  84523. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84524. */
  84525. maxAngularSpeed: number;
  84526. /**
  84527. * The texture used to render each particle. (this can be a spritesheet)
  84528. */
  84529. particleTexture: Nullable<Texture>;
  84530. /**
  84531. * The layer mask we are rendering the particles through.
  84532. */
  84533. layerMask: number;
  84534. /**
  84535. * This can help using your own shader to render the particle system.
  84536. * The according effect will be created
  84537. */
  84538. customShader: any;
  84539. /**
  84540. * By default particle system starts as soon as they are created. This prevents the
  84541. * automatic start to happen and let you decide when to start emitting particles.
  84542. */
  84543. preventAutoStart: boolean;
  84544. private _noiseTexture;
  84545. /**
  84546. * Gets or sets a texture used to add random noise to particle positions
  84547. */
  84548. get noiseTexture(): Nullable<ProceduralTexture>;
  84549. set noiseTexture(value: Nullable<ProceduralTexture>);
  84550. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84551. noiseStrength: Vector3;
  84552. /**
  84553. * Callback triggered when the particle animation is ending.
  84554. */
  84555. onAnimationEnd: Nullable<() => void>;
  84556. /**
  84557. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84558. */
  84559. blendMode: number;
  84560. /**
  84561. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84562. * to override the particles.
  84563. */
  84564. forceDepthWrite: boolean;
  84565. /** 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 */
  84566. preWarmCycles: number;
  84567. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84568. preWarmStepOffset: number;
  84569. /**
  84570. * 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)
  84571. */
  84572. spriteCellChangeSpeed: number;
  84573. /**
  84574. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84575. */
  84576. startSpriteCellID: number;
  84577. /**
  84578. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84579. */
  84580. endSpriteCellID: number;
  84581. /**
  84582. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84583. */
  84584. spriteCellWidth: number;
  84585. /**
  84586. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84587. */
  84588. spriteCellHeight: number;
  84589. /**
  84590. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84591. */
  84592. spriteRandomStartCell: boolean;
  84593. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84594. translationPivot: Vector2;
  84595. /** @hidden */
  84596. protected _isAnimationSheetEnabled: boolean;
  84597. /**
  84598. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84599. */
  84600. beginAnimationOnStart: boolean;
  84601. /**
  84602. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84603. */
  84604. beginAnimationFrom: number;
  84605. /**
  84606. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84607. */
  84608. beginAnimationTo: number;
  84609. /**
  84610. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84611. */
  84612. beginAnimationLoop: boolean;
  84613. /**
  84614. * Gets or sets a world offset applied to all particles
  84615. */
  84616. worldOffset: Vector3;
  84617. /**
  84618. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84619. */
  84620. get isAnimationSheetEnabled(): boolean;
  84621. set isAnimationSheetEnabled(value: boolean);
  84622. /**
  84623. * Get hosting scene
  84624. * @returns the scene
  84625. */
  84626. getScene(): Scene;
  84627. /**
  84628. * You can use gravity if you want to give an orientation to your particles.
  84629. */
  84630. gravity: Vector3;
  84631. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84632. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84633. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84634. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84635. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84636. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84637. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84638. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84639. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84640. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84641. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84642. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84643. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84644. /**
  84645. * Defines the delay in milliseconds before starting the system (0 by default)
  84646. */
  84647. startDelay: number;
  84648. /**
  84649. * Gets the current list of drag gradients.
  84650. * You must use addDragGradient and removeDragGradient to udpate this list
  84651. * @returns the list of drag gradients
  84652. */
  84653. getDragGradients(): Nullable<Array<FactorGradient>>;
  84654. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84655. limitVelocityDamping: number;
  84656. /**
  84657. * Gets the current list of limit velocity gradients.
  84658. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84659. * @returns the list of limit velocity gradients
  84660. */
  84661. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84662. /**
  84663. * Gets the current list of color gradients.
  84664. * You must use addColorGradient and removeColorGradient to udpate this list
  84665. * @returns the list of color gradients
  84666. */
  84667. getColorGradients(): Nullable<Array<ColorGradient>>;
  84668. /**
  84669. * Gets the current list of size gradients.
  84670. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84671. * @returns the list of size gradients
  84672. */
  84673. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84674. /**
  84675. * Gets the current list of color remap gradients.
  84676. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84677. * @returns the list of color remap gradients
  84678. */
  84679. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84680. /**
  84681. * Gets the current list of alpha remap gradients.
  84682. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84683. * @returns the list of alpha remap gradients
  84684. */
  84685. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84686. /**
  84687. * Gets the current list of life time gradients.
  84688. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84689. * @returns the list of life time gradients
  84690. */
  84691. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84692. /**
  84693. * Gets the current list of angular speed gradients.
  84694. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84695. * @returns the list of angular speed gradients
  84696. */
  84697. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84698. /**
  84699. * Gets the current list of velocity gradients.
  84700. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84701. * @returns the list of velocity gradients
  84702. */
  84703. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84704. /**
  84705. * Gets the current list of start size gradients.
  84706. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84707. * @returns the list of start size gradients
  84708. */
  84709. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84710. /**
  84711. * Gets the current list of emit rate gradients.
  84712. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84713. * @returns the list of emit rate gradients
  84714. */
  84715. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84716. /**
  84717. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84718. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84719. */
  84720. get direction1(): Vector3;
  84721. set direction1(value: Vector3);
  84722. /**
  84723. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84724. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84725. */
  84726. get direction2(): Vector3;
  84727. set direction2(value: Vector3);
  84728. /**
  84729. * 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.
  84730. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84731. */
  84732. get minEmitBox(): Vector3;
  84733. set minEmitBox(value: Vector3);
  84734. /**
  84735. * 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.
  84736. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84737. */
  84738. get maxEmitBox(): Vector3;
  84739. set maxEmitBox(value: Vector3);
  84740. /**
  84741. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84742. */
  84743. color1: Color4;
  84744. /**
  84745. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84746. */
  84747. color2: Color4;
  84748. /**
  84749. * Color the particle will have at the end of its lifetime
  84750. */
  84751. colorDead: Color4;
  84752. /**
  84753. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84754. */
  84755. textureMask: Color4;
  84756. /**
  84757. * The particle emitter type defines the emitter used by the particle system.
  84758. * It can be for example box, sphere, or cone...
  84759. */
  84760. particleEmitterType: IParticleEmitterType;
  84761. /** @hidden */
  84762. _isSubEmitter: boolean;
  84763. /**
  84764. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84765. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84766. */
  84767. billboardMode: number;
  84768. protected _isBillboardBased: boolean;
  84769. /**
  84770. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84771. */
  84772. get isBillboardBased(): boolean;
  84773. set isBillboardBased(value: boolean);
  84774. /**
  84775. * The scene the particle system belongs to.
  84776. */
  84777. protected _scene: Scene;
  84778. /**
  84779. * Local cache of defines for image processing.
  84780. */
  84781. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84782. /**
  84783. * Default configuration related to image processing available in the standard Material.
  84784. */
  84785. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84786. /**
  84787. * Gets the image processing configuration used either in this material.
  84788. */
  84789. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84790. /**
  84791. * Sets the Default image processing configuration used either in the this material.
  84792. *
  84793. * If sets to null, the scene one is in use.
  84794. */
  84795. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84796. /**
  84797. * Attaches a new image processing configuration to the Standard Material.
  84798. * @param configuration
  84799. */
  84800. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84801. /** @hidden */
  84802. protected _reset(): void;
  84803. /** @hidden */
  84804. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84805. /**
  84806. * Instantiates a particle system.
  84807. * 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.
  84808. * @param name The name of the particle system
  84809. */
  84810. constructor(name: string);
  84811. /**
  84812. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84813. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84814. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84815. * @returns the emitter
  84816. */
  84817. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84818. /**
  84819. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84820. * @param radius The radius of the hemisphere to emit from
  84821. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84822. * @returns the emitter
  84823. */
  84824. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84825. /**
  84826. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84827. * @param radius The radius of the sphere to emit from
  84828. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84829. * @returns the emitter
  84830. */
  84831. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84832. /**
  84833. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84834. * @param radius The radius of the sphere to emit from
  84835. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84836. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84837. * @returns the emitter
  84838. */
  84839. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84840. /**
  84841. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84842. * @param radius The radius of the emission cylinder
  84843. * @param height The height of the emission cylinder
  84844. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84845. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84846. * @returns the emitter
  84847. */
  84848. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84849. /**
  84850. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84851. * @param radius The radius of the cylinder to emit from
  84852. * @param height The height of the emission cylinder
  84853. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84854. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84855. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84856. * @returns the emitter
  84857. */
  84858. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84859. /**
  84860. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84861. * @param radius The radius of the cone to emit from
  84862. * @param angle The base angle of the cone
  84863. * @returns the emitter
  84864. */
  84865. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84866. /**
  84867. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84868. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84869. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84870. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84871. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84872. * @returns the emitter
  84873. */
  84874. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84875. }
  84876. }
  84877. declare module BABYLON {
  84878. /**
  84879. * Type of sub emitter
  84880. */
  84881. export enum SubEmitterType {
  84882. /**
  84883. * Attached to the particle over it's lifetime
  84884. */
  84885. ATTACHED = 0,
  84886. /**
  84887. * Created when the particle dies
  84888. */
  84889. END = 1
  84890. }
  84891. /**
  84892. * Sub emitter class used to emit particles from an existing particle
  84893. */
  84894. export class SubEmitter {
  84895. /**
  84896. * the particle system to be used by the sub emitter
  84897. */
  84898. particleSystem: ParticleSystem;
  84899. /**
  84900. * Type of the submitter (Default: END)
  84901. */
  84902. type: SubEmitterType;
  84903. /**
  84904. * 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)
  84905. * Note: This only is supported when using an emitter of type Mesh
  84906. */
  84907. inheritDirection: boolean;
  84908. /**
  84909. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84910. */
  84911. inheritedVelocityAmount: number;
  84912. /**
  84913. * Creates a sub emitter
  84914. * @param particleSystem the particle system to be used by the sub emitter
  84915. */
  84916. constructor(
  84917. /**
  84918. * the particle system to be used by the sub emitter
  84919. */
  84920. particleSystem: ParticleSystem);
  84921. /**
  84922. * Clones the sub emitter
  84923. * @returns the cloned sub emitter
  84924. */
  84925. clone(): SubEmitter;
  84926. /**
  84927. * Serialize current object to a JSON object
  84928. * @returns the serialized object
  84929. */
  84930. serialize(): any;
  84931. /** @hidden */
  84932. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84933. /**
  84934. * Creates a new SubEmitter from a serialized JSON version
  84935. * @param serializationObject defines the JSON object to read from
  84936. * @param scene defines the hosting scene
  84937. * @param rootUrl defines the rootUrl for data loading
  84938. * @returns a new SubEmitter
  84939. */
  84940. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84941. /** Release associated resources */
  84942. dispose(): void;
  84943. }
  84944. }
  84945. declare module BABYLON {
  84946. /** @hidden */
  84947. export var imageProcessingDeclaration: {
  84948. name: string;
  84949. shader: string;
  84950. };
  84951. }
  84952. declare module BABYLON {
  84953. /** @hidden */
  84954. export var imageProcessingFunctions: {
  84955. name: string;
  84956. shader: string;
  84957. };
  84958. }
  84959. declare module BABYLON {
  84960. /** @hidden */
  84961. export var particlesPixelShader: {
  84962. name: string;
  84963. shader: string;
  84964. };
  84965. }
  84966. declare module BABYLON {
  84967. /** @hidden */
  84968. export var particlesVertexShader: {
  84969. name: string;
  84970. shader: string;
  84971. };
  84972. }
  84973. declare module BABYLON {
  84974. /**
  84975. * This represents a particle system in Babylon.
  84976. * 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.
  84977. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84978. * @example https://doc.babylonjs.com/babylon101/particles
  84979. */
  84980. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84981. /**
  84982. * Billboard mode will only apply to Y axis
  84983. */
  84984. static readonly BILLBOARDMODE_Y: number;
  84985. /**
  84986. * Billboard mode will apply to all axes
  84987. */
  84988. static readonly BILLBOARDMODE_ALL: number;
  84989. /**
  84990. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84991. */
  84992. static readonly BILLBOARDMODE_STRETCHED: number;
  84993. /**
  84994. * This function can be defined to provide custom update for active particles.
  84995. * This function will be called instead of regular update (age, position, color, etc.).
  84996. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84997. */
  84998. updateFunction: (particles: Particle[]) => void;
  84999. private _emitterWorldMatrix;
  85000. /**
  85001. * This function can be defined to specify initial direction for every new particle.
  85002. * It by default use the emitterType defined function
  85003. */
  85004. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85005. /**
  85006. * This function can be defined to specify initial position for every new particle.
  85007. * It by default use the emitterType defined function
  85008. */
  85009. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85010. /**
  85011. * @hidden
  85012. */
  85013. _inheritedVelocityOffset: Vector3;
  85014. /**
  85015. * An event triggered when the system is disposed
  85016. */
  85017. onDisposeObservable: Observable<ParticleSystem>;
  85018. private _onDisposeObserver;
  85019. /**
  85020. * Sets a callback that will be triggered when the system is disposed
  85021. */
  85022. set onDispose(callback: () => void);
  85023. private _particles;
  85024. private _epsilon;
  85025. private _capacity;
  85026. private _stockParticles;
  85027. private _newPartsExcess;
  85028. private _vertexData;
  85029. private _vertexBuffer;
  85030. private _vertexBuffers;
  85031. private _spriteBuffer;
  85032. private _indexBuffer;
  85033. private _effect;
  85034. private _customEffect;
  85035. private _cachedDefines;
  85036. private _scaledColorStep;
  85037. private _colorDiff;
  85038. private _scaledDirection;
  85039. private _scaledGravity;
  85040. private _currentRenderId;
  85041. private _alive;
  85042. private _useInstancing;
  85043. private _started;
  85044. private _stopped;
  85045. private _actualFrame;
  85046. private _scaledUpdateSpeed;
  85047. private _vertexBufferSize;
  85048. /** @hidden */
  85049. _currentEmitRateGradient: Nullable<FactorGradient>;
  85050. /** @hidden */
  85051. _currentEmitRate1: number;
  85052. /** @hidden */
  85053. _currentEmitRate2: number;
  85054. /** @hidden */
  85055. _currentStartSizeGradient: Nullable<FactorGradient>;
  85056. /** @hidden */
  85057. _currentStartSize1: number;
  85058. /** @hidden */
  85059. _currentStartSize2: number;
  85060. private readonly _rawTextureWidth;
  85061. private _rampGradientsTexture;
  85062. private _useRampGradients;
  85063. /** Gets or sets a boolean indicating that ramp gradients must be used
  85064. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85065. */
  85066. get useRampGradients(): boolean;
  85067. set useRampGradients(value: boolean);
  85068. /**
  85069. * 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.
  85070. * 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: [])
  85071. */
  85072. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85073. private _subEmitters;
  85074. /**
  85075. * @hidden
  85076. * If the particle systems emitter should be disposed when the particle system is disposed
  85077. */
  85078. _disposeEmitterOnDispose: boolean;
  85079. /**
  85080. * The current active Sub-systems, this property is used by the root particle system only.
  85081. */
  85082. activeSubSystems: Array<ParticleSystem>;
  85083. /**
  85084. * Specifies if the particles are updated in emitter local space or world space
  85085. */
  85086. isLocal: boolean;
  85087. private _rootParticleSystem;
  85088. /**
  85089. * Gets the current list of active particles
  85090. */
  85091. get particles(): Particle[];
  85092. /**
  85093. * Returns the string "ParticleSystem"
  85094. * @returns a string containing the class name
  85095. */
  85096. getClassName(): string;
  85097. /**
  85098. * Instantiates a particle system.
  85099. * 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.
  85100. * @param name The name of the particle system
  85101. * @param capacity The max number of particles alive at the same time
  85102. * @param scene The scene the particle system belongs to
  85103. * @param customEffect a custom effect used to change the way particles are rendered by default
  85104. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85105. * @param epsilon Offset used to render the particles
  85106. */
  85107. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85108. private _addFactorGradient;
  85109. private _removeFactorGradient;
  85110. /**
  85111. * Adds a new life time gradient
  85112. * @param gradient defines the gradient to use (between 0 and 1)
  85113. * @param factor defines the life time factor to affect to the specified gradient
  85114. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85115. * @returns the current particle system
  85116. */
  85117. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85118. /**
  85119. * Remove a specific life time gradient
  85120. * @param gradient defines the gradient to remove
  85121. * @returns the current particle system
  85122. */
  85123. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85124. /**
  85125. * Adds a new size gradient
  85126. * @param gradient defines the gradient to use (between 0 and 1)
  85127. * @param factor defines the size factor to affect to the specified gradient
  85128. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85129. * @returns the current particle system
  85130. */
  85131. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85132. /**
  85133. * Remove a specific size gradient
  85134. * @param gradient defines the gradient to remove
  85135. * @returns the current particle system
  85136. */
  85137. removeSizeGradient(gradient: number): IParticleSystem;
  85138. /**
  85139. * Adds a new color remap gradient
  85140. * @param gradient defines the gradient to use (between 0 and 1)
  85141. * @param min defines the color remap minimal range
  85142. * @param max defines the color remap maximal range
  85143. * @returns the current particle system
  85144. */
  85145. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85146. /**
  85147. * Remove a specific color remap gradient
  85148. * @param gradient defines the gradient to remove
  85149. * @returns the current particle system
  85150. */
  85151. removeColorRemapGradient(gradient: number): IParticleSystem;
  85152. /**
  85153. * Adds a new alpha remap gradient
  85154. * @param gradient defines the gradient to use (between 0 and 1)
  85155. * @param min defines the alpha remap minimal range
  85156. * @param max defines the alpha remap maximal range
  85157. * @returns the current particle system
  85158. */
  85159. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85160. /**
  85161. * Remove a specific alpha remap gradient
  85162. * @param gradient defines the gradient to remove
  85163. * @returns the current particle system
  85164. */
  85165. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85166. /**
  85167. * Adds a new angular speed gradient
  85168. * @param gradient defines the gradient to use (between 0 and 1)
  85169. * @param factor defines the angular speed to affect to the specified gradient
  85170. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85171. * @returns the current particle system
  85172. */
  85173. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85174. /**
  85175. * Remove a specific angular speed gradient
  85176. * @param gradient defines the gradient to remove
  85177. * @returns the current particle system
  85178. */
  85179. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85180. /**
  85181. * Adds a new velocity gradient
  85182. * @param gradient defines the gradient to use (between 0 and 1)
  85183. * @param factor defines the velocity to affect to the specified gradient
  85184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85185. * @returns the current particle system
  85186. */
  85187. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85188. /**
  85189. * Remove a specific velocity gradient
  85190. * @param gradient defines the gradient to remove
  85191. * @returns the current particle system
  85192. */
  85193. removeVelocityGradient(gradient: number): IParticleSystem;
  85194. /**
  85195. * Adds a new limit velocity gradient
  85196. * @param gradient defines the gradient to use (between 0 and 1)
  85197. * @param factor defines the limit velocity value to affect to the specified gradient
  85198. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85199. * @returns the current particle system
  85200. */
  85201. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85202. /**
  85203. * Remove a specific limit velocity gradient
  85204. * @param gradient defines the gradient to remove
  85205. * @returns the current particle system
  85206. */
  85207. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85208. /**
  85209. * Adds a new drag gradient
  85210. * @param gradient defines the gradient to use (between 0 and 1)
  85211. * @param factor defines the drag value to affect to the specified gradient
  85212. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85213. * @returns the current particle system
  85214. */
  85215. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85216. /**
  85217. * Remove a specific drag gradient
  85218. * @param gradient defines the gradient to remove
  85219. * @returns the current particle system
  85220. */
  85221. removeDragGradient(gradient: number): IParticleSystem;
  85222. /**
  85223. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85224. * @param gradient defines the gradient to use (between 0 and 1)
  85225. * @param factor defines the emit rate value to affect to the specified gradient
  85226. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85227. * @returns the current particle system
  85228. */
  85229. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85230. /**
  85231. * Remove a specific emit rate gradient
  85232. * @param gradient defines the gradient to remove
  85233. * @returns the current particle system
  85234. */
  85235. removeEmitRateGradient(gradient: number): IParticleSystem;
  85236. /**
  85237. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85238. * @param gradient defines the gradient to use (between 0 and 1)
  85239. * @param factor defines the start size value to affect to the specified gradient
  85240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85241. * @returns the current particle system
  85242. */
  85243. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85244. /**
  85245. * Remove a specific start size gradient
  85246. * @param gradient defines the gradient to remove
  85247. * @returns the current particle system
  85248. */
  85249. removeStartSizeGradient(gradient: number): IParticleSystem;
  85250. private _createRampGradientTexture;
  85251. /**
  85252. * Gets the current list of ramp gradients.
  85253. * You must use addRampGradient and removeRampGradient to udpate this list
  85254. * @returns the list of ramp gradients
  85255. */
  85256. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85257. /**
  85258. * Adds a new ramp gradient used to remap particle colors
  85259. * @param gradient defines the gradient to use (between 0 and 1)
  85260. * @param color defines the color to affect to the specified gradient
  85261. * @returns the current particle system
  85262. */
  85263. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85264. /**
  85265. * Remove a specific ramp gradient
  85266. * @param gradient defines the gradient to remove
  85267. * @returns the current particle system
  85268. */
  85269. removeRampGradient(gradient: number): ParticleSystem;
  85270. /**
  85271. * Adds a new color gradient
  85272. * @param gradient defines the gradient to use (between 0 and 1)
  85273. * @param color1 defines the color to affect to the specified gradient
  85274. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85275. * @returns this particle system
  85276. */
  85277. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85278. /**
  85279. * Remove a specific color gradient
  85280. * @param gradient defines the gradient to remove
  85281. * @returns this particle system
  85282. */
  85283. removeColorGradient(gradient: number): IParticleSystem;
  85284. private _fetchR;
  85285. protected _reset(): void;
  85286. private _resetEffect;
  85287. private _createVertexBuffers;
  85288. private _createIndexBuffer;
  85289. /**
  85290. * Gets the maximum number of particles active at the same time.
  85291. * @returns The max number of active particles.
  85292. */
  85293. getCapacity(): number;
  85294. /**
  85295. * Gets whether there are still active particles in the system.
  85296. * @returns True if it is alive, otherwise false.
  85297. */
  85298. isAlive(): boolean;
  85299. /**
  85300. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85301. * @returns True if it has been started, otherwise false.
  85302. */
  85303. isStarted(): boolean;
  85304. private _prepareSubEmitterInternalArray;
  85305. /**
  85306. * Starts the particle system and begins to emit
  85307. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85308. */
  85309. start(delay?: number): void;
  85310. /**
  85311. * Stops the particle system.
  85312. * @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.
  85313. */
  85314. stop(stopSubEmitters?: boolean): void;
  85315. /**
  85316. * Remove all active particles
  85317. */
  85318. reset(): void;
  85319. /**
  85320. * @hidden (for internal use only)
  85321. */
  85322. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85323. /**
  85324. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85325. * Its lifetime will start back at 0.
  85326. */
  85327. recycleParticle: (particle: Particle) => void;
  85328. private _stopSubEmitters;
  85329. private _createParticle;
  85330. private _removeFromRoot;
  85331. private _emitFromParticle;
  85332. private _update;
  85333. /** @hidden */
  85334. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85335. /** @hidden */
  85336. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85337. /** @hidden */
  85338. private _getEffect;
  85339. /**
  85340. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85341. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85342. */
  85343. animate(preWarmOnly?: boolean): void;
  85344. private _appendParticleVertices;
  85345. /**
  85346. * Rebuilds the particle system.
  85347. */
  85348. rebuild(): void;
  85349. /**
  85350. * Is this system ready to be used/rendered
  85351. * @return true if the system is ready
  85352. */
  85353. isReady(): boolean;
  85354. private _render;
  85355. /**
  85356. * Renders the particle system in its current state.
  85357. * @returns the current number of particles
  85358. */
  85359. render(): number;
  85360. /**
  85361. * Disposes the particle system and free the associated resources
  85362. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85363. */
  85364. dispose(disposeTexture?: boolean): void;
  85365. /**
  85366. * Clones the particle system.
  85367. * @param name The name of the cloned object
  85368. * @param newEmitter The new emitter to use
  85369. * @returns the cloned particle system
  85370. */
  85371. clone(name: string, newEmitter: any): ParticleSystem;
  85372. /**
  85373. * Serializes the particle system to a JSON object.
  85374. * @returns the JSON object
  85375. */
  85376. serialize(): any;
  85377. /** @hidden */
  85378. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85379. /** @hidden */
  85380. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85381. /**
  85382. * Parses a JSON object to create a particle system.
  85383. * @param parsedParticleSystem The JSON object to parse
  85384. * @param scene The scene to create the particle system in
  85385. * @param rootUrl The root url to use to load external dependencies like texture
  85386. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85387. * @returns the Parsed particle system
  85388. */
  85389. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85390. }
  85391. }
  85392. declare module BABYLON {
  85393. /**
  85394. * A particle represents one of the element emitted by a particle system.
  85395. * This is mainly define by its coordinates, direction, velocity and age.
  85396. */
  85397. export class Particle {
  85398. /**
  85399. * The particle system the particle belongs to.
  85400. */
  85401. particleSystem: ParticleSystem;
  85402. private static _Count;
  85403. /**
  85404. * Unique ID of the particle
  85405. */
  85406. id: number;
  85407. /**
  85408. * The world position of the particle in the scene.
  85409. */
  85410. position: Vector3;
  85411. /**
  85412. * The world direction of the particle in the scene.
  85413. */
  85414. direction: Vector3;
  85415. /**
  85416. * The color of the particle.
  85417. */
  85418. color: Color4;
  85419. /**
  85420. * The color change of the particle per step.
  85421. */
  85422. colorStep: Color4;
  85423. /**
  85424. * Defines how long will the life of the particle be.
  85425. */
  85426. lifeTime: number;
  85427. /**
  85428. * The current age of the particle.
  85429. */
  85430. age: number;
  85431. /**
  85432. * The current size of the particle.
  85433. */
  85434. size: number;
  85435. /**
  85436. * The current scale of the particle.
  85437. */
  85438. scale: Vector2;
  85439. /**
  85440. * The current angle of the particle.
  85441. */
  85442. angle: number;
  85443. /**
  85444. * Defines how fast is the angle changing.
  85445. */
  85446. angularSpeed: number;
  85447. /**
  85448. * Defines the cell index used by the particle to be rendered from a sprite.
  85449. */
  85450. cellIndex: number;
  85451. /**
  85452. * The information required to support color remapping
  85453. */
  85454. remapData: Vector4;
  85455. /** @hidden */
  85456. _randomCellOffset?: number;
  85457. /** @hidden */
  85458. _initialDirection: Nullable<Vector3>;
  85459. /** @hidden */
  85460. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85461. /** @hidden */
  85462. _initialStartSpriteCellID: number;
  85463. /** @hidden */
  85464. _initialEndSpriteCellID: number;
  85465. /** @hidden */
  85466. _currentColorGradient: Nullable<ColorGradient>;
  85467. /** @hidden */
  85468. _currentColor1: Color4;
  85469. /** @hidden */
  85470. _currentColor2: Color4;
  85471. /** @hidden */
  85472. _currentSizeGradient: Nullable<FactorGradient>;
  85473. /** @hidden */
  85474. _currentSize1: number;
  85475. /** @hidden */
  85476. _currentSize2: number;
  85477. /** @hidden */
  85478. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85479. /** @hidden */
  85480. _currentAngularSpeed1: number;
  85481. /** @hidden */
  85482. _currentAngularSpeed2: number;
  85483. /** @hidden */
  85484. _currentVelocityGradient: Nullable<FactorGradient>;
  85485. /** @hidden */
  85486. _currentVelocity1: number;
  85487. /** @hidden */
  85488. _currentVelocity2: number;
  85489. /** @hidden */
  85490. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85491. /** @hidden */
  85492. _currentLimitVelocity1: number;
  85493. /** @hidden */
  85494. _currentLimitVelocity2: number;
  85495. /** @hidden */
  85496. _currentDragGradient: Nullable<FactorGradient>;
  85497. /** @hidden */
  85498. _currentDrag1: number;
  85499. /** @hidden */
  85500. _currentDrag2: number;
  85501. /** @hidden */
  85502. _randomNoiseCoordinates1: Vector3;
  85503. /** @hidden */
  85504. _randomNoiseCoordinates2: Vector3;
  85505. /** @hidden */
  85506. _localPosition?: Vector3;
  85507. /**
  85508. * Creates a new instance Particle
  85509. * @param particleSystem the particle system the particle belongs to
  85510. */
  85511. constructor(
  85512. /**
  85513. * The particle system the particle belongs to.
  85514. */
  85515. particleSystem: ParticleSystem);
  85516. private updateCellInfoFromSystem;
  85517. /**
  85518. * Defines how the sprite cell index is updated for the particle
  85519. */
  85520. updateCellIndex(): void;
  85521. /** @hidden */
  85522. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85523. /** @hidden */
  85524. _inheritParticleInfoToSubEmitters(): void;
  85525. /** @hidden */
  85526. _reset(): void;
  85527. /**
  85528. * Copy the properties of particle to another one.
  85529. * @param other the particle to copy the information to.
  85530. */
  85531. copyTo(other: Particle): void;
  85532. }
  85533. }
  85534. declare module BABYLON {
  85535. /**
  85536. * Particle emitter represents a volume emitting particles.
  85537. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85538. */
  85539. export interface IParticleEmitterType {
  85540. /**
  85541. * Called by the particle System when the direction is computed for the created particle.
  85542. * @param worldMatrix is the world matrix of the particle system
  85543. * @param directionToUpdate is the direction vector to update with the result
  85544. * @param particle is the particle we are computed the direction for
  85545. * @param isLocal defines if the direction should be set in local space
  85546. */
  85547. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85548. /**
  85549. * Called by the particle System when the position is computed for the created particle.
  85550. * @param worldMatrix is the world matrix of the particle system
  85551. * @param positionToUpdate is the position vector to update with the result
  85552. * @param particle is the particle we are computed the position for
  85553. * @param isLocal defines if the position should be set in local space
  85554. */
  85555. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85556. /**
  85557. * Clones the current emitter and returns a copy of it
  85558. * @returns the new emitter
  85559. */
  85560. clone(): IParticleEmitterType;
  85561. /**
  85562. * Called by the GPUParticleSystem to setup the update shader
  85563. * @param effect defines the update shader
  85564. */
  85565. applyToShader(effect: Effect): void;
  85566. /**
  85567. * Returns a string to use to update the GPU particles update shader
  85568. * @returns the effect defines string
  85569. */
  85570. getEffectDefines(): string;
  85571. /**
  85572. * Returns a string representing the class name
  85573. * @returns a string containing the class name
  85574. */
  85575. getClassName(): string;
  85576. /**
  85577. * Serializes the particle system to a JSON object.
  85578. * @returns the JSON object
  85579. */
  85580. serialize(): any;
  85581. /**
  85582. * Parse properties from a JSON object
  85583. * @param serializationObject defines the JSON object
  85584. * @param scene defines the hosting scene
  85585. */
  85586. parse(serializationObject: any, scene: Scene): void;
  85587. }
  85588. }
  85589. declare module BABYLON {
  85590. /**
  85591. * Particle emitter emitting particles from the inside of a box.
  85592. * It emits the particles randomly between 2 given directions.
  85593. */
  85594. export class BoxParticleEmitter implements IParticleEmitterType {
  85595. /**
  85596. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85597. */
  85598. direction1: Vector3;
  85599. /**
  85600. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85601. */
  85602. direction2: Vector3;
  85603. /**
  85604. * 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.
  85605. */
  85606. minEmitBox: Vector3;
  85607. /**
  85608. * 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.
  85609. */
  85610. maxEmitBox: Vector3;
  85611. /**
  85612. * Creates a new instance BoxParticleEmitter
  85613. */
  85614. constructor();
  85615. /**
  85616. * Called by the particle System when the direction is computed for the created particle.
  85617. * @param worldMatrix is the world matrix of the particle system
  85618. * @param directionToUpdate is the direction vector to update with the result
  85619. * @param particle is the particle we are computed the direction for
  85620. * @param isLocal defines if the direction should be set in local space
  85621. */
  85622. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85623. /**
  85624. * Called by the particle System when the position is computed for the created particle.
  85625. * @param worldMatrix is the world matrix of the particle system
  85626. * @param positionToUpdate is the position vector to update with the result
  85627. * @param particle is the particle we are computed the position for
  85628. * @param isLocal defines if the position should be set in local space
  85629. */
  85630. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85631. /**
  85632. * Clones the current emitter and returns a copy of it
  85633. * @returns the new emitter
  85634. */
  85635. clone(): BoxParticleEmitter;
  85636. /**
  85637. * Called by the GPUParticleSystem to setup the update shader
  85638. * @param effect defines the update shader
  85639. */
  85640. applyToShader(effect: Effect): void;
  85641. /**
  85642. * Returns a string to use to update the GPU particles update shader
  85643. * @returns a string containng the defines string
  85644. */
  85645. getEffectDefines(): string;
  85646. /**
  85647. * Returns the string "BoxParticleEmitter"
  85648. * @returns a string containing the class name
  85649. */
  85650. getClassName(): string;
  85651. /**
  85652. * Serializes the particle system to a JSON object.
  85653. * @returns the JSON object
  85654. */
  85655. serialize(): any;
  85656. /**
  85657. * Parse properties from a JSON object
  85658. * @param serializationObject defines the JSON object
  85659. */
  85660. parse(serializationObject: any): void;
  85661. }
  85662. }
  85663. declare module BABYLON {
  85664. /**
  85665. * Particle emitter emitting particles from the inside of a cone.
  85666. * It emits the particles alongside the cone volume from the base to the particle.
  85667. * The emission direction might be randomized.
  85668. */
  85669. export class ConeParticleEmitter implements IParticleEmitterType {
  85670. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85671. directionRandomizer: number;
  85672. private _radius;
  85673. private _angle;
  85674. private _height;
  85675. /**
  85676. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85677. */
  85678. radiusRange: number;
  85679. /**
  85680. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85681. */
  85682. heightRange: number;
  85683. /**
  85684. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85685. */
  85686. emitFromSpawnPointOnly: boolean;
  85687. /**
  85688. * Gets or sets the radius of the emission cone
  85689. */
  85690. get radius(): number;
  85691. set radius(value: number);
  85692. /**
  85693. * Gets or sets the angle of the emission cone
  85694. */
  85695. get angle(): number;
  85696. set angle(value: number);
  85697. private _buildHeight;
  85698. /**
  85699. * Creates a new instance ConeParticleEmitter
  85700. * @param radius the radius of the emission cone (1 by default)
  85701. * @param angle the cone base angle (PI by default)
  85702. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85703. */
  85704. constructor(radius?: number, angle?: number,
  85705. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85706. directionRandomizer?: number);
  85707. /**
  85708. * Called by the particle System when the direction is computed for the created particle.
  85709. * @param worldMatrix is the world matrix of the particle system
  85710. * @param directionToUpdate is the direction vector to update with the result
  85711. * @param particle is the particle we are computed the direction for
  85712. * @param isLocal defines if the direction should be set in local space
  85713. */
  85714. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85715. /**
  85716. * Called by the particle System when the position is computed for the created particle.
  85717. * @param worldMatrix is the world matrix of the particle system
  85718. * @param positionToUpdate is the position vector to update with the result
  85719. * @param particle is the particle we are computed the position for
  85720. * @param isLocal defines if the position should be set in local space
  85721. */
  85722. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85723. /**
  85724. * Clones the current emitter and returns a copy of it
  85725. * @returns the new emitter
  85726. */
  85727. clone(): ConeParticleEmitter;
  85728. /**
  85729. * Called by the GPUParticleSystem to setup the update shader
  85730. * @param effect defines the update shader
  85731. */
  85732. applyToShader(effect: Effect): void;
  85733. /**
  85734. * Returns a string to use to update the GPU particles update shader
  85735. * @returns a string containng the defines string
  85736. */
  85737. getEffectDefines(): string;
  85738. /**
  85739. * Returns the string "ConeParticleEmitter"
  85740. * @returns a string containing the class name
  85741. */
  85742. getClassName(): string;
  85743. /**
  85744. * Serializes the particle system to a JSON object.
  85745. * @returns the JSON object
  85746. */
  85747. serialize(): any;
  85748. /**
  85749. * Parse properties from a JSON object
  85750. * @param serializationObject defines the JSON object
  85751. */
  85752. parse(serializationObject: any): void;
  85753. }
  85754. }
  85755. declare module BABYLON {
  85756. /**
  85757. * Particle emitter emitting particles from the inside of a cylinder.
  85758. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85759. */
  85760. export class CylinderParticleEmitter implements IParticleEmitterType {
  85761. /**
  85762. * The radius of the emission cylinder.
  85763. */
  85764. radius: number;
  85765. /**
  85766. * The height of the emission cylinder.
  85767. */
  85768. height: number;
  85769. /**
  85770. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85771. */
  85772. radiusRange: number;
  85773. /**
  85774. * How much to randomize the particle direction [0-1].
  85775. */
  85776. directionRandomizer: number;
  85777. /**
  85778. * Creates a new instance CylinderParticleEmitter
  85779. * @param radius the radius of the emission cylinder (1 by default)
  85780. * @param height the height of the emission cylinder (1 by default)
  85781. * @param radiusRange the range of the emission cylinder [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 cylinder.
  85787. */
  85788. radius?: number,
  85789. /**
  85790. * The height of the emission cylinder.
  85791. */
  85792. height?: number,
  85793. /**
  85794. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85795. */
  85796. radiusRange?: number,
  85797. /**
  85798. * How much to randomize the particle direction [0-1].
  85799. */
  85800. directionRandomizer?: number);
  85801. /**
  85802. * Called by the particle System when the direction is computed for the created particle.
  85803. * @param worldMatrix is the world matrix of the particle system
  85804. * @param directionToUpdate is the direction vector to update with the result
  85805. * @param particle is the particle we are computed the direction for
  85806. * @param isLocal defines if the direction should be set in local space
  85807. */
  85808. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85809. /**
  85810. * Called by the particle System when the position is computed for the created particle.
  85811. * @param worldMatrix is the world matrix of the particle system
  85812. * @param positionToUpdate is the position vector to update with the result
  85813. * @param particle is the particle we are computed the position for
  85814. * @param isLocal defines if the position should be set in local space
  85815. */
  85816. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85817. /**
  85818. * Clones the current emitter and returns a copy of it
  85819. * @returns the new emitter
  85820. */
  85821. clone(): CylinderParticleEmitter;
  85822. /**
  85823. * Called by the GPUParticleSystem to setup the update shader
  85824. * @param effect defines the update shader
  85825. */
  85826. applyToShader(effect: Effect): void;
  85827. /**
  85828. * Returns a string to use to update the GPU particles update shader
  85829. * @returns a string containng the defines string
  85830. */
  85831. getEffectDefines(): string;
  85832. /**
  85833. * Returns the string "CylinderParticleEmitter"
  85834. * @returns a string containing the class name
  85835. */
  85836. getClassName(): string;
  85837. /**
  85838. * Serializes the particle system to a JSON object.
  85839. * @returns the JSON object
  85840. */
  85841. serialize(): any;
  85842. /**
  85843. * Parse properties from a JSON object
  85844. * @param serializationObject defines the JSON object
  85845. */
  85846. parse(serializationObject: any): void;
  85847. }
  85848. /**
  85849. * Particle emitter emitting particles from the inside of a cylinder.
  85850. * It emits the particles randomly between two vectors.
  85851. */
  85852. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85853. /**
  85854. * The min limit of the emission direction.
  85855. */
  85856. direction1: Vector3;
  85857. /**
  85858. * The max limit of the emission direction.
  85859. */
  85860. direction2: Vector3;
  85861. /**
  85862. * Creates a new instance CylinderDirectedParticleEmitter
  85863. * @param radius the radius of the emission cylinder (1 by default)
  85864. * @param height the height of the emission cylinder (1 by default)
  85865. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85866. * @param direction1 the min limit of the emission direction (up vector by default)
  85867. * @param direction2 the max limit of the emission direction (up vector by default)
  85868. */
  85869. constructor(radius?: number, height?: number, radiusRange?: number,
  85870. /**
  85871. * The min limit of the emission direction.
  85872. */
  85873. direction1?: Vector3,
  85874. /**
  85875. * The max limit of the emission direction.
  85876. */
  85877. direction2?: Vector3);
  85878. /**
  85879. * Called by the particle System when the direction is computed for the created particle.
  85880. * @param worldMatrix is the world matrix of the particle system
  85881. * @param directionToUpdate is the direction vector to update with the result
  85882. * @param particle is the particle we are computed the direction for
  85883. */
  85884. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85885. /**
  85886. * Clones the current emitter and returns a copy of it
  85887. * @returns the new emitter
  85888. */
  85889. clone(): CylinderDirectedParticleEmitter;
  85890. /**
  85891. * Called by the GPUParticleSystem to setup the update shader
  85892. * @param effect defines the update shader
  85893. */
  85894. applyToShader(effect: Effect): void;
  85895. /**
  85896. * Returns a string to use to update the GPU particles update shader
  85897. * @returns a string containng the defines string
  85898. */
  85899. getEffectDefines(): string;
  85900. /**
  85901. * Returns the string "CylinderDirectedParticleEmitter"
  85902. * @returns a string containing the class name
  85903. */
  85904. getClassName(): string;
  85905. /**
  85906. * Serializes the particle system to a JSON object.
  85907. * @returns the JSON object
  85908. */
  85909. serialize(): any;
  85910. /**
  85911. * Parse properties from a JSON object
  85912. * @param serializationObject defines the JSON object
  85913. */
  85914. parse(serializationObject: any): void;
  85915. }
  85916. }
  85917. declare module BABYLON {
  85918. /**
  85919. * Particle emitter emitting particles from the inside of a hemisphere.
  85920. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85921. */
  85922. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85923. /**
  85924. * The radius of the emission hemisphere.
  85925. */
  85926. radius: number;
  85927. /**
  85928. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85929. */
  85930. radiusRange: number;
  85931. /**
  85932. * How much to randomize the particle direction [0-1].
  85933. */
  85934. directionRandomizer: number;
  85935. /**
  85936. * Creates a new instance HemisphericParticleEmitter
  85937. * @param radius the radius of the emission hemisphere (1 by default)
  85938. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85939. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85940. */
  85941. constructor(
  85942. /**
  85943. * The radius of the emission hemisphere.
  85944. */
  85945. radius?: number,
  85946. /**
  85947. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85948. */
  85949. radiusRange?: number,
  85950. /**
  85951. * How much to randomize the particle direction [0-1].
  85952. */
  85953. directionRandomizer?: number);
  85954. /**
  85955. * Called by the particle System when the direction is computed for the created particle.
  85956. * @param worldMatrix is the world matrix of the particle system
  85957. * @param directionToUpdate is the direction vector to update with the result
  85958. * @param particle is the particle we are computed the direction for
  85959. * @param isLocal defines if the direction should be set in local space
  85960. */
  85961. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85962. /**
  85963. * Called by the particle System when the position is computed for the created particle.
  85964. * @param worldMatrix is the world matrix of the particle system
  85965. * @param positionToUpdate is the position vector to update with the result
  85966. * @param particle is the particle we are computed the position for
  85967. * @param isLocal defines if the position should be set in local space
  85968. */
  85969. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85970. /**
  85971. * Clones the current emitter and returns a copy of it
  85972. * @returns the new emitter
  85973. */
  85974. clone(): HemisphericParticleEmitter;
  85975. /**
  85976. * Called by the GPUParticleSystem to setup the update shader
  85977. * @param effect defines the update shader
  85978. */
  85979. applyToShader(effect: Effect): void;
  85980. /**
  85981. * Returns a string to use to update the GPU particles update shader
  85982. * @returns a string containng the defines string
  85983. */
  85984. getEffectDefines(): string;
  85985. /**
  85986. * Returns the string "HemisphericParticleEmitter"
  85987. * @returns a string containing the class name
  85988. */
  85989. getClassName(): string;
  85990. /**
  85991. * Serializes the particle system to a JSON object.
  85992. * @returns the JSON object
  85993. */
  85994. serialize(): any;
  85995. /**
  85996. * Parse properties from a JSON object
  85997. * @param serializationObject defines the JSON object
  85998. */
  85999. parse(serializationObject: any): void;
  86000. }
  86001. }
  86002. declare module BABYLON {
  86003. /**
  86004. * Particle emitter emitting particles from a point.
  86005. * It emits the particles randomly between 2 given directions.
  86006. */
  86007. export class PointParticleEmitter implements IParticleEmitterType {
  86008. /**
  86009. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86010. */
  86011. direction1: Vector3;
  86012. /**
  86013. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86014. */
  86015. direction2: Vector3;
  86016. /**
  86017. * Creates a new instance PointParticleEmitter
  86018. */
  86019. constructor();
  86020. /**
  86021. * Called by the particle System when the direction is computed for the created particle.
  86022. * @param worldMatrix is the world matrix of the particle system
  86023. * @param directionToUpdate is the direction vector to update with the result
  86024. * @param particle is the particle we are computed the direction for
  86025. * @param isLocal defines if the direction should be set in local space
  86026. */
  86027. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86028. /**
  86029. * Called by the particle System when the position is computed for the created particle.
  86030. * @param worldMatrix is the world matrix of the particle system
  86031. * @param positionToUpdate is the position vector to update with the result
  86032. * @param particle is the particle we are computed the position for
  86033. * @param isLocal defines if the position should be set in local space
  86034. */
  86035. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86036. /**
  86037. * Clones the current emitter and returns a copy of it
  86038. * @returns the new emitter
  86039. */
  86040. clone(): PointParticleEmitter;
  86041. /**
  86042. * Called by the GPUParticleSystem to setup the update shader
  86043. * @param effect defines the update shader
  86044. */
  86045. applyToShader(effect: Effect): void;
  86046. /**
  86047. * Returns a string to use to update the GPU particles update shader
  86048. * @returns a string containng the defines string
  86049. */
  86050. getEffectDefines(): string;
  86051. /**
  86052. * Returns the string "PointParticleEmitter"
  86053. * @returns a string containing the class name
  86054. */
  86055. getClassName(): string;
  86056. /**
  86057. * Serializes the particle system to a JSON object.
  86058. * @returns the JSON object
  86059. */
  86060. serialize(): any;
  86061. /**
  86062. * Parse properties from a JSON object
  86063. * @param serializationObject defines the JSON object
  86064. */
  86065. parse(serializationObject: any): void;
  86066. }
  86067. }
  86068. declare module BABYLON {
  86069. /**
  86070. * Particle emitter emitting particles from the inside of a sphere.
  86071. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86072. */
  86073. export class SphereParticleEmitter implements IParticleEmitterType {
  86074. /**
  86075. * The radius of the emission sphere.
  86076. */
  86077. radius: number;
  86078. /**
  86079. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86080. */
  86081. radiusRange: number;
  86082. /**
  86083. * How much to randomize the particle direction [0-1].
  86084. */
  86085. directionRandomizer: number;
  86086. /**
  86087. * Creates a new instance SphereParticleEmitter
  86088. * @param radius the radius of the emission sphere (1 by default)
  86089. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86090. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86091. */
  86092. constructor(
  86093. /**
  86094. * The radius of the emission sphere.
  86095. */
  86096. radius?: number,
  86097. /**
  86098. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86099. */
  86100. radiusRange?: number,
  86101. /**
  86102. * How much to randomize the particle direction [0-1].
  86103. */
  86104. directionRandomizer?: number);
  86105. /**
  86106. * Called by the particle System when the direction is computed for the created particle.
  86107. * @param worldMatrix is the world matrix of the particle system
  86108. * @param directionToUpdate is the direction vector to update with the result
  86109. * @param particle is the particle we are computed the direction for
  86110. * @param isLocal defines if the direction should be set in local space
  86111. */
  86112. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86113. /**
  86114. * Called by the particle System when the position is computed for the created particle.
  86115. * @param worldMatrix is the world matrix of the particle system
  86116. * @param positionToUpdate is the position vector to update with the result
  86117. * @param particle is the particle we are computed the position for
  86118. * @param isLocal defines if the position should be set in local space
  86119. */
  86120. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86121. /**
  86122. * Clones the current emitter and returns a copy of it
  86123. * @returns the new emitter
  86124. */
  86125. clone(): SphereParticleEmitter;
  86126. /**
  86127. * Called by the GPUParticleSystem to setup the update shader
  86128. * @param effect defines the update shader
  86129. */
  86130. applyToShader(effect: Effect): void;
  86131. /**
  86132. * Returns a string to use to update the GPU particles update shader
  86133. * @returns a string containng the defines string
  86134. */
  86135. getEffectDefines(): string;
  86136. /**
  86137. * Returns the string "SphereParticleEmitter"
  86138. * @returns a string containing the class name
  86139. */
  86140. getClassName(): string;
  86141. /**
  86142. * Serializes the particle system to a JSON object.
  86143. * @returns the JSON object
  86144. */
  86145. serialize(): any;
  86146. /**
  86147. * Parse properties from a JSON object
  86148. * @param serializationObject defines the JSON object
  86149. */
  86150. parse(serializationObject: any): void;
  86151. }
  86152. /**
  86153. * Particle emitter emitting particles from the inside of a sphere.
  86154. * It emits the particles randomly between two vectors.
  86155. */
  86156. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86157. /**
  86158. * The min limit of the emission direction.
  86159. */
  86160. direction1: Vector3;
  86161. /**
  86162. * The max limit of the emission direction.
  86163. */
  86164. direction2: Vector3;
  86165. /**
  86166. * Creates a new instance SphereDirectedParticleEmitter
  86167. * @param radius the radius of the emission sphere (1 by default)
  86168. * @param direction1 the min limit of the emission direction (up vector by default)
  86169. * @param direction2 the max limit of the emission direction (up vector by default)
  86170. */
  86171. constructor(radius?: number,
  86172. /**
  86173. * The min limit of the emission direction.
  86174. */
  86175. direction1?: Vector3,
  86176. /**
  86177. * The max limit of the emission direction.
  86178. */
  86179. direction2?: Vector3);
  86180. /**
  86181. * Called by the particle System when the direction is computed for the created particle.
  86182. * @param worldMatrix is the world matrix of the particle system
  86183. * @param directionToUpdate is the direction vector to update with the result
  86184. * @param particle is the particle we are computed the direction for
  86185. */
  86186. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86187. /**
  86188. * Clones the current emitter and returns a copy of it
  86189. * @returns the new emitter
  86190. */
  86191. clone(): SphereDirectedParticleEmitter;
  86192. /**
  86193. * Called by the GPUParticleSystem to setup the update shader
  86194. * @param effect defines the update shader
  86195. */
  86196. applyToShader(effect: Effect): void;
  86197. /**
  86198. * Returns a string to use to update the GPU particles update shader
  86199. * @returns a string containng the defines string
  86200. */
  86201. getEffectDefines(): string;
  86202. /**
  86203. * Returns the string "SphereDirectedParticleEmitter"
  86204. * @returns a string containing the class name
  86205. */
  86206. getClassName(): string;
  86207. /**
  86208. * Serializes the particle system to a JSON object.
  86209. * @returns the JSON object
  86210. */
  86211. serialize(): any;
  86212. /**
  86213. * Parse properties from a JSON object
  86214. * @param serializationObject defines the JSON object
  86215. */
  86216. parse(serializationObject: any): void;
  86217. }
  86218. }
  86219. declare module BABYLON {
  86220. /**
  86221. * Particle emitter emitting particles from a custom list of positions.
  86222. */
  86223. export class CustomParticleEmitter implements IParticleEmitterType {
  86224. /**
  86225. * Gets or sets the position generator that will create the inital position of each particle.
  86226. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86227. */
  86228. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86229. /**
  86230. * Gets or sets the destination generator that will create the final destination of each particle.
  86231. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86232. */
  86233. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86234. /**
  86235. * Creates a new instance CustomParticleEmitter
  86236. */
  86237. constructor();
  86238. /**
  86239. * Called by the particle System when the direction is computed for the created particle.
  86240. * @param worldMatrix is the world matrix of the particle system
  86241. * @param directionToUpdate is the direction vector to update with the result
  86242. * @param particle is the particle we are computed the direction for
  86243. * @param isLocal defines if the direction should be set in local space
  86244. */
  86245. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86246. /**
  86247. * Called by the particle System when the position is computed for the created particle.
  86248. * @param worldMatrix is the world matrix of the particle system
  86249. * @param positionToUpdate is the position vector to update with the result
  86250. * @param particle is the particle we are computed the position for
  86251. * @param isLocal defines if the position should be set in local space
  86252. */
  86253. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86254. /**
  86255. * Clones the current emitter and returns a copy of it
  86256. * @returns the new emitter
  86257. */
  86258. clone(): CustomParticleEmitter;
  86259. /**
  86260. * Called by the GPUParticleSystem to setup the update shader
  86261. * @param effect defines the update shader
  86262. */
  86263. applyToShader(effect: Effect): void;
  86264. /**
  86265. * Returns a string to use to update the GPU particles update shader
  86266. * @returns a string containng the defines string
  86267. */
  86268. getEffectDefines(): string;
  86269. /**
  86270. * Returns the string "PointParticleEmitter"
  86271. * @returns a string containing the class name
  86272. */
  86273. getClassName(): string;
  86274. /**
  86275. * Serializes the particle system to a JSON object.
  86276. * @returns the JSON object
  86277. */
  86278. serialize(): any;
  86279. /**
  86280. * Parse properties from a JSON object
  86281. * @param serializationObject defines the JSON object
  86282. */
  86283. parse(serializationObject: any): void;
  86284. }
  86285. }
  86286. declare module BABYLON {
  86287. /**
  86288. * Particle emitter emitting particles from the inside of a box.
  86289. * It emits the particles randomly between 2 given directions.
  86290. */
  86291. export class MeshParticleEmitter implements IParticleEmitterType {
  86292. /** Defines the mesh to use as source */
  86293. mesh?: AbstractMesh | undefined;
  86294. private _indices;
  86295. private _positions;
  86296. private _normals;
  86297. private _storedNormal;
  86298. /**
  86299. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86300. */
  86301. direction1: Vector3;
  86302. /**
  86303. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86304. */
  86305. direction2: Vector3;
  86306. /**
  86307. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86308. */
  86309. useMeshNormalsForDirection: boolean;
  86310. /**
  86311. * Creates a new instance MeshParticleEmitter
  86312. * @param mesh defines the mesh to use as source
  86313. */
  86314. constructor(
  86315. /** Defines the mesh to use as source */
  86316. mesh?: AbstractMesh | undefined);
  86317. /**
  86318. * Called by the particle System when the direction is computed for the created particle.
  86319. * @param worldMatrix is the world matrix of the particle system
  86320. * @param directionToUpdate is the direction vector to update with the result
  86321. * @param particle is the particle we are computed the direction for
  86322. * @param isLocal defines if the direction should be set in local space
  86323. */
  86324. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86325. /**
  86326. * Called by the particle System when the position is computed for the created particle.
  86327. * @param worldMatrix is the world matrix of the particle system
  86328. * @param positionToUpdate is the position vector to update with the result
  86329. * @param particle is the particle we are computed the position for
  86330. * @param isLocal defines if the position should be set in local space
  86331. */
  86332. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86333. /**
  86334. * Clones the current emitter and returns a copy of it
  86335. * @returns the new emitter
  86336. */
  86337. clone(): MeshParticleEmitter;
  86338. /**
  86339. * Called by the GPUParticleSystem to setup the update shader
  86340. * @param effect defines the update shader
  86341. */
  86342. applyToShader(effect: Effect): void;
  86343. /**
  86344. * Returns a string to use to update the GPU particles update shader
  86345. * @returns a string containng the defines string
  86346. */
  86347. getEffectDefines(): string;
  86348. /**
  86349. * Returns the string "BoxParticleEmitter"
  86350. * @returns a string containing the class name
  86351. */
  86352. getClassName(): string;
  86353. /**
  86354. * Serializes the particle system to a JSON object.
  86355. * @returns the JSON object
  86356. */
  86357. serialize(): any;
  86358. /**
  86359. * Parse properties from a JSON object
  86360. * @param serializationObject defines the JSON object
  86361. * @param scene defines the hosting scene
  86362. */
  86363. parse(serializationObject: any, scene: Scene): void;
  86364. }
  86365. }
  86366. declare module BABYLON {
  86367. /**
  86368. * Interface representing a particle system in Babylon.js.
  86369. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86370. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86371. */
  86372. export interface IParticleSystem {
  86373. /**
  86374. * List of animations used by the particle system.
  86375. */
  86376. animations: Animation[];
  86377. /**
  86378. * The id of the Particle system.
  86379. */
  86380. id: string;
  86381. /**
  86382. * The name of the Particle system.
  86383. */
  86384. name: string;
  86385. /**
  86386. * The emitter represents the Mesh or position we are attaching the particle system to.
  86387. */
  86388. emitter: Nullable<AbstractMesh | Vector3>;
  86389. /**
  86390. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86391. */
  86392. isBillboardBased: boolean;
  86393. /**
  86394. * The rendering group used by the Particle system to chose when to render.
  86395. */
  86396. renderingGroupId: number;
  86397. /**
  86398. * The layer mask we are rendering the particles through.
  86399. */
  86400. layerMask: number;
  86401. /**
  86402. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86403. */
  86404. updateSpeed: number;
  86405. /**
  86406. * The amount of time the particle system is running (depends of the overall update speed).
  86407. */
  86408. targetStopDuration: number;
  86409. /**
  86410. * The texture used to render each particle. (this can be a spritesheet)
  86411. */
  86412. particleTexture: Nullable<Texture>;
  86413. /**
  86414. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86415. */
  86416. blendMode: number;
  86417. /**
  86418. * Minimum life time of emitting particles.
  86419. */
  86420. minLifeTime: number;
  86421. /**
  86422. * Maximum life time of emitting particles.
  86423. */
  86424. maxLifeTime: number;
  86425. /**
  86426. * Minimum Size of emitting particles.
  86427. */
  86428. minSize: number;
  86429. /**
  86430. * Maximum Size of emitting particles.
  86431. */
  86432. maxSize: number;
  86433. /**
  86434. * Minimum scale of emitting particles on X axis.
  86435. */
  86436. minScaleX: number;
  86437. /**
  86438. * Maximum scale of emitting particles on X axis.
  86439. */
  86440. maxScaleX: number;
  86441. /**
  86442. * Minimum scale of emitting particles on Y axis.
  86443. */
  86444. minScaleY: number;
  86445. /**
  86446. * Maximum scale of emitting particles on Y axis.
  86447. */
  86448. maxScaleY: number;
  86449. /**
  86450. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86451. */
  86452. color1: Color4;
  86453. /**
  86454. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86455. */
  86456. color2: Color4;
  86457. /**
  86458. * Color the particle will have at the end of its lifetime.
  86459. */
  86460. colorDead: Color4;
  86461. /**
  86462. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86463. */
  86464. emitRate: number;
  86465. /**
  86466. * You can use gravity if you want to give an orientation to your particles.
  86467. */
  86468. gravity: Vector3;
  86469. /**
  86470. * Minimum power of emitting particles.
  86471. */
  86472. minEmitPower: number;
  86473. /**
  86474. * Maximum power of emitting particles.
  86475. */
  86476. maxEmitPower: number;
  86477. /**
  86478. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86479. */
  86480. minAngularSpeed: number;
  86481. /**
  86482. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86483. */
  86484. maxAngularSpeed: number;
  86485. /**
  86486. * Gets or sets the minimal initial rotation in radians.
  86487. */
  86488. minInitialRotation: number;
  86489. /**
  86490. * Gets or sets the maximal initial rotation in radians.
  86491. */
  86492. maxInitialRotation: number;
  86493. /**
  86494. * The particle emitter type defines the emitter used by the particle system.
  86495. * It can be for example box, sphere, or cone...
  86496. */
  86497. particleEmitterType: Nullable<IParticleEmitterType>;
  86498. /**
  86499. * Defines the delay in milliseconds before starting the system (0 by default)
  86500. */
  86501. startDelay: number;
  86502. /**
  86503. * 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
  86504. */
  86505. preWarmCycles: number;
  86506. /**
  86507. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86508. */
  86509. preWarmStepOffset: number;
  86510. /**
  86511. * 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)
  86512. */
  86513. spriteCellChangeSpeed: number;
  86514. /**
  86515. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86516. */
  86517. startSpriteCellID: number;
  86518. /**
  86519. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86520. */
  86521. endSpriteCellID: number;
  86522. /**
  86523. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86524. */
  86525. spriteCellWidth: number;
  86526. /**
  86527. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86528. */
  86529. spriteCellHeight: number;
  86530. /**
  86531. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86532. */
  86533. spriteRandomStartCell: boolean;
  86534. /**
  86535. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86536. */
  86537. isAnimationSheetEnabled: boolean;
  86538. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86539. translationPivot: Vector2;
  86540. /**
  86541. * Gets or sets a texture used to add random noise to particle positions
  86542. */
  86543. noiseTexture: Nullable<BaseTexture>;
  86544. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86545. noiseStrength: Vector3;
  86546. /**
  86547. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86548. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86549. */
  86550. billboardMode: number;
  86551. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86552. limitVelocityDamping: number;
  86553. /**
  86554. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86555. */
  86556. beginAnimationOnStart: boolean;
  86557. /**
  86558. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86559. */
  86560. beginAnimationFrom: number;
  86561. /**
  86562. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86563. */
  86564. beginAnimationTo: number;
  86565. /**
  86566. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86567. */
  86568. beginAnimationLoop: boolean;
  86569. /**
  86570. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86571. */
  86572. disposeOnStop: boolean;
  86573. /**
  86574. * Specifies if the particles are updated in emitter local space or world space
  86575. */
  86576. isLocal: boolean;
  86577. /**
  86578. * Gets the maximum number of particles active at the same time.
  86579. * @returns The max number of active particles.
  86580. */
  86581. getCapacity(): number;
  86582. /**
  86583. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86584. * @returns True if it has been started, otherwise false.
  86585. */
  86586. isStarted(): boolean;
  86587. /**
  86588. * Animates the particle system for this frame.
  86589. */
  86590. animate(): void;
  86591. /**
  86592. * Renders the particle system in its current state.
  86593. * @returns the current number of particles
  86594. */
  86595. render(): number;
  86596. /**
  86597. * Dispose the particle system and frees its associated resources.
  86598. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86599. */
  86600. dispose(disposeTexture?: boolean): void;
  86601. /**
  86602. * Clones the particle system.
  86603. * @param name The name of the cloned object
  86604. * @param newEmitter The new emitter to use
  86605. * @returns the cloned particle system
  86606. */
  86607. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86608. /**
  86609. * Serializes the particle system to a JSON object.
  86610. * @returns the JSON object
  86611. */
  86612. serialize(): any;
  86613. /**
  86614. * Rebuild the particle system
  86615. */
  86616. rebuild(): void;
  86617. /**
  86618. * Starts the particle system and begins to emit
  86619. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86620. */
  86621. start(delay?: number): void;
  86622. /**
  86623. * Stops the particle system.
  86624. */
  86625. stop(): void;
  86626. /**
  86627. * Remove all active particles
  86628. */
  86629. reset(): void;
  86630. /**
  86631. * Is this system ready to be used/rendered
  86632. * @return true if the system is ready
  86633. */
  86634. isReady(): boolean;
  86635. /**
  86636. * Returns the string "ParticleSystem"
  86637. * @returns a string containing the class name
  86638. */
  86639. getClassName(): string;
  86640. /**
  86641. * Adds a new color gradient
  86642. * @param gradient defines the gradient to use (between 0 and 1)
  86643. * @param color1 defines the color to affect to the specified gradient
  86644. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86645. * @returns the current particle system
  86646. */
  86647. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86648. /**
  86649. * Remove a specific color gradient
  86650. * @param gradient defines the gradient to remove
  86651. * @returns the current particle system
  86652. */
  86653. removeColorGradient(gradient: number): IParticleSystem;
  86654. /**
  86655. * Adds a new size gradient
  86656. * @param gradient defines the gradient to use (between 0 and 1)
  86657. * @param factor defines the size factor to affect to the specified gradient
  86658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86659. * @returns the current particle system
  86660. */
  86661. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86662. /**
  86663. * Remove a specific size gradient
  86664. * @param gradient defines the gradient to remove
  86665. * @returns the current particle system
  86666. */
  86667. removeSizeGradient(gradient: number): IParticleSystem;
  86668. /**
  86669. * Gets the current list of color gradients.
  86670. * You must use addColorGradient and removeColorGradient to udpate this list
  86671. * @returns the list of color gradients
  86672. */
  86673. getColorGradients(): Nullable<Array<ColorGradient>>;
  86674. /**
  86675. * Gets the current list of size gradients.
  86676. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86677. * @returns the list of size gradients
  86678. */
  86679. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86680. /**
  86681. * Gets the current list of angular speed gradients.
  86682. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86683. * @returns the list of angular speed gradients
  86684. */
  86685. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86686. /**
  86687. * Adds a new angular speed gradient
  86688. * @param gradient defines the gradient to use (between 0 and 1)
  86689. * @param factor defines the angular speed to affect to the specified gradient
  86690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86691. * @returns the current particle system
  86692. */
  86693. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86694. /**
  86695. * Remove a specific angular speed gradient
  86696. * @param gradient defines the gradient to remove
  86697. * @returns the current particle system
  86698. */
  86699. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86700. /**
  86701. * Gets the current list of velocity gradients.
  86702. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86703. * @returns the list of velocity gradients
  86704. */
  86705. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86706. /**
  86707. * Adds a new velocity gradient
  86708. * @param gradient defines the gradient to use (between 0 and 1)
  86709. * @param factor defines the velocity to affect to the specified gradient
  86710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86711. * @returns the current particle system
  86712. */
  86713. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86714. /**
  86715. * Remove a specific velocity gradient
  86716. * @param gradient defines the gradient to remove
  86717. * @returns the current particle system
  86718. */
  86719. removeVelocityGradient(gradient: number): IParticleSystem;
  86720. /**
  86721. * Gets the current list of limit velocity gradients.
  86722. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86723. * @returns the list of limit velocity gradients
  86724. */
  86725. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86726. /**
  86727. * Adds a new limit velocity gradient
  86728. * @param gradient defines the gradient to use (between 0 and 1)
  86729. * @param factor defines the limit velocity to affect to the specified gradient
  86730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86731. * @returns the current particle system
  86732. */
  86733. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86734. /**
  86735. * Remove a specific limit velocity gradient
  86736. * @param gradient defines the gradient to remove
  86737. * @returns the current particle system
  86738. */
  86739. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86740. /**
  86741. * Adds a new drag gradient
  86742. * @param gradient defines the gradient to use (between 0 and 1)
  86743. * @param factor defines the drag to affect to the specified gradient
  86744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86745. * @returns the current particle system
  86746. */
  86747. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86748. /**
  86749. * Remove a specific drag gradient
  86750. * @param gradient defines the gradient to remove
  86751. * @returns the current particle system
  86752. */
  86753. removeDragGradient(gradient: number): IParticleSystem;
  86754. /**
  86755. * Gets the current list of drag gradients.
  86756. * You must use addDragGradient and removeDragGradient to udpate this list
  86757. * @returns the list of drag gradients
  86758. */
  86759. getDragGradients(): Nullable<Array<FactorGradient>>;
  86760. /**
  86761. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86762. * @param gradient defines the gradient to use (between 0 and 1)
  86763. * @param factor defines the emit rate to affect to the specified gradient
  86764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86765. * @returns the current particle system
  86766. */
  86767. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86768. /**
  86769. * Remove a specific emit rate gradient
  86770. * @param gradient defines the gradient to remove
  86771. * @returns the current particle system
  86772. */
  86773. removeEmitRateGradient(gradient: number): IParticleSystem;
  86774. /**
  86775. * Gets the current list of emit rate gradients.
  86776. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86777. * @returns the list of emit rate gradients
  86778. */
  86779. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86780. /**
  86781. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86782. * @param gradient defines the gradient to use (between 0 and 1)
  86783. * @param factor defines the start size to affect to the specified gradient
  86784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86785. * @returns the current particle system
  86786. */
  86787. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86788. /**
  86789. * Remove a specific start size gradient
  86790. * @param gradient defines the gradient to remove
  86791. * @returns the current particle system
  86792. */
  86793. removeStartSizeGradient(gradient: number): IParticleSystem;
  86794. /**
  86795. * Gets the current list of start size gradients.
  86796. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86797. * @returns the list of start size gradients
  86798. */
  86799. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86800. /**
  86801. * Adds a new life time gradient
  86802. * @param gradient defines the gradient to use (between 0 and 1)
  86803. * @param factor defines the life time factor to affect to the specified gradient
  86804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86805. * @returns the current particle system
  86806. */
  86807. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86808. /**
  86809. * Remove a specific life time gradient
  86810. * @param gradient defines the gradient to remove
  86811. * @returns the current particle system
  86812. */
  86813. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86814. /**
  86815. * Gets the current list of life time gradients.
  86816. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86817. * @returns the list of life time gradients
  86818. */
  86819. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86820. /**
  86821. * Gets the current list of color gradients.
  86822. * You must use addColorGradient and removeColorGradient to udpate this list
  86823. * @returns the list of color gradients
  86824. */
  86825. getColorGradients(): Nullable<Array<ColorGradient>>;
  86826. /**
  86827. * Adds a new ramp gradient used to remap particle colors
  86828. * @param gradient defines the gradient to use (between 0 and 1)
  86829. * @param color defines the color to affect to the specified gradient
  86830. * @returns the current particle system
  86831. */
  86832. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86833. /**
  86834. * Gets the current list of ramp gradients.
  86835. * You must use addRampGradient and removeRampGradient to udpate this list
  86836. * @returns the list of ramp gradients
  86837. */
  86838. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86839. /** Gets or sets a boolean indicating that ramp gradients must be used
  86840. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86841. */
  86842. useRampGradients: boolean;
  86843. /**
  86844. * Adds a new color remap gradient
  86845. * @param gradient defines the gradient to use (between 0 and 1)
  86846. * @param min defines the color remap minimal range
  86847. * @param max defines the color remap maximal range
  86848. * @returns the current particle system
  86849. */
  86850. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86851. /**
  86852. * Gets the current list of color remap gradients.
  86853. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86854. * @returns the list of color remap gradients
  86855. */
  86856. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86857. /**
  86858. * Adds a new alpha remap gradient
  86859. * @param gradient defines the gradient to use (between 0 and 1)
  86860. * @param min defines the alpha remap minimal range
  86861. * @param max defines the alpha remap maximal range
  86862. * @returns the current particle system
  86863. */
  86864. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86865. /**
  86866. * Gets the current list of alpha remap gradients.
  86867. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86868. * @returns the list of alpha remap gradients
  86869. */
  86870. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86871. /**
  86872. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86873. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86874. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86875. * @returns the emitter
  86876. */
  86877. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86878. /**
  86879. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86880. * @param radius The radius of the hemisphere to emit from
  86881. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86882. * @returns the emitter
  86883. */
  86884. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86885. /**
  86886. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86887. * @param radius The radius of the sphere to emit from
  86888. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86889. * @returns the emitter
  86890. */
  86891. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86892. /**
  86893. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86894. * @param radius The radius of the sphere to emit from
  86895. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86896. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86897. * @returns the emitter
  86898. */
  86899. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86900. /**
  86901. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86902. * @param radius The radius of the emission cylinder
  86903. * @param height The height of the emission cylinder
  86904. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86905. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86906. * @returns the emitter
  86907. */
  86908. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86909. /**
  86910. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86911. * @param radius The radius of the cylinder to emit from
  86912. * @param height The height of the emission cylinder
  86913. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86914. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86915. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86916. * @returns the emitter
  86917. */
  86918. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86919. /**
  86920. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86921. * @param radius The radius of the cone to emit from
  86922. * @param angle The base angle of the cone
  86923. * @returns the emitter
  86924. */
  86925. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86926. /**
  86927. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86928. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86929. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86930. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86931. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86932. * @returns the emitter
  86933. */
  86934. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86935. /**
  86936. * Get hosting scene
  86937. * @returns the scene
  86938. */
  86939. getScene(): Scene;
  86940. }
  86941. }
  86942. declare module BABYLON {
  86943. /**
  86944. * 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.
  86945. * @see https://doc.babylonjs.com/how_to/transformnode
  86946. */
  86947. export class TransformNode extends Node {
  86948. /**
  86949. * Object will not rotate to face the camera
  86950. */
  86951. static BILLBOARDMODE_NONE: number;
  86952. /**
  86953. * Object will rotate to face the camera but only on the x axis
  86954. */
  86955. static BILLBOARDMODE_X: number;
  86956. /**
  86957. * Object will rotate to face the camera but only on the y axis
  86958. */
  86959. static BILLBOARDMODE_Y: number;
  86960. /**
  86961. * Object will rotate to face the camera but only on the z axis
  86962. */
  86963. static BILLBOARDMODE_Z: number;
  86964. /**
  86965. * Object will rotate to face the camera
  86966. */
  86967. static BILLBOARDMODE_ALL: number;
  86968. /**
  86969. * Object will rotate to face the camera's position instead of orientation
  86970. */
  86971. static BILLBOARDMODE_USE_POSITION: number;
  86972. private _forward;
  86973. private _forwardInverted;
  86974. private _up;
  86975. private _right;
  86976. private _rightInverted;
  86977. private _position;
  86978. private _rotation;
  86979. private _rotationQuaternion;
  86980. protected _scaling: Vector3;
  86981. protected _isDirty: boolean;
  86982. private _transformToBoneReferal;
  86983. private _isAbsoluteSynced;
  86984. private _billboardMode;
  86985. /**
  86986. * Gets or sets the billboard mode. Default is 0.
  86987. *
  86988. * | Value | Type | Description |
  86989. * | --- | --- | --- |
  86990. * | 0 | BILLBOARDMODE_NONE | |
  86991. * | 1 | BILLBOARDMODE_X | |
  86992. * | 2 | BILLBOARDMODE_Y | |
  86993. * | 4 | BILLBOARDMODE_Z | |
  86994. * | 7 | BILLBOARDMODE_ALL | |
  86995. *
  86996. */
  86997. get billboardMode(): number;
  86998. set billboardMode(value: number);
  86999. private _preserveParentRotationForBillboard;
  87000. /**
  87001. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  87002. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  87003. */
  87004. get preserveParentRotationForBillboard(): boolean;
  87005. set preserveParentRotationForBillboard(value: boolean);
  87006. /**
  87007. * 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
  87008. */
  87009. scalingDeterminant: number;
  87010. private _infiniteDistance;
  87011. /**
  87012. * Gets or sets the distance of the object to max, often used by skybox
  87013. */
  87014. get infiniteDistance(): boolean;
  87015. set infiniteDistance(value: boolean);
  87016. /**
  87017. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  87018. * By default the system will update normals to compensate
  87019. */
  87020. ignoreNonUniformScaling: boolean;
  87021. /**
  87022. * 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
  87023. */
  87024. reIntegrateRotationIntoRotationQuaternion: boolean;
  87025. /** @hidden */
  87026. _poseMatrix: Nullable<Matrix>;
  87027. /** @hidden */
  87028. _localMatrix: Matrix;
  87029. private _usePivotMatrix;
  87030. private _absolutePosition;
  87031. private _absoluteScaling;
  87032. private _absoluteRotationQuaternion;
  87033. private _pivotMatrix;
  87034. private _pivotMatrixInverse;
  87035. protected _postMultiplyPivotMatrix: boolean;
  87036. protected _isWorldMatrixFrozen: boolean;
  87037. /** @hidden */
  87038. _indexInSceneTransformNodesArray: number;
  87039. /**
  87040. * An event triggered after the world matrix is updated
  87041. */
  87042. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  87043. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  87044. /**
  87045. * Gets a string identifying the name of the class
  87046. * @returns "TransformNode" string
  87047. */
  87048. getClassName(): string;
  87049. /**
  87050. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  87051. */
  87052. get position(): Vector3;
  87053. set position(newPosition: Vector3);
  87054. /**
  87055. * 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)).
  87056. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  87057. */
  87058. get rotation(): Vector3;
  87059. set rotation(newRotation: Vector3);
  87060. /**
  87061. * 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)).
  87062. */
  87063. get scaling(): Vector3;
  87064. set scaling(newScaling: Vector3);
  87065. /**
  87066. * 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).
  87067. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  87068. */
  87069. get rotationQuaternion(): Nullable<Quaternion>;
  87070. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  87071. /**
  87072. * The forward direction of that transform in world space.
  87073. */
  87074. get forward(): Vector3;
  87075. /**
  87076. * The up direction of that transform in world space.
  87077. */
  87078. get up(): Vector3;
  87079. /**
  87080. * The right direction of that transform in world space.
  87081. */
  87082. get right(): Vector3;
  87083. /**
  87084. * Copies the parameter passed Matrix into the mesh Pose matrix.
  87085. * @param matrix the matrix to copy the pose from
  87086. * @returns this TransformNode.
  87087. */
  87088. updatePoseMatrix(matrix: Matrix): TransformNode;
  87089. /**
  87090. * Returns the mesh Pose matrix.
  87091. * @returns the pose matrix
  87092. */
  87093. getPoseMatrix(): Matrix;
  87094. /** @hidden */
  87095. _isSynchronized(): boolean;
  87096. /** @hidden */
  87097. _initCache(): void;
  87098. /**
  87099. * Flag the transform node as dirty (Forcing it to update everything)
  87100. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  87101. * @returns this transform node
  87102. */
  87103. markAsDirty(property: string): TransformNode;
  87104. /**
  87105. * Returns the current mesh absolute position.
  87106. * Returns a Vector3.
  87107. */
  87108. get absolutePosition(): Vector3;
  87109. /**
  87110. * Returns the current mesh absolute scaling.
  87111. * Returns a Vector3.
  87112. */
  87113. get absoluteScaling(): Vector3;
  87114. /**
  87115. * Returns the current mesh absolute rotation.
  87116. * Returns a Quaternion.
  87117. */
  87118. get absoluteRotationQuaternion(): Quaternion;
  87119. /**
  87120. * Sets a new matrix to apply before all other transformation
  87121. * @param matrix defines the transform matrix
  87122. * @returns the current TransformNode
  87123. */
  87124. setPreTransformMatrix(matrix: Matrix): TransformNode;
  87125. /**
  87126. * Sets a new pivot matrix to the current node
  87127. * @param matrix defines the new pivot matrix to use
  87128. * @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
  87129. * @returns the current TransformNode
  87130. */
  87131. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  87132. /**
  87133. * Returns the mesh pivot matrix.
  87134. * Default : Identity.
  87135. * @returns the matrix
  87136. */
  87137. getPivotMatrix(): Matrix;
  87138. /**
  87139. * Instantiate (when possible) or clone that node with its hierarchy
  87140. * @param newParent defines the new parent to use for the instance (or clone)
  87141. * @param options defines options to configure how copy is done
  87142. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  87143. * @returns an instance (or a clone) of the current node with its hiearchy
  87144. */
  87145. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  87146. doNotInstantiate: boolean;
  87147. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  87148. /**
  87149. * Prevents the World matrix to be computed any longer
  87150. * @param newWorldMatrix defines an optional matrix to use as world matrix
  87151. * @returns the TransformNode.
  87152. */
  87153. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  87154. /**
  87155. * Allows back the World matrix computation.
  87156. * @returns the TransformNode.
  87157. */
  87158. unfreezeWorldMatrix(): this;
  87159. /**
  87160. * True if the World matrix has been frozen.
  87161. */
  87162. get isWorldMatrixFrozen(): boolean;
  87163. /**
  87164. * Retuns the mesh absolute position in the World.
  87165. * @returns a Vector3.
  87166. */
  87167. getAbsolutePosition(): Vector3;
  87168. /**
  87169. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  87170. * @param absolutePosition the absolute position to set
  87171. * @returns the TransformNode.
  87172. */
  87173. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87174. /**
  87175. * Sets the mesh position in its local space.
  87176. * @param vector3 the position to set in localspace
  87177. * @returns the TransformNode.
  87178. */
  87179. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  87180. /**
  87181. * Returns the mesh position in the local space from the current World matrix values.
  87182. * @returns a new Vector3.
  87183. */
  87184. getPositionExpressedInLocalSpace(): Vector3;
  87185. /**
  87186. * Translates the mesh along the passed Vector3 in its local space.
  87187. * @param vector3 the distance to translate in localspace
  87188. * @returns the TransformNode.
  87189. */
  87190. locallyTranslate(vector3: Vector3): TransformNode;
  87191. private static _lookAtVectorCache;
  87192. /**
  87193. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  87194. * @param targetPoint the position (must be in same space as current mesh) to look at
  87195. * @param yawCor optional yaw (y-axis) correction in radians
  87196. * @param pitchCor optional pitch (x-axis) correction in radians
  87197. * @param rollCor optional roll (z-axis) correction in radians
  87198. * @param space the choosen space of the target
  87199. * @returns the TransformNode.
  87200. */
  87201. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  87202. /**
  87203. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87204. * This Vector3 is expressed in the World space.
  87205. * @param localAxis axis to rotate
  87206. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87207. */
  87208. getDirection(localAxis: Vector3): Vector3;
  87209. /**
  87210. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87211. * localAxis is expressed in the mesh local space.
  87212. * result is computed in the Wordl space from the mesh World matrix.
  87213. * @param localAxis axis to rotate
  87214. * @param result the resulting transformnode
  87215. * @returns this TransformNode.
  87216. */
  87217. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87218. /**
  87219. * Sets this transform node rotation to the given local axis.
  87220. * @param localAxis the axis in local space
  87221. * @param yawCor optional yaw (y-axis) correction in radians
  87222. * @param pitchCor optional pitch (x-axis) correction in radians
  87223. * @param rollCor optional roll (z-axis) correction in radians
  87224. * @returns this TransformNode
  87225. */
  87226. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87227. /**
  87228. * Sets a new pivot point to the current node
  87229. * @param point defines the new pivot point to use
  87230. * @param space defines if the point is in world or local space (local by default)
  87231. * @returns the current TransformNode
  87232. */
  87233. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87234. /**
  87235. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87236. * @returns the pivot point
  87237. */
  87238. getPivotPoint(): Vector3;
  87239. /**
  87240. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87241. * @param result the vector3 to store the result
  87242. * @returns this TransformNode.
  87243. */
  87244. getPivotPointToRef(result: Vector3): TransformNode;
  87245. /**
  87246. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87247. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87248. */
  87249. getAbsolutePivotPoint(): Vector3;
  87250. /**
  87251. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87252. * @param result vector3 to store the result
  87253. * @returns this TransformNode.
  87254. */
  87255. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87256. /**
  87257. * Defines the passed node as the parent of the current node.
  87258. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87259. * @see https://doc.babylonjs.com/how_to/parenting
  87260. * @param node the node ot set as the parent
  87261. * @returns this TransformNode.
  87262. */
  87263. setParent(node: Nullable<Node>): TransformNode;
  87264. private _nonUniformScaling;
  87265. /**
  87266. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87267. */
  87268. get nonUniformScaling(): boolean;
  87269. /** @hidden */
  87270. _updateNonUniformScalingState(value: boolean): boolean;
  87271. /**
  87272. * Attach the current TransformNode to another TransformNode associated with a bone
  87273. * @param bone Bone affecting the TransformNode
  87274. * @param affectedTransformNode TransformNode associated with the bone
  87275. * @returns this object
  87276. */
  87277. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87278. /**
  87279. * Detach the transform node if its associated with a bone
  87280. * @returns this object
  87281. */
  87282. detachFromBone(): TransformNode;
  87283. private static _rotationAxisCache;
  87284. /**
  87285. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87286. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87287. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87288. * The passed axis is also normalized.
  87289. * @param axis the axis to rotate around
  87290. * @param amount the amount to rotate in radians
  87291. * @param space Space to rotate in (Default: local)
  87292. * @returns the TransformNode.
  87293. */
  87294. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87295. /**
  87296. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87297. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87298. * The passed axis is also normalized. .
  87299. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87300. * @param point the point to rotate around
  87301. * @param axis the axis to rotate around
  87302. * @param amount the amount to rotate in radians
  87303. * @returns the TransformNode
  87304. */
  87305. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87306. /**
  87307. * Translates the mesh along the axis vector for the passed distance in the given space.
  87308. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87309. * @param axis the axis to translate in
  87310. * @param distance the distance to translate
  87311. * @param space Space to rotate in (Default: local)
  87312. * @returns the TransformNode.
  87313. */
  87314. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87315. /**
  87316. * Adds a rotation step to the mesh current rotation.
  87317. * x, y, z are Euler angles expressed in radians.
  87318. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87319. * This means this rotation is made in the mesh local space only.
  87320. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87321. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87322. * ```javascript
  87323. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87324. * ```
  87325. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87326. * 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.
  87327. * @param x Rotation to add
  87328. * @param y Rotation to add
  87329. * @param z Rotation to add
  87330. * @returns the TransformNode.
  87331. */
  87332. addRotation(x: number, y: number, z: number): TransformNode;
  87333. /**
  87334. * @hidden
  87335. */
  87336. protected _getEffectiveParent(): Nullable<Node>;
  87337. /**
  87338. * Computes the world matrix of the node
  87339. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87340. * @returns the world matrix
  87341. */
  87342. computeWorldMatrix(force?: boolean): Matrix;
  87343. /**
  87344. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87345. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87346. */
  87347. resetLocalMatrix(independentOfChildren?: boolean): void;
  87348. protected _afterComputeWorldMatrix(): void;
  87349. /**
  87350. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87351. * @param func callback function to add
  87352. *
  87353. * @returns the TransformNode.
  87354. */
  87355. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87356. /**
  87357. * Removes a registered callback function.
  87358. * @param func callback function to remove
  87359. * @returns the TransformNode.
  87360. */
  87361. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87362. /**
  87363. * Gets the position of the current mesh in camera space
  87364. * @param camera defines the camera to use
  87365. * @returns a position
  87366. */
  87367. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87368. /**
  87369. * Returns the distance from the mesh to the active camera
  87370. * @param camera defines the camera to use
  87371. * @returns the distance
  87372. */
  87373. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87374. /**
  87375. * Clone the current transform node
  87376. * @param name Name of the new clone
  87377. * @param newParent New parent for the clone
  87378. * @param doNotCloneChildren Do not clone children hierarchy
  87379. * @returns the new transform node
  87380. */
  87381. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87382. /**
  87383. * Serializes the objects information.
  87384. * @param currentSerializationObject defines the object to serialize in
  87385. * @returns the serialized object
  87386. */
  87387. serialize(currentSerializationObject?: any): any;
  87388. /**
  87389. * Returns a new TransformNode object parsed from the source provided.
  87390. * @param parsedTransformNode is the source.
  87391. * @param scene the scne the object belongs to
  87392. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87393. * @returns a new TransformNode object parsed from the source provided.
  87394. */
  87395. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87396. /**
  87397. * Get all child-transformNodes of this node
  87398. * @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
  87399. * @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
  87400. * @returns an array of TransformNode
  87401. */
  87402. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87403. /**
  87404. * Releases resources associated with this transform node.
  87405. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87406. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87407. */
  87408. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87409. /**
  87410. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87411. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87412. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87413. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87414. * @returns the current mesh
  87415. */
  87416. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87417. private _syncAbsoluteScalingAndRotation;
  87418. }
  87419. }
  87420. declare module BABYLON {
  87421. /**
  87422. * Class used to override all child animations of a given target
  87423. */
  87424. export class AnimationPropertiesOverride {
  87425. /**
  87426. * Gets or sets a value indicating if animation blending must be used
  87427. */
  87428. enableBlending: boolean;
  87429. /**
  87430. * Gets or sets the blending speed to use when enableBlending is true
  87431. */
  87432. blendingSpeed: number;
  87433. /**
  87434. * Gets or sets the default loop mode to use
  87435. */
  87436. loopMode: number;
  87437. }
  87438. }
  87439. declare module BABYLON {
  87440. /**
  87441. * Class used to store bone information
  87442. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87443. */
  87444. export class Bone extends Node {
  87445. /**
  87446. * defines the bone name
  87447. */
  87448. name: string;
  87449. private static _tmpVecs;
  87450. private static _tmpQuat;
  87451. private static _tmpMats;
  87452. /**
  87453. * Gets the list of child bones
  87454. */
  87455. children: Bone[];
  87456. /** Gets the animations associated with this bone */
  87457. animations: Animation[];
  87458. /**
  87459. * Gets or sets bone length
  87460. */
  87461. length: number;
  87462. /**
  87463. * @hidden Internal only
  87464. * Set this value to map this bone to a different index in the transform matrices
  87465. * Set this value to -1 to exclude the bone from the transform matrices
  87466. */
  87467. _index: Nullable<number>;
  87468. private _skeleton;
  87469. private _localMatrix;
  87470. private _restPose;
  87471. private _baseMatrix;
  87472. private _absoluteTransform;
  87473. private _invertedAbsoluteTransform;
  87474. private _parent;
  87475. private _scalingDeterminant;
  87476. private _worldTransform;
  87477. private _localScaling;
  87478. private _localRotation;
  87479. private _localPosition;
  87480. private _needToDecompose;
  87481. private _needToCompose;
  87482. /** @hidden */
  87483. _linkedTransformNode: Nullable<TransformNode>;
  87484. /** @hidden */
  87485. _waitingTransformNodeId: Nullable<string>;
  87486. /** @hidden */
  87487. get _matrix(): Matrix;
  87488. /** @hidden */
  87489. set _matrix(value: Matrix);
  87490. /**
  87491. * Create a new bone
  87492. * @param name defines the bone name
  87493. * @param skeleton defines the parent skeleton
  87494. * @param parentBone defines the parent (can be null if the bone is the root)
  87495. * @param localMatrix defines the local matrix
  87496. * @param restPose defines the rest pose matrix
  87497. * @param baseMatrix defines the base matrix
  87498. * @param index defines index of the bone in the hiearchy
  87499. */
  87500. constructor(
  87501. /**
  87502. * defines the bone name
  87503. */
  87504. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87505. /**
  87506. * Gets the current object class name.
  87507. * @return the class name
  87508. */
  87509. getClassName(): string;
  87510. /**
  87511. * Gets the parent skeleton
  87512. * @returns a skeleton
  87513. */
  87514. getSkeleton(): Skeleton;
  87515. /**
  87516. * Gets parent bone
  87517. * @returns a bone or null if the bone is the root of the bone hierarchy
  87518. */
  87519. getParent(): Nullable<Bone>;
  87520. /**
  87521. * Returns an array containing the root bones
  87522. * @returns an array containing the root bones
  87523. */
  87524. getChildren(): Array<Bone>;
  87525. /**
  87526. * Gets the node index in matrix array generated for rendering
  87527. * @returns the node index
  87528. */
  87529. getIndex(): number;
  87530. /**
  87531. * Sets the parent bone
  87532. * @param parent defines the parent (can be null if the bone is the root)
  87533. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87534. */
  87535. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87536. /**
  87537. * Gets the local matrix
  87538. * @returns a matrix
  87539. */
  87540. getLocalMatrix(): Matrix;
  87541. /**
  87542. * Gets the base matrix (initial matrix which remains unchanged)
  87543. * @returns a matrix
  87544. */
  87545. getBaseMatrix(): Matrix;
  87546. /**
  87547. * Gets the rest pose matrix
  87548. * @returns a matrix
  87549. */
  87550. getRestPose(): Matrix;
  87551. /**
  87552. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87553. */
  87554. getWorldMatrix(): Matrix;
  87555. /**
  87556. * Sets the local matrix to rest pose matrix
  87557. */
  87558. returnToRest(): void;
  87559. /**
  87560. * Gets the inverse of the absolute transform matrix.
  87561. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87562. * @returns a matrix
  87563. */
  87564. getInvertedAbsoluteTransform(): Matrix;
  87565. /**
  87566. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87567. * @returns a matrix
  87568. */
  87569. getAbsoluteTransform(): Matrix;
  87570. /**
  87571. * Links with the given transform node.
  87572. * The local matrix of this bone is copied from the transform node every frame.
  87573. * @param transformNode defines the transform node to link to
  87574. */
  87575. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87576. /**
  87577. * Gets the node used to drive the bone's transformation
  87578. * @returns a transform node or null
  87579. */
  87580. getTransformNode(): Nullable<TransformNode>;
  87581. /** Gets or sets current position (in local space) */
  87582. get position(): Vector3;
  87583. set position(newPosition: Vector3);
  87584. /** Gets or sets current rotation (in local space) */
  87585. get rotation(): Vector3;
  87586. set rotation(newRotation: Vector3);
  87587. /** Gets or sets current rotation quaternion (in local space) */
  87588. get rotationQuaternion(): Quaternion;
  87589. set rotationQuaternion(newRotation: Quaternion);
  87590. /** Gets or sets current scaling (in local space) */
  87591. get scaling(): Vector3;
  87592. set scaling(newScaling: Vector3);
  87593. /**
  87594. * Gets the animation properties override
  87595. */
  87596. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87597. private _decompose;
  87598. private _compose;
  87599. /**
  87600. * Update the base and local matrices
  87601. * @param matrix defines the new base or local matrix
  87602. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87603. * @param updateLocalMatrix defines if the local matrix should be updated
  87604. */
  87605. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87606. /** @hidden */
  87607. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87608. /**
  87609. * Flag the bone as dirty (Forcing it to update everything)
  87610. */
  87611. markAsDirty(): void;
  87612. /** @hidden */
  87613. _markAsDirtyAndCompose(): void;
  87614. private _markAsDirtyAndDecompose;
  87615. /**
  87616. * Translate the bone in local or world space
  87617. * @param vec The amount to translate the bone
  87618. * @param space The space that the translation is in
  87619. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87620. */
  87621. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87622. /**
  87623. * Set the postion of the bone in local or world space
  87624. * @param position The position to set the bone
  87625. * @param space The space that the position is in
  87626. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87627. */
  87628. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87629. /**
  87630. * Set the absolute position of the bone (world space)
  87631. * @param position The position to set the bone
  87632. * @param mesh The mesh that this bone is attached to
  87633. */
  87634. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87635. /**
  87636. * Scale the bone on the x, y and z axes (in local space)
  87637. * @param x The amount to scale the bone on the x axis
  87638. * @param y The amount to scale the bone on the y axis
  87639. * @param z The amount to scale the bone on the z axis
  87640. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87641. */
  87642. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87643. /**
  87644. * Set the bone scaling in local space
  87645. * @param scale defines the scaling vector
  87646. */
  87647. setScale(scale: Vector3): void;
  87648. /**
  87649. * Gets the current scaling in local space
  87650. * @returns the current scaling vector
  87651. */
  87652. getScale(): Vector3;
  87653. /**
  87654. * Gets the current scaling in local space and stores it in a target vector
  87655. * @param result defines the target vector
  87656. */
  87657. getScaleToRef(result: Vector3): void;
  87658. /**
  87659. * Set the yaw, pitch, and roll of the bone in local or world space
  87660. * @param yaw The rotation of the bone on the y axis
  87661. * @param pitch The rotation of the bone on the x axis
  87662. * @param roll The rotation of the bone on the z axis
  87663. * @param space The space that the axes of rotation are in
  87664. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87665. */
  87666. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87667. /**
  87668. * Add a rotation to the bone on an axis in local or world space
  87669. * @param axis The axis to rotate the bone on
  87670. * @param amount The amount to rotate the bone
  87671. * @param space The space that the axis is in
  87672. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87673. */
  87674. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87675. /**
  87676. * Set the rotation of the bone to a particular axis angle in local or world space
  87677. * @param axis The axis to rotate the bone on
  87678. * @param angle The angle that the bone should be rotated to
  87679. * @param space The space that the axis is in
  87680. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87681. */
  87682. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87683. /**
  87684. * Set the euler rotation of the bone in local of world space
  87685. * @param rotation The euler rotation that the bone should be set to
  87686. * @param space The space that the rotation is in
  87687. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87688. */
  87689. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87690. /**
  87691. * Set the quaternion rotation of the bone in local of world space
  87692. * @param quat The quaternion rotation that the bone should be set to
  87693. * @param space The space that the rotation is in
  87694. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87695. */
  87696. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87697. /**
  87698. * Set the rotation matrix of the bone in local of world space
  87699. * @param rotMat The rotation matrix that the bone should be set to
  87700. * @param space The space that the rotation is in
  87701. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87702. */
  87703. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87704. private _rotateWithMatrix;
  87705. private _getNegativeRotationToRef;
  87706. /**
  87707. * Get the position of the bone in local or world space
  87708. * @param space The space that the returned position is in
  87709. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87710. * @returns The position of the bone
  87711. */
  87712. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87713. /**
  87714. * Copy the position of the bone to a vector3 in local or world space
  87715. * @param space The space that the returned position is in
  87716. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87717. * @param result The vector3 to copy the position to
  87718. */
  87719. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87720. /**
  87721. * Get the absolute position of the bone (world space)
  87722. * @param mesh The mesh that this bone is attached to
  87723. * @returns The absolute position of the bone
  87724. */
  87725. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87726. /**
  87727. * Copy the absolute position of the bone (world space) to the result param
  87728. * @param mesh The mesh that this bone is attached to
  87729. * @param result The vector3 to copy the absolute position to
  87730. */
  87731. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87732. /**
  87733. * Compute the absolute transforms of this bone and its children
  87734. */
  87735. computeAbsoluteTransforms(): void;
  87736. /**
  87737. * Get the world direction from an axis that is in the local space of the bone
  87738. * @param localAxis The local direction that is used to compute the world direction
  87739. * @param mesh The mesh that this bone is attached to
  87740. * @returns The world direction
  87741. */
  87742. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87743. /**
  87744. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87745. * @param localAxis The local direction that is used to compute the world direction
  87746. * @param mesh The mesh that this bone is attached to
  87747. * @param result The vector3 that the world direction will be copied to
  87748. */
  87749. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87750. /**
  87751. * Get the euler rotation of the bone in local or world space
  87752. * @param space The space that the rotation should be in
  87753. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87754. * @returns The euler rotation
  87755. */
  87756. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87757. /**
  87758. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87759. * @param space The space that the rotation should be in
  87760. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87761. * @param result The vector3 that the rotation should be copied to
  87762. */
  87763. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87764. /**
  87765. * Get the quaternion rotation of the bone in either local or world space
  87766. * @param space The space that the rotation should be in
  87767. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87768. * @returns The quaternion rotation
  87769. */
  87770. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87771. /**
  87772. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87773. * @param space The space that the rotation should be in
  87774. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87775. * @param result The quaternion that the rotation should be copied to
  87776. */
  87777. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87778. /**
  87779. * Get the rotation matrix of the bone in local or world space
  87780. * @param space The space that the rotation should be in
  87781. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87782. * @returns The rotation matrix
  87783. */
  87784. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87785. /**
  87786. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87787. * @param space The space that the rotation should be in
  87788. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87789. * @param result The quaternion that the rotation should be copied to
  87790. */
  87791. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87792. /**
  87793. * Get the world position of a point that is in the local space of the bone
  87794. * @param position The local position
  87795. * @param mesh The mesh that this bone is attached to
  87796. * @returns The world position
  87797. */
  87798. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87799. /**
  87800. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87801. * @param position The local position
  87802. * @param mesh The mesh that this bone is attached to
  87803. * @param result The vector3 that the world position should be copied to
  87804. */
  87805. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87806. /**
  87807. * Get the local position of a point that is in world space
  87808. * @param position The world position
  87809. * @param mesh The mesh that this bone is attached to
  87810. * @returns The local position
  87811. */
  87812. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87813. /**
  87814. * Get the local position of a point that is in world space and copy it to the result param
  87815. * @param position The world position
  87816. * @param mesh The mesh that this bone is attached to
  87817. * @param result The vector3 that the local position should be copied to
  87818. */
  87819. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87820. }
  87821. }
  87822. declare module BABYLON {
  87823. /**
  87824. * Defines a runtime animation
  87825. */
  87826. export class RuntimeAnimation {
  87827. private _events;
  87828. /**
  87829. * The current frame of the runtime animation
  87830. */
  87831. private _currentFrame;
  87832. /**
  87833. * The animation used by the runtime animation
  87834. */
  87835. private _animation;
  87836. /**
  87837. * The target of the runtime animation
  87838. */
  87839. private _target;
  87840. /**
  87841. * The initiating animatable
  87842. */
  87843. private _host;
  87844. /**
  87845. * The original value of the runtime animation
  87846. */
  87847. private _originalValue;
  87848. /**
  87849. * The original blend value of the runtime animation
  87850. */
  87851. private _originalBlendValue;
  87852. /**
  87853. * The offsets cache of the runtime animation
  87854. */
  87855. private _offsetsCache;
  87856. /**
  87857. * The high limits cache of the runtime animation
  87858. */
  87859. private _highLimitsCache;
  87860. /**
  87861. * Specifies if the runtime animation has been stopped
  87862. */
  87863. private _stopped;
  87864. /**
  87865. * The blending factor of the runtime animation
  87866. */
  87867. private _blendingFactor;
  87868. /**
  87869. * The BabylonJS scene
  87870. */
  87871. private _scene;
  87872. /**
  87873. * The current value of the runtime animation
  87874. */
  87875. private _currentValue;
  87876. /** @hidden */
  87877. _animationState: _IAnimationState;
  87878. /**
  87879. * The active target of the runtime animation
  87880. */
  87881. private _activeTargets;
  87882. private _currentActiveTarget;
  87883. private _directTarget;
  87884. /**
  87885. * The target path of the runtime animation
  87886. */
  87887. private _targetPath;
  87888. /**
  87889. * The weight of the runtime animation
  87890. */
  87891. private _weight;
  87892. /**
  87893. * The ratio offset of the runtime animation
  87894. */
  87895. private _ratioOffset;
  87896. /**
  87897. * The previous delay of the runtime animation
  87898. */
  87899. private _previousDelay;
  87900. /**
  87901. * The previous ratio of the runtime animation
  87902. */
  87903. private _previousRatio;
  87904. private _enableBlending;
  87905. private _keys;
  87906. private _minFrame;
  87907. private _maxFrame;
  87908. private _minValue;
  87909. private _maxValue;
  87910. private _targetIsArray;
  87911. /**
  87912. * Gets the current frame of the runtime animation
  87913. */
  87914. get currentFrame(): number;
  87915. /**
  87916. * Gets the weight of the runtime animation
  87917. */
  87918. get weight(): number;
  87919. /**
  87920. * Gets the current value of the runtime animation
  87921. */
  87922. get currentValue(): any;
  87923. /**
  87924. * Gets the target path of the runtime animation
  87925. */
  87926. get targetPath(): string;
  87927. /**
  87928. * Gets the actual target of the runtime animation
  87929. */
  87930. get target(): any;
  87931. /** @hidden */
  87932. _onLoop: () => void;
  87933. /**
  87934. * Create a new RuntimeAnimation object
  87935. * @param target defines the target of the animation
  87936. * @param animation defines the source animation object
  87937. * @param scene defines the hosting scene
  87938. * @param host defines the initiating Animatable
  87939. */
  87940. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87941. private _preparePath;
  87942. /**
  87943. * Gets the animation from the runtime animation
  87944. */
  87945. get animation(): Animation;
  87946. /**
  87947. * Resets the runtime animation to the beginning
  87948. * @param restoreOriginal defines whether to restore the target property to the original value
  87949. */
  87950. reset(restoreOriginal?: boolean): void;
  87951. /**
  87952. * Specifies if the runtime animation is stopped
  87953. * @returns Boolean specifying if the runtime animation is stopped
  87954. */
  87955. isStopped(): boolean;
  87956. /**
  87957. * Disposes of the runtime animation
  87958. */
  87959. dispose(): void;
  87960. /**
  87961. * Apply the interpolated value to the target
  87962. * @param currentValue defines the value computed by the animation
  87963. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87964. */
  87965. setValue(currentValue: any, weight: number): void;
  87966. private _getOriginalValues;
  87967. private _setValue;
  87968. /**
  87969. * Gets the loop pmode of the runtime animation
  87970. * @returns Loop Mode
  87971. */
  87972. private _getCorrectLoopMode;
  87973. /**
  87974. * Move the current animation to a given frame
  87975. * @param frame defines the frame to move to
  87976. */
  87977. goToFrame(frame: number): void;
  87978. /**
  87979. * @hidden Internal use only
  87980. */
  87981. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87982. /**
  87983. * Execute the current animation
  87984. * @param delay defines the delay to add to the current frame
  87985. * @param from defines the lower bound of the animation range
  87986. * @param to defines the upper bound of the animation range
  87987. * @param loop defines if the current animation must loop
  87988. * @param speedRatio defines the current speed ratio
  87989. * @param weight defines the weight of the animation (default is -1 so no weight)
  87990. * @param onLoop optional callback called when animation loops
  87991. * @returns a boolean indicating if the animation is running
  87992. */
  87993. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87994. }
  87995. }
  87996. declare module BABYLON {
  87997. /**
  87998. * Class used to store an actual running animation
  87999. */
  88000. export class Animatable {
  88001. /** defines the target object */
  88002. target: any;
  88003. /** defines the starting frame number (default is 0) */
  88004. fromFrame: number;
  88005. /** defines the ending frame number (default is 100) */
  88006. toFrame: number;
  88007. /** defines if the animation must loop (default is false) */
  88008. loopAnimation: boolean;
  88009. /** defines a callback to call when animation ends if it is not looping */
  88010. onAnimationEnd?: (() => void) | null | undefined;
  88011. /** defines a callback to call when animation loops */
  88012. onAnimationLoop?: (() => void) | null | undefined;
  88013. private _localDelayOffset;
  88014. private _pausedDelay;
  88015. private _runtimeAnimations;
  88016. private _paused;
  88017. private _scene;
  88018. private _speedRatio;
  88019. private _weight;
  88020. private _syncRoot;
  88021. /**
  88022. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  88023. * This will only apply for non looping animation (default is true)
  88024. */
  88025. disposeOnEnd: boolean;
  88026. /**
  88027. * Gets a boolean indicating if the animation has started
  88028. */
  88029. animationStarted: boolean;
  88030. /**
  88031. * Observer raised when the animation ends
  88032. */
  88033. onAnimationEndObservable: Observable<Animatable>;
  88034. /**
  88035. * Observer raised when the animation loops
  88036. */
  88037. onAnimationLoopObservable: Observable<Animatable>;
  88038. /**
  88039. * Gets the root Animatable used to synchronize and normalize animations
  88040. */
  88041. get syncRoot(): Nullable<Animatable>;
  88042. /**
  88043. * Gets the current frame of the first RuntimeAnimation
  88044. * Used to synchronize Animatables
  88045. */
  88046. get masterFrame(): number;
  88047. /**
  88048. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  88049. */
  88050. get weight(): number;
  88051. set weight(value: number);
  88052. /**
  88053. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  88054. */
  88055. get speedRatio(): number;
  88056. set speedRatio(value: number);
  88057. /**
  88058. * Creates a new Animatable
  88059. * @param scene defines the hosting scene
  88060. * @param target defines the target object
  88061. * @param fromFrame defines the starting frame number (default is 0)
  88062. * @param toFrame defines the ending frame number (default is 100)
  88063. * @param loopAnimation defines if the animation must loop (default is false)
  88064. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  88065. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  88066. * @param animations defines a group of animation to add to the new Animatable
  88067. * @param onAnimationLoop defines a callback to call when animation loops
  88068. */
  88069. constructor(scene: Scene,
  88070. /** defines the target object */
  88071. target: any,
  88072. /** defines the starting frame number (default is 0) */
  88073. fromFrame?: number,
  88074. /** defines the ending frame number (default is 100) */
  88075. toFrame?: number,
  88076. /** defines if the animation must loop (default is false) */
  88077. loopAnimation?: boolean, speedRatio?: number,
  88078. /** defines a callback to call when animation ends if it is not looping */
  88079. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  88080. /** defines a callback to call when animation loops */
  88081. onAnimationLoop?: (() => void) | null | undefined);
  88082. /**
  88083. * Synchronize and normalize current Animatable with a source Animatable
  88084. * This is useful when using animation weights and when animations are not of the same length
  88085. * @param root defines the root Animatable to synchronize with
  88086. * @returns the current Animatable
  88087. */
  88088. syncWith(root: Animatable): Animatable;
  88089. /**
  88090. * Gets the list of runtime animations
  88091. * @returns an array of RuntimeAnimation
  88092. */
  88093. getAnimations(): RuntimeAnimation[];
  88094. /**
  88095. * Adds more animations to the current animatable
  88096. * @param target defines the target of the animations
  88097. * @param animations defines the new animations to add
  88098. */
  88099. appendAnimations(target: any, animations: Animation[]): void;
  88100. /**
  88101. * Gets the source animation for a specific property
  88102. * @param property defines the propertyu to look for
  88103. * @returns null or the source animation for the given property
  88104. */
  88105. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  88106. /**
  88107. * Gets the runtime animation for a specific property
  88108. * @param property defines the propertyu to look for
  88109. * @returns null or the runtime animation for the given property
  88110. */
  88111. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  88112. /**
  88113. * Resets the animatable to its original state
  88114. */
  88115. reset(): void;
  88116. /**
  88117. * Allows the animatable to blend with current running animations
  88118. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88119. * @param blendingSpeed defines the blending speed to use
  88120. */
  88121. enableBlending(blendingSpeed: number): void;
  88122. /**
  88123. * Disable animation blending
  88124. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88125. */
  88126. disableBlending(): void;
  88127. /**
  88128. * Jump directly to a given frame
  88129. * @param frame defines the frame to jump to
  88130. */
  88131. goToFrame(frame: number): void;
  88132. /**
  88133. * Pause the animation
  88134. */
  88135. pause(): void;
  88136. /**
  88137. * Restart the animation
  88138. */
  88139. restart(): void;
  88140. private _raiseOnAnimationEnd;
  88141. /**
  88142. * Stop and delete the current animation
  88143. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  88144. * @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)
  88145. */
  88146. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  88147. /**
  88148. * Wait asynchronously for the animation to end
  88149. * @returns a promise which will be fullfilled when the animation ends
  88150. */
  88151. waitAsync(): Promise<Animatable>;
  88152. /** @hidden */
  88153. _animate(delay: number): boolean;
  88154. }
  88155. interface Scene {
  88156. /** @hidden */
  88157. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  88158. /** @hidden */
  88159. _processLateAnimationBindingsForMatrices(holder: {
  88160. totalWeight: number;
  88161. animations: RuntimeAnimation[];
  88162. originalValue: Matrix;
  88163. }): any;
  88164. /** @hidden */
  88165. _processLateAnimationBindingsForQuaternions(holder: {
  88166. totalWeight: number;
  88167. animations: RuntimeAnimation[];
  88168. originalValue: Quaternion;
  88169. }, refQuaternion: Quaternion): Quaternion;
  88170. /** @hidden */
  88171. _processLateAnimationBindings(): void;
  88172. /**
  88173. * Will start the animation sequence of a given target
  88174. * @param target defines the target
  88175. * @param from defines from which frame should animation start
  88176. * @param to defines until which frame should animation run.
  88177. * @param weight defines the weight to apply to the animation (1.0 by default)
  88178. * @param loop defines if the animation loops
  88179. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88180. * @param onAnimationEnd defines the function to be executed when the animation ends
  88181. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88182. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88183. * @param onAnimationLoop defines the callback to call when an animation loops
  88184. * @returns the animatable object created for this animation
  88185. */
  88186. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88187. /**
  88188. * Will start the animation sequence of a given target
  88189. * @param target defines the target
  88190. * @param from defines from which frame should animation start
  88191. * @param to defines until which frame should animation run.
  88192. * @param loop defines if the animation loops
  88193. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88194. * @param onAnimationEnd defines the function to be executed when the animation ends
  88195. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88196. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88197. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  88198. * @param onAnimationLoop defines the callback to call when an animation loops
  88199. * @returns the animatable object created for this animation
  88200. */
  88201. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88202. /**
  88203. * Will start the animation sequence of a given target and its hierarchy
  88204. * @param target defines the target
  88205. * @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.
  88206. * @param from defines from which frame should animation start
  88207. * @param to defines until which frame should animation run.
  88208. * @param loop defines if the animation loops
  88209. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88210. * @param onAnimationEnd defines the function to be executed when the animation ends
  88211. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88212. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88213. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88214. * @param onAnimationLoop defines the callback to call when an animation loops
  88215. * @returns the list of created animatables
  88216. */
  88217. 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[];
  88218. /**
  88219. * Begin a new animation on a given node
  88220. * @param target defines the target where the animation will take place
  88221. * @param animations defines the list of animations to start
  88222. * @param from defines the initial value
  88223. * @param to defines the final value
  88224. * @param loop defines if you want animation to loop (off by default)
  88225. * @param speedRatio defines the speed ratio to apply to all animations
  88226. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88227. * @param onAnimationLoop defines the callback to call when an animation loops
  88228. * @returns the list of created animatables
  88229. */
  88230. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  88231. /**
  88232. * Begin a new animation on a given node and its hierarchy
  88233. * @param target defines the root node where the animation will take place
  88234. * @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.
  88235. * @param animations defines the list of animations to start
  88236. * @param from defines the initial value
  88237. * @param to defines the final value
  88238. * @param loop defines if you want animation to loop (off by default)
  88239. * @param speedRatio defines the speed ratio to apply to all animations
  88240. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88241. * @param onAnimationLoop defines the callback to call when an animation loops
  88242. * @returns the list of animatables created for all nodes
  88243. */
  88244. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88245. /**
  88246. * Gets the animatable associated with a specific target
  88247. * @param target defines the target of the animatable
  88248. * @returns the required animatable if found
  88249. */
  88250. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88251. /**
  88252. * Gets all animatables associated with a given target
  88253. * @param target defines the target to look animatables for
  88254. * @returns an array of Animatables
  88255. */
  88256. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88257. /**
  88258. * Stops and removes all animations that have been applied to the scene
  88259. */
  88260. stopAllAnimations(): void;
  88261. /**
  88262. * Gets the current delta time used by animation engine
  88263. */
  88264. deltaTime: number;
  88265. }
  88266. interface Bone {
  88267. /**
  88268. * Copy an animation range from another bone
  88269. * @param source defines the source bone
  88270. * @param rangeName defines the range name to copy
  88271. * @param frameOffset defines the frame offset
  88272. * @param rescaleAsRequired defines if rescaling must be applied if required
  88273. * @param skelDimensionsRatio defines the scaling ratio
  88274. * @returns true if operation was successful
  88275. */
  88276. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  88277. }
  88278. }
  88279. declare module BABYLON {
  88280. /**
  88281. * Class used to handle skinning animations
  88282. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88283. */
  88284. export class Skeleton implements IAnimatable {
  88285. /** defines the skeleton name */
  88286. name: string;
  88287. /** defines the skeleton Id */
  88288. id: string;
  88289. /**
  88290. * Defines the list of child bones
  88291. */
  88292. bones: Bone[];
  88293. /**
  88294. * Defines an estimate of the dimension of the skeleton at rest
  88295. */
  88296. dimensionsAtRest: Vector3;
  88297. /**
  88298. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88299. */
  88300. needInitialSkinMatrix: boolean;
  88301. /**
  88302. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88303. */
  88304. overrideMesh: Nullable<AbstractMesh>;
  88305. /**
  88306. * Gets the list of animations attached to this skeleton
  88307. */
  88308. animations: Array<Animation>;
  88309. private _scene;
  88310. private _isDirty;
  88311. private _transformMatrices;
  88312. private _transformMatrixTexture;
  88313. private _meshesWithPoseMatrix;
  88314. private _animatables;
  88315. private _identity;
  88316. private _synchronizedWithMesh;
  88317. private _ranges;
  88318. private _lastAbsoluteTransformsUpdateId;
  88319. private _canUseTextureForBones;
  88320. private _uniqueId;
  88321. /** @hidden */
  88322. _numBonesWithLinkedTransformNode: number;
  88323. /** @hidden */
  88324. _hasWaitingData: Nullable<boolean>;
  88325. /**
  88326. * Specifies if the skeleton should be serialized
  88327. */
  88328. doNotSerialize: boolean;
  88329. private _useTextureToStoreBoneMatrices;
  88330. /**
  88331. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88332. * Please note that this option is not available if the hardware does not support it
  88333. */
  88334. get useTextureToStoreBoneMatrices(): boolean;
  88335. set useTextureToStoreBoneMatrices(value: boolean);
  88336. private _animationPropertiesOverride;
  88337. /**
  88338. * Gets or sets the animation properties override
  88339. */
  88340. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88341. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88342. /**
  88343. * List of inspectable custom properties (used by the Inspector)
  88344. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88345. */
  88346. inspectableCustomProperties: IInspectable[];
  88347. /**
  88348. * An observable triggered before computing the skeleton's matrices
  88349. */
  88350. onBeforeComputeObservable: Observable<Skeleton>;
  88351. /**
  88352. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88353. */
  88354. get isUsingTextureForMatrices(): boolean;
  88355. /**
  88356. * Gets the unique ID of this skeleton
  88357. */
  88358. get uniqueId(): number;
  88359. /**
  88360. * Creates a new skeleton
  88361. * @param name defines the skeleton name
  88362. * @param id defines the skeleton Id
  88363. * @param scene defines the hosting scene
  88364. */
  88365. constructor(
  88366. /** defines the skeleton name */
  88367. name: string,
  88368. /** defines the skeleton Id */
  88369. id: string, scene: Scene);
  88370. /**
  88371. * Gets the current object class name.
  88372. * @return the class name
  88373. */
  88374. getClassName(): string;
  88375. /**
  88376. * Returns an array containing the root bones
  88377. * @returns an array containing the root bones
  88378. */
  88379. getChildren(): Array<Bone>;
  88380. /**
  88381. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88382. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88383. * @returns a Float32Array containing matrices data
  88384. */
  88385. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88386. /**
  88387. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88388. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88389. * @returns a raw texture containing the data
  88390. */
  88391. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88392. /**
  88393. * Gets the current hosting scene
  88394. * @returns a scene object
  88395. */
  88396. getScene(): Scene;
  88397. /**
  88398. * Gets a string representing the current skeleton data
  88399. * @param fullDetails defines a boolean indicating if we want a verbose version
  88400. * @returns a string representing the current skeleton data
  88401. */
  88402. toString(fullDetails?: boolean): string;
  88403. /**
  88404. * Get bone's index searching by name
  88405. * @param name defines bone's name to search for
  88406. * @return the indice of the bone. Returns -1 if not found
  88407. */
  88408. getBoneIndexByName(name: string): number;
  88409. /**
  88410. * Creater a new animation range
  88411. * @param name defines the name of the range
  88412. * @param from defines the start key
  88413. * @param to defines the end key
  88414. */
  88415. createAnimationRange(name: string, from: number, to: number): void;
  88416. /**
  88417. * Delete a specific animation range
  88418. * @param name defines the name of the range
  88419. * @param deleteFrames defines if frames must be removed as well
  88420. */
  88421. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88422. /**
  88423. * Gets a specific animation range
  88424. * @param name defines the name of the range to look for
  88425. * @returns the requested animation range or null if not found
  88426. */
  88427. getAnimationRange(name: string): Nullable<AnimationRange>;
  88428. /**
  88429. * Gets the list of all animation ranges defined on this skeleton
  88430. * @returns an array
  88431. */
  88432. getAnimationRanges(): Nullable<AnimationRange>[];
  88433. /**
  88434. * Copy animation range from a source skeleton.
  88435. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88436. * @param source defines the source skeleton
  88437. * @param name defines the name of the range to copy
  88438. * @param rescaleAsRequired defines if rescaling must be applied if required
  88439. * @returns true if operation was successful
  88440. */
  88441. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88442. /**
  88443. * Forces the skeleton to go to rest pose
  88444. */
  88445. returnToRest(): void;
  88446. private _getHighestAnimationFrame;
  88447. /**
  88448. * Begin a specific animation range
  88449. * @param name defines the name of the range to start
  88450. * @param loop defines if looping must be turned on (false by default)
  88451. * @param speedRatio defines the speed ratio to apply (1 by default)
  88452. * @param onAnimationEnd defines a callback which will be called when animation will end
  88453. * @returns a new animatable
  88454. */
  88455. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88456. /** @hidden */
  88457. _markAsDirty(): void;
  88458. /** @hidden */
  88459. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88460. /** @hidden */
  88461. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88462. private _computeTransformMatrices;
  88463. /**
  88464. * Build all resources required to render a skeleton
  88465. */
  88466. prepare(): void;
  88467. /**
  88468. * Gets the list of animatables currently running for this skeleton
  88469. * @returns an array of animatables
  88470. */
  88471. getAnimatables(): IAnimatable[];
  88472. /**
  88473. * Clone the current skeleton
  88474. * @param name defines the name of the new skeleton
  88475. * @param id defines the id of the new skeleton
  88476. * @returns the new skeleton
  88477. */
  88478. clone(name: string, id?: string): Skeleton;
  88479. /**
  88480. * Enable animation blending for this skeleton
  88481. * @param blendingSpeed defines the blending speed to apply
  88482. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88483. */
  88484. enableBlending(blendingSpeed?: number): void;
  88485. /**
  88486. * Releases all resources associated with the current skeleton
  88487. */
  88488. dispose(): void;
  88489. /**
  88490. * Serialize the skeleton in a JSON object
  88491. * @returns a JSON object
  88492. */
  88493. serialize(): any;
  88494. /**
  88495. * Creates a new skeleton from serialized data
  88496. * @param parsedSkeleton defines the serialized data
  88497. * @param scene defines the hosting scene
  88498. * @returns a new skeleton
  88499. */
  88500. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88501. /**
  88502. * Compute all node absolute transforms
  88503. * @param forceUpdate defines if computation must be done even if cache is up to date
  88504. */
  88505. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88506. /**
  88507. * Gets the root pose matrix
  88508. * @returns a matrix
  88509. */
  88510. getPoseMatrix(): Nullable<Matrix>;
  88511. /**
  88512. * Sorts bones per internal index
  88513. */
  88514. sortBones(): void;
  88515. private _sortBones;
  88516. }
  88517. }
  88518. declare module BABYLON {
  88519. /**
  88520. * Creates an instance based on a source mesh.
  88521. */
  88522. export class InstancedMesh extends AbstractMesh {
  88523. private _sourceMesh;
  88524. private _currentLOD;
  88525. /** @hidden */
  88526. _indexInSourceMeshInstanceArray: number;
  88527. constructor(name: string, source: Mesh);
  88528. /**
  88529. * Returns the string "InstancedMesh".
  88530. */
  88531. getClassName(): string;
  88532. /** Gets the list of lights affecting that mesh */
  88533. get lightSources(): Light[];
  88534. _resyncLightSources(): void;
  88535. _resyncLightSource(light: Light): void;
  88536. _removeLightSource(light: Light, dispose: boolean): void;
  88537. /**
  88538. * If the source mesh receives shadows
  88539. */
  88540. get receiveShadows(): boolean;
  88541. /**
  88542. * The material of the source mesh
  88543. */
  88544. get material(): Nullable<Material>;
  88545. /**
  88546. * Visibility of the source mesh
  88547. */
  88548. get visibility(): number;
  88549. /**
  88550. * Skeleton of the source mesh
  88551. */
  88552. get skeleton(): Nullable<Skeleton>;
  88553. /**
  88554. * Rendering ground id of the source mesh
  88555. */
  88556. get renderingGroupId(): number;
  88557. set renderingGroupId(value: number);
  88558. /**
  88559. * Returns the total number of vertices (integer).
  88560. */
  88561. getTotalVertices(): number;
  88562. /**
  88563. * Returns a positive integer : the total number of indices in this mesh geometry.
  88564. * @returns the numner of indices or zero if the mesh has no geometry.
  88565. */
  88566. getTotalIndices(): number;
  88567. /**
  88568. * The source mesh of the instance
  88569. */
  88570. get sourceMesh(): Mesh;
  88571. /**
  88572. * Is this node ready to be used/rendered
  88573. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88574. * @return {boolean} is it ready
  88575. */
  88576. isReady(completeCheck?: boolean): boolean;
  88577. /**
  88578. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88579. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88580. * @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.
  88581. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88582. */
  88583. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88584. /**
  88585. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88586. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88587. * The `data` are either a numeric array either a Float32Array.
  88588. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88589. * 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).
  88590. * Note that a new underlying VertexBuffer object is created each call.
  88591. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88592. *
  88593. * Possible `kind` values :
  88594. * - VertexBuffer.PositionKind
  88595. * - VertexBuffer.UVKind
  88596. * - VertexBuffer.UV2Kind
  88597. * - VertexBuffer.UV3Kind
  88598. * - VertexBuffer.UV4Kind
  88599. * - VertexBuffer.UV5Kind
  88600. * - VertexBuffer.UV6Kind
  88601. * - VertexBuffer.ColorKind
  88602. * - VertexBuffer.MatricesIndicesKind
  88603. * - VertexBuffer.MatricesIndicesExtraKind
  88604. * - VertexBuffer.MatricesWeightsKind
  88605. * - VertexBuffer.MatricesWeightsExtraKind
  88606. *
  88607. * Returns the Mesh.
  88608. */
  88609. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88610. /**
  88611. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88612. * If the mesh has no geometry, it is simply returned as it is.
  88613. * The `data` are either a numeric array either a Float32Array.
  88614. * No new underlying VertexBuffer object is created.
  88615. * 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.
  88616. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88617. *
  88618. * Possible `kind` values :
  88619. * - VertexBuffer.PositionKind
  88620. * - VertexBuffer.UVKind
  88621. * - VertexBuffer.UV2Kind
  88622. * - VertexBuffer.UV3Kind
  88623. * - VertexBuffer.UV4Kind
  88624. * - VertexBuffer.UV5Kind
  88625. * - VertexBuffer.UV6Kind
  88626. * - VertexBuffer.ColorKind
  88627. * - VertexBuffer.MatricesIndicesKind
  88628. * - VertexBuffer.MatricesIndicesExtraKind
  88629. * - VertexBuffer.MatricesWeightsKind
  88630. * - VertexBuffer.MatricesWeightsExtraKind
  88631. *
  88632. * Returns the Mesh.
  88633. */
  88634. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88635. /**
  88636. * Sets the mesh indices.
  88637. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88638. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88639. * This method creates a new index buffer each call.
  88640. * Returns the Mesh.
  88641. */
  88642. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88643. /**
  88644. * Boolean : True if the mesh owns the requested kind of data.
  88645. */
  88646. isVerticesDataPresent(kind: string): boolean;
  88647. /**
  88648. * Returns an array of indices (IndicesArray).
  88649. */
  88650. getIndices(): Nullable<IndicesArray>;
  88651. get _positions(): Nullable<Vector3[]>;
  88652. /**
  88653. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88654. * This means the mesh underlying bounding box and sphere are recomputed.
  88655. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88656. * @returns the current mesh
  88657. */
  88658. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88659. /** @hidden */
  88660. _preActivate(): InstancedMesh;
  88661. /** @hidden */
  88662. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88663. /** @hidden */
  88664. _postActivate(): void;
  88665. getWorldMatrix(): Matrix;
  88666. get isAnInstance(): boolean;
  88667. /**
  88668. * Returns the current associated LOD AbstractMesh.
  88669. */
  88670. getLOD(camera: Camera): AbstractMesh;
  88671. /** @hidden */
  88672. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88673. /** @hidden */
  88674. _syncSubMeshes(): InstancedMesh;
  88675. /** @hidden */
  88676. _generatePointsArray(): boolean;
  88677. /**
  88678. * Creates a new InstancedMesh from the current mesh.
  88679. * - name (string) : the cloned mesh name
  88680. * - newParent (optional Node) : the optional Node to parent the clone to.
  88681. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88682. *
  88683. * Returns the clone.
  88684. */
  88685. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88686. /**
  88687. * Disposes the InstancedMesh.
  88688. * Returns nothing.
  88689. */
  88690. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88691. }
  88692. interface Mesh {
  88693. /**
  88694. * Register a custom buffer that will be instanced
  88695. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88696. * @param kind defines the buffer kind
  88697. * @param stride defines the stride in floats
  88698. */
  88699. registerInstancedBuffer(kind: string, stride: number): void;
  88700. /** @hidden */
  88701. _userInstancedBuffersStorage: {
  88702. data: {
  88703. [key: string]: Float32Array;
  88704. };
  88705. sizes: {
  88706. [key: string]: number;
  88707. };
  88708. vertexBuffers: {
  88709. [key: string]: Nullable<VertexBuffer>;
  88710. };
  88711. strides: {
  88712. [key: string]: number;
  88713. };
  88714. };
  88715. }
  88716. interface AbstractMesh {
  88717. /**
  88718. * Object used to store instanced buffers defined by user
  88719. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88720. */
  88721. instancedBuffers: {
  88722. [key: string]: any;
  88723. };
  88724. }
  88725. }
  88726. declare module BABYLON {
  88727. /**
  88728. * Defines the options associated with the creation of a shader material.
  88729. */
  88730. export interface IShaderMaterialOptions {
  88731. /**
  88732. * Does the material work in alpha blend mode
  88733. */
  88734. needAlphaBlending: boolean;
  88735. /**
  88736. * Does the material work in alpha test mode
  88737. */
  88738. needAlphaTesting: boolean;
  88739. /**
  88740. * The list of attribute names used in the shader
  88741. */
  88742. attributes: string[];
  88743. /**
  88744. * The list of unifrom names used in the shader
  88745. */
  88746. uniforms: string[];
  88747. /**
  88748. * The list of UBO names used in the shader
  88749. */
  88750. uniformBuffers: string[];
  88751. /**
  88752. * The list of sampler names used in the shader
  88753. */
  88754. samplers: string[];
  88755. /**
  88756. * The list of defines used in the shader
  88757. */
  88758. defines: string[];
  88759. }
  88760. /**
  88761. * 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.
  88762. *
  88763. * This returned material effects how the mesh will look based on the code in the shaders.
  88764. *
  88765. * @see http://doc.babylonjs.com/how_to/shader_material
  88766. */
  88767. export class ShaderMaterial extends Material {
  88768. private _shaderPath;
  88769. private _options;
  88770. private _textures;
  88771. private _textureArrays;
  88772. private _floats;
  88773. private _ints;
  88774. private _floatsArrays;
  88775. private _colors3;
  88776. private _colors3Arrays;
  88777. private _colors4;
  88778. private _colors4Arrays;
  88779. private _vectors2;
  88780. private _vectors3;
  88781. private _vectors4;
  88782. private _matrices;
  88783. private _matrixArrays;
  88784. private _matrices3x3;
  88785. private _matrices2x2;
  88786. private _vectors2Arrays;
  88787. private _vectors3Arrays;
  88788. private _vectors4Arrays;
  88789. private _cachedWorldViewMatrix;
  88790. private _cachedWorldViewProjectionMatrix;
  88791. private _renderId;
  88792. private _multiview;
  88793. /**
  88794. * Instantiate a new shader material.
  88795. * 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.
  88796. * This returned material effects how the mesh will look based on the code in the shaders.
  88797. * @see http://doc.babylonjs.com/how_to/shader_material
  88798. * @param name Define the name of the material in the scene
  88799. * @param scene Define the scene the material belongs to
  88800. * @param shaderPath Defines the route to the shader code in one of three ways:
  88801. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88802. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88803. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88804. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88805. * @param options Define the options used to create the shader
  88806. */
  88807. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88808. /**
  88809. * Gets the shader path used to define the shader code
  88810. * It can be modified to trigger a new compilation
  88811. */
  88812. get shaderPath(): any;
  88813. /**
  88814. * Sets the shader path used to define the shader code
  88815. * It can be modified to trigger a new compilation
  88816. */
  88817. set shaderPath(shaderPath: any);
  88818. /**
  88819. * Gets the options used to compile the shader.
  88820. * They can be modified to trigger a new compilation
  88821. */
  88822. get options(): IShaderMaterialOptions;
  88823. /**
  88824. * Gets the current class name of the material e.g. "ShaderMaterial"
  88825. * Mainly use in serialization.
  88826. * @returns the class name
  88827. */
  88828. getClassName(): string;
  88829. /**
  88830. * Specifies if the material will require alpha blending
  88831. * @returns a boolean specifying if alpha blending is needed
  88832. */
  88833. needAlphaBlending(): boolean;
  88834. /**
  88835. * Specifies if this material should be rendered in alpha test mode
  88836. * @returns a boolean specifying if an alpha test is needed.
  88837. */
  88838. needAlphaTesting(): boolean;
  88839. private _checkUniform;
  88840. /**
  88841. * Set a texture in the shader.
  88842. * @param name Define the name of the uniform samplers as defined in the shader
  88843. * @param texture Define the texture to bind to this sampler
  88844. * @return the material itself allowing "fluent" like uniform updates
  88845. */
  88846. setTexture(name: string, texture: Texture): ShaderMaterial;
  88847. /**
  88848. * Set a texture array in the shader.
  88849. * @param name Define the name of the uniform sampler array as defined in the shader
  88850. * @param textures Define the list of textures to bind to this sampler
  88851. * @return the material itself allowing "fluent" like uniform updates
  88852. */
  88853. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88854. /**
  88855. * Set a float in the shader.
  88856. * @param name Define the name of the uniform as defined in the shader
  88857. * @param value Define the value to give to the uniform
  88858. * @return the material itself allowing "fluent" like uniform updates
  88859. */
  88860. setFloat(name: string, value: number): ShaderMaterial;
  88861. /**
  88862. * Set a int in the shader.
  88863. * @param name Define the name of the uniform as defined in the shader
  88864. * @param value Define the value to give to the uniform
  88865. * @return the material itself allowing "fluent" like uniform updates
  88866. */
  88867. setInt(name: string, value: number): ShaderMaterial;
  88868. /**
  88869. * Set an array of floats in the shader.
  88870. * @param name Define the name of the uniform as defined in the shader
  88871. * @param value Define the value to give to the uniform
  88872. * @return the material itself allowing "fluent" like uniform updates
  88873. */
  88874. setFloats(name: string, value: number[]): ShaderMaterial;
  88875. /**
  88876. * Set a vec3 in the shader from a Color3.
  88877. * @param name Define the name of the uniform as defined in the shader
  88878. * @param value Define the value to give to the uniform
  88879. * @return the material itself allowing "fluent" like uniform updates
  88880. */
  88881. setColor3(name: string, value: Color3): ShaderMaterial;
  88882. /**
  88883. * Set a vec3 array in the shader from a Color3 array.
  88884. * @param name Define the name of the uniform as defined in the shader
  88885. * @param value Define the value to give to the uniform
  88886. * @return the material itself allowing "fluent" like uniform updates
  88887. */
  88888. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88889. /**
  88890. * Set a vec4 in the shader from a Color4.
  88891. * @param name Define the name of the uniform as defined in the shader
  88892. * @param value Define the value to give to the uniform
  88893. * @return the material itself allowing "fluent" like uniform updates
  88894. */
  88895. setColor4(name: string, value: Color4): ShaderMaterial;
  88896. /**
  88897. * Set a vec4 array in the shader from a Color4 array.
  88898. * @param name Define the name of the uniform as defined in the shader
  88899. * @param value Define the value to give to the uniform
  88900. * @return the material itself allowing "fluent" like uniform updates
  88901. */
  88902. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88903. /**
  88904. * Set a vec2 in the shader from a Vector2.
  88905. * @param name Define the name of the uniform as defined in the shader
  88906. * @param value Define the value to give to the uniform
  88907. * @return the material itself allowing "fluent" like uniform updates
  88908. */
  88909. setVector2(name: string, value: Vector2): ShaderMaterial;
  88910. /**
  88911. * Set a vec3 in the shader from a Vector3.
  88912. * @param name Define the name of the uniform as defined in the shader
  88913. * @param value Define the value to give to the uniform
  88914. * @return the material itself allowing "fluent" like uniform updates
  88915. */
  88916. setVector3(name: string, value: Vector3): ShaderMaterial;
  88917. /**
  88918. * Set a vec4 in the shader from a Vector4.
  88919. * @param name Define the name of the uniform as defined in the shader
  88920. * @param value Define the value to give to the uniform
  88921. * @return the material itself allowing "fluent" like uniform updates
  88922. */
  88923. setVector4(name: string, value: Vector4): ShaderMaterial;
  88924. /**
  88925. * Set a mat4 in the shader from a Matrix.
  88926. * @param name Define the name of the uniform as defined in the shader
  88927. * @param value Define the value to give to the uniform
  88928. * @return the material itself allowing "fluent" like uniform updates
  88929. */
  88930. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88931. /**
  88932. * Set a float32Array in the shader from a matrix array.
  88933. * @param name Define the name of the uniform as defined in the shader
  88934. * @param value Define the value to give to the uniform
  88935. * @return the material itself allowing "fluent" like uniform updates
  88936. */
  88937. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88938. /**
  88939. * Set a mat3 in the shader from a Float32Array.
  88940. * @param name Define the name of the uniform as defined in the shader
  88941. * @param value Define the value to give to the uniform
  88942. * @return the material itself allowing "fluent" like uniform updates
  88943. */
  88944. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88945. /**
  88946. * Set a mat2 in the shader from a Float32Array.
  88947. * @param name Define the name of the uniform as defined in the shader
  88948. * @param value Define the value to give to the uniform
  88949. * @return the material itself allowing "fluent" like uniform updates
  88950. */
  88951. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88952. /**
  88953. * Set a vec2 array in the shader from a number array.
  88954. * @param name Define the name of the uniform as defined in the shader
  88955. * @param value Define the value to give to the uniform
  88956. * @return the material itself allowing "fluent" like uniform updates
  88957. */
  88958. setArray2(name: string, value: number[]): ShaderMaterial;
  88959. /**
  88960. * Set a vec3 array in the shader from a number array.
  88961. * @param name Define the name of the uniform as defined in the shader
  88962. * @param value Define the value to give to the uniform
  88963. * @return the material itself allowing "fluent" like uniform updates
  88964. */
  88965. setArray3(name: string, value: number[]): ShaderMaterial;
  88966. /**
  88967. * Set a vec4 array in the shader from a number array.
  88968. * @param name Define the name of the uniform as defined in the shader
  88969. * @param value Define the value to give to the uniform
  88970. * @return the material itself allowing "fluent" like uniform updates
  88971. */
  88972. setArray4(name: string, value: number[]): ShaderMaterial;
  88973. private _checkCache;
  88974. /**
  88975. * Specifies that the submesh is ready to be used
  88976. * @param mesh defines the mesh to check
  88977. * @param subMesh defines which submesh to check
  88978. * @param useInstances specifies that instances should be used
  88979. * @returns a boolean indicating that the submesh is ready or not
  88980. */
  88981. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88982. /**
  88983. * Checks if the material is ready to render the requested mesh
  88984. * @param mesh Define the mesh to render
  88985. * @param useInstances Define whether or not the material is used with instances
  88986. * @returns true if ready, otherwise false
  88987. */
  88988. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88989. /**
  88990. * Binds the world matrix to the material
  88991. * @param world defines the world transformation matrix
  88992. */
  88993. bindOnlyWorldMatrix(world: Matrix): void;
  88994. /**
  88995. * Binds the material to the mesh
  88996. * @param world defines the world transformation matrix
  88997. * @param mesh defines the mesh to bind the material to
  88998. */
  88999. bind(world: Matrix, mesh?: Mesh): void;
  89000. /**
  89001. * Gets the active textures from the material
  89002. * @returns an array of textures
  89003. */
  89004. getActiveTextures(): BaseTexture[];
  89005. /**
  89006. * Specifies if the material uses a texture
  89007. * @param texture defines the texture to check against the material
  89008. * @returns a boolean specifying if the material uses the texture
  89009. */
  89010. hasTexture(texture: BaseTexture): boolean;
  89011. /**
  89012. * Makes a duplicate of the material, and gives it a new name
  89013. * @param name defines the new name for the duplicated material
  89014. * @returns the cloned material
  89015. */
  89016. clone(name: string): ShaderMaterial;
  89017. /**
  89018. * Disposes the material
  89019. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89020. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89021. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89022. */
  89023. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89024. /**
  89025. * Serializes this material in a JSON representation
  89026. * @returns the serialized material object
  89027. */
  89028. serialize(): any;
  89029. /**
  89030. * Creates a shader material from parsed shader material data
  89031. * @param source defines the JSON represnetation of the material
  89032. * @param scene defines the hosting scene
  89033. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89034. * @returns a new material
  89035. */
  89036. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  89037. }
  89038. }
  89039. declare module BABYLON {
  89040. /** @hidden */
  89041. export var colorPixelShader: {
  89042. name: string;
  89043. shader: string;
  89044. };
  89045. }
  89046. declare module BABYLON {
  89047. /** @hidden */
  89048. export var colorVertexShader: {
  89049. name: string;
  89050. shader: string;
  89051. };
  89052. }
  89053. declare module BABYLON {
  89054. /**
  89055. * Line mesh
  89056. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  89057. */
  89058. export class LinesMesh extends Mesh {
  89059. /**
  89060. * If vertex color should be applied to the mesh
  89061. */
  89062. readonly useVertexColor?: boolean | undefined;
  89063. /**
  89064. * If vertex alpha should be applied to the mesh
  89065. */
  89066. readonly useVertexAlpha?: boolean | undefined;
  89067. /**
  89068. * Color of the line (Default: White)
  89069. */
  89070. color: Color3;
  89071. /**
  89072. * Alpha of the line (Default: 1)
  89073. */
  89074. alpha: number;
  89075. /**
  89076. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89077. * This margin is expressed in world space coordinates, so its value may vary.
  89078. * Default value is 0.1
  89079. */
  89080. intersectionThreshold: number;
  89081. private _colorShader;
  89082. private color4;
  89083. /**
  89084. * Creates a new LinesMesh
  89085. * @param name defines the name
  89086. * @param scene defines the hosting scene
  89087. * @param parent defines the parent mesh if any
  89088. * @param source defines the optional source LinesMesh used to clone data from
  89089. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89090. * When false, achieved by calling a clone(), also passing False.
  89091. * This will make creation of children, recursive.
  89092. * @param useVertexColor defines if this LinesMesh supports vertex color
  89093. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  89094. */
  89095. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  89096. /**
  89097. * If vertex color should be applied to the mesh
  89098. */
  89099. useVertexColor?: boolean | undefined,
  89100. /**
  89101. * If vertex alpha should be applied to the mesh
  89102. */
  89103. useVertexAlpha?: boolean | undefined);
  89104. private _addClipPlaneDefine;
  89105. private _removeClipPlaneDefine;
  89106. isReady(): boolean;
  89107. /**
  89108. * Returns the string "LineMesh"
  89109. */
  89110. getClassName(): string;
  89111. /**
  89112. * @hidden
  89113. */
  89114. get material(): Material;
  89115. /**
  89116. * @hidden
  89117. */
  89118. set material(value: Material);
  89119. /**
  89120. * @hidden
  89121. */
  89122. get checkCollisions(): boolean;
  89123. /** @hidden */
  89124. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89125. /** @hidden */
  89126. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89127. /**
  89128. * Disposes of the line mesh
  89129. * @param doNotRecurse If children should be disposed
  89130. */
  89131. dispose(doNotRecurse?: boolean): void;
  89132. /**
  89133. * Returns a new LineMesh object cloned from the current one.
  89134. */
  89135. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  89136. /**
  89137. * Creates a new InstancedLinesMesh object from the mesh model.
  89138. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89139. * @param name defines the name of the new instance
  89140. * @returns a new InstancedLinesMesh
  89141. */
  89142. createInstance(name: string): InstancedLinesMesh;
  89143. }
  89144. /**
  89145. * Creates an instance based on a source LinesMesh
  89146. */
  89147. export class InstancedLinesMesh extends InstancedMesh {
  89148. /**
  89149. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89150. * This margin is expressed in world space coordinates, so its value may vary.
  89151. * Initilized with the intersectionThreshold value of the source LinesMesh
  89152. */
  89153. intersectionThreshold: number;
  89154. constructor(name: string, source: LinesMesh);
  89155. /**
  89156. * Returns the string "InstancedLinesMesh".
  89157. */
  89158. getClassName(): string;
  89159. }
  89160. }
  89161. declare module BABYLON {
  89162. /** @hidden */
  89163. export var linePixelShader: {
  89164. name: string;
  89165. shader: string;
  89166. };
  89167. }
  89168. declare module BABYLON {
  89169. /** @hidden */
  89170. export var lineVertexShader: {
  89171. name: string;
  89172. shader: string;
  89173. };
  89174. }
  89175. declare module BABYLON {
  89176. interface AbstractMesh {
  89177. /**
  89178. * Gets the edgesRenderer associated with the mesh
  89179. */
  89180. edgesRenderer: Nullable<EdgesRenderer>;
  89181. }
  89182. interface LinesMesh {
  89183. /**
  89184. * Enables the edge rendering mode on the mesh.
  89185. * This mode makes the mesh edges visible
  89186. * @param epsilon defines the maximal distance between two angles to detect a face
  89187. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89188. * @returns the currentAbstractMesh
  89189. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89190. */
  89191. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  89192. }
  89193. interface InstancedLinesMesh {
  89194. /**
  89195. * Enables the edge rendering mode on the mesh.
  89196. * This mode makes the mesh edges visible
  89197. * @param epsilon defines the maximal distance between two angles to detect a face
  89198. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89199. * @returns the current InstancedLinesMesh
  89200. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89201. */
  89202. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  89203. }
  89204. /**
  89205. * Defines the minimum contract an Edges renderer should follow.
  89206. */
  89207. export interface IEdgesRenderer extends IDisposable {
  89208. /**
  89209. * Gets or sets a boolean indicating if the edgesRenderer is active
  89210. */
  89211. isEnabled: boolean;
  89212. /**
  89213. * Renders the edges of the attached mesh,
  89214. */
  89215. render(): void;
  89216. /**
  89217. * Checks wether or not the edges renderer is ready to render.
  89218. * @return true if ready, otherwise false.
  89219. */
  89220. isReady(): boolean;
  89221. }
  89222. /**
  89223. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89224. */
  89225. export class EdgesRenderer implements IEdgesRenderer {
  89226. /**
  89227. * Define the size of the edges with an orthographic camera
  89228. */
  89229. edgesWidthScalerForOrthographic: number;
  89230. /**
  89231. * Define the size of the edges with a perspective camera
  89232. */
  89233. edgesWidthScalerForPerspective: number;
  89234. protected _source: AbstractMesh;
  89235. protected _linesPositions: number[];
  89236. protected _linesNormals: number[];
  89237. protected _linesIndices: number[];
  89238. protected _epsilon: number;
  89239. protected _indicesCount: number;
  89240. protected _lineShader: ShaderMaterial;
  89241. protected _ib: DataBuffer;
  89242. protected _buffers: {
  89243. [key: string]: Nullable<VertexBuffer>;
  89244. };
  89245. protected _checkVerticesInsteadOfIndices: boolean;
  89246. private _meshRebuildObserver;
  89247. private _meshDisposeObserver;
  89248. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89249. isEnabled: boolean;
  89250. /**
  89251. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89252. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89253. * @param source Mesh used to create edges
  89254. * @param epsilon sum of angles in adjacency to check for edge
  89255. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89256. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89257. */
  89258. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89259. protected _prepareRessources(): void;
  89260. /** @hidden */
  89261. _rebuild(): void;
  89262. /**
  89263. * Releases the required resources for the edges renderer
  89264. */
  89265. dispose(): void;
  89266. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89267. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89268. /**
  89269. * Checks if the pair of p0 and p1 is en edge
  89270. * @param faceIndex
  89271. * @param edge
  89272. * @param faceNormals
  89273. * @param p0
  89274. * @param p1
  89275. * @private
  89276. */
  89277. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89278. /**
  89279. * push line into the position, normal and index buffer
  89280. * @protected
  89281. */
  89282. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89283. /**
  89284. * Generates lines edges from adjacencjes
  89285. * @private
  89286. */
  89287. _generateEdgesLines(): void;
  89288. /**
  89289. * Checks wether or not the edges renderer is ready to render.
  89290. * @return true if ready, otherwise false.
  89291. */
  89292. isReady(): boolean;
  89293. /**
  89294. * Renders the edges of the attached mesh,
  89295. */
  89296. render(): void;
  89297. }
  89298. /**
  89299. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89300. */
  89301. export class LineEdgesRenderer extends EdgesRenderer {
  89302. /**
  89303. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89304. * @param source LineMesh used to generate edges
  89305. * @param epsilon not important (specified angle for edge detection)
  89306. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89307. */
  89308. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89309. /**
  89310. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89311. */
  89312. _generateEdgesLines(): void;
  89313. }
  89314. }
  89315. declare module BABYLON {
  89316. /**
  89317. * This represents the object necessary to create a rendering group.
  89318. * This is exclusively used and created by the rendering manager.
  89319. * To modify the behavior, you use the available helpers in your scene or meshes.
  89320. * @hidden
  89321. */
  89322. export class RenderingGroup {
  89323. index: number;
  89324. private static _zeroVector;
  89325. private _scene;
  89326. private _opaqueSubMeshes;
  89327. private _transparentSubMeshes;
  89328. private _alphaTestSubMeshes;
  89329. private _depthOnlySubMeshes;
  89330. private _particleSystems;
  89331. private _spriteManagers;
  89332. private _opaqueSortCompareFn;
  89333. private _alphaTestSortCompareFn;
  89334. private _transparentSortCompareFn;
  89335. private _renderOpaque;
  89336. private _renderAlphaTest;
  89337. private _renderTransparent;
  89338. /** @hidden */
  89339. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89340. onBeforeTransparentRendering: () => void;
  89341. /**
  89342. * Set the opaque sort comparison function.
  89343. * If null the sub meshes will be render in the order they were created
  89344. */
  89345. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89346. /**
  89347. * Set the alpha test sort comparison function.
  89348. * If null the sub meshes will be render in the order they were created
  89349. */
  89350. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89351. /**
  89352. * Set the transparent sort comparison function.
  89353. * If null the sub meshes will be render in the order they were created
  89354. */
  89355. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89356. /**
  89357. * Creates a new rendering group.
  89358. * @param index The rendering group index
  89359. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89360. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89361. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89362. */
  89363. 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>);
  89364. /**
  89365. * Render all the sub meshes contained in the group.
  89366. * @param customRenderFunction Used to override the default render behaviour of the group.
  89367. * @returns true if rendered some submeshes.
  89368. */
  89369. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89370. /**
  89371. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89372. * @param subMeshes The submeshes to render
  89373. */
  89374. private renderOpaqueSorted;
  89375. /**
  89376. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89377. * @param subMeshes The submeshes to render
  89378. */
  89379. private renderAlphaTestSorted;
  89380. /**
  89381. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89382. * @param subMeshes The submeshes to render
  89383. */
  89384. private renderTransparentSorted;
  89385. /**
  89386. * Renders the submeshes in a specified order.
  89387. * @param subMeshes The submeshes to sort before render
  89388. * @param sortCompareFn The comparison function use to sort
  89389. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89390. * @param transparent Specifies to activate blending if true
  89391. */
  89392. private static renderSorted;
  89393. /**
  89394. * Renders the submeshes in the order they were dispatched (no sort applied).
  89395. * @param subMeshes The submeshes to render
  89396. */
  89397. private static renderUnsorted;
  89398. /**
  89399. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89400. * are rendered back to front if in the same alpha index.
  89401. *
  89402. * @param a The first submesh
  89403. * @param b The second submesh
  89404. * @returns The result of the comparison
  89405. */
  89406. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89407. /**
  89408. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89409. * are rendered back to front.
  89410. *
  89411. * @param a The first submesh
  89412. * @param b The second submesh
  89413. * @returns The result of the comparison
  89414. */
  89415. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89416. /**
  89417. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89418. * are rendered front to back (prevent overdraw).
  89419. *
  89420. * @param a The first submesh
  89421. * @param b The second submesh
  89422. * @returns The result of the comparison
  89423. */
  89424. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89425. /**
  89426. * Resets the different lists of submeshes to prepare a new frame.
  89427. */
  89428. prepare(): void;
  89429. dispose(): void;
  89430. /**
  89431. * Inserts the submesh in its correct queue depending on its material.
  89432. * @param subMesh The submesh to dispatch
  89433. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89434. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89435. */
  89436. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89437. dispatchSprites(spriteManager: ISpriteManager): void;
  89438. dispatchParticles(particleSystem: IParticleSystem): void;
  89439. private _renderParticles;
  89440. private _renderSprites;
  89441. }
  89442. }
  89443. declare module BABYLON {
  89444. /**
  89445. * Interface describing the different options available in the rendering manager
  89446. * regarding Auto Clear between groups.
  89447. */
  89448. export interface IRenderingManagerAutoClearSetup {
  89449. /**
  89450. * Defines whether or not autoclear is enable.
  89451. */
  89452. autoClear: boolean;
  89453. /**
  89454. * Defines whether or not to autoclear the depth buffer.
  89455. */
  89456. depth: boolean;
  89457. /**
  89458. * Defines whether or not to autoclear the stencil buffer.
  89459. */
  89460. stencil: boolean;
  89461. }
  89462. /**
  89463. * This class is used by the onRenderingGroupObservable
  89464. */
  89465. export class RenderingGroupInfo {
  89466. /**
  89467. * The Scene that being rendered
  89468. */
  89469. scene: Scene;
  89470. /**
  89471. * The camera currently used for the rendering pass
  89472. */
  89473. camera: Nullable<Camera>;
  89474. /**
  89475. * The ID of the renderingGroup being processed
  89476. */
  89477. renderingGroupId: number;
  89478. }
  89479. /**
  89480. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89481. * It is enable to manage the different groups as well as the different necessary sort functions.
  89482. * This should not be used directly aside of the few static configurations
  89483. */
  89484. export class RenderingManager {
  89485. /**
  89486. * The max id used for rendering groups (not included)
  89487. */
  89488. static MAX_RENDERINGGROUPS: number;
  89489. /**
  89490. * The min id used for rendering groups (included)
  89491. */
  89492. static MIN_RENDERINGGROUPS: number;
  89493. /**
  89494. * Used to globally prevent autoclearing scenes.
  89495. */
  89496. static AUTOCLEAR: boolean;
  89497. /**
  89498. * @hidden
  89499. */
  89500. _useSceneAutoClearSetup: boolean;
  89501. private _scene;
  89502. private _renderingGroups;
  89503. private _depthStencilBufferAlreadyCleaned;
  89504. private _autoClearDepthStencil;
  89505. private _customOpaqueSortCompareFn;
  89506. private _customAlphaTestSortCompareFn;
  89507. private _customTransparentSortCompareFn;
  89508. private _renderingGroupInfo;
  89509. /**
  89510. * Instantiates a new rendering group for a particular scene
  89511. * @param scene Defines the scene the groups belongs to
  89512. */
  89513. constructor(scene: Scene);
  89514. private _clearDepthStencilBuffer;
  89515. /**
  89516. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89517. * @hidden
  89518. */
  89519. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89520. /**
  89521. * Resets the different information of the group to prepare a new frame
  89522. * @hidden
  89523. */
  89524. reset(): void;
  89525. /**
  89526. * Dispose and release the group and its associated resources.
  89527. * @hidden
  89528. */
  89529. dispose(): void;
  89530. /**
  89531. * Clear the info related to rendering groups preventing retention points during dispose.
  89532. */
  89533. freeRenderingGroups(): void;
  89534. private _prepareRenderingGroup;
  89535. /**
  89536. * Add a sprite manager to the rendering manager in order to render it this frame.
  89537. * @param spriteManager Define the sprite manager to render
  89538. */
  89539. dispatchSprites(spriteManager: ISpriteManager): void;
  89540. /**
  89541. * Add a particle system to the rendering manager in order to render it this frame.
  89542. * @param particleSystem Define the particle system to render
  89543. */
  89544. dispatchParticles(particleSystem: IParticleSystem): void;
  89545. /**
  89546. * Add a submesh to the manager in order to render it this frame
  89547. * @param subMesh The submesh to dispatch
  89548. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89549. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89550. */
  89551. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89552. /**
  89553. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89554. * This allowed control for front to back rendering or reversly depending of the special needs.
  89555. *
  89556. * @param renderingGroupId The rendering group id corresponding to its index
  89557. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89558. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89559. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89560. */
  89561. 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;
  89562. /**
  89563. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89564. *
  89565. * @param renderingGroupId The rendering group id corresponding to its index
  89566. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89567. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89568. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89569. */
  89570. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89571. /**
  89572. * Gets the current auto clear configuration for one rendering group of the rendering
  89573. * manager.
  89574. * @param index the rendering group index to get the information for
  89575. * @returns The auto clear setup for the requested rendering group
  89576. */
  89577. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89578. }
  89579. }
  89580. declare module BABYLON {
  89581. /**
  89582. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89583. */
  89584. export interface ICustomShaderOptions {
  89585. /**
  89586. * Gets or sets the custom shader name to use
  89587. */
  89588. shaderName: string;
  89589. /**
  89590. * The list of attribute names used in the shader
  89591. */
  89592. attributes?: string[];
  89593. /**
  89594. * The list of unifrom names used in the shader
  89595. */
  89596. uniforms?: string[];
  89597. /**
  89598. * The list of sampler names used in the shader
  89599. */
  89600. samplers?: string[];
  89601. /**
  89602. * The list of defines used in the shader
  89603. */
  89604. defines?: string[];
  89605. }
  89606. /**
  89607. * Interface to implement to create a shadow generator compatible with BJS.
  89608. */
  89609. export interface IShadowGenerator {
  89610. /**
  89611. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89612. * @returns The render target texture if present otherwise, null
  89613. */
  89614. getShadowMap(): Nullable<RenderTargetTexture>;
  89615. /**
  89616. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89617. * @param subMesh The submesh we want to render in the shadow map
  89618. * @param useInstances Defines wether will draw in the map using instances
  89619. * @returns true if ready otherwise, false
  89620. */
  89621. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89622. /**
  89623. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89624. * @param defines Defines of the material we want to update
  89625. * @param lightIndex Index of the light in the enabled light list of the material
  89626. */
  89627. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89628. /**
  89629. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89630. * defined in the generator but impacting the effect).
  89631. * It implies the unifroms available on the materials are the standard BJS ones.
  89632. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89633. * @param effect The effect we are binfing the information for
  89634. */
  89635. bindShadowLight(lightIndex: string, effect: Effect): void;
  89636. /**
  89637. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89638. * (eq to shadow prjection matrix * light transform matrix)
  89639. * @returns The transform matrix used to create the shadow map
  89640. */
  89641. getTransformMatrix(): Matrix;
  89642. /**
  89643. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89644. * Cube and 2D textures for instance.
  89645. */
  89646. recreateShadowMap(): void;
  89647. /**
  89648. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89649. * @param onCompiled Callback triggered at the and of the effects compilation
  89650. * @param options Sets of optional options forcing the compilation with different modes
  89651. */
  89652. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89653. useInstances: boolean;
  89654. }>): void;
  89655. /**
  89656. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89657. * @param options Sets of optional options forcing the compilation with different modes
  89658. * @returns A promise that resolves when the compilation completes
  89659. */
  89660. forceCompilationAsync(options?: Partial<{
  89661. useInstances: boolean;
  89662. }>): Promise<void>;
  89663. /**
  89664. * Serializes the shadow generator setup to a json object.
  89665. * @returns The serialized JSON object
  89666. */
  89667. serialize(): any;
  89668. /**
  89669. * Disposes the Shadow map and related Textures and effects.
  89670. */
  89671. dispose(): void;
  89672. }
  89673. /**
  89674. * Default implementation IShadowGenerator.
  89675. * This is the main object responsible of generating shadows in the framework.
  89676. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89677. */
  89678. export class ShadowGenerator implements IShadowGenerator {
  89679. /**
  89680. * Name of the shadow generator class
  89681. */
  89682. static CLASSNAME: string;
  89683. /**
  89684. * Shadow generator mode None: no filtering applied.
  89685. */
  89686. static readonly FILTER_NONE: number;
  89687. /**
  89688. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89689. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89690. */
  89691. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89692. /**
  89693. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89694. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89695. */
  89696. static readonly FILTER_POISSONSAMPLING: number;
  89697. /**
  89698. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89699. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89700. */
  89701. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89702. /**
  89703. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89704. * edge artifacts on steep falloff.
  89705. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89706. */
  89707. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89708. /**
  89709. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89710. * edge artifacts on steep falloff.
  89711. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89712. */
  89713. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89714. /**
  89715. * Shadow generator mode PCF: Percentage Closer Filtering
  89716. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89717. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89718. */
  89719. static readonly FILTER_PCF: number;
  89720. /**
  89721. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89722. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89723. * Contact Hardening
  89724. */
  89725. static readonly FILTER_PCSS: number;
  89726. /**
  89727. * Reserved for PCF and PCSS
  89728. * Highest Quality.
  89729. *
  89730. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89731. *
  89732. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89733. */
  89734. static readonly QUALITY_HIGH: number;
  89735. /**
  89736. * Reserved for PCF and PCSS
  89737. * Good tradeoff for quality/perf cross devices
  89738. *
  89739. * Execute PCF on a 3*3 kernel.
  89740. *
  89741. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89742. */
  89743. static readonly QUALITY_MEDIUM: number;
  89744. /**
  89745. * Reserved for PCF and PCSS
  89746. * The lowest quality but the fastest.
  89747. *
  89748. * Execute PCF on a 1*1 kernel.
  89749. *
  89750. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89751. */
  89752. static readonly QUALITY_LOW: number;
  89753. /** Gets or sets the custom shader name to use */
  89754. customShaderOptions: ICustomShaderOptions;
  89755. /**
  89756. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89757. */
  89758. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89759. /**
  89760. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89761. */
  89762. onAfterShadowMapRenderObservable: Observable<Effect>;
  89763. /**
  89764. * Observable triggered before a mesh is rendered in the shadow map.
  89765. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89766. */
  89767. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89768. /**
  89769. * Observable triggered after a mesh is rendered in the shadow map.
  89770. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89771. */
  89772. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89773. protected _bias: number;
  89774. /**
  89775. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89776. */
  89777. get bias(): number;
  89778. /**
  89779. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89780. */
  89781. set bias(bias: number);
  89782. protected _normalBias: number;
  89783. /**
  89784. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89785. */
  89786. get normalBias(): number;
  89787. /**
  89788. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89789. */
  89790. set normalBias(normalBias: number);
  89791. protected _blurBoxOffset: number;
  89792. /**
  89793. * Gets the blur box offset: offset applied during the blur pass.
  89794. * Only useful if useKernelBlur = false
  89795. */
  89796. get blurBoxOffset(): number;
  89797. /**
  89798. * Sets the blur box offset: offset applied during the blur pass.
  89799. * Only useful if useKernelBlur = false
  89800. */
  89801. set blurBoxOffset(value: number);
  89802. protected _blurScale: number;
  89803. /**
  89804. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89805. * 2 means half of the size.
  89806. */
  89807. get blurScale(): number;
  89808. /**
  89809. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89810. * 2 means half of the size.
  89811. */
  89812. set blurScale(value: number);
  89813. protected _blurKernel: number;
  89814. /**
  89815. * Gets the blur kernel: kernel size of the blur pass.
  89816. * Only useful if useKernelBlur = true
  89817. */
  89818. get blurKernel(): number;
  89819. /**
  89820. * Sets the blur kernel: kernel size of the blur pass.
  89821. * Only useful if useKernelBlur = true
  89822. */
  89823. set blurKernel(value: number);
  89824. protected _useKernelBlur: boolean;
  89825. /**
  89826. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89827. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89828. */
  89829. get useKernelBlur(): boolean;
  89830. /**
  89831. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89832. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89833. */
  89834. set useKernelBlur(value: boolean);
  89835. protected _depthScale: number;
  89836. /**
  89837. * Gets the depth scale used in ESM mode.
  89838. */
  89839. get depthScale(): number;
  89840. /**
  89841. * Sets the depth scale used in ESM mode.
  89842. * This can override the scale stored on the light.
  89843. */
  89844. set depthScale(value: number);
  89845. protected _validateFilter(filter: number): number;
  89846. protected _filter: number;
  89847. /**
  89848. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89849. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89850. */
  89851. get filter(): number;
  89852. /**
  89853. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89854. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89855. */
  89856. set filter(value: number);
  89857. /**
  89858. * Gets if the current filter is set to Poisson Sampling.
  89859. */
  89860. get usePoissonSampling(): boolean;
  89861. /**
  89862. * Sets the current filter to Poisson Sampling.
  89863. */
  89864. set usePoissonSampling(value: boolean);
  89865. /**
  89866. * Gets if the current filter is set to ESM.
  89867. */
  89868. get useExponentialShadowMap(): boolean;
  89869. /**
  89870. * Sets the current filter is to ESM.
  89871. */
  89872. set useExponentialShadowMap(value: boolean);
  89873. /**
  89874. * Gets if the current filter is set to filtered ESM.
  89875. */
  89876. get useBlurExponentialShadowMap(): boolean;
  89877. /**
  89878. * Gets if the current filter is set to filtered ESM.
  89879. */
  89880. set useBlurExponentialShadowMap(value: boolean);
  89881. /**
  89882. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89883. * exponential to prevent steep falloff artifacts).
  89884. */
  89885. get useCloseExponentialShadowMap(): boolean;
  89886. /**
  89887. * Sets the current filter to "close ESM" (using the inverse of the
  89888. * exponential to prevent steep falloff artifacts).
  89889. */
  89890. set useCloseExponentialShadowMap(value: boolean);
  89891. /**
  89892. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89893. * exponential to prevent steep falloff artifacts).
  89894. */
  89895. get useBlurCloseExponentialShadowMap(): boolean;
  89896. /**
  89897. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89898. * exponential to prevent steep falloff artifacts).
  89899. */
  89900. set useBlurCloseExponentialShadowMap(value: boolean);
  89901. /**
  89902. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89903. */
  89904. get usePercentageCloserFiltering(): boolean;
  89905. /**
  89906. * Sets the current filter to "PCF" (percentage closer filtering).
  89907. */
  89908. set usePercentageCloserFiltering(value: boolean);
  89909. protected _filteringQuality: number;
  89910. /**
  89911. * Gets the PCF or PCSS Quality.
  89912. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89913. */
  89914. get filteringQuality(): number;
  89915. /**
  89916. * Sets the PCF or PCSS Quality.
  89917. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89918. */
  89919. set filteringQuality(filteringQuality: number);
  89920. /**
  89921. * Gets if the current filter is set to "PCSS" (contact hardening).
  89922. */
  89923. get useContactHardeningShadow(): boolean;
  89924. /**
  89925. * Sets the current filter to "PCSS" (contact hardening).
  89926. */
  89927. set useContactHardeningShadow(value: boolean);
  89928. protected _contactHardeningLightSizeUVRatio: number;
  89929. /**
  89930. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89931. * Using a ratio helps keeping shape stability independently of the map size.
  89932. *
  89933. * It does not account for the light projection as it was having too much
  89934. * instability during the light setup or during light position changes.
  89935. *
  89936. * Only valid if useContactHardeningShadow is true.
  89937. */
  89938. get contactHardeningLightSizeUVRatio(): number;
  89939. /**
  89940. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89941. * Using a ratio helps keeping shape stability independently of the map size.
  89942. *
  89943. * It does not account for the light projection as it was having too much
  89944. * instability during the light setup or during light position changes.
  89945. *
  89946. * Only valid if useContactHardeningShadow is true.
  89947. */
  89948. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89949. protected _darkness: number;
  89950. /** Gets or sets the actual darkness of a shadow */
  89951. get darkness(): number;
  89952. set darkness(value: number);
  89953. /**
  89954. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89955. * 0 means strongest and 1 would means no shadow.
  89956. * @returns the darkness.
  89957. */
  89958. getDarkness(): number;
  89959. /**
  89960. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89961. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89962. * @returns the shadow generator allowing fluent coding.
  89963. */
  89964. setDarkness(darkness: number): ShadowGenerator;
  89965. protected _transparencyShadow: boolean;
  89966. /** Gets or sets the ability to have transparent shadow */
  89967. get transparencyShadow(): boolean;
  89968. set transparencyShadow(value: boolean);
  89969. /**
  89970. * Sets the ability to have transparent shadow (boolean).
  89971. * @param transparent True if transparent else False
  89972. * @returns the shadow generator allowing fluent coding
  89973. */
  89974. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89975. protected _shadowMap: Nullable<RenderTargetTexture>;
  89976. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89977. /**
  89978. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89979. * @returns The render target texture if present otherwise, null
  89980. */
  89981. getShadowMap(): Nullable<RenderTargetTexture>;
  89982. /**
  89983. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89984. * @returns The render target texture if the shadow map is present otherwise, null
  89985. */
  89986. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89987. /**
  89988. * Gets the class name of that object
  89989. * @returns "ShadowGenerator"
  89990. */
  89991. getClassName(): string;
  89992. /**
  89993. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89994. * @param mesh Mesh to add
  89995. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89996. * @returns the Shadow Generator itself
  89997. */
  89998. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89999. /**
  90000. * Helper function to remove a mesh and its descendants from the list of shadow casters
  90001. * @param mesh Mesh to remove
  90002. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  90003. * @returns the Shadow Generator itself
  90004. */
  90005. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90006. /**
  90007. * Controls the extent to which the shadows fade out at the edge of the frustum
  90008. */
  90009. frustumEdgeFalloff: number;
  90010. protected _light: IShadowLight;
  90011. /**
  90012. * Returns the associated light object.
  90013. * @returns the light generating the shadow
  90014. */
  90015. getLight(): IShadowLight;
  90016. /**
  90017. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  90018. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  90019. * It might on the other hand introduce peter panning.
  90020. */
  90021. forceBackFacesOnly: boolean;
  90022. protected _scene: Scene;
  90023. protected _lightDirection: Vector3;
  90024. protected _effect: Effect;
  90025. protected _viewMatrix: Matrix;
  90026. protected _projectionMatrix: Matrix;
  90027. protected _transformMatrix: Matrix;
  90028. protected _cachedPosition: Vector3;
  90029. protected _cachedDirection: Vector3;
  90030. protected _cachedDefines: string;
  90031. protected _currentRenderID: number;
  90032. protected _boxBlurPostprocess: Nullable<PostProcess>;
  90033. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  90034. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  90035. protected _blurPostProcesses: PostProcess[];
  90036. protected _mapSize: number;
  90037. protected _currentFaceIndex: number;
  90038. protected _currentFaceIndexCache: number;
  90039. protected _textureType: number;
  90040. protected _defaultTextureMatrix: Matrix;
  90041. protected _storedUniqueId: Nullable<number>;
  90042. /** @hidden */
  90043. static _SceneComponentInitialization: (scene: Scene) => void;
  90044. /**
  90045. * Creates a ShadowGenerator object.
  90046. * A ShadowGenerator is the required tool to use the shadows.
  90047. * Each light casting shadows needs to use its own ShadowGenerator.
  90048. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  90049. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  90050. * @param light The light object generating the shadows.
  90051. * @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.
  90052. */
  90053. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  90054. protected _initializeGenerator(): void;
  90055. protected _createTargetRenderTexture(): void;
  90056. protected _initializeShadowMap(): void;
  90057. protected _initializeBlurRTTAndPostProcesses(): void;
  90058. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  90059. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  90060. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  90061. protected _applyFilterValues(): void;
  90062. /**
  90063. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90064. * @param onCompiled Callback triggered at the and of the effects compilation
  90065. * @param options Sets of optional options forcing the compilation with different modes
  90066. */
  90067. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  90068. useInstances: boolean;
  90069. }>): void;
  90070. /**
  90071. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90072. * @param options Sets of optional options forcing the compilation with different modes
  90073. * @returns A promise that resolves when the compilation completes
  90074. */
  90075. forceCompilationAsync(options?: Partial<{
  90076. useInstances: boolean;
  90077. }>): Promise<void>;
  90078. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  90079. /**
  90080. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  90081. * @param subMesh The submesh we want to render in the shadow map
  90082. * @param useInstances Defines wether will draw in the map using instances
  90083. * @returns true if ready otherwise, false
  90084. */
  90085. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  90086. /**
  90087. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  90088. * @param defines Defines of the material we want to update
  90089. * @param lightIndex Index of the light in the enabled light list of the material
  90090. */
  90091. prepareDefines(defines: any, lightIndex: number): void;
  90092. /**
  90093. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  90094. * defined in the generator but impacting the effect).
  90095. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  90096. * @param effect The effect we are binfing the information for
  90097. */
  90098. bindShadowLight(lightIndex: string, effect: Effect): void;
  90099. /**
  90100. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  90101. * (eq to shadow prjection matrix * light transform matrix)
  90102. * @returns The transform matrix used to create the shadow map
  90103. */
  90104. getTransformMatrix(): Matrix;
  90105. /**
  90106. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  90107. * Cube and 2D textures for instance.
  90108. */
  90109. recreateShadowMap(): void;
  90110. protected _disposeBlurPostProcesses(): void;
  90111. protected _disposeRTTandPostProcesses(): void;
  90112. /**
  90113. * Disposes the ShadowGenerator.
  90114. * Returns nothing.
  90115. */
  90116. dispose(): void;
  90117. /**
  90118. * Serializes the shadow generator setup to a json object.
  90119. * @returns The serialized JSON object
  90120. */
  90121. serialize(): any;
  90122. /**
  90123. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  90124. * @param parsedShadowGenerator The JSON object to parse
  90125. * @param scene The scene to create the shadow map for
  90126. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  90127. * @returns The parsed shadow generator
  90128. */
  90129. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  90130. }
  90131. }
  90132. declare module BABYLON {
  90133. /**
  90134. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  90135. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  90136. * 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.
  90137. */
  90138. export abstract class Light extends Node {
  90139. /**
  90140. * Falloff Default: light is falling off following the material specification:
  90141. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  90142. */
  90143. static readonly FALLOFF_DEFAULT: number;
  90144. /**
  90145. * Falloff Physical: light is falling off following the inverse squared distance law.
  90146. */
  90147. static readonly FALLOFF_PHYSICAL: number;
  90148. /**
  90149. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  90150. * to enhance interoperability with other engines.
  90151. */
  90152. static readonly FALLOFF_GLTF: number;
  90153. /**
  90154. * Falloff Standard: light is falling off like in the standard material
  90155. * to enhance interoperability with other materials.
  90156. */
  90157. static readonly FALLOFF_STANDARD: number;
  90158. /**
  90159. * If every light affecting the material is in this lightmapMode,
  90160. * material.lightmapTexture adds or multiplies
  90161. * (depends on material.useLightmapAsShadowmap)
  90162. * after every other light calculations.
  90163. */
  90164. static readonly LIGHTMAP_DEFAULT: number;
  90165. /**
  90166. * material.lightmapTexture as only diffuse lighting from this light
  90167. * adds only specular lighting from this light
  90168. * adds dynamic shadows
  90169. */
  90170. static readonly LIGHTMAP_SPECULAR: number;
  90171. /**
  90172. * material.lightmapTexture as only lighting
  90173. * no light calculation from this light
  90174. * only adds dynamic shadows from this light
  90175. */
  90176. static readonly LIGHTMAP_SHADOWSONLY: number;
  90177. /**
  90178. * Each light type uses the default quantity according to its type:
  90179. * point/spot lights use luminous intensity
  90180. * directional lights use illuminance
  90181. */
  90182. static readonly INTENSITYMODE_AUTOMATIC: number;
  90183. /**
  90184. * lumen (lm)
  90185. */
  90186. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  90187. /**
  90188. * candela (lm/sr)
  90189. */
  90190. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  90191. /**
  90192. * lux (lm/m^2)
  90193. */
  90194. static readonly INTENSITYMODE_ILLUMINANCE: number;
  90195. /**
  90196. * nit (cd/m^2)
  90197. */
  90198. static readonly INTENSITYMODE_LUMINANCE: number;
  90199. /**
  90200. * Light type const id of the point light.
  90201. */
  90202. static readonly LIGHTTYPEID_POINTLIGHT: number;
  90203. /**
  90204. * Light type const id of the directional light.
  90205. */
  90206. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  90207. /**
  90208. * Light type const id of the spot light.
  90209. */
  90210. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  90211. /**
  90212. * Light type const id of the hemispheric light.
  90213. */
  90214. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  90215. /**
  90216. * Diffuse gives the basic color to an object.
  90217. */
  90218. diffuse: Color3;
  90219. /**
  90220. * Specular produces a highlight color on an object.
  90221. * Note: This is note affecting PBR materials.
  90222. */
  90223. specular: Color3;
  90224. /**
  90225. * Defines the falloff type for this light. This lets overrriding how punctual light are
  90226. * falling off base on range or angle.
  90227. * This can be set to any values in Light.FALLOFF_x.
  90228. *
  90229. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  90230. * other types of materials.
  90231. */
  90232. falloffType: number;
  90233. /**
  90234. * Strength of the light.
  90235. * Note: By default it is define in the framework own unit.
  90236. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90237. */
  90238. intensity: number;
  90239. private _range;
  90240. protected _inverseSquaredRange: number;
  90241. /**
  90242. * Defines how far from the source the light is impacting in scene units.
  90243. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90244. */
  90245. get range(): number;
  90246. /**
  90247. * Defines how far from the source the light is impacting in scene units.
  90248. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90249. */
  90250. set range(value: number);
  90251. /**
  90252. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90253. * of light.
  90254. */
  90255. private _photometricScale;
  90256. private _intensityMode;
  90257. /**
  90258. * Gets the photometric scale used to interpret the intensity.
  90259. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90260. */
  90261. get intensityMode(): number;
  90262. /**
  90263. * Sets the photometric scale used to interpret the intensity.
  90264. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90265. */
  90266. set intensityMode(value: number);
  90267. private _radius;
  90268. /**
  90269. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90270. */
  90271. get radius(): number;
  90272. /**
  90273. * sets the light radius used by PBR Materials to simulate soft area lights.
  90274. */
  90275. set radius(value: number);
  90276. private _renderPriority;
  90277. /**
  90278. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90279. * exceeding the number allowed of the materials.
  90280. */
  90281. renderPriority: number;
  90282. private _shadowEnabled;
  90283. /**
  90284. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90285. * the current shadow generator.
  90286. */
  90287. get shadowEnabled(): boolean;
  90288. /**
  90289. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90290. * the current shadow generator.
  90291. */
  90292. set shadowEnabled(value: boolean);
  90293. private _includedOnlyMeshes;
  90294. /**
  90295. * Gets the only meshes impacted by this light.
  90296. */
  90297. get includedOnlyMeshes(): AbstractMesh[];
  90298. /**
  90299. * Sets the only meshes impacted by this light.
  90300. */
  90301. set includedOnlyMeshes(value: AbstractMesh[]);
  90302. private _excludedMeshes;
  90303. /**
  90304. * Gets the meshes not impacted by this light.
  90305. */
  90306. get excludedMeshes(): AbstractMesh[];
  90307. /**
  90308. * Sets the meshes not impacted by this light.
  90309. */
  90310. set excludedMeshes(value: AbstractMesh[]);
  90311. private _excludeWithLayerMask;
  90312. /**
  90313. * Gets the layer id use to find what meshes are not impacted by the light.
  90314. * Inactive if 0
  90315. */
  90316. get excludeWithLayerMask(): number;
  90317. /**
  90318. * Sets the layer id use to find what meshes are not impacted by the light.
  90319. * Inactive if 0
  90320. */
  90321. set excludeWithLayerMask(value: number);
  90322. private _includeOnlyWithLayerMask;
  90323. /**
  90324. * Gets the layer id use to find what meshes are impacted by the light.
  90325. * Inactive if 0
  90326. */
  90327. get includeOnlyWithLayerMask(): number;
  90328. /**
  90329. * Sets the layer id use to find what meshes are impacted by the light.
  90330. * Inactive if 0
  90331. */
  90332. set includeOnlyWithLayerMask(value: number);
  90333. private _lightmapMode;
  90334. /**
  90335. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90336. */
  90337. get lightmapMode(): number;
  90338. /**
  90339. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90340. */
  90341. set lightmapMode(value: number);
  90342. /**
  90343. * Shadow generator associted to the light.
  90344. * @hidden Internal use only.
  90345. */
  90346. _shadowGenerator: Nullable<IShadowGenerator>;
  90347. /**
  90348. * @hidden Internal use only.
  90349. */
  90350. _excludedMeshesIds: string[];
  90351. /**
  90352. * @hidden Internal use only.
  90353. */
  90354. _includedOnlyMeshesIds: string[];
  90355. /**
  90356. * The current light unifom buffer.
  90357. * @hidden Internal use only.
  90358. */
  90359. _uniformBuffer: UniformBuffer;
  90360. /** @hidden */
  90361. _renderId: number;
  90362. /**
  90363. * Creates a Light object in the scene.
  90364. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90365. * @param name The firendly name of the light
  90366. * @param scene The scene the light belongs too
  90367. */
  90368. constructor(name: string, scene: Scene);
  90369. protected abstract _buildUniformLayout(): void;
  90370. /**
  90371. * Sets the passed Effect "effect" with the Light information.
  90372. * @param effect The effect to update
  90373. * @param lightIndex The index of the light in the effect to update
  90374. * @returns The light
  90375. */
  90376. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90377. /**
  90378. * Sets the passed Effect "effect" with the Light textures.
  90379. * @param effect The effect to update
  90380. * @param lightIndex The index of the light in the effect to update
  90381. * @returns The light
  90382. */
  90383. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90384. /**
  90385. * Binds the lights information from the scene to the effect for the given mesh.
  90386. * @param lightIndex Light index
  90387. * @param scene The scene where the light belongs to
  90388. * @param effect The effect we are binding the data to
  90389. * @param useSpecular Defines if specular is supported
  90390. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90391. */
  90392. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90393. /**
  90394. * Sets the passed Effect "effect" with the Light information.
  90395. * @param effect The effect to update
  90396. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90397. * @returns The light
  90398. */
  90399. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90400. /**
  90401. * Returns the string "Light".
  90402. * @returns the class name
  90403. */
  90404. getClassName(): string;
  90405. /** @hidden */
  90406. readonly _isLight: boolean;
  90407. /**
  90408. * Converts the light information to a readable string for debug purpose.
  90409. * @param fullDetails Supports for multiple levels of logging within scene loading
  90410. * @returns the human readable light info
  90411. */
  90412. toString(fullDetails?: boolean): string;
  90413. /** @hidden */
  90414. protected _syncParentEnabledState(): void;
  90415. /**
  90416. * Set the enabled state of this node.
  90417. * @param value - the new enabled state
  90418. */
  90419. setEnabled(value: boolean): void;
  90420. /**
  90421. * Returns the Light associated shadow generator if any.
  90422. * @return the associated shadow generator.
  90423. */
  90424. getShadowGenerator(): Nullable<IShadowGenerator>;
  90425. /**
  90426. * Returns a Vector3, the absolute light position in the World.
  90427. * @returns the world space position of the light
  90428. */
  90429. getAbsolutePosition(): Vector3;
  90430. /**
  90431. * Specifies if the light will affect the passed mesh.
  90432. * @param mesh The mesh to test against the light
  90433. * @return true the mesh is affected otherwise, false.
  90434. */
  90435. canAffectMesh(mesh: AbstractMesh): boolean;
  90436. /**
  90437. * Sort function to order lights for rendering.
  90438. * @param a First Light object to compare to second.
  90439. * @param b Second Light object to compare first.
  90440. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90441. */
  90442. static CompareLightsPriority(a: Light, b: Light): number;
  90443. /**
  90444. * Releases resources associated with this node.
  90445. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90446. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90447. */
  90448. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90449. /**
  90450. * Returns the light type ID (integer).
  90451. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90452. */
  90453. getTypeID(): number;
  90454. /**
  90455. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90456. * @returns the scaled intensity in intensity mode unit
  90457. */
  90458. getScaledIntensity(): number;
  90459. /**
  90460. * Returns a new Light object, named "name", from the current one.
  90461. * @param name The name of the cloned light
  90462. * @returns the new created light
  90463. */
  90464. clone(name: string): Nullable<Light>;
  90465. /**
  90466. * Serializes the current light into a Serialization object.
  90467. * @returns the serialized object.
  90468. */
  90469. serialize(): any;
  90470. /**
  90471. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90472. * This new light is named "name" and added to the passed scene.
  90473. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90474. * @param name The friendly name of the light
  90475. * @param scene The scene the new light will belong to
  90476. * @returns the constructor function
  90477. */
  90478. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90479. /**
  90480. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90481. * @param parsedLight The JSON representation of the light
  90482. * @param scene The scene to create the parsed light in
  90483. * @returns the created light after parsing
  90484. */
  90485. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90486. private _hookArrayForExcluded;
  90487. private _hookArrayForIncludedOnly;
  90488. private _resyncMeshes;
  90489. /**
  90490. * Forces the meshes to update their light related information in their rendering used effects
  90491. * @hidden Internal Use Only
  90492. */
  90493. _markMeshesAsLightDirty(): void;
  90494. /**
  90495. * Recomputes the cached photometric scale if needed.
  90496. */
  90497. private _computePhotometricScale;
  90498. /**
  90499. * Returns the Photometric Scale according to the light type and intensity mode.
  90500. */
  90501. private _getPhotometricScale;
  90502. /**
  90503. * Reorder the light in the scene according to their defined priority.
  90504. * @hidden Internal Use Only
  90505. */
  90506. _reorderLightsInScene(): void;
  90507. /**
  90508. * Prepares the list of defines specific to the light type.
  90509. * @param defines the list of defines
  90510. * @param lightIndex defines the index of the light for the effect
  90511. */
  90512. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90513. }
  90514. }
  90515. declare module BABYLON {
  90516. /**
  90517. * Interface used to define Action
  90518. */
  90519. export interface IAction {
  90520. /**
  90521. * Trigger for the action
  90522. */
  90523. trigger: number;
  90524. /** Options of the trigger */
  90525. triggerOptions: any;
  90526. /**
  90527. * Gets the trigger parameters
  90528. * @returns the trigger parameters
  90529. */
  90530. getTriggerParameter(): any;
  90531. /**
  90532. * Internal only - executes current action event
  90533. * @hidden
  90534. */
  90535. _executeCurrent(evt?: ActionEvent): void;
  90536. /**
  90537. * Serialize placeholder for child classes
  90538. * @param parent of child
  90539. * @returns the serialized object
  90540. */
  90541. serialize(parent: any): any;
  90542. /**
  90543. * Internal only
  90544. * @hidden
  90545. */
  90546. _prepare(): void;
  90547. /**
  90548. * Internal only - manager for action
  90549. * @hidden
  90550. */
  90551. _actionManager: AbstractActionManager;
  90552. /**
  90553. * Adds action to chain of actions, may be a DoNothingAction
  90554. * @param action defines the next action to execute
  90555. * @returns The action passed in
  90556. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90557. */
  90558. then(action: IAction): IAction;
  90559. }
  90560. /**
  90561. * The action to be carried out following a trigger
  90562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90563. */
  90564. export class Action implements IAction {
  90565. /** the trigger, with or without parameters, for the action */
  90566. triggerOptions: any;
  90567. /**
  90568. * Trigger for the action
  90569. */
  90570. trigger: number;
  90571. /**
  90572. * Internal only - manager for action
  90573. * @hidden
  90574. */
  90575. _actionManager: ActionManager;
  90576. private _nextActiveAction;
  90577. private _child;
  90578. private _condition?;
  90579. private _triggerParameter;
  90580. /**
  90581. * An event triggered prior to action being executed.
  90582. */
  90583. onBeforeExecuteObservable: Observable<Action>;
  90584. /**
  90585. * Creates a new Action
  90586. * @param triggerOptions the trigger, with or without parameters, for the action
  90587. * @param condition an optional determinant of action
  90588. */
  90589. constructor(
  90590. /** the trigger, with or without parameters, for the action */
  90591. triggerOptions: any, condition?: Condition);
  90592. /**
  90593. * Internal only
  90594. * @hidden
  90595. */
  90596. _prepare(): void;
  90597. /**
  90598. * Gets the trigger parameters
  90599. * @returns the trigger parameters
  90600. */
  90601. getTriggerParameter(): any;
  90602. /**
  90603. * Internal only - executes current action event
  90604. * @hidden
  90605. */
  90606. _executeCurrent(evt?: ActionEvent): void;
  90607. /**
  90608. * Execute placeholder for child classes
  90609. * @param evt optional action event
  90610. */
  90611. execute(evt?: ActionEvent): void;
  90612. /**
  90613. * Skips to next active action
  90614. */
  90615. skipToNextActiveAction(): void;
  90616. /**
  90617. * Adds action to chain of actions, may be a DoNothingAction
  90618. * @param action defines the next action to execute
  90619. * @returns The action passed in
  90620. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90621. */
  90622. then(action: Action): Action;
  90623. /**
  90624. * Internal only
  90625. * @hidden
  90626. */
  90627. _getProperty(propertyPath: string): string;
  90628. /**
  90629. * Internal only
  90630. * @hidden
  90631. */
  90632. _getEffectiveTarget(target: any, propertyPath: string): any;
  90633. /**
  90634. * Serialize placeholder for child classes
  90635. * @param parent of child
  90636. * @returns the serialized object
  90637. */
  90638. serialize(parent: any): any;
  90639. /**
  90640. * Internal only called by serialize
  90641. * @hidden
  90642. */
  90643. protected _serialize(serializedAction: any, parent?: any): any;
  90644. /**
  90645. * Internal only
  90646. * @hidden
  90647. */
  90648. static _SerializeValueAsString: (value: any) => string;
  90649. /**
  90650. * Internal only
  90651. * @hidden
  90652. */
  90653. static _GetTargetProperty: (target: Node | Scene) => {
  90654. name: string;
  90655. targetType: string;
  90656. value: string;
  90657. };
  90658. }
  90659. }
  90660. declare module BABYLON {
  90661. /**
  90662. * A Condition applied to an Action
  90663. */
  90664. export class Condition {
  90665. /**
  90666. * Internal only - manager for action
  90667. * @hidden
  90668. */
  90669. _actionManager: ActionManager;
  90670. /**
  90671. * Internal only
  90672. * @hidden
  90673. */
  90674. _evaluationId: number;
  90675. /**
  90676. * Internal only
  90677. * @hidden
  90678. */
  90679. _currentResult: boolean;
  90680. /**
  90681. * Creates a new Condition
  90682. * @param actionManager the manager of the action the condition is applied to
  90683. */
  90684. constructor(actionManager: ActionManager);
  90685. /**
  90686. * Check if the current condition is valid
  90687. * @returns a boolean
  90688. */
  90689. isValid(): boolean;
  90690. /**
  90691. * Internal only
  90692. * @hidden
  90693. */
  90694. _getProperty(propertyPath: string): string;
  90695. /**
  90696. * Internal only
  90697. * @hidden
  90698. */
  90699. _getEffectiveTarget(target: any, propertyPath: string): any;
  90700. /**
  90701. * Serialize placeholder for child classes
  90702. * @returns the serialized object
  90703. */
  90704. serialize(): any;
  90705. /**
  90706. * Internal only
  90707. * @hidden
  90708. */
  90709. protected _serialize(serializedCondition: any): any;
  90710. }
  90711. /**
  90712. * Defines specific conditional operators as extensions of Condition
  90713. */
  90714. export class ValueCondition extends Condition {
  90715. /** path to specify the property of the target the conditional operator uses */
  90716. propertyPath: string;
  90717. /** the value compared by the conditional operator against the current value of the property */
  90718. value: any;
  90719. /** the conditional operator, default ValueCondition.IsEqual */
  90720. operator: number;
  90721. /**
  90722. * Internal only
  90723. * @hidden
  90724. */
  90725. private static _IsEqual;
  90726. /**
  90727. * Internal only
  90728. * @hidden
  90729. */
  90730. private static _IsDifferent;
  90731. /**
  90732. * Internal only
  90733. * @hidden
  90734. */
  90735. private static _IsGreater;
  90736. /**
  90737. * Internal only
  90738. * @hidden
  90739. */
  90740. private static _IsLesser;
  90741. /**
  90742. * returns the number for IsEqual
  90743. */
  90744. static get IsEqual(): number;
  90745. /**
  90746. * Returns the number for IsDifferent
  90747. */
  90748. static get IsDifferent(): number;
  90749. /**
  90750. * Returns the number for IsGreater
  90751. */
  90752. static get IsGreater(): number;
  90753. /**
  90754. * Returns the number for IsLesser
  90755. */
  90756. static get IsLesser(): number;
  90757. /**
  90758. * Internal only The action manager for the condition
  90759. * @hidden
  90760. */
  90761. _actionManager: ActionManager;
  90762. /**
  90763. * Internal only
  90764. * @hidden
  90765. */
  90766. private _target;
  90767. /**
  90768. * Internal only
  90769. * @hidden
  90770. */
  90771. private _effectiveTarget;
  90772. /**
  90773. * Internal only
  90774. * @hidden
  90775. */
  90776. private _property;
  90777. /**
  90778. * Creates a new ValueCondition
  90779. * @param actionManager manager for the action the condition applies to
  90780. * @param target for the action
  90781. * @param propertyPath path to specify the property of the target the conditional operator uses
  90782. * @param value the value compared by the conditional operator against the current value of the property
  90783. * @param operator the conditional operator, default ValueCondition.IsEqual
  90784. */
  90785. constructor(actionManager: ActionManager, target: any,
  90786. /** path to specify the property of the target the conditional operator uses */
  90787. propertyPath: string,
  90788. /** the value compared by the conditional operator against the current value of the property */
  90789. value: any,
  90790. /** the conditional operator, default ValueCondition.IsEqual */
  90791. operator?: number);
  90792. /**
  90793. * Compares the given value with the property value for the specified conditional operator
  90794. * @returns the result of the comparison
  90795. */
  90796. isValid(): boolean;
  90797. /**
  90798. * Serialize the ValueCondition into a JSON compatible object
  90799. * @returns serialization object
  90800. */
  90801. serialize(): any;
  90802. /**
  90803. * Gets the name of the conditional operator for the ValueCondition
  90804. * @param operator the conditional operator
  90805. * @returns the name
  90806. */
  90807. static GetOperatorName(operator: number): string;
  90808. }
  90809. /**
  90810. * Defines a predicate condition as an extension of Condition
  90811. */
  90812. export class PredicateCondition extends Condition {
  90813. /** defines the predicate function used to validate the condition */
  90814. predicate: () => boolean;
  90815. /**
  90816. * Internal only - manager for action
  90817. * @hidden
  90818. */
  90819. _actionManager: ActionManager;
  90820. /**
  90821. * Creates a new PredicateCondition
  90822. * @param actionManager manager for the action the condition applies to
  90823. * @param predicate defines the predicate function used to validate the condition
  90824. */
  90825. constructor(actionManager: ActionManager,
  90826. /** defines the predicate function used to validate the condition */
  90827. predicate: () => boolean);
  90828. /**
  90829. * @returns the validity of the predicate condition
  90830. */
  90831. isValid(): boolean;
  90832. }
  90833. /**
  90834. * Defines a state condition as an extension of Condition
  90835. */
  90836. export class StateCondition extends Condition {
  90837. /** Value to compare with target state */
  90838. value: string;
  90839. /**
  90840. * Internal only - manager for action
  90841. * @hidden
  90842. */
  90843. _actionManager: ActionManager;
  90844. /**
  90845. * Internal only
  90846. * @hidden
  90847. */
  90848. private _target;
  90849. /**
  90850. * Creates a new StateCondition
  90851. * @param actionManager manager for the action the condition applies to
  90852. * @param target of the condition
  90853. * @param value to compare with target state
  90854. */
  90855. constructor(actionManager: ActionManager, target: any,
  90856. /** Value to compare with target state */
  90857. value: string);
  90858. /**
  90859. * Gets a boolean indicating if the current condition is met
  90860. * @returns the validity of the state
  90861. */
  90862. isValid(): boolean;
  90863. /**
  90864. * Serialize the StateCondition into a JSON compatible object
  90865. * @returns serialization object
  90866. */
  90867. serialize(): any;
  90868. }
  90869. }
  90870. declare module BABYLON {
  90871. /**
  90872. * This defines an action responsible to toggle a boolean once triggered.
  90873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90874. */
  90875. export class SwitchBooleanAction extends Action {
  90876. /**
  90877. * The path to the boolean property in the target object
  90878. */
  90879. propertyPath: string;
  90880. private _target;
  90881. private _effectiveTarget;
  90882. private _property;
  90883. /**
  90884. * Instantiate the action
  90885. * @param triggerOptions defines the trigger options
  90886. * @param target defines the object containing the boolean
  90887. * @param propertyPath defines the path to the boolean property in the target object
  90888. * @param condition defines the trigger related conditions
  90889. */
  90890. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90891. /** @hidden */
  90892. _prepare(): void;
  90893. /**
  90894. * Execute the action toggle the boolean value.
  90895. */
  90896. execute(): void;
  90897. /**
  90898. * Serializes the actions and its related information.
  90899. * @param parent defines the object to serialize in
  90900. * @returns the serialized object
  90901. */
  90902. serialize(parent: any): any;
  90903. }
  90904. /**
  90905. * This defines an action responsible to set a the state field of the target
  90906. * to a desired value once triggered.
  90907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90908. */
  90909. export class SetStateAction extends Action {
  90910. /**
  90911. * The value to store in the state field.
  90912. */
  90913. value: string;
  90914. private _target;
  90915. /**
  90916. * Instantiate the action
  90917. * @param triggerOptions defines the trigger options
  90918. * @param target defines the object containing the state property
  90919. * @param value defines the value to store in the state field
  90920. * @param condition defines the trigger related conditions
  90921. */
  90922. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90923. /**
  90924. * Execute the action and store the value on the target state property.
  90925. */
  90926. execute(): void;
  90927. /**
  90928. * Serializes the actions and its related information.
  90929. * @param parent defines the object to serialize in
  90930. * @returns the serialized object
  90931. */
  90932. serialize(parent: any): any;
  90933. }
  90934. /**
  90935. * This defines an action responsible to set a property of the target
  90936. * to a desired value once triggered.
  90937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90938. */
  90939. export class SetValueAction extends Action {
  90940. /**
  90941. * The path of the property to set in the target.
  90942. */
  90943. propertyPath: string;
  90944. /**
  90945. * The value to set in the property
  90946. */
  90947. value: any;
  90948. private _target;
  90949. private _effectiveTarget;
  90950. private _property;
  90951. /**
  90952. * Instantiate the action
  90953. * @param triggerOptions defines the trigger options
  90954. * @param target defines the object containing the property
  90955. * @param propertyPath defines the path of the property to set in the target
  90956. * @param value defines the value to set in the property
  90957. * @param condition defines the trigger related conditions
  90958. */
  90959. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90960. /** @hidden */
  90961. _prepare(): void;
  90962. /**
  90963. * Execute the action and set the targetted property to the desired value.
  90964. */
  90965. execute(): void;
  90966. /**
  90967. * Serializes the actions and its related information.
  90968. * @param parent defines the object to serialize in
  90969. * @returns the serialized object
  90970. */
  90971. serialize(parent: any): any;
  90972. }
  90973. /**
  90974. * This defines an action responsible to increment the target value
  90975. * to a desired value once triggered.
  90976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90977. */
  90978. export class IncrementValueAction extends Action {
  90979. /**
  90980. * The path of the property to increment in the target.
  90981. */
  90982. propertyPath: string;
  90983. /**
  90984. * The value we should increment the property by.
  90985. */
  90986. value: any;
  90987. private _target;
  90988. private _effectiveTarget;
  90989. private _property;
  90990. /**
  90991. * Instantiate the action
  90992. * @param triggerOptions defines the trigger options
  90993. * @param target defines the object containing the property
  90994. * @param propertyPath defines the path of the property to increment in the target
  90995. * @param value defines the value value we should increment the property by
  90996. * @param condition defines the trigger related conditions
  90997. */
  90998. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90999. /** @hidden */
  91000. _prepare(): void;
  91001. /**
  91002. * Execute the action and increment the target of the value amount.
  91003. */
  91004. execute(): void;
  91005. /**
  91006. * Serializes the actions and its related information.
  91007. * @param parent defines the object to serialize in
  91008. * @returns the serialized object
  91009. */
  91010. serialize(parent: any): any;
  91011. }
  91012. /**
  91013. * This defines an action responsible to start an animation once triggered.
  91014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91015. */
  91016. export class PlayAnimationAction extends Action {
  91017. /**
  91018. * Where the animation should start (animation frame)
  91019. */
  91020. from: number;
  91021. /**
  91022. * Where the animation should stop (animation frame)
  91023. */
  91024. to: number;
  91025. /**
  91026. * Define if the animation should loop or stop after the first play.
  91027. */
  91028. loop?: boolean;
  91029. private _target;
  91030. /**
  91031. * Instantiate the action
  91032. * @param triggerOptions defines the trigger options
  91033. * @param target defines the target animation or animation name
  91034. * @param from defines from where the animation should start (animation frame)
  91035. * @param end defines where the animation should stop (animation frame)
  91036. * @param loop defines if the animation should loop or stop after the first play
  91037. * @param condition defines the trigger related conditions
  91038. */
  91039. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91040. /** @hidden */
  91041. _prepare(): void;
  91042. /**
  91043. * Execute the action and play the animation.
  91044. */
  91045. execute(): void;
  91046. /**
  91047. * Serializes the actions and its related information.
  91048. * @param parent defines the object to serialize in
  91049. * @returns the serialized object
  91050. */
  91051. serialize(parent: any): any;
  91052. }
  91053. /**
  91054. * This defines an action responsible to stop an animation once triggered.
  91055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91056. */
  91057. export class StopAnimationAction extends Action {
  91058. private _target;
  91059. /**
  91060. * Instantiate the action
  91061. * @param triggerOptions defines the trigger options
  91062. * @param target defines the target animation or animation name
  91063. * @param condition defines the trigger related conditions
  91064. */
  91065. constructor(triggerOptions: any, target: any, condition?: Condition);
  91066. /** @hidden */
  91067. _prepare(): void;
  91068. /**
  91069. * Execute the action and stop the animation.
  91070. */
  91071. execute(): void;
  91072. /**
  91073. * Serializes the actions and its related information.
  91074. * @param parent defines the object to serialize in
  91075. * @returns the serialized object
  91076. */
  91077. serialize(parent: any): any;
  91078. }
  91079. /**
  91080. * This defines an action responsible that does nothing once triggered.
  91081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91082. */
  91083. export class DoNothingAction extends Action {
  91084. /**
  91085. * Instantiate the action
  91086. * @param triggerOptions defines the trigger options
  91087. * @param condition defines the trigger related conditions
  91088. */
  91089. constructor(triggerOptions?: any, condition?: Condition);
  91090. /**
  91091. * Execute the action and do nothing.
  91092. */
  91093. execute(): void;
  91094. /**
  91095. * Serializes the actions and its related information.
  91096. * @param parent defines the object to serialize in
  91097. * @returns the serialized object
  91098. */
  91099. serialize(parent: any): any;
  91100. }
  91101. /**
  91102. * This defines an action responsible to trigger several actions once triggered.
  91103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91104. */
  91105. export class CombineAction extends Action {
  91106. /**
  91107. * The list of aggregated animations to run.
  91108. */
  91109. children: Action[];
  91110. /**
  91111. * Instantiate the action
  91112. * @param triggerOptions defines the trigger options
  91113. * @param children defines the list of aggregated animations to run
  91114. * @param condition defines the trigger related conditions
  91115. */
  91116. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91117. /** @hidden */
  91118. _prepare(): void;
  91119. /**
  91120. * Execute the action and executes all the aggregated actions.
  91121. */
  91122. execute(evt: ActionEvent): void;
  91123. /**
  91124. * Serializes the actions and its related information.
  91125. * @param parent defines the object to serialize in
  91126. * @returns the serialized object
  91127. */
  91128. serialize(parent: any): any;
  91129. }
  91130. /**
  91131. * This defines an action responsible to run code (external event) once triggered.
  91132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91133. */
  91134. export class ExecuteCodeAction extends Action {
  91135. /**
  91136. * The callback function to run.
  91137. */
  91138. func: (evt: ActionEvent) => void;
  91139. /**
  91140. * Instantiate the action
  91141. * @param triggerOptions defines the trigger options
  91142. * @param func defines the callback function to run
  91143. * @param condition defines the trigger related conditions
  91144. */
  91145. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91146. /**
  91147. * Execute the action and run the attached code.
  91148. */
  91149. execute(evt: ActionEvent): void;
  91150. }
  91151. /**
  91152. * This defines an action responsible to set the parent property of the target once triggered.
  91153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91154. */
  91155. export class SetParentAction extends Action {
  91156. private _parent;
  91157. private _target;
  91158. /**
  91159. * Instantiate the action
  91160. * @param triggerOptions defines the trigger options
  91161. * @param target defines the target containing the parent property
  91162. * @param parent defines from where the animation should start (animation frame)
  91163. * @param condition defines the trigger related conditions
  91164. */
  91165. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91166. /** @hidden */
  91167. _prepare(): void;
  91168. /**
  91169. * Execute the action and set the parent property.
  91170. */
  91171. execute(): void;
  91172. /**
  91173. * Serializes the actions and its related information.
  91174. * @param parent defines the object to serialize in
  91175. * @returns the serialized object
  91176. */
  91177. serialize(parent: any): any;
  91178. }
  91179. }
  91180. declare module BABYLON {
  91181. /**
  91182. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91183. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91185. */
  91186. export class ActionManager extends AbstractActionManager {
  91187. /**
  91188. * Nothing
  91189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91190. */
  91191. static readonly NothingTrigger: number;
  91192. /**
  91193. * On pick
  91194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91195. */
  91196. static readonly OnPickTrigger: number;
  91197. /**
  91198. * On left pick
  91199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91200. */
  91201. static readonly OnLeftPickTrigger: number;
  91202. /**
  91203. * On right pick
  91204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91205. */
  91206. static readonly OnRightPickTrigger: number;
  91207. /**
  91208. * On center pick
  91209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91210. */
  91211. static readonly OnCenterPickTrigger: number;
  91212. /**
  91213. * On pick down
  91214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91215. */
  91216. static readonly OnPickDownTrigger: number;
  91217. /**
  91218. * On double pick
  91219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91220. */
  91221. static readonly OnDoublePickTrigger: number;
  91222. /**
  91223. * On pick up
  91224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91225. */
  91226. static readonly OnPickUpTrigger: number;
  91227. /**
  91228. * On pick out.
  91229. * This trigger will only be raised if you also declared a OnPickDown
  91230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91231. */
  91232. static readonly OnPickOutTrigger: number;
  91233. /**
  91234. * On long press
  91235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91236. */
  91237. static readonly OnLongPressTrigger: number;
  91238. /**
  91239. * On pointer over
  91240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91241. */
  91242. static readonly OnPointerOverTrigger: number;
  91243. /**
  91244. * On pointer out
  91245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91246. */
  91247. static readonly OnPointerOutTrigger: number;
  91248. /**
  91249. * On every frame
  91250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91251. */
  91252. static readonly OnEveryFrameTrigger: number;
  91253. /**
  91254. * On intersection enter
  91255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91256. */
  91257. static readonly OnIntersectionEnterTrigger: number;
  91258. /**
  91259. * On intersection exit
  91260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91261. */
  91262. static readonly OnIntersectionExitTrigger: number;
  91263. /**
  91264. * On key down
  91265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91266. */
  91267. static readonly OnKeyDownTrigger: number;
  91268. /**
  91269. * On key up
  91270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91271. */
  91272. static readonly OnKeyUpTrigger: number;
  91273. private _scene;
  91274. /**
  91275. * Creates a new action manager
  91276. * @param scene defines the hosting scene
  91277. */
  91278. constructor(scene: Scene);
  91279. /**
  91280. * Releases all associated resources
  91281. */
  91282. dispose(): void;
  91283. /**
  91284. * Gets hosting scene
  91285. * @returns the hosting scene
  91286. */
  91287. getScene(): Scene;
  91288. /**
  91289. * Does this action manager handles actions of any of the given triggers
  91290. * @param triggers defines the triggers to be tested
  91291. * @return a boolean indicating whether one (or more) of the triggers is handled
  91292. */
  91293. hasSpecificTriggers(triggers: number[]): boolean;
  91294. /**
  91295. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91296. * speed.
  91297. * @param triggerA defines the trigger to be tested
  91298. * @param triggerB defines the trigger to be tested
  91299. * @return a boolean indicating whether one (or more) of the triggers is handled
  91300. */
  91301. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91302. /**
  91303. * Does this action manager handles actions of a given trigger
  91304. * @param trigger defines the trigger to be tested
  91305. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91306. * @return whether the trigger is handled
  91307. */
  91308. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91309. /**
  91310. * Does this action manager has pointer triggers
  91311. */
  91312. get hasPointerTriggers(): boolean;
  91313. /**
  91314. * Does this action manager has pick triggers
  91315. */
  91316. get hasPickTriggers(): boolean;
  91317. /**
  91318. * Registers an action to this action manager
  91319. * @param action defines the action to be registered
  91320. * @return the action amended (prepared) after registration
  91321. */
  91322. registerAction(action: IAction): Nullable<IAction>;
  91323. /**
  91324. * Unregisters an action to this action manager
  91325. * @param action defines the action to be unregistered
  91326. * @return a boolean indicating whether the action has been unregistered
  91327. */
  91328. unregisterAction(action: IAction): Boolean;
  91329. /**
  91330. * Process a specific trigger
  91331. * @param trigger defines the trigger to process
  91332. * @param evt defines the event details to be processed
  91333. */
  91334. processTrigger(trigger: number, evt?: IActionEvent): void;
  91335. /** @hidden */
  91336. _getEffectiveTarget(target: any, propertyPath: string): any;
  91337. /** @hidden */
  91338. _getProperty(propertyPath: string): string;
  91339. /**
  91340. * Serialize this manager to a JSON object
  91341. * @param name defines the property name to store this manager
  91342. * @returns a JSON representation of this manager
  91343. */
  91344. serialize(name: string): any;
  91345. /**
  91346. * Creates a new ActionManager from a JSON data
  91347. * @param parsedActions defines the JSON data to read from
  91348. * @param object defines the hosting mesh
  91349. * @param scene defines the hosting scene
  91350. */
  91351. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91352. /**
  91353. * Get a trigger name by index
  91354. * @param trigger defines the trigger index
  91355. * @returns a trigger name
  91356. */
  91357. static GetTriggerName(trigger: number): string;
  91358. }
  91359. }
  91360. declare module BABYLON {
  91361. /**
  91362. * Class used to represent a sprite
  91363. * @see http://doc.babylonjs.com/babylon101/sprites
  91364. */
  91365. export class Sprite {
  91366. /** defines the name */
  91367. name: string;
  91368. /** Gets or sets the current world position */
  91369. position: Vector3;
  91370. /** Gets or sets the main color */
  91371. color: Color4;
  91372. /** Gets or sets the width */
  91373. width: number;
  91374. /** Gets or sets the height */
  91375. height: number;
  91376. /** Gets or sets rotation angle */
  91377. angle: number;
  91378. /** Gets or sets the cell index in the sprite sheet */
  91379. cellIndex: number;
  91380. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91381. cellRef: string;
  91382. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91383. invertU: number;
  91384. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91385. invertV: number;
  91386. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91387. disposeWhenFinishedAnimating: boolean;
  91388. /** Gets the list of attached animations */
  91389. animations: Animation[];
  91390. /** Gets or sets a boolean indicating if the sprite can be picked */
  91391. isPickable: boolean;
  91392. /**
  91393. * Gets or sets the associated action manager
  91394. */
  91395. actionManager: Nullable<ActionManager>;
  91396. private _animationStarted;
  91397. private _loopAnimation;
  91398. private _fromIndex;
  91399. private _toIndex;
  91400. private _delay;
  91401. private _direction;
  91402. private _manager;
  91403. private _time;
  91404. private _onAnimationEnd;
  91405. /**
  91406. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91407. */
  91408. isVisible: boolean;
  91409. /**
  91410. * Gets or sets the sprite size
  91411. */
  91412. get size(): number;
  91413. set size(value: number);
  91414. /**
  91415. * Creates a new Sprite
  91416. * @param name defines the name
  91417. * @param manager defines the manager
  91418. */
  91419. constructor(
  91420. /** defines the name */
  91421. name: string, manager: ISpriteManager);
  91422. /**
  91423. * Starts an animation
  91424. * @param from defines the initial key
  91425. * @param to defines the end key
  91426. * @param loop defines if the animation must loop
  91427. * @param delay defines the start delay (in ms)
  91428. * @param onAnimationEnd defines a callback to call when animation ends
  91429. */
  91430. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91431. /** Stops current animation (if any) */
  91432. stopAnimation(): void;
  91433. /** @hidden */
  91434. _animate(deltaTime: number): void;
  91435. /** Release associated resources */
  91436. dispose(): void;
  91437. }
  91438. }
  91439. declare module BABYLON {
  91440. /**
  91441. * Information about the result of picking within a scene
  91442. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91443. */
  91444. export class PickingInfo {
  91445. /** @hidden */
  91446. _pickingUnavailable: boolean;
  91447. /**
  91448. * If the pick collided with an object
  91449. */
  91450. hit: boolean;
  91451. /**
  91452. * Distance away where the pick collided
  91453. */
  91454. distance: number;
  91455. /**
  91456. * The location of pick collision
  91457. */
  91458. pickedPoint: Nullable<Vector3>;
  91459. /**
  91460. * The mesh corresponding the the pick collision
  91461. */
  91462. pickedMesh: Nullable<AbstractMesh>;
  91463. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91464. bu: number;
  91465. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91466. bv: number;
  91467. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91468. faceId: number;
  91469. /** Id of the the submesh that was picked */
  91470. subMeshId: number;
  91471. /** If a sprite was picked, this will be the sprite the pick collided with */
  91472. pickedSprite: Nullable<Sprite>;
  91473. /**
  91474. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91475. */
  91476. originMesh: Nullable<AbstractMesh>;
  91477. /**
  91478. * The ray that was used to perform the picking.
  91479. */
  91480. ray: Nullable<Ray>;
  91481. /**
  91482. * Gets the normal correspodning to the face the pick collided with
  91483. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91484. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91485. * @returns The normal correspodning to the face the pick collided with
  91486. */
  91487. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91488. /**
  91489. * Gets the texture coordinates of where the pick occured
  91490. * @returns the vector containing the coordnates of the texture
  91491. */
  91492. getTextureCoordinates(): Nullable<Vector2>;
  91493. }
  91494. }
  91495. declare module BABYLON {
  91496. /**
  91497. * Gather the list of pointer event types as constants.
  91498. */
  91499. export class PointerEventTypes {
  91500. /**
  91501. * 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.
  91502. */
  91503. static readonly POINTERDOWN: number;
  91504. /**
  91505. * The pointerup event is fired when a pointer is no longer active.
  91506. */
  91507. static readonly POINTERUP: number;
  91508. /**
  91509. * The pointermove event is fired when a pointer changes coordinates.
  91510. */
  91511. static readonly POINTERMOVE: number;
  91512. /**
  91513. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91514. */
  91515. static readonly POINTERWHEEL: number;
  91516. /**
  91517. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91518. */
  91519. static readonly POINTERPICK: number;
  91520. /**
  91521. * The pointertap event is fired when a the object has been touched and released without drag.
  91522. */
  91523. static readonly POINTERTAP: number;
  91524. /**
  91525. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91526. */
  91527. static readonly POINTERDOUBLETAP: number;
  91528. }
  91529. /**
  91530. * Base class of pointer info types.
  91531. */
  91532. export class PointerInfoBase {
  91533. /**
  91534. * Defines the type of event (PointerEventTypes)
  91535. */
  91536. type: number;
  91537. /**
  91538. * Defines the related dom event
  91539. */
  91540. event: PointerEvent | MouseWheelEvent;
  91541. /**
  91542. * Instantiates the base class of pointers info.
  91543. * @param type Defines the type of event (PointerEventTypes)
  91544. * @param event Defines the related dom event
  91545. */
  91546. constructor(
  91547. /**
  91548. * Defines the type of event (PointerEventTypes)
  91549. */
  91550. type: number,
  91551. /**
  91552. * Defines the related dom event
  91553. */
  91554. event: PointerEvent | MouseWheelEvent);
  91555. }
  91556. /**
  91557. * This class is used to store pointer related info for the onPrePointerObservable event.
  91558. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91559. */
  91560. export class PointerInfoPre extends PointerInfoBase {
  91561. /**
  91562. * Ray from a pointer if availible (eg. 6dof controller)
  91563. */
  91564. ray: Nullable<Ray>;
  91565. /**
  91566. * Defines the local position of the pointer on the canvas.
  91567. */
  91568. localPosition: Vector2;
  91569. /**
  91570. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91571. */
  91572. skipOnPointerObservable: boolean;
  91573. /**
  91574. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91575. * @param type Defines the type of event (PointerEventTypes)
  91576. * @param event Defines the related dom event
  91577. * @param localX Defines the local x coordinates of the pointer when the event occured
  91578. * @param localY Defines the local y coordinates of the pointer when the event occured
  91579. */
  91580. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91581. }
  91582. /**
  91583. * This type contains all the data related to a pointer event in Babylon.js.
  91584. * 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.
  91585. */
  91586. export class PointerInfo extends PointerInfoBase {
  91587. /**
  91588. * Defines the picking info associated to the info (if any)\
  91589. */
  91590. pickInfo: Nullable<PickingInfo>;
  91591. /**
  91592. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91593. * @param type Defines the type of event (PointerEventTypes)
  91594. * @param event Defines the related dom event
  91595. * @param pickInfo Defines the picking info associated to the info (if any)\
  91596. */
  91597. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91598. /**
  91599. * Defines the picking info associated to the info (if any)\
  91600. */
  91601. pickInfo: Nullable<PickingInfo>);
  91602. }
  91603. /**
  91604. * Data relating to a touch event on the screen.
  91605. */
  91606. export interface PointerTouch {
  91607. /**
  91608. * X coordinate of touch.
  91609. */
  91610. x: number;
  91611. /**
  91612. * Y coordinate of touch.
  91613. */
  91614. y: number;
  91615. /**
  91616. * Id of touch. Unique for each finger.
  91617. */
  91618. pointerId: number;
  91619. /**
  91620. * Event type passed from DOM.
  91621. */
  91622. type: any;
  91623. }
  91624. }
  91625. declare module BABYLON {
  91626. /**
  91627. * Manage the mouse inputs to control the movement of a free camera.
  91628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91629. */
  91630. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91631. /**
  91632. * Define if touch is enabled in the mouse input
  91633. */
  91634. touchEnabled: boolean;
  91635. /**
  91636. * Defines the camera the input is attached to.
  91637. */
  91638. camera: FreeCamera;
  91639. /**
  91640. * Defines the buttons associated with the input to handle camera move.
  91641. */
  91642. buttons: number[];
  91643. /**
  91644. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91645. */
  91646. angularSensibility: number;
  91647. private _pointerInput;
  91648. private _onMouseMove;
  91649. private _observer;
  91650. private previousPosition;
  91651. /**
  91652. * Observable for when a pointer move event occurs containing the move offset
  91653. */
  91654. onPointerMovedObservable: Observable<{
  91655. offsetX: number;
  91656. offsetY: number;
  91657. }>;
  91658. /**
  91659. * @hidden
  91660. * If the camera should be rotated automatically based on pointer movement
  91661. */
  91662. _allowCameraRotation: boolean;
  91663. /**
  91664. * Manage the mouse inputs to control the movement of a free camera.
  91665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91666. * @param touchEnabled Defines if touch is enabled or not
  91667. */
  91668. constructor(
  91669. /**
  91670. * Define if touch is enabled in the mouse input
  91671. */
  91672. touchEnabled?: boolean);
  91673. /**
  91674. * Attach the input controls to a specific dom element to get the input from.
  91675. * @param element Defines the element the controls should be listened from
  91676. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91677. */
  91678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91679. /**
  91680. * Called on JS contextmenu event.
  91681. * Override this method to provide functionality.
  91682. */
  91683. protected onContextMenu(evt: PointerEvent): void;
  91684. /**
  91685. * Detach the current controls from the specified dom element.
  91686. * @param element Defines the element to stop listening the inputs from
  91687. */
  91688. detachControl(element: Nullable<HTMLElement>): void;
  91689. /**
  91690. * Gets the class name of the current intput.
  91691. * @returns the class name
  91692. */
  91693. getClassName(): string;
  91694. /**
  91695. * Get the friendly name associated with the input class.
  91696. * @returns the input friendly name
  91697. */
  91698. getSimpleName(): string;
  91699. }
  91700. }
  91701. declare module BABYLON {
  91702. /**
  91703. * Manage the touch inputs to control the movement of a free camera.
  91704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91705. */
  91706. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91707. /**
  91708. * Defines the camera the input is attached to.
  91709. */
  91710. camera: FreeCamera;
  91711. /**
  91712. * Defines the touch sensibility for rotation.
  91713. * The higher the faster.
  91714. */
  91715. touchAngularSensibility: number;
  91716. /**
  91717. * Defines the touch sensibility for move.
  91718. * The higher the faster.
  91719. */
  91720. touchMoveSensibility: number;
  91721. private _offsetX;
  91722. private _offsetY;
  91723. private _pointerPressed;
  91724. private _pointerInput;
  91725. private _observer;
  91726. private _onLostFocus;
  91727. /**
  91728. * Attach the input controls to a specific dom element to get the input from.
  91729. * @param element Defines the element the controls should be listened from
  91730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91731. */
  91732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91733. /**
  91734. * Detach the current controls from the specified dom element.
  91735. * @param element Defines the element to stop listening the inputs from
  91736. */
  91737. detachControl(element: Nullable<HTMLElement>): void;
  91738. /**
  91739. * Update the current camera state depending on the inputs that have been used this frame.
  91740. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91741. */
  91742. checkInputs(): void;
  91743. /**
  91744. * Gets the class name of the current intput.
  91745. * @returns the class name
  91746. */
  91747. getClassName(): string;
  91748. /**
  91749. * Get the friendly name associated with the input class.
  91750. * @returns the input friendly name
  91751. */
  91752. getSimpleName(): string;
  91753. }
  91754. }
  91755. declare module BABYLON {
  91756. /**
  91757. * Default Inputs manager for the FreeCamera.
  91758. * It groups all the default supported inputs for ease of use.
  91759. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91760. */
  91761. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91762. /**
  91763. * @hidden
  91764. */
  91765. _mouseInput: Nullable<FreeCameraMouseInput>;
  91766. /**
  91767. * Instantiates a new FreeCameraInputsManager.
  91768. * @param camera Defines the camera the inputs belong to
  91769. */
  91770. constructor(camera: FreeCamera);
  91771. /**
  91772. * Add keyboard input support to the input manager.
  91773. * @returns the current input manager
  91774. */
  91775. addKeyboard(): FreeCameraInputsManager;
  91776. /**
  91777. * Add mouse input support to the input manager.
  91778. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91779. * @returns the current input manager
  91780. */
  91781. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91782. /**
  91783. * Removes the mouse input support from the manager
  91784. * @returns the current input manager
  91785. */
  91786. removeMouse(): FreeCameraInputsManager;
  91787. /**
  91788. * Add touch input support to the input manager.
  91789. * @returns the current input manager
  91790. */
  91791. addTouch(): FreeCameraInputsManager;
  91792. /**
  91793. * Remove all attached input methods from a camera
  91794. */
  91795. clear(): void;
  91796. }
  91797. }
  91798. declare module BABYLON {
  91799. /**
  91800. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91801. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91802. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91803. */
  91804. export class FreeCamera extends TargetCamera {
  91805. /**
  91806. * Define the collision ellipsoid of the camera.
  91807. * This is helpful to simulate a camera body like the player body around the camera
  91808. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91809. */
  91810. ellipsoid: Vector3;
  91811. /**
  91812. * Define an offset for the position of the ellipsoid around the camera.
  91813. * This can be helpful to determine the center of the body near the gravity center of the body
  91814. * instead of its head.
  91815. */
  91816. ellipsoidOffset: Vector3;
  91817. /**
  91818. * Enable or disable collisions of the camera with the rest of the scene objects.
  91819. */
  91820. checkCollisions: boolean;
  91821. /**
  91822. * Enable or disable gravity on the camera.
  91823. */
  91824. applyGravity: boolean;
  91825. /**
  91826. * Define the input manager associated to the camera.
  91827. */
  91828. inputs: FreeCameraInputsManager;
  91829. /**
  91830. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91831. * Higher values reduce sensitivity.
  91832. */
  91833. get angularSensibility(): number;
  91834. /**
  91835. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91836. * Higher values reduce sensitivity.
  91837. */
  91838. set angularSensibility(value: number);
  91839. /**
  91840. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91841. */
  91842. get keysUp(): number[];
  91843. set keysUp(value: number[]);
  91844. /**
  91845. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91846. */
  91847. get keysDown(): number[];
  91848. set keysDown(value: number[]);
  91849. /**
  91850. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91851. */
  91852. get keysLeft(): number[];
  91853. set keysLeft(value: number[]);
  91854. /**
  91855. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91856. */
  91857. get keysRight(): number[];
  91858. set keysRight(value: number[]);
  91859. /**
  91860. * Event raised when the camera collide with a mesh in the scene.
  91861. */
  91862. onCollide: (collidedMesh: AbstractMesh) => void;
  91863. private _collider;
  91864. private _needMoveForGravity;
  91865. private _oldPosition;
  91866. private _diffPosition;
  91867. private _newPosition;
  91868. /** @hidden */
  91869. _localDirection: Vector3;
  91870. /** @hidden */
  91871. _transformedDirection: Vector3;
  91872. /**
  91873. * Instantiates a Free Camera.
  91874. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91875. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91876. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91877. * @param name Define the name of the camera in the scene
  91878. * @param position Define the start position of the camera in the scene
  91879. * @param scene Define the scene the camera belongs to
  91880. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91881. */
  91882. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91883. /**
  91884. * Attached controls to the current camera.
  91885. * @param element Defines the element the controls should be listened from
  91886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91887. */
  91888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91889. /**
  91890. * Detach the current controls from the camera.
  91891. * The camera will stop reacting to inputs.
  91892. * @param element Defines the element to stop listening the inputs from
  91893. */
  91894. detachControl(element: HTMLElement): void;
  91895. private _collisionMask;
  91896. /**
  91897. * Define a collision mask to limit the list of object the camera can collide with
  91898. */
  91899. get collisionMask(): number;
  91900. set collisionMask(mask: number);
  91901. /** @hidden */
  91902. _collideWithWorld(displacement: Vector3): void;
  91903. private _onCollisionPositionChange;
  91904. /** @hidden */
  91905. _checkInputs(): void;
  91906. /** @hidden */
  91907. _decideIfNeedsToMove(): boolean;
  91908. /** @hidden */
  91909. _updatePosition(): void;
  91910. /**
  91911. * Destroy the camera and release the current resources hold by it.
  91912. */
  91913. dispose(): void;
  91914. /**
  91915. * Gets the current object class name.
  91916. * @return the class name
  91917. */
  91918. getClassName(): string;
  91919. }
  91920. }
  91921. declare module BABYLON {
  91922. /**
  91923. * Represents a gamepad control stick position
  91924. */
  91925. export class StickValues {
  91926. /**
  91927. * The x component of the control stick
  91928. */
  91929. x: number;
  91930. /**
  91931. * The y component of the control stick
  91932. */
  91933. y: number;
  91934. /**
  91935. * Initializes the gamepad x and y control stick values
  91936. * @param x The x component of the gamepad control stick value
  91937. * @param y The y component of the gamepad control stick value
  91938. */
  91939. constructor(
  91940. /**
  91941. * The x component of the control stick
  91942. */
  91943. x: number,
  91944. /**
  91945. * The y component of the control stick
  91946. */
  91947. y: number);
  91948. }
  91949. /**
  91950. * An interface which manages callbacks for gamepad button changes
  91951. */
  91952. export interface GamepadButtonChanges {
  91953. /**
  91954. * Called when a gamepad has been changed
  91955. */
  91956. changed: boolean;
  91957. /**
  91958. * Called when a gamepad press event has been triggered
  91959. */
  91960. pressChanged: boolean;
  91961. /**
  91962. * Called when a touch event has been triggered
  91963. */
  91964. touchChanged: boolean;
  91965. /**
  91966. * Called when a value has changed
  91967. */
  91968. valueChanged: boolean;
  91969. }
  91970. /**
  91971. * Represents a gamepad
  91972. */
  91973. export class Gamepad {
  91974. /**
  91975. * The id of the gamepad
  91976. */
  91977. id: string;
  91978. /**
  91979. * The index of the gamepad
  91980. */
  91981. index: number;
  91982. /**
  91983. * The browser gamepad
  91984. */
  91985. browserGamepad: any;
  91986. /**
  91987. * Specifies what type of gamepad this represents
  91988. */
  91989. type: number;
  91990. private _leftStick;
  91991. private _rightStick;
  91992. /** @hidden */
  91993. _isConnected: boolean;
  91994. private _leftStickAxisX;
  91995. private _leftStickAxisY;
  91996. private _rightStickAxisX;
  91997. private _rightStickAxisY;
  91998. /**
  91999. * Triggered when the left control stick has been changed
  92000. */
  92001. private _onleftstickchanged;
  92002. /**
  92003. * Triggered when the right control stick has been changed
  92004. */
  92005. private _onrightstickchanged;
  92006. /**
  92007. * Represents a gamepad controller
  92008. */
  92009. static GAMEPAD: number;
  92010. /**
  92011. * Represents a generic controller
  92012. */
  92013. static GENERIC: number;
  92014. /**
  92015. * Represents an XBox controller
  92016. */
  92017. static XBOX: number;
  92018. /**
  92019. * Represents a pose-enabled controller
  92020. */
  92021. static POSE_ENABLED: number;
  92022. /**
  92023. * Represents an Dual Shock controller
  92024. */
  92025. static DUALSHOCK: number;
  92026. /**
  92027. * Specifies whether the left control stick should be Y-inverted
  92028. */
  92029. protected _invertLeftStickY: boolean;
  92030. /**
  92031. * Specifies if the gamepad has been connected
  92032. */
  92033. get isConnected(): boolean;
  92034. /**
  92035. * Initializes the gamepad
  92036. * @param id The id of the gamepad
  92037. * @param index The index of the gamepad
  92038. * @param browserGamepad The browser gamepad
  92039. * @param leftStickX The x component of the left joystick
  92040. * @param leftStickY The y component of the left joystick
  92041. * @param rightStickX The x component of the right joystick
  92042. * @param rightStickY The y component of the right joystick
  92043. */
  92044. constructor(
  92045. /**
  92046. * The id of the gamepad
  92047. */
  92048. id: string,
  92049. /**
  92050. * The index of the gamepad
  92051. */
  92052. index: number,
  92053. /**
  92054. * The browser gamepad
  92055. */
  92056. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  92057. /**
  92058. * Callback triggered when the left joystick has changed
  92059. * @param callback
  92060. */
  92061. onleftstickchanged(callback: (values: StickValues) => void): void;
  92062. /**
  92063. * Callback triggered when the right joystick has changed
  92064. * @param callback
  92065. */
  92066. onrightstickchanged(callback: (values: StickValues) => void): void;
  92067. /**
  92068. * Gets the left joystick
  92069. */
  92070. get leftStick(): StickValues;
  92071. /**
  92072. * Sets the left joystick values
  92073. */
  92074. set leftStick(newValues: StickValues);
  92075. /**
  92076. * Gets the right joystick
  92077. */
  92078. get rightStick(): StickValues;
  92079. /**
  92080. * Sets the right joystick value
  92081. */
  92082. set rightStick(newValues: StickValues);
  92083. /**
  92084. * Updates the gamepad joystick positions
  92085. */
  92086. update(): void;
  92087. /**
  92088. * Disposes the gamepad
  92089. */
  92090. dispose(): void;
  92091. }
  92092. /**
  92093. * Represents a generic gamepad
  92094. */
  92095. export class GenericPad extends Gamepad {
  92096. private _buttons;
  92097. private _onbuttondown;
  92098. private _onbuttonup;
  92099. /**
  92100. * Observable triggered when a button has been pressed
  92101. */
  92102. onButtonDownObservable: Observable<number>;
  92103. /**
  92104. * Observable triggered when a button has been released
  92105. */
  92106. onButtonUpObservable: Observable<number>;
  92107. /**
  92108. * Callback triggered when a button has been pressed
  92109. * @param callback Called when a button has been pressed
  92110. */
  92111. onbuttondown(callback: (buttonPressed: number) => void): void;
  92112. /**
  92113. * Callback triggered when a button has been released
  92114. * @param callback Called when a button has been released
  92115. */
  92116. onbuttonup(callback: (buttonReleased: number) => void): void;
  92117. /**
  92118. * Initializes the generic gamepad
  92119. * @param id The id of the generic gamepad
  92120. * @param index The index of the generic gamepad
  92121. * @param browserGamepad The browser gamepad
  92122. */
  92123. constructor(id: string, index: number, browserGamepad: any);
  92124. private _setButtonValue;
  92125. /**
  92126. * Updates the generic gamepad
  92127. */
  92128. update(): void;
  92129. /**
  92130. * Disposes the generic gamepad
  92131. */
  92132. dispose(): void;
  92133. }
  92134. }
  92135. declare module BABYLON {
  92136. /**
  92137. * Defines the types of pose enabled controllers that are supported
  92138. */
  92139. export enum PoseEnabledControllerType {
  92140. /**
  92141. * HTC Vive
  92142. */
  92143. VIVE = 0,
  92144. /**
  92145. * Oculus Rift
  92146. */
  92147. OCULUS = 1,
  92148. /**
  92149. * Windows mixed reality
  92150. */
  92151. WINDOWS = 2,
  92152. /**
  92153. * Samsung gear VR
  92154. */
  92155. GEAR_VR = 3,
  92156. /**
  92157. * Google Daydream
  92158. */
  92159. DAYDREAM = 4,
  92160. /**
  92161. * Generic
  92162. */
  92163. GENERIC = 5
  92164. }
  92165. /**
  92166. * Defines the MutableGamepadButton interface for the state of a gamepad button
  92167. */
  92168. export interface MutableGamepadButton {
  92169. /**
  92170. * Value of the button/trigger
  92171. */
  92172. value: number;
  92173. /**
  92174. * If the button/trigger is currently touched
  92175. */
  92176. touched: boolean;
  92177. /**
  92178. * If the button/trigger is currently pressed
  92179. */
  92180. pressed: boolean;
  92181. }
  92182. /**
  92183. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  92184. * @hidden
  92185. */
  92186. export interface ExtendedGamepadButton extends GamepadButton {
  92187. /**
  92188. * If the button/trigger is currently pressed
  92189. */
  92190. readonly pressed: boolean;
  92191. /**
  92192. * If the button/trigger is currently touched
  92193. */
  92194. readonly touched: boolean;
  92195. /**
  92196. * Value of the button/trigger
  92197. */
  92198. readonly value: number;
  92199. }
  92200. /** @hidden */
  92201. export interface _GamePadFactory {
  92202. /**
  92203. * Returns whether or not the current gamepad can be created for this type of controller.
  92204. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92205. * @returns true if it can be created, otherwise false
  92206. */
  92207. canCreate(gamepadInfo: any): boolean;
  92208. /**
  92209. * Creates a new instance of the Gamepad.
  92210. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92211. * @returns the new gamepad instance
  92212. */
  92213. create(gamepadInfo: any): Gamepad;
  92214. }
  92215. /**
  92216. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92217. */
  92218. export class PoseEnabledControllerHelper {
  92219. /** @hidden */
  92220. static _ControllerFactories: _GamePadFactory[];
  92221. /** @hidden */
  92222. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  92223. /**
  92224. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92225. * @param vrGamepad the gamepad to initialized
  92226. * @returns a vr controller of the type the gamepad identified as
  92227. */
  92228. static InitiateController(vrGamepad: any): Gamepad;
  92229. }
  92230. /**
  92231. * Defines the PoseEnabledController object that contains state of a vr capable controller
  92232. */
  92233. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92234. /**
  92235. * If the controller is used in a webXR session
  92236. */
  92237. isXR: boolean;
  92238. private _deviceRoomPosition;
  92239. private _deviceRoomRotationQuaternion;
  92240. /**
  92241. * The device position in babylon space
  92242. */
  92243. devicePosition: Vector3;
  92244. /**
  92245. * The device rotation in babylon space
  92246. */
  92247. deviceRotationQuaternion: Quaternion;
  92248. /**
  92249. * The scale factor of the device in babylon space
  92250. */
  92251. deviceScaleFactor: number;
  92252. /**
  92253. * (Likely devicePosition should be used instead) The device position in its room space
  92254. */
  92255. position: Vector3;
  92256. /**
  92257. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  92258. */
  92259. rotationQuaternion: Quaternion;
  92260. /**
  92261. * The type of controller (Eg. Windows mixed reality)
  92262. */
  92263. controllerType: PoseEnabledControllerType;
  92264. protected _calculatedPosition: Vector3;
  92265. private _calculatedRotation;
  92266. /**
  92267. * The raw pose from the device
  92268. */
  92269. rawPose: DevicePose;
  92270. private _trackPosition;
  92271. private _maxRotationDistFromHeadset;
  92272. private _draggedRoomRotation;
  92273. /**
  92274. * @hidden
  92275. */
  92276. _disableTrackPosition(fixedPosition: Vector3): void;
  92277. /**
  92278. * Internal, the mesh attached to the controller
  92279. * @hidden
  92280. */
  92281. _mesh: Nullable<AbstractMesh>;
  92282. private _poseControlledCamera;
  92283. private _leftHandSystemQuaternion;
  92284. /**
  92285. * Internal, matrix used to convert room space to babylon space
  92286. * @hidden
  92287. */
  92288. _deviceToWorld: Matrix;
  92289. /**
  92290. * Node to be used when casting a ray from the controller
  92291. * @hidden
  92292. */
  92293. _pointingPoseNode: Nullable<TransformNode>;
  92294. /**
  92295. * Name of the child mesh that can be used to cast a ray from the controller
  92296. */
  92297. static readonly POINTING_POSE: string;
  92298. /**
  92299. * Creates a new PoseEnabledController from a gamepad
  92300. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92301. */
  92302. constructor(browserGamepad: any);
  92303. private _workingMatrix;
  92304. /**
  92305. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92306. */
  92307. update(): void;
  92308. /**
  92309. * Updates only the pose device and mesh without doing any button event checking
  92310. */
  92311. protected _updatePoseAndMesh(): void;
  92312. /**
  92313. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92314. * @param poseData raw pose fromthe device
  92315. */
  92316. updateFromDevice(poseData: DevicePose): void;
  92317. /**
  92318. * @hidden
  92319. */
  92320. _meshAttachedObservable: Observable<AbstractMesh>;
  92321. /**
  92322. * Attaches a mesh to the controller
  92323. * @param mesh the mesh to be attached
  92324. */
  92325. attachToMesh(mesh: AbstractMesh): void;
  92326. /**
  92327. * Attaches the controllers mesh to a camera
  92328. * @param camera the camera the mesh should be attached to
  92329. */
  92330. attachToPoseControlledCamera(camera: TargetCamera): void;
  92331. /**
  92332. * Disposes of the controller
  92333. */
  92334. dispose(): void;
  92335. /**
  92336. * The mesh that is attached to the controller
  92337. */
  92338. get mesh(): Nullable<AbstractMesh>;
  92339. /**
  92340. * Gets the ray of the controller in the direction the controller is pointing
  92341. * @param length the length the resulting ray should be
  92342. * @returns a ray in the direction the controller is pointing
  92343. */
  92344. getForwardRay(length?: number): Ray;
  92345. }
  92346. }
  92347. declare module BABYLON {
  92348. /**
  92349. * Defines the WebVRController object that represents controllers tracked in 3D space
  92350. */
  92351. export abstract class WebVRController extends PoseEnabledController {
  92352. /**
  92353. * Internal, the default controller model for the controller
  92354. */
  92355. protected _defaultModel: Nullable<AbstractMesh>;
  92356. /**
  92357. * Fired when the trigger state has changed
  92358. */
  92359. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92360. /**
  92361. * Fired when the main button state has changed
  92362. */
  92363. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92364. /**
  92365. * Fired when the secondary button state has changed
  92366. */
  92367. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92368. /**
  92369. * Fired when the pad state has changed
  92370. */
  92371. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92372. /**
  92373. * Fired when controllers stick values have changed
  92374. */
  92375. onPadValuesChangedObservable: Observable<StickValues>;
  92376. /**
  92377. * Array of button availible on the controller
  92378. */
  92379. protected _buttons: Array<MutableGamepadButton>;
  92380. private _onButtonStateChange;
  92381. /**
  92382. * Fired when a controller button's state has changed
  92383. * @param callback the callback containing the button that was modified
  92384. */
  92385. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92386. /**
  92387. * X and Y axis corresponding to the controllers joystick
  92388. */
  92389. pad: StickValues;
  92390. /**
  92391. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92392. */
  92393. hand: string;
  92394. /**
  92395. * The default controller model for the controller
  92396. */
  92397. get defaultModel(): Nullable<AbstractMesh>;
  92398. /**
  92399. * Creates a new WebVRController from a gamepad
  92400. * @param vrGamepad the gamepad that the WebVRController should be created from
  92401. */
  92402. constructor(vrGamepad: any);
  92403. /**
  92404. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92405. */
  92406. update(): void;
  92407. /**
  92408. * Function to be called when a button is modified
  92409. */
  92410. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92411. /**
  92412. * Loads a mesh and attaches it to the controller
  92413. * @param scene the scene the mesh should be added to
  92414. * @param meshLoaded callback for when the mesh has been loaded
  92415. */
  92416. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92417. private _setButtonValue;
  92418. private _changes;
  92419. private _checkChanges;
  92420. /**
  92421. * Disposes of th webVRCOntroller
  92422. */
  92423. dispose(): void;
  92424. }
  92425. }
  92426. declare module BABYLON {
  92427. /**
  92428. * The HemisphericLight simulates the ambient environment light,
  92429. * so the passed direction is the light reflection direction, not the incoming direction.
  92430. */
  92431. export class HemisphericLight extends Light {
  92432. /**
  92433. * The groundColor is the light in the opposite direction to the one specified during creation.
  92434. * 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.
  92435. */
  92436. groundColor: Color3;
  92437. /**
  92438. * The light reflection direction, not the incoming direction.
  92439. */
  92440. direction: Vector3;
  92441. /**
  92442. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92443. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92444. * The HemisphericLight can't cast shadows.
  92445. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92446. * @param name The friendly name of the light
  92447. * @param direction The direction of the light reflection
  92448. * @param scene The scene the light belongs to
  92449. */
  92450. constructor(name: string, direction: Vector3, scene: Scene);
  92451. protected _buildUniformLayout(): void;
  92452. /**
  92453. * Returns the string "HemisphericLight".
  92454. * @return The class name
  92455. */
  92456. getClassName(): string;
  92457. /**
  92458. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92459. * Returns the updated direction.
  92460. * @param target The target the direction should point to
  92461. * @return The computed direction
  92462. */
  92463. setDirectionToTarget(target: Vector3): Vector3;
  92464. /**
  92465. * Returns the shadow generator associated to the light.
  92466. * @returns Always null for hemispheric lights because it does not support shadows.
  92467. */
  92468. getShadowGenerator(): Nullable<IShadowGenerator>;
  92469. /**
  92470. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92471. * @param effect The effect to update
  92472. * @param lightIndex The index of the light in the effect to update
  92473. * @returns The hemispheric light
  92474. */
  92475. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92476. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92477. /**
  92478. * Computes the world matrix of the node
  92479. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92480. * @param useWasUpdatedFlag defines a reserved property
  92481. * @returns the world matrix
  92482. */
  92483. computeWorldMatrix(): Matrix;
  92484. /**
  92485. * Returns the integer 3.
  92486. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92487. */
  92488. getTypeID(): number;
  92489. /**
  92490. * Prepares the list of defines specific to the light type.
  92491. * @param defines the list of defines
  92492. * @param lightIndex defines the index of the light for the effect
  92493. */
  92494. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92495. }
  92496. }
  92497. declare module BABYLON {
  92498. /** @hidden */
  92499. export var vrMultiviewToSingleviewPixelShader: {
  92500. name: string;
  92501. shader: string;
  92502. };
  92503. }
  92504. declare module BABYLON {
  92505. /**
  92506. * Renders to multiple views with a single draw call
  92507. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92508. */
  92509. export class MultiviewRenderTarget extends RenderTargetTexture {
  92510. /**
  92511. * Creates a multiview render target
  92512. * @param scene scene used with the render target
  92513. * @param size the size of the render target (used for each view)
  92514. */
  92515. constructor(scene: Scene, size?: number | {
  92516. width: number;
  92517. height: number;
  92518. } | {
  92519. ratio: number;
  92520. });
  92521. /**
  92522. * @hidden
  92523. * @param faceIndex the face index, if its a cube texture
  92524. */
  92525. _bindFrameBuffer(faceIndex?: number): void;
  92526. /**
  92527. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92528. * @returns the view count
  92529. */
  92530. getViewCount(): number;
  92531. }
  92532. }
  92533. declare module BABYLON {
  92534. /**
  92535. * Represents a camera frustum
  92536. */
  92537. export class Frustum {
  92538. /**
  92539. * Gets the planes representing the frustum
  92540. * @param transform matrix to be applied to the returned planes
  92541. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92542. */
  92543. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92544. /**
  92545. * Gets the near frustum plane transformed by the transform matrix
  92546. * @param transform transformation matrix to be applied to the resulting frustum plane
  92547. * @param frustumPlane the resuling frustum plane
  92548. */
  92549. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92550. /**
  92551. * Gets the far frustum plane transformed by the transform matrix
  92552. * @param transform transformation matrix to be applied to the resulting frustum plane
  92553. * @param frustumPlane the resuling frustum plane
  92554. */
  92555. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92556. /**
  92557. * Gets the left frustum plane transformed by the transform matrix
  92558. * @param transform transformation matrix to be applied to the resulting frustum plane
  92559. * @param frustumPlane the resuling frustum plane
  92560. */
  92561. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92562. /**
  92563. * Gets the right frustum plane transformed by the transform matrix
  92564. * @param transform transformation matrix to be applied to the resulting frustum plane
  92565. * @param frustumPlane the resuling frustum plane
  92566. */
  92567. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92568. /**
  92569. * Gets the top frustum plane transformed by the transform matrix
  92570. * @param transform transformation matrix to be applied to the resulting frustum plane
  92571. * @param frustumPlane the resuling frustum plane
  92572. */
  92573. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92574. /**
  92575. * Gets the bottom frustum plane transformed by the transform matrix
  92576. * @param transform transformation matrix to be applied to the resulting frustum plane
  92577. * @param frustumPlane the resuling frustum plane
  92578. */
  92579. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92580. /**
  92581. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92582. * @param transform transformation matrix to be applied to the resulting frustum planes
  92583. * @param frustumPlanes the resuling frustum planes
  92584. */
  92585. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92586. }
  92587. }
  92588. declare module BABYLON {
  92589. interface Engine {
  92590. /**
  92591. * Creates a new multiview render target
  92592. * @param width defines the width of the texture
  92593. * @param height defines the height of the texture
  92594. * @returns the created multiview texture
  92595. */
  92596. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92597. /**
  92598. * Binds a multiview framebuffer to be drawn to
  92599. * @param multiviewTexture texture to bind
  92600. */
  92601. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92602. }
  92603. interface Camera {
  92604. /**
  92605. * @hidden
  92606. * 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)
  92607. */
  92608. _useMultiviewToSingleView: boolean;
  92609. /**
  92610. * @hidden
  92611. * 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)
  92612. */
  92613. _multiviewTexture: Nullable<RenderTargetTexture>;
  92614. /**
  92615. * @hidden
  92616. * ensures the multiview texture of the camera exists and has the specified width/height
  92617. * @param width height to set on the multiview texture
  92618. * @param height width to set on the multiview texture
  92619. */
  92620. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92621. }
  92622. interface Scene {
  92623. /** @hidden */
  92624. _transformMatrixR: Matrix;
  92625. /** @hidden */
  92626. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92627. /** @hidden */
  92628. _createMultiviewUbo(): void;
  92629. /** @hidden */
  92630. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92631. /** @hidden */
  92632. _renderMultiviewToSingleView(camera: Camera): void;
  92633. }
  92634. }
  92635. declare module BABYLON {
  92636. /**
  92637. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92638. * This will not be used for webXR as it supports displaying texture arrays directly
  92639. */
  92640. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92641. /**
  92642. * Initializes a VRMultiviewToSingleview
  92643. * @param name name of the post process
  92644. * @param camera camera to be applied to
  92645. * @param scaleFactor scaling factor to the size of the output texture
  92646. */
  92647. constructor(name: string, camera: Camera, scaleFactor: number);
  92648. }
  92649. }
  92650. declare module BABYLON {
  92651. /**
  92652. * Interface used to define additional presentation attributes
  92653. */
  92654. export interface IVRPresentationAttributes {
  92655. /**
  92656. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92657. */
  92658. highRefreshRate: boolean;
  92659. /**
  92660. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92661. */
  92662. foveationLevel: number;
  92663. }
  92664. interface Engine {
  92665. /** @hidden */
  92666. _vrDisplay: any;
  92667. /** @hidden */
  92668. _vrSupported: boolean;
  92669. /** @hidden */
  92670. _oldSize: Size;
  92671. /** @hidden */
  92672. _oldHardwareScaleFactor: number;
  92673. /** @hidden */
  92674. _vrExclusivePointerMode: boolean;
  92675. /** @hidden */
  92676. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92677. /** @hidden */
  92678. _onVRDisplayPointerRestricted: () => void;
  92679. /** @hidden */
  92680. _onVRDisplayPointerUnrestricted: () => void;
  92681. /** @hidden */
  92682. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92683. /** @hidden */
  92684. _onVrDisplayDisconnect: Nullable<() => void>;
  92685. /** @hidden */
  92686. _onVrDisplayPresentChange: Nullable<() => void>;
  92687. /**
  92688. * Observable signaled when VR display mode changes
  92689. */
  92690. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92691. /**
  92692. * Observable signaled when VR request present is complete
  92693. */
  92694. onVRRequestPresentComplete: Observable<boolean>;
  92695. /**
  92696. * Observable signaled when VR request present starts
  92697. */
  92698. onVRRequestPresentStart: Observable<Engine>;
  92699. /**
  92700. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92701. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92702. */
  92703. isInVRExclusivePointerMode: boolean;
  92704. /**
  92705. * Gets a boolean indicating if a webVR device was detected
  92706. * @returns true if a webVR device was detected
  92707. */
  92708. isVRDevicePresent(): boolean;
  92709. /**
  92710. * Gets the current webVR device
  92711. * @returns the current webVR device (or null)
  92712. */
  92713. getVRDevice(): any;
  92714. /**
  92715. * Initializes a webVR display and starts listening to display change events
  92716. * The onVRDisplayChangedObservable will be notified upon these changes
  92717. * @returns A promise containing a VRDisplay and if vr is supported
  92718. */
  92719. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92720. /** @hidden */
  92721. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92722. /**
  92723. * Gets or sets the presentation attributes used to configure VR rendering
  92724. */
  92725. vrPresentationAttributes?: IVRPresentationAttributes;
  92726. /**
  92727. * Call this function to switch to webVR mode
  92728. * Will do nothing if webVR is not supported or if there is no webVR device
  92729. * @param options the webvr options provided to the camera. mainly used for multiview
  92730. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92731. */
  92732. enableVR(options: WebVROptions): void;
  92733. /** @hidden */
  92734. _onVRFullScreenTriggered(): void;
  92735. }
  92736. }
  92737. declare module BABYLON {
  92738. /**
  92739. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92740. * IMPORTANT!! The data is right-hand data.
  92741. * @export
  92742. * @interface DevicePose
  92743. */
  92744. export interface DevicePose {
  92745. /**
  92746. * The position of the device, values in array are [x,y,z].
  92747. */
  92748. readonly position: Nullable<Float32Array>;
  92749. /**
  92750. * The linearVelocity of the device, values in array are [x,y,z].
  92751. */
  92752. readonly linearVelocity: Nullable<Float32Array>;
  92753. /**
  92754. * The linearAcceleration of the device, values in array are [x,y,z].
  92755. */
  92756. readonly linearAcceleration: Nullable<Float32Array>;
  92757. /**
  92758. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92759. */
  92760. readonly orientation: Nullable<Float32Array>;
  92761. /**
  92762. * The angularVelocity of the device, values in array are [x,y,z].
  92763. */
  92764. readonly angularVelocity: Nullable<Float32Array>;
  92765. /**
  92766. * The angularAcceleration of the device, values in array are [x,y,z].
  92767. */
  92768. readonly angularAcceleration: Nullable<Float32Array>;
  92769. }
  92770. /**
  92771. * Interface representing a pose controlled object in Babylon.
  92772. * A pose controlled object has both regular pose values as well as pose values
  92773. * from an external device such as a VR head mounted display
  92774. */
  92775. export interface PoseControlled {
  92776. /**
  92777. * The position of the object in babylon space.
  92778. */
  92779. position: Vector3;
  92780. /**
  92781. * The rotation quaternion of the object in babylon space.
  92782. */
  92783. rotationQuaternion: Quaternion;
  92784. /**
  92785. * The position of the device in babylon space.
  92786. */
  92787. devicePosition?: Vector3;
  92788. /**
  92789. * The rotation quaternion of the device in babylon space.
  92790. */
  92791. deviceRotationQuaternion: Quaternion;
  92792. /**
  92793. * The raw pose coming from the device.
  92794. */
  92795. rawPose: Nullable<DevicePose>;
  92796. /**
  92797. * The scale of the device to be used when translating from device space to babylon space.
  92798. */
  92799. deviceScaleFactor: number;
  92800. /**
  92801. * Updates the poseControlled values based on the input device pose.
  92802. * @param poseData the pose data to update the object with
  92803. */
  92804. updateFromDevice(poseData: DevicePose): void;
  92805. }
  92806. /**
  92807. * Set of options to customize the webVRCamera
  92808. */
  92809. export interface WebVROptions {
  92810. /**
  92811. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92812. */
  92813. trackPosition?: boolean;
  92814. /**
  92815. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92816. */
  92817. positionScale?: number;
  92818. /**
  92819. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92820. */
  92821. displayName?: string;
  92822. /**
  92823. * Should the native controller meshes be initialized. (default: true)
  92824. */
  92825. controllerMeshes?: boolean;
  92826. /**
  92827. * Creating a default HemiLight only on controllers. (default: true)
  92828. */
  92829. defaultLightingOnControllers?: boolean;
  92830. /**
  92831. * If you don't want to use the default VR button of the helper. (default: false)
  92832. */
  92833. useCustomVRButton?: boolean;
  92834. /**
  92835. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92836. */
  92837. customVRButton?: HTMLButtonElement;
  92838. /**
  92839. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92840. */
  92841. rayLength?: number;
  92842. /**
  92843. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92844. */
  92845. defaultHeight?: number;
  92846. /**
  92847. * If multiview should be used if availible (default: false)
  92848. */
  92849. useMultiview?: boolean;
  92850. }
  92851. /**
  92852. * This represents a WebVR camera.
  92853. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92854. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92855. */
  92856. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92857. private webVROptions;
  92858. /**
  92859. * @hidden
  92860. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92861. */
  92862. _vrDevice: any;
  92863. /**
  92864. * The rawPose of the vrDevice.
  92865. */
  92866. rawPose: Nullable<DevicePose>;
  92867. private _onVREnabled;
  92868. private _specsVersion;
  92869. private _attached;
  92870. private _frameData;
  92871. protected _descendants: Array<Node>;
  92872. private _deviceRoomPosition;
  92873. /** @hidden */
  92874. _deviceRoomRotationQuaternion: Quaternion;
  92875. private _standingMatrix;
  92876. /**
  92877. * Represents device position in babylon space.
  92878. */
  92879. devicePosition: Vector3;
  92880. /**
  92881. * Represents device rotation in babylon space.
  92882. */
  92883. deviceRotationQuaternion: Quaternion;
  92884. /**
  92885. * The scale of the device to be used when translating from device space to babylon space.
  92886. */
  92887. deviceScaleFactor: number;
  92888. private _deviceToWorld;
  92889. private _worldToDevice;
  92890. /**
  92891. * References to the webVR controllers for the vrDevice.
  92892. */
  92893. controllers: Array<WebVRController>;
  92894. /**
  92895. * Emits an event when a controller is attached.
  92896. */
  92897. onControllersAttachedObservable: Observable<WebVRController[]>;
  92898. /**
  92899. * Emits an event when a controller's mesh has been loaded;
  92900. */
  92901. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92902. /**
  92903. * Emits an event when the HMD's pose has been updated.
  92904. */
  92905. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92906. private _poseSet;
  92907. /**
  92908. * If the rig cameras be used as parent instead of this camera.
  92909. */
  92910. rigParenting: boolean;
  92911. private _lightOnControllers;
  92912. private _defaultHeight?;
  92913. /**
  92914. * Instantiates a WebVRFreeCamera.
  92915. * @param name The name of the WebVRFreeCamera
  92916. * @param position The starting anchor position for the camera
  92917. * @param scene The scene the camera belongs to
  92918. * @param webVROptions a set of customizable options for the webVRCamera
  92919. */
  92920. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92921. /**
  92922. * Gets the device distance from the ground in meters.
  92923. * @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.
  92924. */
  92925. deviceDistanceToRoomGround(): number;
  92926. /**
  92927. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92928. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92929. */
  92930. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92931. /**
  92932. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92933. * @returns A promise with a boolean set to if the standing matrix is supported.
  92934. */
  92935. useStandingMatrixAsync(): Promise<boolean>;
  92936. /**
  92937. * Disposes the camera
  92938. */
  92939. dispose(): void;
  92940. /**
  92941. * Gets a vrController by name.
  92942. * @param name The name of the controller to retreive
  92943. * @returns the controller matching the name specified or null if not found
  92944. */
  92945. getControllerByName(name: string): Nullable<WebVRController>;
  92946. private _leftController;
  92947. /**
  92948. * The controller corresponding to the users left hand.
  92949. */
  92950. get leftController(): Nullable<WebVRController>;
  92951. private _rightController;
  92952. /**
  92953. * The controller corresponding to the users right hand.
  92954. */
  92955. get rightController(): Nullable<WebVRController>;
  92956. /**
  92957. * Casts a ray forward from the vrCamera's gaze.
  92958. * @param length Length of the ray (default: 100)
  92959. * @returns the ray corresponding to the gaze
  92960. */
  92961. getForwardRay(length?: number): Ray;
  92962. /**
  92963. * @hidden
  92964. * Updates the camera based on device's frame data
  92965. */
  92966. _checkInputs(): void;
  92967. /**
  92968. * Updates the poseControlled values based on the input device pose.
  92969. * @param poseData Pose coming from the device
  92970. */
  92971. updateFromDevice(poseData: DevicePose): void;
  92972. private _htmlElementAttached;
  92973. private _detachIfAttached;
  92974. /**
  92975. * WebVR's attach control will start broadcasting frames to the device.
  92976. * Note that in certain browsers (chrome for example) this function must be called
  92977. * within a user-interaction callback. Example:
  92978. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92979. *
  92980. * @param element html element to attach the vrDevice to
  92981. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92982. */
  92983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92984. /**
  92985. * Detaches the camera from the html element and disables VR
  92986. *
  92987. * @param element html element to detach from
  92988. */
  92989. detachControl(element: HTMLElement): void;
  92990. /**
  92991. * @returns the name of this class
  92992. */
  92993. getClassName(): string;
  92994. /**
  92995. * Calls resetPose on the vrDisplay
  92996. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92997. */
  92998. resetToCurrentRotation(): void;
  92999. /**
  93000. * @hidden
  93001. * Updates the rig cameras (left and right eye)
  93002. */
  93003. _updateRigCameras(): void;
  93004. private _workingVector;
  93005. private _oneVector;
  93006. private _workingMatrix;
  93007. private updateCacheCalled;
  93008. private _correctPositionIfNotTrackPosition;
  93009. /**
  93010. * @hidden
  93011. * Updates the cached values of the camera
  93012. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  93013. */
  93014. _updateCache(ignoreParentClass?: boolean): void;
  93015. /**
  93016. * @hidden
  93017. * Get current device position in babylon world
  93018. */
  93019. _computeDevicePosition(): void;
  93020. /**
  93021. * Updates the current device position and rotation in the babylon world
  93022. */
  93023. update(): void;
  93024. /**
  93025. * @hidden
  93026. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  93027. * @returns an identity matrix
  93028. */
  93029. _getViewMatrix(): Matrix;
  93030. private _tmpMatrix;
  93031. /**
  93032. * This function is called by the two RIG cameras.
  93033. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  93034. * @hidden
  93035. */
  93036. _getWebVRViewMatrix(): Matrix;
  93037. /** @hidden */
  93038. _getWebVRProjectionMatrix(): Matrix;
  93039. private _onGamepadConnectedObserver;
  93040. private _onGamepadDisconnectedObserver;
  93041. private _updateCacheWhenTrackingDisabledObserver;
  93042. /**
  93043. * Initializes the controllers and their meshes
  93044. */
  93045. initControllers(): void;
  93046. }
  93047. }
  93048. declare module BABYLON {
  93049. /**
  93050. * Size options for a post process
  93051. */
  93052. export type PostProcessOptions = {
  93053. width: number;
  93054. height: number;
  93055. };
  93056. /**
  93057. * PostProcess can be used to apply a shader to a texture after it has been rendered
  93058. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93059. */
  93060. export class PostProcess {
  93061. /** Name of the PostProcess. */
  93062. name: string;
  93063. /**
  93064. * Gets or sets the unique id of the post process
  93065. */
  93066. uniqueId: number;
  93067. /**
  93068. * Width of the texture to apply the post process on
  93069. */
  93070. width: number;
  93071. /**
  93072. * Height of the texture to apply the post process on
  93073. */
  93074. height: number;
  93075. /**
  93076. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  93077. * @hidden
  93078. */
  93079. _outputTexture: Nullable<InternalTexture>;
  93080. /**
  93081. * Sampling mode used by the shader
  93082. * See https://doc.babylonjs.com/classes/3.1/texture
  93083. */
  93084. renderTargetSamplingMode: number;
  93085. /**
  93086. * Clear color to use when screen clearing
  93087. */
  93088. clearColor: Color4;
  93089. /**
  93090. * If the buffer needs to be cleared before applying the post process. (default: true)
  93091. * Should be set to false if shader will overwrite all previous pixels.
  93092. */
  93093. autoClear: boolean;
  93094. /**
  93095. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  93096. */
  93097. alphaMode: number;
  93098. /**
  93099. * Sets the setAlphaBlendConstants of the babylon engine
  93100. */
  93101. alphaConstants: Color4;
  93102. /**
  93103. * Animations to be used for the post processing
  93104. */
  93105. animations: Animation[];
  93106. /**
  93107. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  93108. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  93109. */
  93110. enablePixelPerfectMode: boolean;
  93111. /**
  93112. * Force the postprocess to be applied without taking in account viewport
  93113. */
  93114. forceFullscreenViewport: boolean;
  93115. /**
  93116. * List of inspectable custom properties (used by the Inspector)
  93117. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93118. */
  93119. inspectableCustomProperties: IInspectable[];
  93120. /**
  93121. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  93122. *
  93123. * | Value | Type | Description |
  93124. * | ----- | ----------------------------------- | ----------- |
  93125. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  93126. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  93127. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  93128. *
  93129. */
  93130. scaleMode: number;
  93131. /**
  93132. * Force textures to be a power of two (default: false)
  93133. */
  93134. alwaysForcePOT: boolean;
  93135. private _samples;
  93136. /**
  93137. * Number of sample textures (default: 1)
  93138. */
  93139. get samples(): number;
  93140. set samples(n: number);
  93141. /**
  93142. * Modify the scale of the post process to be the same as the viewport (default: false)
  93143. */
  93144. adaptScaleToCurrentViewport: boolean;
  93145. private _camera;
  93146. private _scene;
  93147. private _engine;
  93148. private _options;
  93149. private _reusable;
  93150. private _textureType;
  93151. private _textureFormat;
  93152. /**
  93153. * Smart array of input and output textures for the post process.
  93154. * @hidden
  93155. */
  93156. _textures: SmartArray<InternalTexture>;
  93157. /**
  93158. * The index in _textures that corresponds to the output texture.
  93159. * @hidden
  93160. */
  93161. _currentRenderTextureInd: number;
  93162. private _effect;
  93163. private _samplers;
  93164. private _fragmentUrl;
  93165. private _vertexUrl;
  93166. private _parameters;
  93167. private _scaleRatio;
  93168. protected _indexParameters: any;
  93169. private _shareOutputWithPostProcess;
  93170. private _texelSize;
  93171. private _forcedOutputTexture;
  93172. /**
  93173. * Returns the fragment url or shader name used in the post process.
  93174. * @returns the fragment url or name in the shader store.
  93175. */
  93176. getEffectName(): string;
  93177. /**
  93178. * An event triggered when the postprocess is activated.
  93179. */
  93180. onActivateObservable: Observable<Camera>;
  93181. private _onActivateObserver;
  93182. /**
  93183. * A function that is added to the onActivateObservable
  93184. */
  93185. set onActivate(callback: Nullable<(camera: Camera) => void>);
  93186. /**
  93187. * An event triggered when the postprocess changes its size.
  93188. */
  93189. onSizeChangedObservable: Observable<PostProcess>;
  93190. private _onSizeChangedObserver;
  93191. /**
  93192. * A function that is added to the onSizeChangedObservable
  93193. */
  93194. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  93195. /**
  93196. * An event triggered when the postprocess applies its effect.
  93197. */
  93198. onApplyObservable: Observable<Effect>;
  93199. private _onApplyObserver;
  93200. /**
  93201. * A function that is added to the onApplyObservable
  93202. */
  93203. set onApply(callback: (effect: Effect) => void);
  93204. /**
  93205. * An event triggered before rendering the postprocess
  93206. */
  93207. onBeforeRenderObservable: Observable<Effect>;
  93208. private _onBeforeRenderObserver;
  93209. /**
  93210. * A function that is added to the onBeforeRenderObservable
  93211. */
  93212. set onBeforeRender(callback: (effect: Effect) => void);
  93213. /**
  93214. * An event triggered after rendering the postprocess
  93215. */
  93216. onAfterRenderObservable: Observable<Effect>;
  93217. private _onAfterRenderObserver;
  93218. /**
  93219. * A function that is added to the onAfterRenderObservable
  93220. */
  93221. set onAfterRender(callback: (efect: Effect) => void);
  93222. /**
  93223. * 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
  93224. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  93225. */
  93226. get inputTexture(): InternalTexture;
  93227. set inputTexture(value: InternalTexture);
  93228. /**
  93229. * Gets the camera which post process is applied to.
  93230. * @returns The camera the post process is applied to.
  93231. */
  93232. getCamera(): Camera;
  93233. /**
  93234. * Gets the texel size of the postprocess.
  93235. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93236. */
  93237. get texelSize(): Vector2;
  93238. /**
  93239. * Creates a new instance PostProcess
  93240. * @param name The name of the PostProcess.
  93241. * @param fragmentUrl The url of the fragment shader to be used.
  93242. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93243. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93244. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93245. * @param camera The camera to apply the render pass to.
  93246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93247. * @param engine The engine which the post process will be applied. (default: current engine)
  93248. * @param reusable If the post process can be reused on the same frame. (default: false)
  93249. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93250. * @param textureType Type of textures used when performing the post process. (default: 0)
  93251. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93252. * @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
  93253. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93254. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93255. */
  93256. constructor(
  93257. /** Name of the PostProcess. */
  93258. 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);
  93259. /**
  93260. * Gets a string idenfifying the name of the class
  93261. * @returns "PostProcess" string
  93262. */
  93263. getClassName(): string;
  93264. /**
  93265. * Gets the engine which this post process belongs to.
  93266. * @returns The engine the post process was enabled with.
  93267. */
  93268. getEngine(): Engine;
  93269. /**
  93270. * The effect that is created when initializing the post process.
  93271. * @returns The created effect corresponding the the postprocess.
  93272. */
  93273. getEffect(): Effect;
  93274. /**
  93275. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  93276. * @param postProcess The post process to share the output with.
  93277. * @returns This post process.
  93278. */
  93279. shareOutputWith(postProcess: PostProcess): PostProcess;
  93280. /**
  93281. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93282. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93283. */
  93284. useOwnOutput(): void;
  93285. /**
  93286. * Updates the effect with the current post process compile time values and recompiles the shader.
  93287. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93288. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93289. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93290. * @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
  93291. * @param onCompiled Called when the shader has been compiled.
  93292. * @param onError Called if there is an error when compiling a shader.
  93293. */
  93294. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93295. /**
  93296. * The post process is reusable if it can be used multiple times within one frame.
  93297. * @returns If the post process is reusable
  93298. */
  93299. isReusable(): boolean;
  93300. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93301. markTextureDirty(): void;
  93302. /**
  93303. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93304. * 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.
  93305. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93306. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93307. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93308. * @returns The target texture that was bound to be written to.
  93309. */
  93310. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93311. /**
  93312. * If the post process is supported.
  93313. */
  93314. get isSupported(): boolean;
  93315. /**
  93316. * The aspect ratio of the output texture.
  93317. */
  93318. get aspectRatio(): number;
  93319. /**
  93320. * Get a value indicating if the post-process is ready to be used
  93321. * @returns true if the post-process is ready (shader is compiled)
  93322. */
  93323. isReady(): boolean;
  93324. /**
  93325. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93326. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93327. */
  93328. apply(): Nullable<Effect>;
  93329. private _disposeTextures;
  93330. /**
  93331. * Disposes the post process.
  93332. * @param camera The camera to dispose the post process on.
  93333. */
  93334. dispose(camera?: Camera): void;
  93335. }
  93336. }
  93337. declare module BABYLON {
  93338. /** @hidden */
  93339. export var kernelBlurVaryingDeclaration: {
  93340. name: string;
  93341. shader: string;
  93342. };
  93343. }
  93344. declare module BABYLON {
  93345. /** @hidden */
  93346. export var kernelBlurFragment: {
  93347. name: string;
  93348. shader: string;
  93349. };
  93350. }
  93351. declare module BABYLON {
  93352. /** @hidden */
  93353. export var kernelBlurFragment2: {
  93354. name: string;
  93355. shader: string;
  93356. };
  93357. }
  93358. declare module BABYLON {
  93359. /** @hidden */
  93360. export var kernelBlurPixelShader: {
  93361. name: string;
  93362. shader: string;
  93363. };
  93364. }
  93365. declare module BABYLON {
  93366. /** @hidden */
  93367. export var kernelBlurVertex: {
  93368. name: string;
  93369. shader: string;
  93370. };
  93371. }
  93372. declare module BABYLON {
  93373. /** @hidden */
  93374. export var kernelBlurVertexShader: {
  93375. name: string;
  93376. shader: string;
  93377. };
  93378. }
  93379. declare module BABYLON {
  93380. /**
  93381. * The Blur Post Process which blurs an image based on a kernel and direction.
  93382. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93383. */
  93384. export class BlurPostProcess extends PostProcess {
  93385. /** The direction in which to blur the image. */
  93386. direction: Vector2;
  93387. private blockCompilation;
  93388. protected _kernel: number;
  93389. protected _idealKernel: number;
  93390. protected _packedFloat: boolean;
  93391. private _staticDefines;
  93392. /**
  93393. * Sets the length in pixels of the blur sample region
  93394. */
  93395. set kernel(v: number);
  93396. /**
  93397. * Gets the length in pixels of the blur sample region
  93398. */
  93399. get kernel(): number;
  93400. /**
  93401. * Sets wether or not the blur needs to unpack/repack floats
  93402. */
  93403. set packedFloat(v: boolean);
  93404. /**
  93405. * Gets wether or not the blur is unpacking/repacking floats
  93406. */
  93407. get packedFloat(): boolean;
  93408. /**
  93409. * Creates a new instance BlurPostProcess
  93410. * @param name The name of the effect.
  93411. * @param direction The direction in which to blur the image.
  93412. * @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.
  93413. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93414. * @param camera The camera to apply the render pass to.
  93415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93416. * @param engine The engine which the post process will be applied. (default: current engine)
  93417. * @param reusable If the post process can be reused on the same frame. (default: false)
  93418. * @param textureType Type of textures used when performing the post process. (default: 0)
  93419. * @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)
  93420. */
  93421. constructor(name: string,
  93422. /** The direction in which to blur the image. */
  93423. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93424. /**
  93425. * Updates the effect with the current post process compile time values and recompiles the shader.
  93426. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93427. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93428. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93429. * @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
  93430. * @param onCompiled Called when the shader has been compiled.
  93431. * @param onError Called if there is an error when compiling a shader.
  93432. */
  93433. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93434. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93435. /**
  93436. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93437. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93438. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93439. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93440. * The gaps between physical kernels are compensated for in the weighting of the samples
  93441. * @param idealKernel Ideal blur kernel.
  93442. * @return Nearest best kernel.
  93443. */
  93444. protected _nearestBestKernel(idealKernel: number): number;
  93445. /**
  93446. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93447. * @param x The point on the Gaussian distribution to sample.
  93448. * @return the value of the Gaussian function at x.
  93449. */
  93450. protected _gaussianWeight(x: number): number;
  93451. /**
  93452. * Generates a string that can be used as a floating point number in GLSL.
  93453. * @param x Value to print.
  93454. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93455. * @return GLSL float string.
  93456. */
  93457. protected _glslFloat(x: number, decimalFigures?: number): string;
  93458. }
  93459. }
  93460. declare module BABYLON {
  93461. /**
  93462. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93463. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93464. * You can then easily use it as a reflectionTexture on a flat surface.
  93465. * In case the surface is not a plane, please consider relying on reflection probes.
  93466. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93467. */
  93468. export class MirrorTexture extends RenderTargetTexture {
  93469. private scene;
  93470. /**
  93471. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93472. * 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.
  93473. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93474. */
  93475. mirrorPlane: Plane;
  93476. /**
  93477. * Define the blur ratio used to blur the reflection if needed.
  93478. */
  93479. set blurRatio(value: number);
  93480. get blurRatio(): number;
  93481. /**
  93482. * Define the adaptive blur kernel used to blur the reflection if needed.
  93483. * This will autocompute the closest best match for the `blurKernel`
  93484. */
  93485. set adaptiveBlurKernel(value: number);
  93486. /**
  93487. * Define the blur kernel used to blur the reflection if needed.
  93488. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93489. */
  93490. set blurKernel(value: number);
  93491. /**
  93492. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93493. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93494. */
  93495. set blurKernelX(value: number);
  93496. get blurKernelX(): number;
  93497. /**
  93498. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93499. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93500. */
  93501. set blurKernelY(value: number);
  93502. get blurKernelY(): number;
  93503. private _autoComputeBlurKernel;
  93504. protected _onRatioRescale(): void;
  93505. private _updateGammaSpace;
  93506. private _imageProcessingConfigChangeObserver;
  93507. private _transformMatrix;
  93508. private _mirrorMatrix;
  93509. private _savedViewMatrix;
  93510. private _blurX;
  93511. private _blurY;
  93512. private _adaptiveBlurKernel;
  93513. private _blurKernelX;
  93514. private _blurKernelY;
  93515. private _blurRatio;
  93516. /**
  93517. * Instantiates a Mirror Texture.
  93518. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93519. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93520. * You can then easily use it as a reflectionTexture on a flat surface.
  93521. * In case the surface is not a plane, please consider relying on reflection probes.
  93522. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93523. * @param name
  93524. * @param size
  93525. * @param scene
  93526. * @param generateMipMaps
  93527. * @param type
  93528. * @param samplingMode
  93529. * @param generateDepthBuffer
  93530. */
  93531. constructor(name: string, size: number | {
  93532. width: number;
  93533. height: number;
  93534. } | {
  93535. ratio: number;
  93536. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93537. private _preparePostProcesses;
  93538. /**
  93539. * Clone the mirror texture.
  93540. * @returns the cloned texture
  93541. */
  93542. clone(): MirrorTexture;
  93543. /**
  93544. * Serialize the texture to a JSON representation you could use in Parse later on
  93545. * @returns the serialized JSON representation
  93546. */
  93547. serialize(): any;
  93548. /**
  93549. * Dispose the texture and release its associated resources.
  93550. */
  93551. dispose(): void;
  93552. }
  93553. }
  93554. declare module BABYLON {
  93555. /**
  93556. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93557. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93558. */
  93559. export class Texture extends BaseTexture {
  93560. /**
  93561. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93562. */
  93563. static SerializeBuffers: boolean;
  93564. /** @hidden */
  93565. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93566. /** @hidden */
  93567. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93568. /** @hidden */
  93569. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93570. /** nearest is mag = nearest and min = nearest and mip = linear */
  93571. static readonly NEAREST_SAMPLINGMODE: number;
  93572. /** nearest is mag = nearest and min = nearest and mip = linear */
  93573. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93574. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93575. static readonly BILINEAR_SAMPLINGMODE: number;
  93576. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93577. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93578. /** Trilinear is mag = linear and min = linear and mip = linear */
  93579. static readonly TRILINEAR_SAMPLINGMODE: number;
  93580. /** Trilinear is mag = linear and min = linear and mip = linear */
  93581. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93582. /** mag = nearest and min = nearest and mip = nearest */
  93583. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93584. /** mag = nearest and min = linear and mip = nearest */
  93585. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93586. /** mag = nearest and min = linear and mip = linear */
  93587. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93588. /** mag = nearest and min = linear and mip = none */
  93589. static readonly NEAREST_LINEAR: number;
  93590. /** mag = nearest and min = nearest and mip = none */
  93591. static readonly NEAREST_NEAREST: number;
  93592. /** mag = linear and min = nearest and mip = nearest */
  93593. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93594. /** mag = linear and min = nearest and mip = linear */
  93595. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93596. /** mag = linear and min = linear and mip = none */
  93597. static readonly LINEAR_LINEAR: number;
  93598. /** mag = linear and min = nearest and mip = none */
  93599. static readonly LINEAR_NEAREST: number;
  93600. /** Explicit coordinates mode */
  93601. static readonly EXPLICIT_MODE: number;
  93602. /** Spherical coordinates mode */
  93603. static readonly SPHERICAL_MODE: number;
  93604. /** Planar coordinates mode */
  93605. static readonly PLANAR_MODE: number;
  93606. /** Cubic coordinates mode */
  93607. static readonly CUBIC_MODE: number;
  93608. /** Projection coordinates mode */
  93609. static readonly PROJECTION_MODE: number;
  93610. /** Inverse Cubic coordinates mode */
  93611. static readonly SKYBOX_MODE: number;
  93612. /** Inverse Cubic coordinates mode */
  93613. static readonly INVCUBIC_MODE: number;
  93614. /** Equirectangular coordinates mode */
  93615. static readonly EQUIRECTANGULAR_MODE: number;
  93616. /** Equirectangular Fixed coordinates mode */
  93617. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93618. /** Equirectangular Fixed Mirrored coordinates mode */
  93619. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93620. /** Texture is not repeating outside of 0..1 UVs */
  93621. static readonly CLAMP_ADDRESSMODE: number;
  93622. /** Texture is repeating outside of 0..1 UVs */
  93623. static readonly WRAP_ADDRESSMODE: number;
  93624. /** Texture is repeating and mirrored */
  93625. static readonly MIRROR_ADDRESSMODE: number;
  93626. /**
  93627. * 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
  93628. */
  93629. static UseSerializedUrlIfAny: boolean;
  93630. /**
  93631. * Define the url of the texture.
  93632. */
  93633. url: Nullable<string>;
  93634. /**
  93635. * Define an offset on the texture to offset the u coordinates of the UVs
  93636. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93637. */
  93638. uOffset: number;
  93639. /**
  93640. * Define an offset on the texture to offset the v coordinates of the UVs
  93641. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93642. */
  93643. vOffset: number;
  93644. /**
  93645. * Define an offset on the texture to scale the u coordinates of the UVs
  93646. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93647. */
  93648. uScale: number;
  93649. /**
  93650. * Define an offset on the texture to scale the v coordinates of the UVs
  93651. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93652. */
  93653. vScale: number;
  93654. /**
  93655. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93656. * @see http://doc.babylonjs.com/how_to/more_materials
  93657. */
  93658. uAng: number;
  93659. /**
  93660. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93661. * @see http://doc.babylonjs.com/how_to/more_materials
  93662. */
  93663. vAng: number;
  93664. /**
  93665. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93666. * @see http://doc.babylonjs.com/how_to/more_materials
  93667. */
  93668. wAng: number;
  93669. /**
  93670. * Defines the center of rotation (U)
  93671. */
  93672. uRotationCenter: number;
  93673. /**
  93674. * Defines the center of rotation (V)
  93675. */
  93676. vRotationCenter: number;
  93677. /**
  93678. * Defines the center of rotation (W)
  93679. */
  93680. wRotationCenter: number;
  93681. /**
  93682. * Are mip maps generated for this texture or not.
  93683. */
  93684. get noMipmap(): boolean;
  93685. /**
  93686. * List of inspectable custom properties (used by the Inspector)
  93687. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93688. */
  93689. inspectableCustomProperties: Nullable<IInspectable[]>;
  93690. private _noMipmap;
  93691. /** @hidden */
  93692. _invertY: boolean;
  93693. private _rowGenerationMatrix;
  93694. private _cachedTextureMatrix;
  93695. private _projectionModeMatrix;
  93696. private _t0;
  93697. private _t1;
  93698. private _t2;
  93699. private _cachedUOffset;
  93700. private _cachedVOffset;
  93701. private _cachedUScale;
  93702. private _cachedVScale;
  93703. private _cachedUAng;
  93704. private _cachedVAng;
  93705. private _cachedWAng;
  93706. private _cachedProjectionMatrixId;
  93707. private _cachedCoordinatesMode;
  93708. /** @hidden */
  93709. protected _initialSamplingMode: number;
  93710. /** @hidden */
  93711. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93712. private _deleteBuffer;
  93713. protected _format: Nullable<number>;
  93714. private _delayedOnLoad;
  93715. private _delayedOnError;
  93716. private _mimeType?;
  93717. /**
  93718. * Observable triggered once the texture has been loaded.
  93719. */
  93720. onLoadObservable: Observable<Texture>;
  93721. protected _isBlocking: boolean;
  93722. /**
  93723. * Is the texture preventing material to render while loading.
  93724. * If false, a default texture will be used instead of the loading one during the preparation step.
  93725. */
  93726. set isBlocking(value: boolean);
  93727. get isBlocking(): boolean;
  93728. /**
  93729. * Get the current sampling mode associated with the texture.
  93730. */
  93731. get samplingMode(): number;
  93732. /**
  93733. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93734. */
  93735. get invertY(): boolean;
  93736. /**
  93737. * Instantiates a new texture.
  93738. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93739. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93740. * @param url defines the url of the picture to load as a texture
  93741. * @param scene defines the scene or engine the texture will belong to
  93742. * @param noMipmap defines if the texture will require mip maps or not
  93743. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93744. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93745. * @param onLoad defines a callback triggered when the texture has been loaded
  93746. * @param onError defines a callback triggered when an error occurred during the loading session
  93747. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93748. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93749. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93750. * @param mimeType defines an optional mime type information
  93751. */
  93752. 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);
  93753. /**
  93754. * Update the url (and optional buffer) of this texture if url was null during construction.
  93755. * @param url the url of the texture
  93756. * @param buffer the buffer of the texture (defaults to null)
  93757. * @param onLoad callback called when the texture is loaded (defaults to null)
  93758. */
  93759. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93760. /**
  93761. * Finish the loading sequence of a texture flagged as delayed load.
  93762. * @hidden
  93763. */
  93764. delayLoad(): void;
  93765. private _prepareRowForTextureGeneration;
  93766. /**
  93767. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93768. * @returns the transform matrix of the texture.
  93769. */
  93770. getTextureMatrix(uBase?: number): Matrix;
  93771. /**
  93772. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93773. * @returns The reflection texture transform
  93774. */
  93775. getReflectionTextureMatrix(): Matrix;
  93776. /**
  93777. * Clones the texture.
  93778. * @returns the cloned texture
  93779. */
  93780. clone(): Texture;
  93781. /**
  93782. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93783. * @returns The JSON representation of the texture
  93784. */
  93785. serialize(): any;
  93786. /**
  93787. * Get the current class name of the texture useful for serialization or dynamic coding.
  93788. * @returns "Texture"
  93789. */
  93790. getClassName(): string;
  93791. /**
  93792. * Dispose the texture and release its associated resources.
  93793. */
  93794. dispose(): void;
  93795. /**
  93796. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93797. * @param parsedTexture Define the JSON representation of the texture
  93798. * @param scene Define the scene the parsed texture should be instantiated in
  93799. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93800. * @returns The parsed texture if successful
  93801. */
  93802. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93803. /**
  93804. * Creates a texture from its base 64 representation.
  93805. * @param data Define the base64 payload without the data: prefix
  93806. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93807. * @param scene Define the scene the texture should belong to
  93808. * @param noMipmap Forces the texture to not create mip map information if true
  93809. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93810. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93811. * @param onLoad define a callback triggered when the texture has been loaded
  93812. * @param onError define a callback triggered when an error occurred during the loading session
  93813. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93814. * @returns the created texture
  93815. */
  93816. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93817. /**
  93818. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93819. * @param data Define the base64 payload without the data: prefix
  93820. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93821. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93822. * @param scene Define the scene the texture should belong to
  93823. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93824. * @param noMipmap Forces the texture to not create mip map information if true
  93825. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93826. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93827. * @param onLoad define a callback triggered when the texture has been loaded
  93828. * @param onError define a callback triggered when an error occurred during the loading session
  93829. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93830. * @returns the created texture
  93831. */
  93832. 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;
  93833. }
  93834. }
  93835. declare module BABYLON {
  93836. /**
  93837. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93838. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93839. */
  93840. export class PostProcessManager {
  93841. private _scene;
  93842. private _indexBuffer;
  93843. private _vertexBuffers;
  93844. /**
  93845. * Creates a new instance PostProcess
  93846. * @param scene The scene that the post process is associated with.
  93847. */
  93848. constructor(scene: Scene);
  93849. private _prepareBuffers;
  93850. private _buildIndexBuffer;
  93851. /**
  93852. * Rebuilds the vertex buffers of the manager.
  93853. * @hidden
  93854. */
  93855. _rebuild(): void;
  93856. /**
  93857. * Prepares a frame to be run through a post process.
  93858. * @param sourceTexture The input texture to the post procesess. (default: null)
  93859. * @param postProcesses An array of post processes to be run. (default: null)
  93860. * @returns True if the post processes were able to be run.
  93861. * @hidden
  93862. */
  93863. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93864. /**
  93865. * Manually render a set of post processes to a texture.
  93866. * @param postProcesses An array of post processes to be run.
  93867. * @param targetTexture The target texture to render to.
  93868. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93869. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93870. * @param lodLevel defines which lod of the texture to render to
  93871. */
  93872. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93873. /**
  93874. * Finalize the result of the output of the postprocesses.
  93875. * @param doNotPresent If true the result will not be displayed to the screen.
  93876. * @param targetTexture The target texture to render to.
  93877. * @param faceIndex The index of the face to bind the target texture to.
  93878. * @param postProcesses The array of post processes to render.
  93879. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93880. * @hidden
  93881. */
  93882. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93883. /**
  93884. * Disposes of the post process manager.
  93885. */
  93886. dispose(): void;
  93887. }
  93888. }
  93889. declare module BABYLON {
  93890. /**
  93891. * This Helps creating a texture that will be created from a camera in your scene.
  93892. * It is basically a dynamic texture that could be used to create special effects for instance.
  93893. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93894. */
  93895. export class RenderTargetTexture extends Texture {
  93896. isCube: boolean;
  93897. /**
  93898. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93899. */
  93900. static readonly REFRESHRATE_RENDER_ONCE: number;
  93901. /**
  93902. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93903. */
  93904. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93905. /**
  93906. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93907. * the central point of your effect and can save a lot of performances.
  93908. */
  93909. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93910. /**
  93911. * Use this predicate to dynamically define the list of mesh you want to render.
  93912. * If set, the renderList property will be overwritten.
  93913. */
  93914. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93915. private _renderList;
  93916. /**
  93917. * Use this list to define the list of mesh you want to render.
  93918. */
  93919. get renderList(): Nullable<Array<AbstractMesh>>;
  93920. set renderList(value: Nullable<Array<AbstractMesh>>);
  93921. /**
  93922. * Use this function to overload the renderList array at rendering time.
  93923. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93924. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93925. * the cube (if the RTT is a cube, else layerOrFace=0).
  93926. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  93927. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  93928. * hold dummy elements!
  93929. */
  93930. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  93931. private _hookArray;
  93932. /**
  93933. * Define if particles should be rendered in your texture.
  93934. */
  93935. renderParticles: boolean;
  93936. /**
  93937. * Define if sprites should be rendered in your texture.
  93938. */
  93939. renderSprites: boolean;
  93940. /**
  93941. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93942. */
  93943. coordinatesMode: number;
  93944. /**
  93945. * Define the camera used to render the texture.
  93946. */
  93947. activeCamera: Nullable<Camera>;
  93948. /**
  93949. * Override the render function of the texture with your own one.
  93950. */
  93951. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93952. /**
  93953. * Define if camera post processes should be use while rendering the texture.
  93954. */
  93955. useCameraPostProcesses: boolean;
  93956. /**
  93957. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93958. */
  93959. ignoreCameraViewport: boolean;
  93960. private _postProcessManager;
  93961. private _postProcesses;
  93962. private _resizeObserver;
  93963. /**
  93964. * An event triggered when the texture is unbind.
  93965. */
  93966. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93967. /**
  93968. * An event triggered when the texture is unbind.
  93969. */
  93970. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93971. private _onAfterUnbindObserver;
  93972. /**
  93973. * Set a after unbind callback in the texture.
  93974. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93975. */
  93976. set onAfterUnbind(callback: () => void);
  93977. /**
  93978. * An event triggered before rendering the texture
  93979. */
  93980. onBeforeRenderObservable: Observable<number>;
  93981. private _onBeforeRenderObserver;
  93982. /**
  93983. * Set a before render callback in the texture.
  93984. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93985. */
  93986. set onBeforeRender(callback: (faceIndex: number) => void);
  93987. /**
  93988. * An event triggered after rendering the texture
  93989. */
  93990. onAfterRenderObservable: Observable<number>;
  93991. private _onAfterRenderObserver;
  93992. /**
  93993. * Set a after render callback in the texture.
  93994. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93995. */
  93996. set onAfterRender(callback: (faceIndex: number) => void);
  93997. /**
  93998. * An event triggered after the texture clear
  93999. */
  94000. onClearObservable: Observable<Engine>;
  94001. private _onClearObserver;
  94002. /**
  94003. * Set a clear callback in the texture.
  94004. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  94005. */
  94006. set onClear(callback: (Engine: Engine) => void);
  94007. /**
  94008. * An event triggered when the texture is resized.
  94009. */
  94010. onResizeObservable: Observable<RenderTargetTexture>;
  94011. /**
  94012. * Define the clear color of the Render Target if it should be different from the scene.
  94013. */
  94014. clearColor: Color4;
  94015. protected _size: number | {
  94016. width: number;
  94017. height: number;
  94018. layers?: number;
  94019. };
  94020. protected _initialSizeParameter: number | {
  94021. width: number;
  94022. height: number;
  94023. } | {
  94024. ratio: number;
  94025. };
  94026. protected _sizeRatio: Nullable<number>;
  94027. /** @hidden */
  94028. _generateMipMaps: boolean;
  94029. protected _renderingManager: RenderingManager;
  94030. /** @hidden */
  94031. _waitingRenderList: string[];
  94032. protected _doNotChangeAspectRatio: boolean;
  94033. protected _currentRefreshId: number;
  94034. protected _refreshRate: number;
  94035. protected _textureMatrix: Matrix;
  94036. protected _samples: number;
  94037. protected _renderTargetOptions: RenderTargetCreationOptions;
  94038. /**
  94039. * Gets render target creation options that were used.
  94040. */
  94041. get renderTargetOptions(): RenderTargetCreationOptions;
  94042. protected _engine: Engine;
  94043. protected _onRatioRescale(): void;
  94044. /**
  94045. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  94046. * It must define where the camera used to render the texture is set
  94047. */
  94048. boundingBoxPosition: Vector3;
  94049. private _boundingBoxSize;
  94050. /**
  94051. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  94052. * When defined, the cubemap will switch to local mode
  94053. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  94054. * @example https://www.babylonjs-playground.com/#RNASML
  94055. */
  94056. set boundingBoxSize(value: Vector3);
  94057. get boundingBoxSize(): Vector3;
  94058. /**
  94059. * In case the RTT has been created with a depth texture, get the associated
  94060. * depth texture.
  94061. * Otherwise, return null.
  94062. */
  94063. get depthStencilTexture(): Nullable<InternalTexture>;
  94064. /**
  94065. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  94066. * or used a shadow, depth texture...
  94067. * @param name The friendly name of the texture
  94068. * @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)
  94069. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  94070. * @param generateMipMaps True if mip maps need to be generated after render.
  94071. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  94072. * @param type The type of the buffer in the RTT (int, half float, float...)
  94073. * @param isCube True if a cube texture needs to be created
  94074. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  94075. * @param generateDepthBuffer True to generate a depth buffer
  94076. * @param generateStencilBuffer True to generate a stencil buffer
  94077. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  94078. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  94079. * @param delayAllocation if the texture allocation should be delayed (default: false)
  94080. */
  94081. constructor(name: string, size: number | {
  94082. width: number;
  94083. height: number;
  94084. layers?: number;
  94085. } | {
  94086. ratio: number;
  94087. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  94088. /**
  94089. * Creates a depth stencil texture.
  94090. * This is only available in WebGL 2 or with the depth texture extension available.
  94091. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  94092. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  94093. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  94094. */
  94095. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  94096. private _processSizeParameter;
  94097. /**
  94098. * Define the number of samples to use in case of MSAA.
  94099. * It defaults to one meaning no MSAA has been enabled.
  94100. */
  94101. get samples(): number;
  94102. set samples(value: number);
  94103. /**
  94104. * Resets the refresh counter of the texture and start bak from scratch.
  94105. * Could be useful to regenerate the texture if it is setup to render only once.
  94106. */
  94107. resetRefreshCounter(): void;
  94108. /**
  94109. * Define the refresh rate of the texture or the rendering frequency.
  94110. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  94111. */
  94112. get refreshRate(): number;
  94113. set refreshRate(value: number);
  94114. /**
  94115. * Adds a post process to the render target rendering passes.
  94116. * @param postProcess define the post process to add
  94117. */
  94118. addPostProcess(postProcess: PostProcess): void;
  94119. /**
  94120. * Clear all the post processes attached to the render target
  94121. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  94122. */
  94123. clearPostProcesses(dispose?: boolean): void;
  94124. /**
  94125. * Remove one of the post process from the list of attached post processes to the texture
  94126. * @param postProcess define the post process to remove from the list
  94127. */
  94128. removePostProcess(postProcess: PostProcess): void;
  94129. /** @hidden */
  94130. _shouldRender(): boolean;
  94131. /**
  94132. * Gets the actual render size of the texture.
  94133. * @returns the width of the render size
  94134. */
  94135. getRenderSize(): number;
  94136. /**
  94137. * Gets the actual render width of the texture.
  94138. * @returns the width of the render size
  94139. */
  94140. getRenderWidth(): number;
  94141. /**
  94142. * Gets the actual render height of the texture.
  94143. * @returns the height of the render size
  94144. */
  94145. getRenderHeight(): number;
  94146. /**
  94147. * Gets the actual number of layers of the texture.
  94148. * @returns the number of layers
  94149. */
  94150. getRenderLayers(): number;
  94151. /**
  94152. * Get if the texture can be rescaled or not.
  94153. */
  94154. get canRescale(): boolean;
  94155. /**
  94156. * Resize the texture using a ratio.
  94157. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  94158. */
  94159. scale(ratio: number): void;
  94160. /**
  94161. * Get the texture reflection matrix used to rotate/transform the reflection.
  94162. * @returns the reflection matrix
  94163. */
  94164. getReflectionTextureMatrix(): Matrix;
  94165. /**
  94166. * Resize the texture to a new desired size.
  94167. * Be carrefull as it will recreate all the data in the new texture.
  94168. * @param size Define the new size. It can be:
  94169. * - a number for squared texture,
  94170. * - an object containing { width: number, height: number }
  94171. * - or an object containing a ratio { ratio: number }
  94172. */
  94173. resize(size: number | {
  94174. width: number;
  94175. height: number;
  94176. } | {
  94177. ratio: number;
  94178. }): void;
  94179. private _defaultRenderListPrepared;
  94180. /**
  94181. * Renders all the objects from the render list into the texture.
  94182. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  94183. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  94184. */
  94185. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  94186. private _bestReflectionRenderTargetDimension;
  94187. private _prepareRenderingManager;
  94188. /**
  94189. * @hidden
  94190. * @param faceIndex face index to bind to if this is a cubetexture
  94191. * @param layer defines the index of the texture to bind in the array
  94192. */
  94193. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  94194. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  94195. private renderToTarget;
  94196. /**
  94197. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94198. * This allowed control for front to back rendering or reversly depending of the special needs.
  94199. *
  94200. * @param renderingGroupId The rendering group id corresponding to its index
  94201. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94202. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94203. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94204. */
  94205. 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;
  94206. /**
  94207. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94208. *
  94209. * @param renderingGroupId The rendering group id corresponding to its index
  94210. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94211. */
  94212. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  94213. /**
  94214. * Clones the texture.
  94215. * @returns the cloned texture
  94216. */
  94217. clone(): RenderTargetTexture;
  94218. /**
  94219. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94220. * @returns The JSON representation of the texture
  94221. */
  94222. serialize(): any;
  94223. /**
  94224. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  94225. */
  94226. disposeFramebufferObjects(): void;
  94227. /**
  94228. * Dispose the texture and release its associated resources.
  94229. */
  94230. dispose(): void;
  94231. /** @hidden */
  94232. _rebuild(): void;
  94233. /**
  94234. * Clear the info related to rendering groups preventing retention point in material dispose.
  94235. */
  94236. freeRenderingGroups(): void;
  94237. /**
  94238. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94239. * @returns the view count
  94240. */
  94241. getViewCount(): number;
  94242. }
  94243. }
  94244. declare module BABYLON {
  94245. /**
  94246. * Options for compiling materials.
  94247. */
  94248. export interface IMaterialCompilationOptions {
  94249. /**
  94250. * Defines whether clip planes are enabled.
  94251. */
  94252. clipPlane: boolean;
  94253. /**
  94254. * Defines whether instances are enabled.
  94255. */
  94256. useInstances: boolean;
  94257. }
  94258. /**
  94259. * Base class for the main features of a material in Babylon.js
  94260. */
  94261. export class Material implements IAnimatable {
  94262. /**
  94263. * Returns the triangle fill mode
  94264. */
  94265. static readonly TriangleFillMode: number;
  94266. /**
  94267. * Returns the wireframe mode
  94268. */
  94269. static readonly WireFrameFillMode: number;
  94270. /**
  94271. * Returns the point fill mode
  94272. */
  94273. static readonly PointFillMode: number;
  94274. /**
  94275. * Returns the point list draw mode
  94276. */
  94277. static readonly PointListDrawMode: number;
  94278. /**
  94279. * Returns the line list draw mode
  94280. */
  94281. static readonly LineListDrawMode: number;
  94282. /**
  94283. * Returns the line loop draw mode
  94284. */
  94285. static readonly LineLoopDrawMode: number;
  94286. /**
  94287. * Returns the line strip draw mode
  94288. */
  94289. static readonly LineStripDrawMode: number;
  94290. /**
  94291. * Returns the triangle strip draw mode
  94292. */
  94293. static readonly TriangleStripDrawMode: number;
  94294. /**
  94295. * Returns the triangle fan draw mode
  94296. */
  94297. static readonly TriangleFanDrawMode: number;
  94298. /**
  94299. * Stores the clock-wise side orientation
  94300. */
  94301. static readonly ClockWiseSideOrientation: number;
  94302. /**
  94303. * Stores the counter clock-wise side orientation
  94304. */
  94305. static readonly CounterClockWiseSideOrientation: number;
  94306. /**
  94307. * The dirty texture flag value
  94308. */
  94309. static readonly TextureDirtyFlag: number;
  94310. /**
  94311. * The dirty light flag value
  94312. */
  94313. static readonly LightDirtyFlag: number;
  94314. /**
  94315. * The dirty fresnel flag value
  94316. */
  94317. static readonly FresnelDirtyFlag: number;
  94318. /**
  94319. * The dirty attribute flag value
  94320. */
  94321. static readonly AttributesDirtyFlag: number;
  94322. /**
  94323. * The dirty misc flag value
  94324. */
  94325. static readonly MiscDirtyFlag: number;
  94326. /**
  94327. * The all dirty flag value
  94328. */
  94329. static readonly AllDirtyFlag: number;
  94330. /**
  94331. * The ID of the material
  94332. */
  94333. id: string;
  94334. /**
  94335. * Gets or sets the unique id of the material
  94336. */
  94337. uniqueId: number;
  94338. /**
  94339. * The name of the material
  94340. */
  94341. name: string;
  94342. /**
  94343. * Gets or sets user defined metadata
  94344. */
  94345. metadata: any;
  94346. /**
  94347. * For internal use only. Please do not use.
  94348. */
  94349. reservedDataStore: any;
  94350. /**
  94351. * Specifies if the ready state should be checked on each call
  94352. */
  94353. checkReadyOnEveryCall: boolean;
  94354. /**
  94355. * Specifies if the ready state should be checked once
  94356. */
  94357. checkReadyOnlyOnce: boolean;
  94358. /**
  94359. * The state of the material
  94360. */
  94361. state: string;
  94362. /**
  94363. * The alpha value of the material
  94364. */
  94365. protected _alpha: number;
  94366. /**
  94367. * List of inspectable custom properties (used by the Inspector)
  94368. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94369. */
  94370. inspectableCustomProperties: IInspectable[];
  94371. /**
  94372. * Sets the alpha value of the material
  94373. */
  94374. set alpha(value: number);
  94375. /**
  94376. * Gets the alpha value of the material
  94377. */
  94378. get alpha(): number;
  94379. /**
  94380. * Specifies if back face culling is enabled
  94381. */
  94382. protected _backFaceCulling: boolean;
  94383. /**
  94384. * Sets the back-face culling state
  94385. */
  94386. set backFaceCulling(value: boolean);
  94387. /**
  94388. * Gets the back-face culling state
  94389. */
  94390. get backFaceCulling(): boolean;
  94391. /**
  94392. * Stores the value for side orientation
  94393. */
  94394. sideOrientation: number;
  94395. /**
  94396. * Callback triggered when the material is compiled
  94397. */
  94398. onCompiled: Nullable<(effect: Effect) => void>;
  94399. /**
  94400. * Callback triggered when an error occurs
  94401. */
  94402. onError: Nullable<(effect: Effect, errors: string) => void>;
  94403. /**
  94404. * Callback triggered to get the render target textures
  94405. */
  94406. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94407. /**
  94408. * Gets a boolean indicating that current material needs to register RTT
  94409. */
  94410. get hasRenderTargetTextures(): boolean;
  94411. /**
  94412. * Specifies if the material should be serialized
  94413. */
  94414. doNotSerialize: boolean;
  94415. /**
  94416. * @hidden
  94417. */
  94418. _storeEffectOnSubMeshes: boolean;
  94419. /**
  94420. * Stores the animations for the material
  94421. */
  94422. animations: Nullable<Array<Animation>>;
  94423. /**
  94424. * An event triggered when the material is disposed
  94425. */
  94426. onDisposeObservable: Observable<Material>;
  94427. /**
  94428. * An observer which watches for dispose events
  94429. */
  94430. private _onDisposeObserver;
  94431. private _onUnBindObservable;
  94432. /**
  94433. * Called during a dispose event
  94434. */
  94435. set onDispose(callback: () => void);
  94436. private _onBindObservable;
  94437. /**
  94438. * An event triggered when the material is bound
  94439. */
  94440. get onBindObservable(): Observable<AbstractMesh>;
  94441. /**
  94442. * An observer which watches for bind events
  94443. */
  94444. private _onBindObserver;
  94445. /**
  94446. * Called during a bind event
  94447. */
  94448. set onBind(callback: (Mesh: AbstractMesh) => void);
  94449. /**
  94450. * An event triggered when the material is unbound
  94451. */
  94452. get onUnBindObservable(): Observable<Material>;
  94453. /**
  94454. * Stores the value of the alpha mode
  94455. */
  94456. private _alphaMode;
  94457. /**
  94458. * Sets the value of the alpha mode.
  94459. *
  94460. * | Value | Type | Description |
  94461. * | --- | --- | --- |
  94462. * | 0 | ALPHA_DISABLE | |
  94463. * | 1 | ALPHA_ADD | |
  94464. * | 2 | ALPHA_COMBINE | |
  94465. * | 3 | ALPHA_SUBTRACT | |
  94466. * | 4 | ALPHA_MULTIPLY | |
  94467. * | 5 | ALPHA_MAXIMIZED | |
  94468. * | 6 | ALPHA_ONEONE | |
  94469. * | 7 | ALPHA_PREMULTIPLIED | |
  94470. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94471. * | 9 | ALPHA_INTERPOLATE | |
  94472. * | 10 | ALPHA_SCREENMODE | |
  94473. *
  94474. */
  94475. set alphaMode(value: number);
  94476. /**
  94477. * Gets the value of the alpha mode
  94478. */
  94479. get alphaMode(): number;
  94480. /**
  94481. * Stores the state of the need depth pre-pass value
  94482. */
  94483. private _needDepthPrePass;
  94484. /**
  94485. * Sets the need depth pre-pass value
  94486. */
  94487. set needDepthPrePass(value: boolean);
  94488. /**
  94489. * Gets the depth pre-pass value
  94490. */
  94491. get needDepthPrePass(): boolean;
  94492. /**
  94493. * Specifies if depth writing should be disabled
  94494. */
  94495. disableDepthWrite: boolean;
  94496. /**
  94497. * Specifies if depth writing should be forced
  94498. */
  94499. forceDepthWrite: boolean;
  94500. /**
  94501. * Specifies the depth function that should be used. 0 means the default engine function
  94502. */
  94503. depthFunction: number;
  94504. /**
  94505. * Specifies if there should be a separate pass for culling
  94506. */
  94507. separateCullingPass: boolean;
  94508. /**
  94509. * Stores the state specifing if fog should be enabled
  94510. */
  94511. private _fogEnabled;
  94512. /**
  94513. * Sets the state for enabling fog
  94514. */
  94515. set fogEnabled(value: boolean);
  94516. /**
  94517. * Gets the value of the fog enabled state
  94518. */
  94519. get fogEnabled(): boolean;
  94520. /**
  94521. * Stores the size of points
  94522. */
  94523. pointSize: number;
  94524. /**
  94525. * Stores the z offset value
  94526. */
  94527. zOffset: number;
  94528. /**
  94529. * Gets a value specifying if wireframe mode is enabled
  94530. */
  94531. get wireframe(): boolean;
  94532. /**
  94533. * Sets the state of wireframe mode
  94534. */
  94535. set wireframe(value: boolean);
  94536. /**
  94537. * Gets the value specifying if point clouds are enabled
  94538. */
  94539. get pointsCloud(): boolean;
  94540. /**
  94541. * Sets the state of point cloud mode
  94542. */
  94543. set pointsCloud(value: boolean);
  94544. /**
  94545. * Gets the material fill mode
  94546. */
  94547. get fillMode(): number;
  94548. /**
  94549. * Sets the material fill mode
  94550. */
  94551. set fillMode(value: number);
  94552. /**
  94553. * @hidden
  94554. * Stores the effects for the material
  94555. */
  94556. _effect: Nullable<Effect>;
  94557. /**
  94558. * Specifies if uniform buffers should be used
  94559. */
  94560. private _useUBO;
  94561. /**
  94562. * Stores a reference to the scene
  94563. */
  94564. private _scene;
  94565. /**
  94566. * Stores the fill mode state
  94567. */
  94568. private _fillMode;
  94569. /**
  94570. * Specifies if the depth write state should be cached
  94571. */
  94572. private _cachedDepthWriteState;
  94573. /**
  94574. * Specifies if the depth function state should be cached
  94575. */
  94576. private _cachedDepthFunctionState;
  94577. /**
  94578. * Stores the uniform buffer
  94579. */
  94580. protected _uniformBuffer: UniformBuffer;
  94581. /** @hidden */
  94582. _indexInSceneMaterialArray: number;
  94583. /** @hidden */
  94584. meshMap: Nullable<{
  94585. [id: string]: AbstractMesh | undefined;
  94586. }>;
  94587. /**
  94588. * Creates a material instance
  94589. * @param name defines the name of the material
  94590. * @param scene defines the scene to reference
  94591. * @param doNotAdd specifies if the material should be added to the scene
  94592. */
  94593. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94594. /**
  94595. * Returns a string representation of the current material
  94596. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94597. * @returns a string with material information
  94598. */
  94599. toString(fullDetails?: boolean): string;
  94600. /**
  94601. * Gets the class name of the material
  94602. * @returns a string with the class name of the material
  94603. */
  94604. getClassName(): string;
  94605. /**
  94606. * Specifies if updates for the material been locked
  94607. */
  94608. get isFrozen(): boolean;
  94609. /**
  94610. * Locks updates for the material
  94611. */
  94612. freeze(): void;
  94613. /**
  94614. * Unlocks updates for the material
  94615. */
  94616. unfreeze(): void;
  94617. /**
  94618. * Specifies if the material is ready to be used
  94619. * @param mesh defines the mesh to check
  94620. * @param useInstances specifies if instances should be used
  94621. * @returns a boolean indicating if the material is ready to be used
  94622. */
  94623. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94624. /**
  94625. * Specifies that the submesh is ready to be used
  94626. * @param mesh defines the mesh to check
  94627. * @param subMesh defines which submesh to check
  94628. * @param useInstances specifies that instances should be used
  94629. * @returns a boolean indicating that the submesh is ready or not
  94630. */
  94631. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94632. /**
  94633. * Returns the material effect
  94634. * @returns the effect associated with the material
  94635. */
  94636. getEffect(): Nullable<Effect>;
  94637. /**
  94638. * Returns the current scene
  94639. * @returns a Scene
  94640. */
  94641. getScene(): Scene;
  94642. /**
  94643. * Specifies if the material will require alpha blending
  94644. * @returns a boolean specifying if alpha blending is needed
  94645. */
  94646. needAlphaBlending(): boolean;
  94647. /**
  94648. * Specifies if the mesh will require alpha blending
  94649. * @param mesh defines the mesh to check
  94650. * @returns a boolean specifying if alpha blending is needed for the mesh
  94651. */
  94652. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94653. /**
  94654. * Specifies if this material should be rendered in alpha test mode
  94655. * @returns a boolean specifying if an alpha test is needed.
  94656. */
  94657. needAlphaTesting(): boolean;
  94658. /**
  94659. * Gets the texture used for the alpha test
  94660. * @returns the texture to use for alpha testing
  94661. */
  94662. getAlphaTestTexture(): Nullable<BaseTexture>;
  94663. /**
  94664. * Marks the material to indicate that it needs to be re-calculated
  94665. */
  94666. markDirty(): void;
  94667. /** @hidden */
  94668. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94669. /**
  94670. * Binds the material to the mesh
  94671. * @param world defines the world transformation matrix
  94672. * @param mesh defines the mesh to bind the material to
  94673. */
  94674. bind(world: Matrix, mesh?: Mesh): void;
  94675. /**
  94676. * Binds the submesh to the material
  94677. * @param world defines the world transformation matrix
  94678. * @param mesh defines the mesh containing the submesh
  94679. * @param subMesh defines the submesh to bind the material to
  94680. */
  94681. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94682. /**
  94683. * Binds the world matrix to the material
  94684. * @param world defines the world transformation matrix
  94685. */
  94686. bindOnlyWorldMatrix(world: Matrix): void;
  94687. /**
  94688. * Binds the scene's uniform buffer to the effect.
  94689. * @param effect defines the effect to bind to the scene uniform buffer
  94690. * @param sceneUbo defines the uniform buffer storing scene data
  94691. */
  94692. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94693. /**
  94694. * Binds the view matrix to the effect
  94695. * @param effect defines the effect to bind the view matrix to
  94696. */
  94697. bindView(effect: Effect): void;
  94698. /**
  94699. * Binds the view projection matrix to the effect
  94700. * @param effect defines the effect to bind the view projection matrix to
  94701. */
  94702. bindViewProjection(effect: Effect): void;
  94703. /**
  94704. * Specifies if material alpha testing should be turned on for the mesh
  94705. * @param mesh defines the mesh to check
  94706. */
  94707. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94708. /**
  94709. * Processes to execute after binding the material to a mesh
  94710. * @param mesh defines the rendered mesh
  94711. */
  94712. protected _afterBind(mesh?: Mesh): void;
  94713. /**
  94714. * Unbinds the material from the mesh
  94715. */
  94716. unbind(): void;
  94717. /**
  94718. * Gets the active textures from the material
  94719. * @returns an array of textures
  94720. */
  94721. getActiveTextures(): BaseTexture[];
  94722. /**
  94723. * Specifies if the material uses a texture
  94724. * @param texture defines the texture to check against the material
  94725. * @returns a boolean specifying if the material uses the texture
  94726. */
  94727. hasTexture(texture: BaseTexture): boolean;
  94728. /**
  94729. * Makes a duplicate of the material, and gives it a new name
  94730. * @param name defines the new name for the duplicated material
  94731. * @returns the cloned material
  94732. */
  94733. clone(name: string): Nullable<Material>;
  94734. /**
  94735. * Gets the meshes bound to the material
  94736. * @returns an array of meshes bound to the material
  94737. */
  94738. getBindedMeshes(): AbstractMesh[];
  94739. /**
  94740. * Force shader compilation
  94741. * @param mesh defines the mesh associated with this material
  94742. * @param onCompiled defines a function to execute once the material is compiled
  94743. * @param options defines the options to configure the compilation
  94744. * @param onError defines a function to execute if the material fails compiling
  94745. */
  94746. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94747. /**
  94748. * Force shader compilation
  94749. * @param mesh defines the mesh that will use this material
  94750. * @param options defines additional options for compiling the shaders
  94751. * @returns a promise that resolves when the compilation completes
  94752. */
  94753. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94754. private static readonly _AllDirtyCallBack;
  94755. private static readonly _ImageProcessingDirtyCallBack;
  94756. private static readonly _TextureDirtyCallBack;
  94757. private static readonly _FresnelDirtyCallBack;
  94758. private static readonly _MiscDirtyCallBack;
  94759. private static readonly _LightsDirtyCallBack;
  94760. private static readonly _AttributeDirtyCallBack;
  94761. private static _FresnelAndMiscDirtyCallBack;
  94762. private static _TextureAndMiscDirtyCallBack;
  94763. private static readonly _DirtyCallbackArray;
  94764. private static readonly _RunDirtyCallBacks;
  94765. /**
  94766. * Marks a define in the material to indicate that it needs to be re-computed
  94767. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94768. */
  94769. markAsDirty(flag: number): void;
  94770. /**
  94771. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94772. * @param func defines a function which checks material defines against the submeshes
  94773. */
  94774. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94775. /**
  94776. * Indicates that we need to re-calculated for all submeshes
  94777. */
  94778. protected _markAllSubMeshesAsAllDirty(): void;
  94779. /**
  94780. * Indicates that image processing needs to be re-calculated for all submeshes
  94781. */
  94782. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94783. /**
  94784. * Indicates that textures need to be re-calculated for all submeshes
  94785. */
  94786. protected _markAllSubMeshesAsTexturesDirty(): void;
  94787. /**
  94788. * Indicates that fresnel needs to be re-calculated for all submeshes
  94789. */
  94790. protected _markAllSubMeshesAsFresnelDirty(): void;
  94791. /**
  94792. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94793. */
  94794. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94795. /**
  94796. * Indicates that lights need to be re-calculated for all submeshes
  94797. */
  94798. protected _markAllSubMeshesAsLightsDirty(): void;
  94799. /**
  94800. * Indicates that attributes need to be re-calculated for all submeshes
  94801. */
  94802. protected _markAllSubMeshesAsAttributesDirty(): void;
  94803. /**
  94804. * Indicates that misc needs to be re-calculated for all submeshes
  94805. */
  94806. protected _markAllSubMeshesAsMiscDirty(): void;
  94807. /**
  94808. * Indicates that textures and misc need to be re-calculated for all submeshes
  94809. */
  94810. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94811. /**
  94812. * Disposes the material
  94813. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94814. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94815. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94816. */
  94817. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94818. /** @hidden */
  94819. private releaseVertexArrayObject;
  94820. /**
  94821. * Serializes this material
  94822. * @returns the serialized material object
  94823. */
  94824. serialize(): any;
  94825. /**
  94826. * Creates a material from parsed material data
  94827. * @param parsedMaterial defines parsed material data
  94828. * @param scene defines the hosting scene
  94829. * @param rootUrl defines the root URL to use to load textures
  94830. * @returns a new material
  94831. */
  94832. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94833. }
  94834. }
  94835. declare module BABYLON {
  94836. /**
  94837. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94838. * separate meshes. This can be use to improve performances.
  94839. * @see http://doc.babylonjs.com/how_to/multi_materials
  94840. */
  94841. export class MultiMaterial extends Material {
  94842. private _subMaterials;
  94843. /**
  94844. * Gets or Sets the list of Materials used within the multi material.
  94845. * They need to be ordered according to the submeshes order in the associated mesh
  94846. */
  94847. get subMaterials(): Nullable<Material>[];
  94848. set subMaterials(value: Nullable<Material>[]);
  94849. /**
  94850. * Function used to align with Node.getChildren()
  94851. * @returns the list of Materials used within the multi material
  94852. */
  94853. getChildren(): Nullable<Material>[];
  94854. /**
  94855. * Instantiates a new Multi Material
  94856. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94857. * separate meshes. This can be use to improve performances.
  94858. * @see http://doc.babylonjs.com/how_to/multi_materials
  94859. * @param name Define the name in the scene
  94860. * @param scene Define the scene the material belongs to
  94861. */
  94862. constructor(name: string, scene: Scene);
  94863. private _hookArray;
  94864. /**
  94865. * Get one of the submaterial by its index in the submaterials array
  94866. * @param index The index to look the sub material at
  94867. * @returns The Material if the index has been defined
  94868. */
  94869. getSubMaterial(index: number): Nullable<Material>;
  94870. /**
  94871. * Get the list of active textures for the whole sub materials list.
  94872. * @returns All the textures that will be used during the rendering
  94873. */
  94874. getActiveTextures(): BaseTexture[];
  94875. /**
  94876. * Gets the current class name of the material e.g. "MultiMaterial"
  94877. * Mainly use in serialization.
  94878. * @returns the class name
  94879. */
  94880. getClassName(): string;
  94881. /**
  94882. * Checks if the material is ready to render the requested sub mesh
  94883. * @param mesh Define the mesh the submesh belongs to
  94884. * @param subMesh Define the sub mesh to look readyness for
  94885. * @param useInstances Define whether or not the material is used with instances
  94886. * @returns true if ready, otherwise false
  94887. */
  94888. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94889. /**
  94890. * Clones the current material and its related sub materials
  94891. * @param name Define the name of the newly cloned material
  94892. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94893. * @returns the cloned material
  94894. */
  94895. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94896. /**
  94897. * Serializes the materials into a JSON representation.
  94898. * @returns the JSON representation
  94899. */
  94900. serialize(): any;
  94901. /**
  94902. * Dispose the material and release its associated resources
  94903. * @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)
  94904. * @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)
  94905. * @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)
  94906. */
  94907. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94908. /**
  94909. * Creates a MultiMaterial from parsed MultiMaterial data.
  94910. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94911. * @param scene defines the hosting scene
  94912. * @returns a new MultiMaterial
  94913. */
  94914. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94915. }
  94916. }
  94917. declare module BABYLON {
  94918. /**
  94919. * Base class for submeshes
  94920. */
  94921. export class BaseSubMesh {
  94922. /** @hidden */
  94923. _materialDefines: Nullable<MaterialDefines>;
  94924. /** @hidden */
  94925. _materialEffect: Nullable<Effect>;
  94926. /**
  94927. * Gets material defines used by the effect associated to the sub mesh
  94928. */
  94929. get materialDefines(): Nullable<MaterialDefines>;
  94930. /**
  94931. * Sets material defines used by the effect associated to the sub mesh
  94932. */
  94933. set materialDefines(defines: Nullable<MaterialDefines>);
  94934. /**
  94935. * Gets associated effect
  94936. */
  94937. get effect(): Nullable<Effect>;
  94938. /**
  94939. * Sets associated effect (effect used to render this submesh)
  94940. * @param effect defines the effect to associate with
  94941. * @param defines defines the set of defines used to compile this effect
  94942. */
  94943. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94944. }
  94945. /**
  94946. * Defines a subdivision inside a mesh
  94947. */
  94948. export class SubMesh extends BaseSubMesh implements ICullable {
  94949. /** the material index to use */
  94950. materialIndex: number;
  94951. /** vertex index start */
  94952. verticesStart: number;
  94953. /** vertices count */
  94954. verticesCount: number;
  94955. /** index start */
  94956. indexStart: number;
  94957. /** indices count */
  94958. indexCount: number;
  94959. /** @hidden */
  94960. _linesIndexCount: number;
  94961. private _mesh;
  94962. private _renderingMesh;
  94963. private _boundingInfo;
  94964. private _linesIndexBuffer;
  94965. /** @hidden */
  94966. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94967. /** @hidden */
  94968. _trianglePlanes: Plane[];
  94969. /** @hidden */
  94970. _lastColliderTransformMatrix: Nullable<Matrix>;
  94971. /** @hidden */
  94972. _renderId: number;
  94973. /** @hidden */
  94974. _alphaIndex: number;
  94975. /** @hidden */
  94976. _distanceToCamera: number;
  94977. /** @hidden */
  94978. _id: number;
  94979. private _currentMaterial;
  94980. /**
  94981. * Add a new submesh to a mesh
  94982. * @param materialIndex defines the material index to use
  94983. * @param verticesStart defines vertex index start
  94984. * @param verticesCount defines vertices count
  94985. * @param indexStart defines index start
  94986. * @param indexCount defines indices count
  94987. * @param mesh defines the parent mesh
  94988. * @param renderingMesh defines an optional rendering mesh
  94989. * @param createBoundingBox defines if bounding box should be created for this submesh
  94990. * @returns the new submesh
  94991. */
  94992. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94993. /**
  94994. * Creates a new submesh
  94995. * @param materialIndex defines the material index to use
  94996. * @param verticesStart defines vertex index start
  94997. * @param verticesCount defines vertices count
  94998. * @param indexStart defines index start
  94999. * @param indexCount defines indices count
  95000. * @param mesh defines the parent mesh
  95001. * @param renderingMesh defines an optional rendering mesh
  95002. * @param createBoundingBox defines if bounding box should be created for this submesh
  95003. */
  95004. constructor(
  95005. /** the material index to use */
  95006. materialIndex: number,
  95007. /** vertex index start */
  95008. verticesStart: number,
  95009. /** vertices count */
  95010. verticesCount: number,
  95011. /** index start */
  95012. indexStart: number,
  95013. /** indices count */
  95014. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  95015. /**
  95016. * Returns true if this submesh covers the entire parent mesh
  95017. * @ignorenaming
  95018. */
  95019. get IsGlobal(): boolean;
  95020. /**
  95021. * Returns the submesh BoudingInfo object
  95022. * @returns current bounding info (or mesh's one if the submesh is global)
  95023. */
  95024. getBoundingInfo(): BoundingInfo;
  95025. /**
  95026. * Sets the submesh BoundingInfo
  95027. * @param boundingInfo defines the new bounding info to use
  95028. * @returns the SubMesh
  95029. */
  95030. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  95031. /**
  95032. * Returns the mesh of the current submesh
  95033. * @return the parent mesh
  95034. */
  95035. getMesh(): AbstractMesh;
  95036. /**
  95037. * Returns the rendering mesh of the submesh
  95038. * @returns the rendering mesh (could be different from parent mesh)
  95039. */
  95040. getRenderingMesh(): Mesh;
  95041. /**
  95042. * Returns the submesh material
  95043. * @returns null or the current material
  95044. */
  95045. getMaterial(): Nullable<Material>;
  95046. /**
  95047. * Sets a new updated BoundingInfo object to the submesh
  95048. * @param data defines an optional position array to use to determine the bounding info
  95049. * @returns the SubMesh
  95050. */
  95051. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  95052. /** @hidden */
  95053. _checkCollision(collider: Collider): boolean;
  95054. /**
  95055. * Updates the submesh BoundingInfo
  95056. * @param world defines the world matrix to use to update the bounding info
  95057. * @returns the submesh
  95058. */
  95059. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  95060. /**
  95061. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  95062. * @param frustumPlanes defines the frustum planes
  95063. * @returns true if the submesh is intersecting with the frustum
  95064. */
  95065. isInFrustum(frustumPlanes: Plane[]): boolean;
  95066. /**
  95067. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  95068. * @param frustumPlanes defines the frustum planes
  95069. * @returns true if the submesh is inside the frustum
  95070. */
  95071. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  95072. /**
  95073. * Renders the submesh
  95074. * @param enableAlphaMode defines if alpha needs to be used
  95075. * @returns the submesh
  95076. */
  95077. render(enableAlphaMode: boolean): SubMesh;
  95078. /**
  95079. * @hidden
  95080. */
  95081. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  95082. /**
  95083. * Checks if the submesh intersects with a ray
  95084. * @param ray defines the ray to test
  95085. * @returns true is the passed ray intersects the submesh bounding box
  95086. */
  95087. canIntersects(ray: Ray): boolean;
  95088. /**
  95089. * Intersects current submesh with a ray
  95090. * @param ray defines the ray to test
  95091. * @param positions defines mesh's positions array
  95092. * @param indices defines mesh's indices array
  95093. * @param fastCheck defines if only bounding info should be used
  95094. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95095. * @returns intersection info or null if no intersection
  95096. */
  95097. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  95098. /** @hidden */
  95099. private _intersectLines;
  95100. /** @hidden */
  95101. private _intersectUnIndexedLines;
  95102. /** @hidden */
  95103. private _intersectTriangles;
  95104. /** @hidden */
  95105. private _intersectUnIndexedTriangles;
  95106. /** @hidden */
  95107. _rebuild(): void;
  95108. /**
  95109. * Creates a new submesh from the passed mesh
  95110. * @param newMesh defines the new hosting mesh
  95111. * @param newRenderingMesh defines an optional rendering mesh
  95112. * @returns the new submesh
  95113. */
  95114. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  95115. /**
  95116. * Release associated resources
  95117. */
  95118. dispose(): void;
  95119. /**
  95120. * Gets the class name
  95121. * @returns the string "SubMesh".
  95122. */
  95123. getClassName(): string;
  95124. /**
  95125. * Creates a new submesh from indices data
  95126. * @param materialIndex the index of the main mesh material
  95127. * @param startIndex the index where to start the copy in the mesh indices array
  95128. * @param indexCount the number of indices to copy then from the startIndex
  95129. * @param mesh the main mesh to create the submesh from
  95130. * @param renderingMesh the optional rendering mesh
  95131. * @returns a new submesh
  95132. */
  95133. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  95134. }
  95135. }
  95136. declare module BABYLON {
  95137. /**
  95138. * Class used to represent data loading progression
  95139. */
  95140. export class SceneLoaderFlags {
  95141. private static _ForceFullSceneLoadingForIncremental;
  95142. private static _ShowLoadingScreen;
  95143. private static _CleanBoneMatrixWeights;
  95144. private static _loggingLevel;
  95145. /**
  95146. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  95147. */
  95148. static get ForceFullSceneLoadingForIncremental(): boolean;
  95149. static set ForceFullSceneLoadingForIncremental(value: boolean);
  95150. /**
  95151. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  95152. */
  95153. static get ShowLoadingScreen(): boolean;
  95154. static set ShowLoadingScreen(value: boolean);
  95155. /**
  95156. * Defines the current logging level (while loading the scene)
  95157. * @ignorenaming
  95158. */
  95159. static get loggingLevel(): number;
  95160. static set loggingLevel(value: number);
  95161. /**
  95162. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  95163. */
  95164. static get CleanBoneMatrixWeights(): boolean;
  95165. static set CleanBoneMatrixWeights(value: boolean);
  95166. }
  95167. }
  95168. declare module BABYLON {
  95169. /**
  95170. * Class used to store geometry data (vertex buffers + index buffer)
  95171. */
  95172. export class Geometry implements IGetSetVerticesData {
  95173. /**
  95174. * Gets or sets the ID of the geometry
  95175. */
  95176. id: string;
  95177. /**
  95178. * Gets or sets the unique ID of the geometry
  95179. */
  95180. uniqueId: number;
  95181. /**
  95182. * Gets the delay loading state of the geometry (none by default which means not delayed)
  95183. */
  95184. delayLoadState: number;
  95185. /**
  95186. * Gets the file containing the data to load when running in delay load state
  95187. */
  95188. delayLoadingFile: Nullable<string>;
  95189. /**
  95190. * Callback called when the geometry is updated
  95191. */
  95192. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  95193. private _scene;
  95194. private _engine;
  95195. private _meshes;
  95196. private _totalVertices;
  95197. /** @hidden */
  95198. _indices: IndicesArray;
  95199. /** @hidden */
  95200. _vertexBuffers: {
  95201. [key: string]: VertexBuffer;
  95202. };
  95203. private _isDisposed;
  95204. private _extend;
  95205. private _boundingBias;
  95206. /** @hidden */
  95207. _delayInfo: Array<string>;
  95208. private _indexBuffer;
  95209. private _indexBufferIsUpdatable;
  95210. /** @hidden */
  95211. _boundingInfo: Nullable<BoundingInfo>;
  95212. /** @hidden */
  95213. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  95214. /** @hidden */
  95215. _softwareSkinningFrameId: number;
  95216. private _vertexArrayObjects;
  95217. private _updatable;
  95218. /** @hidden */
  95219. _positions: Nullable<Vector3[]>;
  95220. /**
  95221. * 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
  95222. */
  95223. get boundingBias(): Vector2;
  95224. /**
  95225. * 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
  95226. */
  95227. set boundingBias(value: Vector2);
  95228. /**
  95229. * Static function used to attach a new empty geometry to a mesh
  95230. * @param mesh defines the mesh to attach the geometry to
  95231. * @returns the new Geometry
  95232. */
  95233. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  95234. /**
  95235. * Creates a new geometry
  95236. * @param id defines the unique ID
  95237. * @param scene defines the hosting scene
  95238. * @param vertexData defines the VertexData used to get geometry data
  95239. * @param updatable defines if geometry must be updatable (false by default)
  95240. * @param mesh defines the mesh that will be associated with the geometry
  95241. */
  95242. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  95243. /**
  95244. * Gets the current extend of the geometry
  95245. */
  95246. get extend(): {
  95247. minimum: Vector3;
  95248. maximum: Vector3;
  95249. };
  95250. /**
  95251. * Gets the hosting scene
  95252. * @returns the hosting Scene
  95253. */
  95254. getScene(): Scene;
  95255. /**
  95256. * Gets the hosting engine
  95257. * @returns the hosting Engine
  95258. */
  95259. getEngine(): Engine;
  95260. /**
  95261. * Defines if the geometry is ready to use
  95262. * @returns true if the geometry is ready to be used
  95263. */
  95264. isReady(): boolean;
  95265. /**
  95266. * Gets a value indicating that the geometry should not be serialized
  95267. */
  95268. get doNotSerialize(): boolean;
  95269. /** @hidden */
  95270. _rebuild(): void;
  95271. /**
  95272. * Affects all geometry data in one call
  95273. * @param vertexData defines the geometry data
  95274. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  95275. */
  95276. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  95277. /**
  95278. * Set specific vertex data
  95279. * @param kind defines the data kind (Position, normal, etc...)
  95280. * @param data defines the vertex data to use
  95281. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95282. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95283. */
  95284. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95285. /**
  95286. * Removes a specific vertex data
  95287. * @param kind defines the data kind (Position, normal, etc...)
  95288. */
  95289. removeVerticesData(kind: string): void;
  95290. /**
  95291. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95292. * @param buffer defines the vertex buffer to use
  95293. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95294. */
  95295. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95296. /**
  95297. * Update a specific vertex buffer
  95298. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95299. * It will do nothing if the buffer is not updatable
  95300. * @param kind defines the data kind (Position, normal, etc...)
  95301. * @param data defines the data to use
  95302. * @param offset defines the offset in the target buffer where to store the data
  95303. * @param useBytes set to true if the offset is in bytes
  95304. */
  95305. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95306. /**
  95307. * Update a specific vertex buffer
  95308. * This function will create a new buffer if the current one is not updatable
  95309. * @param kind defines the data kind (Position, normal, etc...)
  95310. * @param data defines the data to use
  95311. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95312. */
  95313. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95314. private _updateBoundingInfo;
  95315. /** @hidden */
  95316. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95317. /**
  95318. * Gets total number of vertices
  95319. * @returns the total number of vertices
  95320. */
  95321. getTotalVertices(): number;
  95322. /**
  95323. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95324. * @param kind defines the data kind (Position, normal, etc...)
  95325. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95326. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95327. * @returns a float array containing vertex data
  95328. */
  95329. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95330. /**
  95331. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95332. * @param kind defines the data kind (Position, normal, etc...)
  95333. * @returns true if the vertex buffer with the specified kind is updatable
  95334. */
  95335. isVertexBufferUpdatable(kind: string): boolean;
  95336. /**
  95337. * Gets a specific vertex buffer
  95338. * @param kind defines the data kind (Position, normal, etc...)
  95339. * @returns a VertexBuffer
  95340. */
  95341. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95342. /**
  95343. * Returns all vertex buffers
  95344. * @return an object holding all vertex buffers indexed by kind
  95345. */
  95346. getVertexBuffers(): Nullable<{
  95347. [key: string]: VertexBuffer;
  95348. }>;
  95349. /**
  95350. * Gets a boolean indicating if specific vertex buffer is present
  95351. * @param kind defines the data kind (Position, normal, etc...)
  95352. * @returns true if data is present
  95353. */
  95354. isVerticesDataPresent(kind: string): boolean;
  95355. /**
  95356. * Gets a list of all attached data kinds (Position, normal, etc...)
  95357. * @returns a list of string containing all kinds
  95358. */
  95359. getVerticesDataKinds(): string[];
  95360. /**
  95361. * Update index buffer
  95362. * @param indices defines the indices to store in the index buffer
  95363. * @param offset defines the offset in the target buffer where to store the data
  95364. * @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)
  95365. */
  95366. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95367. /**
  95368. * Creates a new index buffer
  95369. * @param indices defines the indices to store in the index buffer
  95370. * @param totalVertices defines the total number of vertices (could be null)
  95371. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95372. */
  95373. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95374. /**
  95375. * Return the total number of indices
  95376. * @returns the total number of indices
  95377. */
  95378. getTotalIndices(): number;
  95379. /**
  95380. * Gets the index buffer array
  95381. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95382. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95383. * @returns the index buffer array
  95384. */
  95385. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95386. /**
  95387. * Gets the index buffer
  95388. * @return the index buffer
  95389. */
  95390. getIndexBuffer(): Nullable<DataBuffer>;
  95391. /** @hidden */
  95392. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95393. /**
  95394. * Release the associated resources for a specific mesh
  95395. * @param mesh defines the source mesh
  95396. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95397. */
  95398. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95399. /**
  95400. * Apply current geometry to a given mesh
  95401. * @param mesh defines the mesh to apply geometry to
  95402. */
  95403. applyToMesh(mesh: Mesh): void;
  95404. private _updateExtend;
  95405. private _applyToMesh;
  95406. private notifyUpdate;
  95407. /**
  95408. * Load the geometry if it was flagged as delay loaded
  95409. * @param scene defines the hosting scene
  95410. * @param onLoaded defines a callback called when the geometry is loaded
  95411. */
  95412. load(scene: Scene, onLoaded?: () => void): void;
  95413. private _queueLoad;
  95414. /**
  95415. * Invert the geometry to move from a right handed system to a left handed one.
  95416. */
  95417. toLeftHanded(): void;
  95418. /** @hidden */
  95419. _resetPointsArrayCache(): void;
  95420. /** @hidden */
  95421. _generatePointsArray(): boolean;
  95422. /**
  95423. * Gets a value indicating if the geometry is disposed
  95424. * @returns true if the geometry was disposed
  95425. */
  95426. isDisposed(): boolean;
  95427. private _disposeVertexArrayObjects;
  95428. /**
  95429. * Free all associated resources
  95430. */
  95431. dispose(): void;
  95432. /**
  95433. * Clone the current geometry into a new geometry
  95434. * @param id defines the unique ID of the new geometry
  95435. * @returns a new geometry object
  95436. */
  95437. copy(id: string): Geometry;
  95438. /**
  95439. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95440. * @return a JSON representation of the current geometry data (without the vertices data)
  95441. */
  95442. serialize(): any;
  95443. private toNumberArray;
  95444. /**
  95445. * Serialize all vertices data into a JSON oject
  95446. * @returns a JSON representation of the current geometry data
  95447. */
  95448. serializeVerticeData(): any;
  95449. /**
  95450. * Extracts a clone of a mesh geometry
  95451. * @param mesh defines the source mesh
  95452. * @param id defines the unique ID of the new geometry object
  95453. * @returns the new geometry object
  95454. */
  95455. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95456. /**
  95457. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95458. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95459. * Be aware Math.random() could cause collisions, but:
  95460. * "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"
  95461. * @returns a string containing a new GUID
  95462. */
  95463. static RandomId(): string;
  95464. /** @hidden */
  95465. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95466. private static _CleanMatricesWeights;
  95467. /**
  95468. * Create a new geometry from persisted data (Using .babylon file format)
  95469. * @param parsedVertexData defines the persisted data
  95470. * @param scene defines the hosting scene
  95471. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95472. * @returns the new geometry object
  95473. */
  95474. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95475. }
  95476. }
  95477. declare module BABYLON {
  95478. /**
  95479. * Define an interface for all classes that will get and set the data on vertices
  95480. */
  95481. export interface IGetSetVerticesData {
  95482. /**
  95483. * Gets a boolean indicating if specific vertex data is present
  95484. * @param kind defines the vertex data kind to use
  95485. * @returns true is data kind is present
  95486. */
  95487. isVerticesDataPresent(kind: string): boolean;
  95488. /**
  95489. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95490. * @param kind defines the data kind (Position, normal, etc...)
  95491. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95492. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95493. * @returns a float array containing vertex data
  95494. */
  95495. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95496. /**
  95497. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95498. * @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.
  95499. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95500. * @returns the indices array or an empty array if the mesh has no geometry
  95501. */
  95502. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95503. /**
  95504. * Set specific vertex data
  95505. * @param kind defines the data kind (Position, normal, etc...)
  95506. * @param data defines the vertex data to use
  95507. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95508. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95509. */
  95510. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95511. /**
  95512. * Update a specific associated vertex buffer
  95513. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95514. * - VertexBuffer.PositionKind
  95515. * - VertexBuffer.UVKind
  95516. * - VertexBuffer.UV2Kind
  95517. * - VertexBuffer.UV3Kind
  95518. * - VertexBuffer.UV4Kind
  95519. * - VertexBuffer.UV5Kind
  95520. * - VertexBuffer.UV6Kind
  95521. * - VertexBuffer.ColorKind
  95522. * - VertexBuffer.MatricesIndicesKind
  95523. * - VertexBuffer.MatricesIndicesExtraKind
  95524. * - VertexBuffer.MatricesWeightsKind
  95525. * - VertexBuffer.MatricesWeightsExtraKind
  95526. * @param data defines the data source
  95527. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95528. * @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)
  95529. */
  95530. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95531. /**
  95532. * Creates a new index buffer
  95533. * @param indices defines the indices to store in the index buffer
  95534. * @param totalVertices defines the total number of vertices (could be null)
  95535. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95536. */
  95537. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95538. }
  95539. /**
  95540. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95541. */
  95542. export class VertexData {
  95543. /**
  95544. * Mesh side orientation : usually the external or front surface
  95545. */
  95546. static readonly FRONTSIDE: number;
  95547. /**
  95548. * Mesh side orientation : usually the internal or back surface
  95549. */
  95550. static readonly BACKSIDE: number;
  95551. /**
  95552. * Mesh side orientation : both internal and external or front and back surfaces
  95553. */
  95554. static readonly DOUBLESIDE: number;
  95555. /**
  95556. * Mesh side orientation : by default, `FRONTSIDE`
  95557. */
  95558. static readonly DEFAULTSIDE: number;
  95559. /**
  95560. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95561. */
  95562. positions: Nullable<FloatArray>;
  95563. /**
  95564. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95565. */
  95566. normals: Nullable<FloatArray>;
  95567. /**
  95568. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95569. */
  95570. tangents: Nullable<FloatArray>;
  95571. /**
  95572. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95573. */
  95574. uvs: Nullable<FloatArray>;
  95575. /**
  95576. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95577. */
  95578. uvs2: Nullable<FloatArray>;
  95579. /**
  95580. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95581. */
  95582. uvs3: Nullable<FloatArray>;
  95583. /**
  95584. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95585. */
  95586. uvs4: Nullable<FloatArray>;
  95587. /**
  95588. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95589. */
  95590. uvs5: Nullable<FloatArray>;
  95591. /**
  95592. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95593. */
  95594. uvs6: Nullable<FloatArray>;
  95595. /**
  95596. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95597. */
  95598. colors: Nullable<FloatArray>;
  95599. /**
  95600. * 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).
  95601. */
  95602. matricesIndices: Nullable<FloatArray>;
  95603. /**
  95604. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95605. */
  95606. matricesWeights: Nullable<FloatArray>;
  95607. /**
  95608. * An array extending the number of possible indices
  95609. */
  95610. matricesIndicesExtra: Nullable<FloatArray>;
  95611. /**
  95612. * An array extending the number of possible weights when the number of indices is extended
  95613. */
  95614. matricesWeightsExtra: Nullable<FloatArray>;
  95615. /**
  95616. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95617. */
  95618. indices: Nullable<IndicesArray>;
  95619. /**
  95620. * Uses the passed data array to set the set the values for the specified kind of data
  95621. * @param data a linear array of floating numbers
  95622. * @param kind the type of data that is being set, eg positions, colors etc
  95623. */
  95624. set(data: FloatArray, kind: string): void;
  95625. /**
  95626. * Associates the vertexData to the passed Mesh.
  95627. * Sets it as updatable or not (default `false`)
  95628. * @param mesh the mesh the vertexData is applied to
  95629. * @param updatable when used and having the value true allows new data to update the vertexData
  95630. * @returns the VertexData
  95631. */
  95632. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95633. /**
  95634. * Associates the vertexData to the passed Geometry.
  95635. * Sets it as updatable or not (default `false`)
  95636. * @param geometry the geometry the vertexData is applied to
  95637. * @param updatable when used and having the value true allows new data to update the vertexData
  95638. * @returns VertexData
  95639. */
  95640. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95641. /**
  95642. * Updates the associated mesh
  95643. * @param mesh the mesh to be updated
  95644. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95645. * @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
  95646. * @returns VertexData
  95647. */
  95648. updateMesh(mesh: Mesh): VertexData;
  95649. /**
  95650. * Updates the associated geometry
  95651. * @param geometry the geometry to be updated
  95652. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95653. * @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
  95654. * @returns VertexData.
  95655. */
  95656. updateGeometry(geometry: Geometry): VertexData;
  95657. private _applyTo;
  95658. private _update;
  95659. /**
  95660. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95661. * @param matrix the transforming matrix
  95662. * @returns the VertexData
  95663. */
  95664. transform(matrix: Matrix): VertexData;
  95665. /**
  95666. * Merges the passed VertexData into the current one
  95667. * @param other the VertexData to be merged into the current one
  95668. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95669. * @returns the modified VertexData
  95670. */
  95671. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95672. private _mergeElement;
  95673. private _validate;
  95674. /**
  95675. * Serializes the VertexData
  95676. * @returns a serialized object
  95677. */
  95678. serialize(): any;
  95679. /**
  95680. * Extracts the vertexData from a mesh
  95681. * @param mesh the mesh from which to extract the VertexData
  95682. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95683. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95684. * @returns the object VertexData associated to the passed mesh
  95685. */
  95686. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95687. /**
  95688. * Extracts the vertexData from the geometry
  95689. * @param geometry the geometry from which to extract the VertexData
  95690. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95691. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95692. * @returns the object VertexData associated to the passed mesh
  95693. */
  95694. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95695. private static _ExtractFrom;
  95696. /**
  95697. * Creates the VertexData for a Ribbon
  95698. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95699. * * pathArray array of paths, each of which an array of successive Vector3
  95700. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95701. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95702. * * 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
  95703. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95704. * * 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)
  95705. * * 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)
  95706. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95707. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95708. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95709. * @returns the VertexData of the ribbon
  95710. */
  95711. static CreateRibbon(options: {
  95712. pathArray: Vector3[][];
  95713. closeArray?: boolean;
  95714. closePath?: boolean;
  95715. offset?: number;
  95716. sideOrientation?: number;
  95717. frontUVs?: Vector4;
  95718. backUVs?: Vector4;
  95719. invertUV?: boolean;
  95720. uvs?: Vector2[];
  95721. colors?: Color4[];
  95722. }): VertexData;
  95723. /**
  95724. * Creates the VertexData for a box
  95725. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95726. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95727. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95728. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95729. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95730. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95731. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95732. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95733. * * 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)
  95734. * * 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)
  95735. * @returns the VertexData of the box
  95736. */
  95737. static CreateBox(options: {
  95738. size?: number;
  95739. width?: number;
  95740. height?: number;
  95741. depth?: number;
  95742. faceUV?: Vector4[];
  95743. faceColors?: Color4[];
  95744. sideOrientation?: number;
  95745. frontUVs?: Vector4;
  95746. backUVs?: Vector4;
  95747. }): VertexData;
  95748. /**
  95749. * Creates the VertexData for a tiled box
  95750. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95751. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95752. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95753. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95754. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95755. * @returns the VertexData of the box
  95756. */
  95757. static CreateTiledBox(options: {
  95758. pattern?: number;
  95759. width?: number;
  95760. height?: number;
  95761. depth?: number;
  95762. tileSize?: number;
  95763. tileWidth?: number;
  95764. tileHeight?: number;
  95765. alignHorizontal?: number;
  95766. alignVertical?: number;
  95767. faceUV?: Vector4[];
  95768. faceColors?: Color4[];
  95769. sideOrientation?: number;
  95770. }): VertexData;
  95771. /**
  95772. * Creates the VertexData for a tiled plane
  95773. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95774. * * pattern a limited pattern arrangement depending on the number
  95775. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95776. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95777. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95778. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95779. * * 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)
  95780. * * 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)
  95781. * @returns the VertexData of the tiled plane
  95782. */
  95783. static CreateTiledPlane(options: {
  95784. pattern?: number;
  95785. tileSize?: number;
  95786. tileWidth?: number;
  95787. tileHeight?: number;
  95788. size?: number;
  95789. width?: number;
  95790. height?: number;
  95791. alignHorizontal?: number;
  95792. alignVertical?: number;
  95793. sideOrientation?: number;
  95794. frontUVs?: Vector4;
  95795. backUVs?: Vector4;
  95796. }): VertexData;
  95797. /**
  95798. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95799. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95800. * * segments sets the number of horizontal strips optional, default 32
  95801. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95802. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95803. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95804. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95805. * * 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
  95806. * * 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
  95807. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95808. * * 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)
  95809. * * 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)
  95810. * @returns the VertexData of the ellipsoid
  95811. */
  95812. static CreateSphere(options: {
  95813. segments?: number;
  95814. diameter?: number;
  95815. diameterX?: number;
  95816. diameterY?: number;
  95817. diameterZ?: number;
  95818. arc?: number;
  95819. slice?: number;
  95820. sideOrientation?: number;
  95821. frontUVs?: Vector4;
  95822. backUVs?: Vector4;
  95823. }): VertexData;
  95824. /**
  95825. * Creates the VertexData for a cylinder, cone or prism
  95826. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95827. * * height sets the height (y direction) of the cylinder, optional, default 2
  95828. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95829. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95830. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95831. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95832. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95833. * * 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
  95834. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95835. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95836. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95837. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95839. * * 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)
  95840. * * 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)
  95841. * @returns the VertexData of the cylinder, cone or prism
  95842. */
  95843. static CreateCylinder(options: {
  95844. height?: number;
  95845. diameterTop?: number;
  95846. diameterBottom?: number;
  95847. diameter?: number;
  95848. tessellation?: number;
  95849. subdivisions?: number;
  95850. arc?: number;
  95851. faceColors?: Color4[];
  95852. faceUV?: Vector4[];
  95853. hasRings?: boolean;
  95854. enclose?: boolean;
  95855. sideOrientation?: number;
  95856. frontUVs?: Vector4;
  95857. backUVs?: Vector4;
  95858. }): VertexData;
  95859. /**
  95860. * Creates the VertexData for a torus
  95861. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95862. * * diameter the diameter of the torus, optional default 1
  95863. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95864. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95865. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95866. * * 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)
  95867. * * 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)
  95868. * @returns the VertexData of the torus
  95869. */
  95870. static CreateTorus(options: {
  95871. diameter?: number;
  95872. thickness?: number;
  95873. tessellation?: number;
  95874. sideOrientation?: number;
  95875. frontUVs?: Vector4;
  95876. backUVs?: Vector4;
  95877. }): VertexData;
  95878. /**
  95879. * Creates the VertexData of the LineSystem
  95880. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95881. * - lines an array of lines, each line being an array of successive Vector3
  95882. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95883. * @returns the VertexData of the LineSystem
  95884. */
  95885. static CreateLineSystem(options: {
  95886. lines: Vector3[][];
  95887. colors?: Nullable<Color4[][]>;
  95888. }): VertexData;
  95889. /**
  95890. * Create the VertexData for a DashedLines
  95891. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95892. * - points an array successive Vector3
  95893. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95894. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95895. * - dashNb the intended total number of dashes, optional, default 200
  95896. * @returns the VertexData for the DashedLines
  95897. */
  95898. static CreateDashedLines(options: {
  95899. points: Vector3[];
  95900. dashSize?: number;
  95901. gapSize?: number;
  95902. dashNb?: number;
  95903. }): VertexData;
  95904. /**
  95905. * Creates the VertexData for a Ground
  95906. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95907. * - width the width (x direction) of the ground, optional, default 1
  95908. * - height the height (z direction) of the ground, optional, default 1
  95909. * - subdivisions the number of subdivisions per side, optional, default 1
  95910. * @returns the VertexData of the Ground
  95911. */
  95912. static CreateGround(options: {
  95913. width?: number;
  95914. height?: number;
  95915. subdivisions?: number;
  95916. subdivisionsX?: number;
  95917. subdivisionsY?: number;
  95918. }): VertexData;
  95919. /**
  95920. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95921. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95922. * * xmin the ground minimum X coordinate, optional, default -1
  95923. * * zmin the ground minimum Z coordinate, optional, default -1
  95924. * * xmax the ground maximum X coordinate, optional, default 1
  95925. * * zmax the ground maximum Z coordinate, optional, default 1
  95926. * * 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}
  95927. * * 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}
  95928. * @returns the VertexData of the TiledGround
  95929. */
  95930. static CreateTiledGround(options: {
  95931. xmin: number;
  95932. zmin: number;
  95933. xmax: number;
  95934. zmax: number;
  95935. subdivisions?: {
  95936. w: number;
  95937. h: number;
  95938. };
  95939. precision?: {
  95940. w: number;
  95941. h: number;
  95942. };
  95943. }): VertexData;
  95944. /**
  95945. * Creates the VertexData of the Ground designed from a heightmap
  95946. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95947. * * width the width (x direction) of the ground
  95948. * * height the height (z direction) of the ground
  95949. * * subdivisions the number of subdivisions per side
  95950. * * minHeight the minimum altitude on the ground, optional, default 0
  95951. * * maxHeight the maximum altitude on the ground, optional default 1
  95952. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95953. * * buffer the array holding the image color data
  95954. * * bufferWidth the width of image
  95955. * * bufferHeight the height of image
  95956. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95957. * @returns the VertexData of the Ground designed from a heightmap
  95958. */
  95959. static CreateGroundFromHeightMap(options: {
  95960. width: number;
  95961. height: number;
  95962. subdivisions: number;
  95963. minHeight: number;
  95964. maxHeight: number;
  95965. colorFilter: Color3;
  95966. buffer: Uint8Array;
  95967. bufferWidth: number;
  95968. bufferHeight: number;
  95969. alphaFilter: number;
  95970. }): VertexData;
  95971. /**
  95972. * Creates the VertexData for a Plane
  95973. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95974. * * size sets the width and height of the plane to the value of size, optional default 1
  95975. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95976. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95978. * * 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)
  95979. * * 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)
  95980. * @returns the VertexData of the box
  95981. */
  95982. static CreatePlane(options: {
  95983. size?: number;
  95984. width?: number;
  95985. height?: number;
  95986. sideOrientation?: number;
  95987. frontUVs?: Vector4;
  95988. backUVs?: Vector4;
  95989. }): VertexData;
  95990. /**
  95991. * Creates the VertexData of the Disc or regular Polygon
  95992. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95993. * * radius the radius of the disc, optional default 0.5
  95994. * * tessellation the number of polygon sides, optional, default 64
  95995. * * 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
  95996. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95997. * * 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)
  95998. * * 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)
  95999. * @returns the VertexData of the box
  96000. */
  96001. static CreateDisc(options: {
  96002. radius?: number;
  96003. tessellation?: number;
  96004. arc?: number;
  96005. sideOrientation?: number;
  96006. frontUVs?: Vector4;
  96007. backUVs?: Vector4;
  96008. }): VertexData;
  96009. /**
  96010. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  96011. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  96012. * @param polygon a mesh built from polygonTriangulation.build()
  96013. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96014. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96015. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96016. * @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)
  96017. * @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)
  96018. * @returns the VertexData of the Polygon
  96019. */
  96020. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  96021. /**
  96022. * Creates the VertexData of the IcoSphere
  96023. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  96024. * * radius the radius of the IcoSphere, optional default 1
  96025. * * radiusX allows stretching in the x direction, optional, default radius
  96026. * * radiusY allows stretching in the y direction, optional, default radius
  96027. * * radiusZ allows stretching in the z direction, optional, default radius
  96028. * * flat when true creates a flat shaded mesh, optional, default true
  96029. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  96030. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96031. * * 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)
  96032. * * 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)
  96033. * @returns the VertexData of the IcoSphere
  96034. */
  96035. static CreateIcoSphere(options: {
  96036. radius?: number;
  96037. radiusX?: number;
  96038. radiusY?: number;
  96039. radiusZ?: number;
  96040. flat?: boolean;
  96041. subdivisions?: number;
  96042. sideOrientation?: number;
  96043. frontUVs?: Vector4;
  96044. backUVs?: Vector4;
  96045. }): VertexData;
  96046. /**
  96047. * Creates the VertexData for a Polyhedron
  96048. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  96049. * * type provided types are:
  96050. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  96051. * * 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)
  96052. * * size the size of the IcoSphere, optional default 1
  96053. * * sizeX allows stretching in the x direction, optional, default size
  96054. * * sizeY allows stretching in the y direction, optional, default size
  96055. * * sizeZ allows stretching in the z direction, optional, default size
  96056. * * 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
  96057. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96058. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96059. * * flat when true creates a flat shaded mesh, optional, default true
  96060. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  96061. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96062. * * 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)
  96063. * * 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)
  96064. * @returns the VertexData of the Polyhedron
  96065. */
  96066. static CreatePolyhedron(options: {
  96067. type?: number;
  96068. size?: number;
  96069. sizeX?: number;
  96070. sizeY?: number;
  96071. sizeZ?: number;
  96072. custom?: any;
  96073. faceUV?: Vector4[];
  96074. faceColors?: Color4[];
  96075. flat?: boolean;
  96076. sideOrientation?: number;
  96077. frontUVs?: Vector4;
  96078. backUVs?: Vector4;
  96079. }): VertexData;
  96080. /**
  96081. * Creates the VertexData for a TorusKnot
  96082. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  96083. * * radius the radius of the torus knot, optional, default 2
  96084. * * tube the thickness of the tube, optional, default 0.5
  96085. * * radialSegments the number of sides on each tube segments, optional, default 32
  96086. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  96087. * * p the number of windings around the z axis, optional, default 2
  96088. * * q the number of windings around the x axis, optional, default 3
  96089. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96090. * * 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)
  96091. * * 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)
  96092. * @returns the VertexData of the Torus Knot
  96093. */
  96094. static CreateTorusKnot(options: {
  96095. radius?: number;
  96096. tube?: number;
  96097. radialSegments?: number;
  96098. tubularSegments?: number;
  96099. p?: number;
  96100. q?: number;
  96101. sideOrientation?: number;
  96102. frontUVs?: Vector4;
  96103. backUVs?: Vector4;
  96104. }): VertexData;
  96105. /**
  96106. * Compute normals for given positions and indices
  96107. * @param positions an array of vertex positions, [...., x, y, z, ......]
  96108. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  96109. * @param normals an array of vertex normals, [...., x, y, z, ......]
  96110. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  96111. * * facetNormals : optional array of facet normals (vector3)
  96112. * * facetPositions : optional array of facet positions (vector3)
  96113. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  96114. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  96115. * * bInfo : optional bounding info, required for facetPartitioning computation
  96116. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  96117. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  96118. * * useRightHandedSystem: optional boolean to for right handed system computation
  96119. * * depthSort : optional boolean to enable the facet depth sort computation
  96120. * * distanceTo : optional Vector3 to compute the facet depth from this location
  96121. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  96122. */
  96123. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  96124. facetNormals?: any;
  96125. facetPositions?: any;
  96126. facetPartitioning?: any;
  96127. ratio?: number;
  96128. bInfo?: any;
  96129. bbSize?: Vector3;
  96130. subDiv?: any;
  96131. useRightHandedSystem?: boolean;
  96132. depthSort?: boolean;
  96133. distanceTo?: Vector3;
  96134. depthSortedFacets?: any;
  96135. }): void;
  96136. /** @hidden */
  96137. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  96138. /**
  96139. * Applies VertexData created from the imported parameters to the geometry
  96140. * @param parsedVertexData the parsed data from an imported file
  96141. * @param geometry the geometry to apply the VertexData to
  96142. */
  96143. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  96144. }
  96145. }
  96146. declare module BABYLON {
  96147. /**
  96148. * Defines a target to use with MorphTargetManager
  96149. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96150. */
  96151. export class MorphTarget implements IAnimatable {
  96152. /** defines the name of the target */
  96153. name: string;
  96154. /**
  96155. * Gets or sets the list of animations
  96156. */
  96157. animations: Animation[];
  96158. private _scene;
  96159. private _positions;
  96160. private _normals;
  96161. private _tangents;
  96162. private _uvs;
  96163. private _influence;
  96164. private _uniqueId;
  96165. /**
  96166. * Observable raised when the influence changes
  96167. */
  96168. onInfluenceChanged: Observable<boolean>;
  96169. /** @hidden */
  96170. _onDataLayoutChanged: Observable<void>;
  96171. /**
  96172. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  96173. */
  96174. get influence(): number;
  96175. set influence(influence: number);
  96176. /**
  96177. * Gets or sets the id of the morph Target
  96178. */
  96179. id: string;
  96180. private _animationPropertiesOverride;
  96181. /**
  96182. * Gets or sets the animation properties override
  96183. */
  96184. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96185. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96186. /**
  96187. * Creates a new MorphTarget
  96188. * @param name defines the name of the target
  96189. * @param influence defines the influence to use
  96190. * @param scene defines the scene the morphtarget belongs to
  96191. */
  96192. constructor(
  96193. /** defines the name of the target */
  96194. name: string, influence?: number, scene?: Nullable<Scene>);
  96195. /**
  96196. * Gets the unique ID of this manager
  96197. */
  96198. get uniqueId(): number;
  96199. /**
  96200. * Gets a boolean defining if the target contains position data
  96201. */
  96202. get hasPositions(): boolean;
  96203. /**
  96204. * Gets a boolean defining if the target contains normal data
  96205. */
  96206. get hasNormals(): boolean;
  96207. /**
  96208. * Gets a boolean defining if the target contains tangent data
  96209. */
  96210. get hasTangents(): boolean;
  96211. /**
  96212. * Gets a boolean defining if the target contains texture coordinates data
  96213. */
  96214. get hasUVs(): boolean;
  96215. /**
  96216. * Affects position data to this target
  96217. * @param data defines the position data to use
  96218. */
  96219. setPositions(data: Nullable<FloatArray>): void;
  96220. /**
  96221. * Gets the position data stored in this target
  96222. * @returns a FloatArray containing the position data (or null if not present)
  96223. */
  96224. getPositions(): Nullable<FloatArray>;
  96225. /**
  96226. * Affects normal data to this target
  96227. * @param data defines the normal data to use
  96228. */
  96229. setNormals(data: Nullable<FloatArray>): void;
  96230. /**
  96231. * Gets the normal data stored in this target
  96232. * @returns a FloatArray containing the normal data (or null if not present)
  96233. */
  96234. getNormals(): Nullable<FloatArray>;
  96235. /**
  96236. * Affects tangent data to this target
  96237. * @param data defines the tangent data to use
  96238. */
  96239. setTangents(data: Nullable<FloatArray>): void;
  96240. /**
  96241. * Gets the tangent data stored in this target
  96242. * @returns a FloatArray containing the tangent data (or null if not present)
  96243. */
  96244. getTangents(): Nullable<FloatArray>;
  96245. /**
  96246. * Affects texture coordinates data to this target
  96247. * @param data defines the texture coordinates data to use
  96248. */
  96249. setUVs(data: Nullable<FloatArray>): void;
  96250. /**
  96251. * Gets the texture coordinates data stored in this target
  96252. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  96253. */
  96254. getUVs(): Nullable<FloatArray>;
  96255. /**
  96256. * Clone the current target
  96257. * @returns a new MorphTarget
  96258. */
  96259. clone(): MorphTarget;
  96260. /**
  96261. * Serializes the current target into a Serialization object
  96262. * @returns the serialized object
  96263. */
  96264. serialize(): any;
  96265. /**
  96266. * Returns the string "MorphTarget"
  96267. * @returns "MorphTarget"
  96268. */
  96269. getClassName(): string;
  96270. /**
  96271. * Creates a new target from serialized data
  96272. * @param serializationObject defines the serialized data to use
  96273. * @returns a new MorphTarget
  96274. */
  96275. static Parse(serializationObject: any): MorphTarget;
  96276. /**
  96277. * Creates a MorphTarget from mesh data
  96278. * @param mesh defines the source mesh
  96279. * @param name defines the name to use for the new target
  96280. * @param influence defines the influence to attach to the target
  96281. * @returns a new MorphTarget
  96282. */
  96283. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96284. }
  96285. }
  96286. declare module BABYLON {
  96287. /**
  96288. * This class is used to deform meshes using morphing between different targets
  96289. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96290. */
  96291. export class MorphTargetManager {
  96292. private _targets;
  96293. private _targetInfluenceChangedObservers;
  96294. private _targetDataLayoutChangedObservers;
  96295. private _activeTargets;
  96296. private _scene;
  96297. private _influences;
  96298. private _supportsNormals;
  96299. private _supportsTangents;
  96300. private _supportsUVs;
  96301. private _vertexCount;
  96302. private _uniqueId;
  96303. private _tempInfluences;
  96304. /**
  96305. * Gets or sets a boolean indicating if normals must be morphed
  96306. */
  96307. enableNormalMorphing: boolean;
  96308. /**
  96309. * Gets or sets a boolean indicating if tangents must be morphed
  96310. */
  96311. enableTangentMorphing: boolean;
  96312. /**
  96313. * Gets or sets a boolean indicating if UV must be morphed
  96314. */
  96315. enableUVMorphing: boolean;
  96316. /**
  96317. * Creates a new MorphTargetManager
  96318. * @param scene defines the current scene
  96319. */
  96320. constructor(scene?: Nullable<Scene>);
  96321. /**
  96322. * Gets the unique ID of this manager
  96323. */
  96324. get uniqueId(): number;
  96325. /**
  96326. * Gets the number of vertices handled by this manager
  96327. */
  96328. get vertexCount(): number;
  96329. /**
  96330. * Gets a boolean indicating if this manager supports morphing of normals
  96331. */
  96332. get supportsNormals(): boolean;
  96333. /**
  96334. * Gets a boolean indicating if this manager supports morphing of tangents
  96335. */
  96336. get supportsTangents(): boolean;
  96337. /**
  96338. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96339. */
  96340. get supportsUVs(): boolean;
  96341. /**
  96342. * Gets the number of targets stored in this manager
  96343. */
  96344. get numTargets(): number;
  96345. /**
  96346. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96347. */
  96348. get numInfluencers(): number;
  96349. /**
  96350. * Gets the list of influences (one per target)
  96351. */
  96352. get influences(): Float32Array;
  96353. /**
  96354. * Gets the active target at specified index. An active target is a target with an influence > 0
  96355. * @param index defines the index to check
  96356. * @returns the requested target
  96357. */
  96358. getActiveTarget(index: number): MorphTarget;
  96359. /**
  96360. * Gets the target at specified index
  96361. * @param index defines the index to check
  96362. * @returns the requested target
  96363. */
  96364. getTarget(index: number): MorphTarget;
  96365. /**
  96366. * Add a new target to this manager
  96367. * @param target defines the target to add
  96368. */
  96369. addTarget(target: MorphTarget): void;
  96370. /**
  96371. * Removes a target from the manager
  96372. * @param target defines the target to remove
  96373. */
  96374. removeTarget(target: MorphTarget): void;
  96375. /**
  96376. * Clone the current manager
  96377. * @returns a new MorphTargetManager
  96378. */
  96379. clone(): MorphTargetManager;
  96380. /**
  96381. * Serializes the current manager into a Serialization object
  96382. * @returns the serialized object
  96383. */
  96384. serialize(): any;
  96385. private _syncActiveTargets;
  96386. /**
  96387. * Syncrhonize the targets with all the meshes using this morph target manager
  96388. */
  96389. synchronize(): void;
  96390. /**
  96391. * Creates a new MorphTargetManager from serialized data
  96392. * @param serializationObject defines the serialized data
  96393. * @param scene defines the hosting scene
  96394. * @returns the new MorphTargetManager
  96395. */
  96396. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96397. }
  96398. }
  96399. declare module BABYLON {
  96400. /**
  96401. * Class used to represent a specific level of detail of a mesh
  96402. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96403. */
  96404. export class MeshLODLevel {
  96405. /** Defines the distance where this level should start being displayed */
  96406. distance: number;
  96407. /** Defines the mesh to use to render this level */
  96408. mesh: Nullable<Mesh>;
  96409. /**
  96410. * Creates a new LOD level
  96411. * @param distance defines the distance where this level should star being displayed
  96412. * @param mesh defines the mesh to use to render this level
  96413. */
  96414. constructor(
  96415. /** Defines the distance where this level should start being displayed */
  96416. distance: number,
  96417. /** Defines the mesh to use to render this level */
  96418. mesh: Nullable<Mesh>);
  96419. }
  96420. }
  96421. declare module BABYLON {
  96422. /**
  96423. * Mesh representing the gorund
  96424. */
  96425. export class GroundMesh extends Mesh {
  96426. /** If octree should be generated */
  96427. generateOctree: boolean;
  96428. private _heightQuads;
  96429. /** @hidden */
  96430. _subdivisionsX: number;
  96431. /** @hidden */
  96432. _subdivisionsY: number;
  96433. /** @hidden */
  96434. _width: number;
  96435. /** @hidden */
  96436. _height: number;
  96437. /** @hidden */
  96438. _minX: number;
  96439. /** @hidden */
  96440. _maxX: number;
  96441. /** @hidden */
  96442. _minZ: number;
  96443. /** @hidden */
  96444. _maxZ: number;
  96445. constructor(name: string, scene: Scene);
  96446. /**
  96447. * "GroundMesh"
  96448. * @returns "GroundMesh"
  96449. */
  96450. getClassName(): string;
  96451. /**
  96452. * The minimum of x and y subdivisions
  96453. */
  96454. get subdivisions(): number;
  96455. /**
  96456. * X subdivisions
  96457. */
  96458. get subdivisionsX(): number;
  96459. /**
  96460. * Y subdivisions
  96461. */
  96462. get subdivisionsY(): number;
  96463. /**
  96464. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96465. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96466. * @param chunksCount the number of subdivisions for x and y
  96467. * @param octreeBlocksSize (Default: 32)
  96468. */
  96469. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96470. /**
  96471. * Returns a height (y) value in the Worl system :
  96472. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96473. * @param x x coordinate
  96474. * @param z z coordinate
  96475. * @returns the ground y position if (x, z) are outside the ground surface.
  96476. */
  96477. getHeightAtCoordinates(x: number, z: number): number;
  96478. /**
  96479. * Returns a normalized vector (Vector3) orthogonal to the ground
  96480. * at the ground coordinates (x, z) expressed in the World system.
  96481. * @param x x coordinate
  96482. * @param z z coordinate
  96483. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96484. */
  96485. getNormalAtCoordinates(x: number, z: number): Vector3;
  96486. /**
  96487. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96488. * at the ground coordinates (x, z) expressed in the World system.
  96489. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96490. * @param x x coordinate
  96491. * @param z z coordinate
  96492. * @param ref vector to store the result
  96493. * @returns the GroundMesh.
  96494. */
  96495. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96496. /**
  96497. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96498. * if the ground has been updated.
  96499. * This can be used in the render loop.
  96500. * @returns the GroundMesh.
  96501. */
  96502. updateCoordinateHeights(): GroundMesh;
  96503. private _getFacetAt;
  96504. private _initHeightQuads;
  96505. private _computeHeightQuads;
  96506. /**
  96507. * Serializes this ground mesh
  96508. * @param serializationObject object to write serialization to
  96509. */
  96510. serialize(serializationObject: any): void;
  96511. /**
  96512. * Parses a serialized ground mesh
  96513. * @param parsedMesh the serialized mesh
  96514. * @param scene the scene to create the ground mesh in
  96515. * @returns the created ground mesh
  96516. */
  96517. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96518. }
  96519. }
  96520. declare module BABYLON {
  96521. /**
  96522. * Interface for Physics-Joint data
  96523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96524. */
  96525. export interface PhysicsJointData {
  96526. /**
  96527. * The main pivot of the joint
  96528. */
  96529. mainPivot?: Vector3;
  96530. /**
  96531. * The connected pivot of the joint
  96532. */
  96533. connectedPivot?: Vector3;
  96534. /**
  96535. * The main axis of the joint
  96536. */
  96537. mainAxis?: Vector3;
  96538. /**
  96539. * The connected axis of the joint
  96540. */
  96541. connectedAxis?: Vector3;
  96542. /**
  96543. * The collision of the joint
  96544. */
  96545. collision?: boolean;
  96546. /**
  96547. * Native Oimo/Cannon/Energy data
  96548. */
  96549. nativeParams?: any;
  96550. }
  96551. /**
  96552. * This is a holder class for the physics joint created by the physics plugin
  96553. * It holds a set of functions to control the underlying joint
  96554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96555. */
  96556. export class PhysicsJoint {
  96557. /**
  96558. * The type of the physics joint
  96559. */
  96560. type: number;
  96561. /**
  96562. * The data for the physics joint
  96563. */
  96564. jointData: PhysicsJointData;
  96565. private _physicsJoint;
  96566. protected _physicsPlugin: IPhysicsEnginePlugin;
  96567. /**
  96568. * Initializes the physics joint
  96569. * @param type The type of the physics joint
  96570. * @param jointData The data for the physics joint
  96571. */
  96572. constructor(
  96573. /**
  96574. * The type of the physics joint
  96575. */
  96576. type: number,
  96577. /**
  96578. * The data for the physics joint
  96579. */
  96580. jointData: PhysicsJointData);
  96581. /**
  96582. * Gets the physics joint
  96583. */
  96584. get physicsJoint(): any;
  96585. /**
  96586. * Sets the physics joint
  96587. */
  96588. set physicsJoint(newJoint: any);
  96589. /**
  96590. * Sets the physics plugin
  96591. */
  96592. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96593. /**
  96594. * Execute a function that is physics-plugin specific.
  96595. * @param {Function} func the function that will be executed.
  96596. * It accepts two parameters: the physics world and the physics joint
  96597. */
  96598. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96599. /**
  96600. * Distance-Joint type
  96601. */
  96602. static DistanceJoint: number;
  96603. /**
  96604. * Hinge-Joint type
  96605. */
  96606. static HingeJoint: number;
  96607. /**
  96608. * Ball-and-Socket joint type
  96609. */
  96610. static BallAndSocketJoint: number;
  96611. /**
  96612. * Wheel-Joint type
  96613. */
  96614. static WheelJoint: number;
  96615. /**
  96616. * Slider-Joint type
  96617. */
  96618. static SliderJoint: number;
  96619. /**
  96620. * Prismatic-Joint type
  96621. */
  96622. static PrismaticJoint: number;
  96623. /**
  96624. * Universal-Joint type
  96625. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96626. */
  96627. static UniversalJoint: number;
  96628. /**
  96629. * Hinge-Joint 2 type
  96630. */
  96631. static Hinge2Joint: number;
  96632. /**
  96633. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96634. */
  96635. static PointToPointJoint: number;
  96636. /**
  96637. * Spring-Joint type
  96638. */
  96639. static SpringJoint: number;
  96640. /**
  96641. * Lock-Joint type
  96642. */
  96643. static LockJoint: number;
  96644. }
  96645. /**
  96646. * A class representing a physics distance joint
  96647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96648. */
  96649. export class DistanceJoint extends PhysicsJoint {
  96650. /**
  96651. *
  96652. * @param jointData The data for the Distance-Joint
  96653. */
  96654. constructor(jointData: DistanceJointData);
  96655. /**
  96656. * Update the predefined distance.
  96657. * @param maxDistance The maximum preferred distance
  96658. * @param minDistance The minimum preferred distance
  96659. */
  96660. updateDistance(maxDistance: number, minDistance?: number): void;
  96661. }
  96662. /**
  96663. * Represents a Motor-Enabled Joint
  96664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96665. */
  96666. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96667. /**
  96668. * Initializes the Motor-Enabled Joint
  96669. * @param type The type of the joint
  96670. * @param jointData The physica joint data for the joint
  96671. */
  96672. constructor(type: number, jointData: PhysicsJointData);
  96673. /**
  96674. * Set the motor values.
  96675. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96676. * @param force the force to apply
  96677. * @param maxForce max force for this motor.
  96678. */
  96679. setMotor(force?: number, maxForce?: number): void;
  96680. /**
  96681. * Set the motor's limits.
  96682. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96683. * @param upperLimit The upper limit of the motor
  96684. * @param lowerLimit The lower limit of the motor
  96685. */
  96686. setLimit(upperLimit: number, lowerLimit?: number): void;
  96687. }
  96688. /**
  96689. * This class represents a single physics Hinge-Joint
  96690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96691. */
  96692. export class HingeJoint extends MotorEnabledJoint {
  96693. /**
  96694. * Initializes the Hinge-Joint
  96695. * @param jointData The joint data for the Hinge-Joint
  96696. */
  96697. constructor(jointData: PhysicsJointData);
  96698. /**
  96699. * Set the motor values.
  96700. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96701. * @param {number} force the force to apply
  96702. * @param {number} maxForce max force for this motor.
  96703. */
  96704. setMotor(force?: number, maxForce?: number): void;
  96705. /**
  96706. * Set the motor's limits.
  96707. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96708. * @param upperLimit The upper limit of the motor
  96709. * @param lowerLimit The lower limit of the motor
  96710. */
  96711. setLimit(upperLimit: number, lowerLimit?: number): void;
  96712. }
  96713. /**
  96714. * This class represents a dual hinge physics joint (same as wheel joint)
  96715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96716. */
  96717. export class Hinge2Joint extends MotorEnabledJoint {
  96718. /**
  96719. * Initializes the Hinge2-Joint
  96720. * @param jointData The joint data for the Hinge2-Joint
  96721. */
  96722. constructor(jointData: PhysicsJointData);
  96723. /**
  96724. * Set the motor values.
  96725. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96726. * @param {number} targetSpeed the speed the motor is to reach
  96727. * @param {number} maxForce max force for this motor.
  96728. * @param {motorIndex} the motor's index, 0 or 1.
  96729. */
  96730. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96731. /**
  96732. * Set the motor limits.
  96733. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96734. * @param {number} upperLimit the upper limit
  96735. * @param {number} lowerLimit lower limit
  96736. * @param {motorIndex} the motor's index, 0 or 1.
  96737. */
  96738. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96739. }
  96740. /**
  96741. * Interface for a motor enabled joint
  96742. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96743. */
  96744. export interface IMotorEnabledJoint {
  96745. /**
  96746. * Physics joint
  96747. */
  96748. physicsJoint: any;
  96749. /**
  96750. * Sets the motor of the motor-enabled joint
  96751. * @param force The force of the motor
  96752. * @param maxForce The maximum force of the motor
  96753. * @param motorIndex The index of the motor
  96754. */
  96755. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96756. /**
  96757. * Sets the limit of the motor
  96758. * @param upperLimit The upper limit of the motor
  96759. * @param lowerLimit The lower limit of the motor
  96760. * @param motorIndex The index of the motor
  96761. */
  96762. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96763. }
  96764. /**
  96765. * Joint data for a Distance-Joint
  96766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96767. */
  96768. export interface DistanceJointData extends PhysicsJointData {
  96769. /**
  96770. * Max distance the 2 joint objects can be apart
  96771. */
  96772. maxDistance: number;
  96773. }
  96774. /**
  96775. * Joint data from a spring joint
  96776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96777. */
  96778. export interface SpringJointData extends PhysicsJointData {
  96779. /**
  96780. * Length of the spring
  96781. */
  96782. length: number;
  96783. /**
  96784. * Stiffness of the spring
  96785. */
  96786. stiffness: number;
  96787. /**
  96788. * Damping of the spring
  96789. */
  96790. damping: number;
  96791. /** this callback will be called when applying the force to the impostors. */
  96792. forceApplicationCallback: () => void;
  96793. }
  96794. }
  96795. declare module BABYLON {
  96796. /**
  96797. * Holds the data for the raycast result
  96798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96799. */
  96800. export class PhysicsRaycastResult {
  96801. private _hasHit;
  96802. private _hitDistance;
  96803. private _hitNormalWorld;
  96804. private _hitPointWorld;
  96805. private _rayFromWorld;
  96806. private _rayToWorld;
  96807. /**
  96808. * Gets if there was a hit
  96809. */
  96810. get hasHit(): boolean;
  96811. /**
  96812. * Gets the distance from the hit
  96813. */
  96814. get hitDistance(): number;
  96815. /**
  96816. * Gets the hit normal/direction in the world
  96817. */
  96818. get hitNormalWorld(): Vector3;
  96819. /**
  96820. * Gets the hit point in the world
  96821. */
  96822. get hitPointWorld(): Vector3;
  96823. /**
  96824. * Gets the ray "start point" of the ray in the world
  96825. */
  96826. get rayFromWorld(): Vector3;
  96827. /**
  96828. * Gets the ray "end point" of the ray in the world
  96829. */
  96830. get rayToWorld(): Vector3;
  96831. /**
  96832. * Sets the hit data (normal & point in world space)
  96833. * @param hitNormalWorld defines the normal in world space
  96834. * @param hitPointWorld defines the point in world space
  96835. */
  96836. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96837. /**
  96838. * Sets the distance from the start point to the hit point
  96839. * @param distance
  96840. */
  96841. setHitDistance(distance: number): void;
  96842. /**
  96843. * Calculates the distance manually
  96844. */
  96845. calculateHitDistance(): void;
  96846. /**
  96847. * Resets all the values to default
  96848. * @param from The from point on world space
  96849. * @param to The to point on world space
  96850. */
  96851. reset(from?: Vector3, to?: Vector3): void;
  96852. }
  96853. /**
  96854. * Interface for the size containing width and height
  96855. */
  96856. interface IXYZ {
  96857. /**
  96858. * X
  96859. */
  96860. x: number;
  96861. /**
  96862. * Y
  96863. */
  96864. y: number;
  96865. /**
  96866. * Z
  96867. */
  96868. z: number;
  96869. }
  96870. }
  96871. declare module BABYLON {
  96872. /**
  96873. * Interface used to describe a physics joint
  96874. */
  96875. export interface PhysicsImpostorJoint {
  96876. /** Defines the main impostor to which the joint is linked */
  96877. mainImpostor: PhysicsImpostor;
  96878. /** Defines the impostor that is connected to the main impostor using this joint */
  96879. connectedImpostor: PhysicsImpostor;
  96880. /** Defines the joint itself */
  96881. joint: PhysicsJoint;
  96882. }
  96883. /** @hidden */
  96884. export interface IPhysicsEnginePlugin {
  96885. world: any;
  96886. name: string;
  96887. setGravity(gravity: Vector3): void;
  96888. setTimeStep(timeStep: number): void;
  96889. getTimeStep(): number;
  96890. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96891. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96892. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96893. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96894. removePhysicsBody(impostor: PhysicsImpostor): void;
  96895. generateJoint(joint: PhysicsImpostorJoint): void;
  96896. removeJoint(joint: PhysicsImpostorJoint): void;
  96897. isSupported(): boolean;
  96898. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96899. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96900. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96901. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96902. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96903. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96904. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96905. getBodyMass(impostor: PhysicsImpostor): number;
  96906. getBodyFriction(impostor: PhysicsImpostor): number;
  96907. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96908. getBodyRestitution(impostor: PhysicsImpostor): number;
  96909. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96910. getBodyPressure?(impostor: PhysicsImpostor): number;
  96911. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96912. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96913. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96914. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96915. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96916. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96917. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96918. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96919. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96920. sleepBody(impostor: PhysicsImpostor): void;
  96921. wakeUpBody(impostor: PhysicsImpostor): void;
  96922. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96923. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96924. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96925. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96926. getRadius(impostor: PhysicsImpostor): number;
  96927. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96928. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96929. dispose(): void;
  96930. }
  96931. /**
  96932. * Interface used to define a physics engine
  96933. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96934. */
  96935. export interface IPhysicsEngine {
  96936. /**
  96937. * Gets the gravity vector used by the simulation
  96938. */
  96939. gravity: Vector3;
  96940. /**
  96941. * Sets the gravity vector used by the simulation
  96942. * @param gravity defines the gravity vector to use
  96943. */
  96944. setGravity(gravity: Vector3): void;
  96945. /**
  96946. * Set the time step of the physics engine.
  96947. * Default is 1/60.
  96948. * To slow it down, enter 1/600 for example.
  96949. * To speed it up, 1/30
  96950. * @param newTimeStep the new timestep to apply to this world.
  96951. */
  96952. setTimeStep(newTimeStep: number): void;
  96953. /**
  96954. * Get the time step of the physics engine.
  96955. * @returns the current time step
  96956. */
  96957. getTimeStep(): number;
  96958. /**
  96959. * Set the sub time step of the physics engine.
  96960. * Default is 0 meaning there is no sub steps
  96961. * To increase physics resolution precision, set a small value (like 1 ms)
  96962. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96963. */
  96964. setSubTimeStep(subTimeStep: number): void;
  96965. /**
  96966. * Get the sub time step of the physics engine.
  96967. * @returns the current sub time step
  96968. */
  96969. getSubTimeStep(): number;
  96970. /**
  96971. * Release all resources
  96972. */
  96973. dispose(): void;
  96974. /**
  96975. * Gets the name of the current physics plugin
  96976. * @returns the name of the plugin
  96977. */
  96978. getPhysicsPluginName(): string;
  96979. /**
  96980. * Adding a new impostor for the impostor tracking.
  96981. * This will be done by the impostor itself.
  96982. * @param impostor the impostor to add
  96983. */
  96984. addImpostor(impostor: PhysicsImpostor): void;
  96985. /**
  96986. * Remove an impostor from the engine.
  96987. * This impostor and its mesh will not longer be updated by the physics engine.
  96988. * @param impostor the impostor to remove
  96989. */
  96990. removeImpostor(impostor: PhysicsImpostor): void;
  96991. /**
  96992. * Add a joint to the physics engine
  96993. * @param mainImpostor defines the main impostor to which the joint is added.
  96994. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96995. * @param joint defines the joint that will connect both impostors.
  96996. */
  96997. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96998. /**
  96999. * Removes a joint from the simulation
  97000. * @param mainImpostor defines the impostor used with the joint
  97001. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  97002. * @param joint defines the joint to remove
  97003. */
  97004. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  97005. /**
  97006. * Gets the current plugin used to run the simulation
  97007. * @returns current plugin
  97008. */
  97009. getPhysicsPlugin(): IPhysicsEnginePlugin;
  97010. /**
  97011. * Gets the list of physic impostors
  97012. * @returns an array of PhysicsImpostor
  97013. */
  97014. getImpostors(): Array<PhysicsImpostor>;
  97015. /**
  97016. * Gets the impostor for a physics enabled object
  97017. * @param object defines the object impersonated by the impostor
  97018. * @returns the PhysicsImpostor or null if not found
  97019. */
  97020. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97021. /**
  97022. * Gets the impostor for a physics body object
  97023. * @param body defines physics body used by the impostor
  97024. * @returns the PhysicsImpostor or null if not found
  97025. */
  97026. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  97027. /**
  97028. * Does a raycast in the physics world
  97029. * @param from when should the ray start?
  97030. * @param to when should the ray end?
  97031. * @returns PhysicsRaycastResult
  97032. */
  97033. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  97034. /**
  97035. * Called by the scene. No need to call it.
  97036. * @param delta defines the timespam between frames
  97037. */
  97038. _step(delta: number): void;
  97039. }
  97040. }
  97041. declare module BABYLON {
  97042. /**
  97043. * The interface for the physics imposter parameters
  97044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97045. */
  97046. export interface PhysicsImpostorParameters {
  97047. /**
  97048. * The mass of the physics imposter
  97049. */
  97050. mass: number;
  97051. /**
  97052. * The friction of the physics imposter
  97053. */
  97054. friction?: number;
  97055. /**
  97056. * The coefficient of restitution of the physics imposter
  97057. */
  97058. restitution?: number;
  97059. /**
  97060. * The native options of the physics imposter
  97061. */
  97062. nativeOptions?: any;
  97063. /**
  97064. * Specifies if the parent should be ignored
  97065. */
  97066. ignoreParent?: boolean;
  97067. /**
  97068. * Specifies if bi-directional transformations should be disabled
  97069. */
  97070. disableBidirectionalTransformation?: boolean;
  97071. /**
  97072. * The pressure inside the physics imposter, soft object only
  97073. */
  97074. pressure?: number;
  97075. /**
  97076. * The stiffness the physics imposter, soft object only
  97077. */
  97078. stiffness?: number;
  97079. /**
  97080. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  97081. */
  97082. velocityIterations?: number;
  97083. /**
  97084. * The number of iterations used in maintaining consistent vertex positions, soft object only
  97085. */
  97086. positionIterations?: number;
  97087. /**
  97088. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  97089. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  97090. * Add to fix multiple points
  97091. */
  97092. fixedPoints?: number;
  97093. /**
  97094. * The collision margin around a soft object
  97095. */
  97096. margin?: number;
  97097. /**
  97098. * The collision margin around a soft object
  97099. */
  97100. damping?: number;
  97101. /**
  97102. * The path for a rope based on an extrusion
  97103. */
  97104. path?: any;
  97105. /**
  97106. * The shape of an extrusion used for a rope based on an extrusion
  97107. */
  97108. shape?: any;
  97109. }
  97110. /**
  97111. * Interface for a physics-enabled object
  97112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97113. */
  97114. export interface IPhysicsEnabledObject {
  97115. /**
  97116. * The position of the physics-enabled object
  97117. */
  97118. position: Vector3;
  97119. /**
  97120. * The rotation of the physics-enabled object
  97121. */
  97122. rotationQuaternion: Nullable<Quaternion>;
  97123. /**
  97124. * The scale of the physics-enabled object
  97125. */
  97126. scaling: Vector3;
  97127. /**
  97128. * The rotation of the physics-enabled object
  97129. */
  97130. rotation?: Vector3;
  97131. /**
  97132. * The parent of the physics-enabled object
  97133. */
  97134. parent?: any;
  97135. /**
  97136. * The bounding info of the physics-enabled object
  97137. * @returns The bounding info of the physics-enabled object
  97138. */
  97139. getBoundingInfo(): BoundingInfo;
  97140. /**
  97141. * Computes the world matrix
  97142. * @param force Specifies if the world matrix should be computed by force
  97143. * @returns A world matrix
  97144. */
  97145. computeWorldMatrix(force: boolean): Matrix;
  97146. /**
  97147. * Gets the world matrix
  97148. * @returns A world matrix
  97149. */
  97150. getWorldMatrix?(): Matrix;
  97151. /**
  97152. * Gets the child meshes
  97153. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  97154. * @returns An array of abstract meshes
  97155. */
  97156. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  97157. /**
  97158. * Gets the vertex data
  97159. * @param kind The type of vertex data
  97160. * @returns A nullable array of numbers, or a float32 array
  97161. */
  97162. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  97163. /**
  97164. * Gets the indices from the mesh
  97165. * @returns A nullable array of index arrays
  97166. */
  97167. getIndices?(): Nullable<IndicesArray>;
  97168. /**
  97169. * Gets the scene from the mesh
  97170. * @returns the indices array or null
  97171. */
  97172. getScene?(): Scene;
  97173. /**
  97174. * Gets the absolute position from the mesh
  97175. * @returns the absolute position
  97176. */
  97177. getAbsolutePosition(): Vector3;
  97178. /**
  97179. * Gets the absolute pivot point from the mesh
  97180. * @returns the absolute pivot point
  97181. */
  97182. getAbsolutePivotPoint(): Vector3;
  97183. /**
  97184. * Rotates the mesh
  97185. * @param axis The axis of rotation
  97186. * @param amount The amount of rotation
  97187. * @param space The space of the rotation
  97188. * @returns The rotation transform node
  97189. */
  97190. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  97191. /**
  97192. * Translates the mesh
  97193. * @param axis The axis of translation
  97194. * @param distance The distance of translation
  97195. * @param space The space of the translation
  97196. * @returns The transform node
  97197. */
  97198. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  97199. /**
  97200. * Sets the absolute position of the mesh
  97201. * @param absolutePosition The absolute position of the mesh
  97202. * @returns The transform node
  97203. */
  97204. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  97205. /**
  97206. * Gets the class name of the mesh
  97207. * @returns The class name
  97208. */
  97209. getClassName(): string;
  97210. }
  97211. /**
  97212. * Represents a physics imposter
  97213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97214. */
  97215. export class PhysicsImpostor {
  97216. /**
  97217. * The physics-enabled object used as the physics imposter
  97218. */
  97219. object: IPhysicsEnabledObject;
  97220. /**
  97221. * The type of the physics imposter
  97222. */
  97223. type: number;
  97224. private _options;
  97225. private _scene?;
  97226. /**
  97227. * The default object size of the imposter
  97228. */
  97229. static DEFAULT_OBJECT_SIZE: Vector3;
  97230. /**
  97231. * The identity quaternion of the imposter
  97232. */
  97233. static IDENTITY_QUATERNION: Quaternion;
  97234. /** @hidden */
  97235. _pluginData: any;
  97236. private _physicsEngine;
  97237. private _physicsBody;
  97238. private _bodyUpdateRequired;
  97239. private _onBeforePhysicsStepCallbacks;
  97240. private _onAfterPhysicsStepCallbacks;
  97241. /** @hidden */
  97242. _onPhysicsCollideCallbacks: Array<{
  97243. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  97244. otherImpostors: Array<PhysicsImpostor>;
  97245. }>;
  97246. private _deltaPosition;
  97247. private _deltaRotation;
  97248. private _deltaRotationConjugated;
  97249. /** @hidden */
  97250. _isFromLine: boolean;
  97251. private _parent;
  97252. private _isDisposed;
  97253. private static _tmpVecs;
  97254. private static _tmpQuat;
  97255. /**
  97256. * Specifies if the physics imposter is disposed
  97257. */
  97258. get isDisposed(): boolean;
  97259. /**
  97260. * Gets the mass of the physics imposter
  97261. */
  97262. get mass(): number;
  97263. set mass(value: number);
  97264. /**
  97265. * Gets the coefficient of friction
  97266. */
  97267. get friction(): number;
  97268. /**
  97269. * Sets the coefficient of friction
  97270. */
  97271. set friction(value: number);
  97272. /**
  97273. * Gets the coefficient of restitution
  97274. */
  97275. get restitution(): number;
  97276. /**
  97277. * Sets the coefficient of restitution
  97278. */
  97279. set restitution(value: number);
  97280. /**
  97281. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97282. */
  97283. get pressure(): number;
  97284. /**
  97285. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97286. */
  97287. set pressure(value: number);
  97288. /**
  97289. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97290. */
  97291. get stiffness(): number;
  97292. /**
  97293. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97294. */
  97295. set stiffness(value: number);
  97296. /**
  97297. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97298. */
  97299. get velocityIterations(): number;
  97300. /**
  97301. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97302. */
  97303. set velocityIterations(value: number);
  97304. /**
  97305. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97306. */
  97307. get positionIterations(): number;
  97308. /**
  97309. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97310. */
  97311. set positionIterations(value: number);
  97312. /**
  97313. * The unique id of the physics imposter
  97314. * set by the physics engine when adding this impostor to the array
  97315. */
  97316. uniqueId: number;
  97317. /**
  97318. * @hidden
  97319. */
  97320. soft: boolean;
  97321. /**
  97322. * @hidden
  97323. */
  97324. segments: number;
  97325. private _joints;
  97326. /**
  97327. * Initializes the physics imposter
  97328. * @param object The physics-enabled object used as the physics imposter
  97329. * @param type The type of the physics imposter
  97330. * @param _options The options for the physics imposter
  97331. * @param _scene The Babylon scene
  97332. */
  97333. constructor(
  97334. /**
  97335. * The physics-enabled object used as the physics imposter
  97336. */
  97337. object: IPhysicsEnabledObject,
  97338. /**
  97339. * The type of the physics imposter
  97340. */
  97341. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97342. /**
  97343. * This function will completly initialize this impostor.
  97344. * It will create a new body - but only if this mesh has no parent.
  97345. * If it has, this impostor will not be used other than to define the impostor
  97346. * of the child mesh.
  97347. * @hidden
  97348. */
  97349. _init(): void;
  97350. private _getPhysicsParent;
  97351. /**
  97352. * Should a new body be generated.
  97353. * @returns boolean specifying if body initialization is required
  97354. */
  97355. isBodyInitRequired(): boolean;
  97356. /**
  97357. * Sets the updated scaling
  97358. * @param updated Specifies if the scaling is updated
  97359. */
  97360. setScalingUpdated(): void;
  97361. /**
  97362. * Force a regeneration of this or the parent's impostor's body.
  97363. * Use under cautious - This will remove all joints already implemented.
  97364. */
  97365. forceUpdate(): void;
  97366. /**
  97367. * Gets the body that holds this impostor. Either its own, or its parent.
  97368. */
  97369. get physicsBody(): any;
  97370. /**
  97371. * Get the parent of the physics imposter
  97372. * @returns Physics imposter or null
  97373. */
  97374. get parent(): Nullable<PhysicsImpostor>;
  97375. /**
  97376. * Sets the parent of the physics imposter
  97377. */
  97378. set parent(value: Nullable<PhysicsImpostor>);
  97379. /**
  97380. * Set the physics body. Used mainly by the physics engine/plugin
  97381. */
  97382. set physicsBody(physicsBody: any);
  97383. /**
  97384. * Resets the update flags
  97385. */
  97386. resetUpdateFlags(): void;
  97387. /**
  97388. * Gets the object extend size
  97389. * @returns the object extend size
  97390. */
  97391. getObjectExtendSize(): Vector3;
  97392. /**
  97393. * Gets the object center
  97394. * @returns The object center
  97395. */
  97396. getObjectCenter(): Vector3;
  97397. /**
  97398. * Get a specific parameter from the options parameters
  97399. * @param paramName The object parameter name
  97400. * @returns The object parameter
  97401. */
  97402. getParam(paramName: string): any;
  97403. /**
  97404. * Sets a specific parameter in the options given to the physics plugin
  97405. * @param paramName The parameter name
  97406. * @param value The value of the parameter
  97407. */
  97408. setParam(paramName: string, value: number): void;
  97409. /**
  97410. * Specifically change the body's mass option. Won't recreate the physics body object
  97411. * @param mass The mass of the physics imposter
  97412. */
  97413. setMass(mass: number): void;
  97414. /**
  97415. * Gets the linear velocity
  97416. * @returns linear velocity or null
  97417. */
  97418. getLinearVelocity(): Nullable<Vector3>;
  97419. /**
  97420. * Sets the linear velocity
  97421. * @param velocity linear velocity or null
  97422. */
  97423. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97424. /**
  97425. * Gets the angular velocity
  97426. * @returns angular velocity or null
  97427. */
  97428. getAngularVelocity(): Nullable<Vector3>;
  97429. /**
  97430. * Sets the angular velocity
  97431. * @param velocity The velocity or null
  97432. */
  97433. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97434. /**
  97435. * Execute a function with the physics plugin native code
  97436. * Provide a function the will have two variables - the world object and the physics body object
  97437. * @param func The function to execute with the physics plugin native code
  97438. */
  97439. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97440. /**
  97441. * Register a function that will be executed before the physics world is stepping forward
  97442. * @param func The function to execute before the physics world is stepped forward
  97443. */
  97444. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97445. /**
  97446. * Unregister a function that will be executed before the physics world is stepping forward
  97447. * @param func The function to execute before the physics world is stepped forward
  97448. */
  97449. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97450. /**
  97451. * Register a function that will be executed after the physics step
  97452. * @param func The function to execute after physics step
  97453. */
  97454. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97455. /**
  97456. * Unregisters a function that will be executed after the physics step
  97457. * @param func The function to execute after physics step
  97458. */
  97459. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97460. /**
  97461. * register a function that will be executed when this impostor collides against a different body
  97462. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97463. * @param func Callback that is executed on collision
  97464. */
  97465. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97466. /**
  97467. * Unregisters the physics imposter on contact
  97468. * @param collideAgainst The physics object to collide against
  97469. * @param func Callback to execute on collision
  97470. */
  97471. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97472. private _tmpQuat;
  97473. private _tmpQuat2;
  97474. /**
  97475. * Get the parent rotation
  97476. * @returns The parent rotation
  97477. */
  97478. getParentsRotation(): Quaternion;
  97479. /**
  97480. * this function is executed by the physics engine.
  97481. */
  97482. beforeStep: () => void;
  97483. /**
  97484. * this function is executed by the physics engine
  97485. */
  97486. afterStep: () => void;
  97487. /**
  97488. * Legacy collision detection event support
  97489. */
  97490. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97491. /**
  97492. * event and body object due to cannon's event-based architecture.
  97493. */
  97494. onCollide: (e: {
  97495. body: any;
  97496. }) => void;
  97497. /**
  97498. * Apply a force
  97499. * @param force The force to apply
  97500. * @param contactPoint The contact point for the force
  97501. * @returns The physics imposter
  97502. */
  97503. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97504. /**
  97505. * Apply an impulse
  97506. * @param force The impulse force
  97507. * @param contactPoint The contact point for the impulse force
  97508. * @returns The physics imposter
  97509. */
  97510. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97511. /**
  97512. * A help function to create a joint
  97513. * @param otherImpostor A physics imposter used to create a joint
  97514. * @param jointType The type of joint
  97515. * @param jointData The data for the joint
  97516. * @returns The physics imposter
  97517. */
  97518. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97519. /**
  97520. * Add a joint to this impostor with a different impostor
  97521. * @param otherImpostor A physics imposter used to add a joint
  97522. * @param joint The joint to add
  97523. * @returns The physics imposter
  97524. */
  97525. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97526. /**
  97527. * Add an anchor to a cloth impostor
  97528. * @param otherImpostor rigid impostor to anchor to
  97529. * @param width ratio across width from 0 to 1
  97530. * @param height ratio up height from 0 to 1
  97531. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97532. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97533. * @returns impostor the soft imposter
  97534. */
  97535. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97536. /**
  97537. * Add a hook to a rope impostor
  97538. * @param otherImpostor rigid impostor to anchor to
  97539. * @param length ratio across rope from 0 to 1
  97540. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97541. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97542. * @returns impostor the rope imposter
  97543. */
  97544. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97545. /**
  97546. * Will keep this body still, in a sleep mode.
  97547. * @returns the physics imposter
  97548. */
  97549. sleep(): PhysicsImpostor;
  97550. /**
  97551. * Wake the body up.
  97552. * @returns The physics imposter
  97553. */
  97554. wakeUp(): PhysicsImpostor;
  97555. /**
  97556. * Clones the physics imposter
  97557. * @param newObject The physics imposter clones to this physics-enabled object
  97558. * @returns A nullable physics imposter
  97559. */
  97560. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97561. /**
  97562. * Disposes the physics imposter
  97563. */
  97564. dispose(): void;
  97565. /**
  97566. * Sets the delta position
  97567. * @param position The delta position amount
  97568. */
  97569. setDeltaPosition(position: Vector3): void;
  97570. /**
  97571. * Sets the delta rotation
  97572. * @param rotation The delta rotation amount
  97573. */
  97574. setDeltaRotation(rotation: Quaternion): void;
  97575. /**
  97576. * Gets the box size of the physics imposter and stores the result in the input parameter
  97577. * @param result Stores the box size
  97578. * @returns The physics imposter
  97579. */
  97580. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97581. /**
  97582. * Gets the radius of the physics imposter
  97583. * @returns Radius of the physics imposter
  97584. */
  97585. getRadius(): number;
  97586. /**
  97587. * Sync a bone with this impostor
  97588. * @param bone The bone to sync to the impostor.
  97589. * @param boneMesh The mesh that the bone is influencing.
  97590. * @param jointPivot The pivot of the joint / bone in local space.
  97591. * @param distToJoint Optional distance from the impostor to the joint.
  97592. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97593. */
  97594. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97595. /**
  97596. * Sync impostor to a bone
  97597. * @param bone The bone that the impostor will be synced to.
  97598. * @param boneMesh The mesh that the bone is influencing.
  97599. * @param jointPivot The pivot of the joint / bone in local space.
  97600. * @param distToJoint Optional distance from the impostor to the joint.
  97601. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97602. * @param boneAxis Optional vector3 axis the bone is aligned with
  97603. */
  97604. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97605. /**
  97606. * No-Imposter type
  97607. */
  97608. static NoImpostor: number;
  97609. /**
  97610. * Sphere-Imposter type
  97611. */
  97612. static SphereImpostor: number;
  97613. /**
  97614. * Box-Imposter type
  97615. */
  97616. static BoxImpostor: number;
  97617. /**
  97618. * Plane-Imposter type
  97619. */
  97620. static PlaneImpostor: number;
  97621. /**
  97622. * Mesh-imposter type
  97623. */
  97624. static MeshImpostor: number;
  97625. /**
  97626. * Capsule-Impostor type (Ammo.js plugin only)
  97627. */
  97628. static CapsuleImpostor: number;
  97629. /**
  97630. * Cylinder-Imposter type
  97631. */
  97632. static CylinderImpostor: number;
  97633. /**
  97634. * Particle-Imposter type
  97635. */
  97636. static ParticleImpostor: number;
  97637. /**
  97638. * Heightmap-Imposter type
  97639. */
  97640. static HeightmapImpostor: number;
  97641. /**
  97642. * ConvexHull-Impostor type (Ammo.js plugin only)
  97643. */
  97644. static ConvexHullImpostor: number;
  97645. /**
  97646. * Custom-Imposter type (Ammo.js plugin only)
  97647. */
  97648. static CustomImpostor: number;
  97649. /**
  97650. * Rope-Imposter type
  97651. */
  97652. static RopeImpostor: number;
  97653. /**
  97654. * Cloth-Imposter type
  97655. */
  97656. static ClothImpostor: number;
  97657. /**
  97658. * Softbody-Imposter type
  97659. */
  97660. static SoftbodyImpostor: number;
  97661. }
  97662. }
  97663. declare module BABYLON {
  97664. /**
  97665. * @hidden
  97666. **/
  97667. export class _CreationDataStorage {
  97668. closePath?: boolean;
  97669. closeArray?: boolean;
  97670. idx: number[];
  97671. dashSize: number;
  97672. gapSize: number;
  97673. path3D: Path3D;
  97674. pathArray: Vector3[][];
  97675. arc: number;
  97676. radius: number;
  97677. cap: number;
  97678. tessellation: number;
  97679. }
  97680. /**
  97681. * @hidden
  97682. **/
  97683. class _InstanceDataStorage {
  97684. visibleInstances: any;
  97685. batchCache: _InstancesBatch;
  97686. instancesBufferSize: number;
  97687. instancesBuffer: Nullable<Buffer>;
  97688. instancesData: Float32Array;
  97689. overridenInstanceCount: number;
  97690. isFrozen: boolean;
  97691. previousBatch: Nullable<_InstancesBatch>;
  97692. hardwareInstancedRendering: boolean;
  97693. sideOrientation: number;
  97694. manualUpdate: boolean;
  97695. }
  97696. /**
  97697. * @hidden
  97698. **/
  97699. export class _InstancesBatch {
  97700. mustReturn: boolean;
  97701. visibleInstances: Nullable<InstancedMesh[]>[];
  97702. renderSelf: boolean[];
  97703. hardwareInstancedRendering: boolean[];
  97704. }
  97705. /**
  97706. * Class used to represent renderable models
  97707. */
  97708. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97709. /**
  97710. * Mesh side orientation : usually the external or front surface
  97711. */
  97712. static readonly FRONTSIDE: number;
  97713. /**
  97714. * Mesh side orientation : usually the internal or back surface
  97715. */
  97716. static readonly BACKSIDE: number;
  97717. /**
  97718. * Mesh side orientation : both internal and external or front and back surfaces
  97719. */
  97720. static readonly DOUBLESIDE: number;
  97721. /**
  97722. * Mesh side orientation : by default, `FRONTSIDE`
  97723. */
  97724. static readonly DEFAULTSIDE: number;
  97725. /**
  97726. * Mesh cap setting : no cap
  97727. */
  97728. static readonly NO_CAP: number;
  97729. /**
  97730. * Mesh cap setting : one cap at the beginning of the mesh
  97731. */
  97732. static readonly CAP_START: number;
  97733. /**
  97734. * Mesh cap setting : one cap at the end of the mesh
  97735. */
  97736. static readonly CAP_END: number;
  97737. /**
  97738. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97739. */
  97740. static readonly CAP_ALL: number;
  97741. /**
  97742. * Mesh pattern setting : no flip or rotate
  97743. */
  97744. static readonly NO_FLIP: number;
  97745. /**
  97746. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97747. */
  97748. static readonly FLIP_TILE: number;
  97749. /**
  97750. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97751. */
  97752. static readonly ROTATE_TILE: number;
  97753. /**
  97754. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97755. */
  97756. static readonly FLIP_ROW: number;
  97757. /**
  97758. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97759. */
  97760. static readonly ROTATE_ROW: number;
  97761. /**
  97762. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97763. */
  97764. static readonly FLIP_N_ROTATE_TILE: number;
  97765. /**
  97766. * Mesh pattern setting : rotate pattern and rotate
  97767. */
  97768. static readonly FLIP_N_ROTATE_ROW: number;
  97769. /**
  97770. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97771. */
  97772. static readonly CENTER: number;
  97773. /**
  97774. * Mesh tile positioning : part tiles on left
  97775. */
  97776. static readonly LEFT: number;
  97777. /**
  97778. * Mesh tile positioning : part tiles on right
  97779. */
  97780. static readonly RIGHT: number;
  97781. /**
  97782. * Mesh tile positioning : part tiles on top
  97783. */
  97784. static readonly TOP: number;
  97785. /**
  97786. * Mesh tile positioning : part tiles on bottom
  97787. */
  97788. static readonly BOTTOM: number;
  97789. /**
  97790. * Gets the default side orientation.
  97791. * @param orientation the orientation to value to attempt to get
  97792. * @returns the default orientation
  97793. * @hidden
  97794. */
  97795. static _GetDefaultSideOrientation(orientation?: number): number;
  97796. private _internalMeshDataInfo;
  97797. /**
  97798. * An event triggered before rendering the mesh
  97799. */
  97800. get onBeforeRenderObservable(): Observable<Mesh>;
  97801. /**
  97802. * An event triggered before binding the mesh
  97803. */
  97804. get onBeforeBindObservable(): Observable<Mesh>;
  97805. /**
  97806. * An event triggered after rendering the mesh
  97807. */
  97808. get onAfterRenderObservable(): Observable<Mesh>;
  97809. /**
  97810. * An event triggered before drawing the mesh
  97811. */
  97812. get onBeforeDrawObservable(): Observable<Mesh>;
  97813. private _onBeforeDrawObserver;
  97814. /**
  97815. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97816. */
  97817. set onBeforeDraw(callback: () => void);
  97818. get hasInstances(): boolean;
  97819. /**
  97820. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97821. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97822. */
  97823. delayLoadState: number;
  97824. /**
  97825. * Gets the list of instances created from this mesh
  97826. * it is not supposed to be modified manually.
  97827. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97828. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97829. */
  97830. instances: InstancedMesh[];
  97831. /**
  97832. * Gets the file containing delay loading data for this mesh
  97833. */
  97834. delayLoadingFile: string;
  97835. /** @hidden */
  97836. _binaryInfo: any;
  97837. /**
  97838. * User defined function used to change how LOD level selection is done
  97839. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97840. */
  97841. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97842. /**
  97843. * Gets or sets the morph target manager
  97844. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97845. */
  97846. get morphTargetManager(): Nullable<MorphTargetManager>;
  97847. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97848. /** @hidden */
  97849. _creationDataStorage: Nullable<_CreationDataStorage>;
  97850. /** @hidden */
  97851. _geometry: Nullable<Geometry>;
  97852. /** @hidden */
  97853. _delayInfo: Array<string>;
  97854. /** @hidden */
  97855. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97856. /** @hidden */
  97857. _instanceDataStorage: _InstanceDataStorage;
  97858. private _effectiveMaterial;
  97859. /** @hidden */
  97860. _shouldGenerateFlatShading: boolean;
  97861. /** @hidden */
  97862. _originalBuilderSideOrientation: number;
  97863. /**
  97864. * Use this property to change the original side orientation defined at construction time
  97865. */
  97866. overrideMaterialSideOrientation: Nullable<number>;
  97867. /**
  97868. * Gets the source mesh (the one used to clone this one from)
  97869. */
  97870. get source(): Nullable<Mesh>;
  97871. /**
  97872. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97873. */
  97874. get isUnIndexed(): boolean;
  97875. set isUnIndexed(value: boolean);
  97876. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97877. get worldMatrixInstancedBuffer(): Float32Array;
  97878. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97879. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97880. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97881. /**
  97882. * @constructor
  97883. * @param name The value used by scene.getMeshByName() to do a lookup.
  97884. * @param scene The scene to add this mesh to.
  97885. * @param parent The parent of this mesh, if it has one
  97886. * @param source An optional Mesh from which geometry is shared, cloned.
  97887. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97888. * When false, achieved by calling a clone(), also passing False.
  97889. * This will make creation of children, recursive.
  97890. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97891. */
  97892. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97893. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97894. doNotInstantiate: boolean;
  97895. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97896. /**
  97897. * Gets the class name
  97898. * @returns the string "Mesh".
  97899. */
  97900. getClassName(): string;
  97901. /** @hidden */
  97902. get _isMesh(): boolean;
  97903. /**
  97904. * Returns a description of this mesh
  97905. * @param fullDetails define if full details about this mesh must be used
  97906. * @returns a descriptive string representing this mesh
  97907. */
  97908. toString(fullDetails?: boolean): string;
  97909. /** @hidden */
  97910. _unBindEffect(): void;
  97911. /**
  97912. * Gets a boolean indicating if this mesh has LOD
  97913. */
  97914. get hasLODLevels(): boolean;
  97915. /**
  97916. * Gets the list of MeshLODLevel associated with the current mesh
  97917. * @returns an array of MeshLODLevel
  97918. */
  97919. getLODLevels(): MeshLODLevel[];
  97920. private _sortLODLevels;
  97921. /**
  97922. * Add a mesh as LOD level triggered at the given distance.
  97923. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97924. * @param distance The distance from the center of the object to show this level
  97925. * @param mesh The mesh to be added as LOD level (can be null)
  97926. * @return This mesh (for chaining)
  97927. */
  97928. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97929. /**
  97930. * Returns the LOD level mesh at the passed distance or null if not found.
  97931. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97932. * @param distance The distance from the center of the object to show this level
  97933. * @returns a Mesh or `null`
  97934. */
  97935. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97936. /**
  97937. * Remove a mesh from the LOD array
  97938. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97939. * @param mesh defines the mesh to be removed
  97940. * @return This mesh (for chaining)
  97941. */
  97942. removeLODLevel(mesh: Mesh): Mesh;
  97943. /**
  97944. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97945. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97946. * @param camera defines the camera to use to compute distance
  97947. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97948. * @return This mesh (for chaining)
  97949. */
  97950. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97951. /**
  97952. * Gets the mesh internal Geometry object
  97953. */
  97954. get geometry(): Nullable<Geometry>;
  97955. /**
  97956. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97957. * @returns the total number of vertices
  97958. */
  97959. getTotalVertices(): number;
  97960. /**
  97961. * Returns the content of an associated vertex buffer
  97962. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97963. * - VertexBuffer.PositionKind
  97964. * - VertexBuffer.UVKind
  97965. * - VertexBuffer.UV2Kind
  97966. * - VertexBuffer.UV3Kind
  97967. * - VertexBuffer.UV4Kind
  97968. * - VertexBuffer.UV5Kind
  97969. * - VertexBuffer.UV6Kind
  97970. * - VertexBuffer.ColorKind
  97971. * - VertexBuffer.MatricesIndicesKind
  97972. * - VertexBuffer.MatricesIndicesExtraKind
  97973. * - VertexBuffer.MatricesWeightsKind
  97974. * - VertexBuffer.MatricesWeightsExtraKind
  97975. * @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
  97976. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97977. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97978. */
  97979. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97980. /**
  97981. * Returns the mesh VertexBuffer object from the requested `kind`
  97982. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97983. * - VertexBuffer.PositionKind
  97984. * - VertexBuffer.NormalKind
  97985. * - VertexBuffer.UVKind
  97986. * - VertexBuffer.UV2Kind
  97987. * - VertexBuffer.UV3Kind
  97988. * - VertexBuffer.UV4Kind
  97989. * - VertexBuffer.UV5Kind
  97990. * - VertexBuffer.UV6Kind
  97991. * - VertexBuffer.ColorKind
  97992. * - VertexBuffer.MatricesIndicesKind
  97993. * - VertexBuffer.MatricesIndicesExtraKind
  97994. * - VertexBuffer.MatricesWeightsKind
  97995. * - VertexBuffer.MatricesWeightsExtraKind
  97996. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97997. */
  97998. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97999. /**
  98000. * Tests if a specific vertex buffer is associated with this mesh
  98001. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  98002. * - VertexBuffer.PositionKind
  98003. * - VertexBuffer.NormalKind
  98004. * - VertexBuffer.UVKind
  98005. * - VertexBuffer.UV2Kind
  98006. * - VertexBuffer.UV3Kind
  98007. * - VertexBuffer.UV4Kind
  98008. * - VertexBuffer.UV5Kind
  98009. * - VertexBuffer.UV6Kind
  98010. * - VertexBuffer.ColorKind
  98011. * - VertexBuffer.MatricesIndicesKind
  98012. * - VertexBuffer.MatricesIndicesExtraKind
  98013. * - VertexBuffer.MatricesWeightsKind
  98014. * - VertexBuffer.MatricesWeightsExtraKind
  98015. * @returns a boolean
  98016. */
  98017. isVerticesDataPresent(kind: string): boolean;
  98018. /**
  98019. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  98020. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  98021. * - VertexBuffer.PositionKind
  98022. * - VertexBuffer.UVKind
  98023. * - VertexBuffer.UV2Kind
  98024. * - VertexBuffer.UV3Kind
  98025. * - VertexBuffer.UV4Kind
  98026. * - VertexBuffer.UV5Kind
  98027. * - VertexBuffer.UV6Kind
  98028. * - VertexBuffer.ColorKind
  98029. * - VertexBuffer.MatricesIndicesKind
  98030. * - VertexBuffer.MatricesIndicesExtraKind
  98031. * - VertexBuffer.MatricesWeightsKind
  98032. * - VertexBuffer.MatricesWeightsExtraKind
  98033. * @returns a boolean
  98034. */
  98035. isVertexBufferUpdatable(kind: string): boolean;
  98036. /**
  98037. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  98038. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98039. * - VertexBuffer.PositionKind
  98040. * - VertexBuffer.NormalKind
  98041. * - VertexBuffer.UVKind
  98042. * - VertexBuffer.UV2Kind
  98043. * - VertexBuffer.UV3Kind
  98044. * - VertexBuffer.UV4Kind
  98045. * - VertexBuffer.UV5Kind
  98046. * - VertexBuffer.UV6Kind
  98047. * - VertexBuffer.ColorKind
  98048. * - VertexBuffer.MatricesIndicesKind
  98049. * - VertexBuffer.MatricesIndicesExtraKind
  98050. * - VertexBuffer.MatricesWeightsKind
  98051. * - VertexBuffer.MatricesWeightsExtraKind
  98052. * @returns an array of strings
  98053. */
  98054. getVerticesDataKinds(): string[];
  98055. /**
  98056. * Returns a positive integer : the total number of indices in this mesh geometry.
  98057. * @returns the numner of indices or zero if the mesh has no geometry.
  98058. */
  98059. getTotalIndices(): number;
  98060. /**
  98061. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  98062. * @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.
  98063. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98064. * @returns the indices array or an empty array if the mesh has no geometry
  98065. */
  98066. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98067. get isBlocked(): boolean;
  98068. /**
  98069. * Determine if the current mesh is ready to be rendered
  98070. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  98071. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  98072. * @returns true if all associated assets are ready (material, textures, shaders)
  98073. */
  98074. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  98075. /**
  98076. * 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.
  98077. */
  98078. get areNormalsFrozen(): boolean;
  98079. /**
  98080. * 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.
  98081. * @returns the current mesh
  98082. */
  98083. freezeNormals(): Mesh;
  98084. /**
  98085. * 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
  98086. * @returns the current mesh
  98087. */
  98088. unfreezeNormals(): Mesh;
  98089. /**
  98090. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  98091. */
  98092. set overridenInstanceCount(count: number);
  98093. /** @hidden */
  98094. _preActivate(): Mesh;
  98095. /** @hidden */
  98096. _preActivateForIntermediateRendering(renderId: number): Mesh;
  98097. /** @hidden */
  98098. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  98099. /**
  98100. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98101. * This means the mesh underlying bounding box and sphere are recomputed.
  98102. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98103. * @returns the current mesh
  98104. */
  98105. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  98106. /** @hidden */
  98107. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  98108. /**
  98109. * This function will subdivide the mesh into multiple submeshes
  98110. * @param count defines the expected number of submeshes
  98111. */
  98112. subdivide(count: number): void;
  98113. /**
  98114. * Copy a FloatArray into a specific associated vertex buffer
  98115. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98116. * - VertexBuffer.PositionKind
  98117. * - VertexBuffer.UVKind
  98118. * - VertexBuffer.UV2Kind
  98119. * - VertexBuffer.UV3Kind
  98120. * - VertexBuffer.UV4Kind
  98121. * - VertexBuffer.UV5Kind
  98122. * - VertexBuffer.UV6Kind
  98123. * - VertexBuffer.ColorKind
  98124. * - VertexBuffer.MatricesIndicesKind
  98125. * - VertexBuffer.MatricesIndicesExtraKind
  98126. * - VertexBuffer.MatricesWeightsKind
  98127. * - VertexBuffer.MatricesWeightsExtraKind
  98128. * @param data defines the data source
  98129. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98130. * @param stride defines the data stride size (can be null)
  98131. * @returns the current mesh
  98132. */
  98133. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  98134. /**
  98135. * Delete a vertex buffer associated with this mesh
  98136. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  98137. * - VertexBuffer.PositionKind
  98138. * - VertexBuffer.UVKind
  98139. * - VertexBuffer.UV2Kind
  98140. * - VertexBuffer.UV3Kind
  98141. * - VertexBuffer.UV4Kind
  98142. * - VertexBuffer.UV5Kind
  98143. * - VertexBuffer.UV6Kind
  98144. * - VertexBuffer.ColorKind
  98145. * - VertexBuffer.MatricesIndicesKind
  98146. * - VertexBuffer.MatricesIndicesExtraKind
  98147. * - VertexBuffer.MatricesWeightsKind
  98148. * - VertexBuffer.MatricesWeightsExtraKind
  98149. */
  98150. removeVerticesData(kind: string): void;
  98151. /**
  98152. * Flags an associated vertex buffer as updatable
  98153. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  98154. * - VertexBuffer.PositionKind
  98155. * - VertexBuffer.UVKind
  98156. * - VertexBuffer.UV2Kind
  98157. * - VertexBuffer.UV3Kind
  98158. * - VertexBuffer.UV4Kind
  98159. * - VertexBuffer.UV5Kind
  98160. * - VertexBuffer.UV6Kind
  98161. * - VertexBuffer.ColorKind
  98162. * - VertexBuffer.MatricesIndicesKind
  98163. * - VertexBuffer.MatricesIndicesExtraKind
  98164. * - VertexBuffer.MatricesWeightsKind
  98165. * - VertexBuffer.MatricesWeightsExtraKind
  98166. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98167. */
  98168. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  98169. /**
  98170. * Sets the mesh global Vertex Buffer
  98171. * @param buffer defines the buffer to use
  98172. * @returns the current mesh
  98173. */
  98174. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  98175. /**
  98176. * Update a specific associated vertex buffer
  98177. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98178. * - VertexBuffer.PositionKind
  98179. * - VertexBuffer.UVKind
  98180. * - VertexBuffer.UV2Kind
  98181. * - VertexBuffer.UV3Kind
  98182. * - VertexBuffer.UV4Kind
  98183. * - VertexBuffer.UV5Kind
  98184. * - VertexBuffer.UV6Kind
  98185. * - VertexBuffer.ColorKind
  98186. * - VertexBuffer.MatricesIndicesKind
  98187. * - VertexBuffer.MatricesIndicesExtraKind
  98188. * - VertexBuffer.MatricesWeightsKind
  98189. * - VertexBuffer.MatricesWeightsExtraKind
  98190. * @param data defines the data source
  98191. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98192. * @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)
  98193. * @returns the current mesh
  98194. */
  98195. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98196. /**
  98197. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  98198. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  98199. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  98200. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  98201. * @returns the current mesh
  98202. */
  98203. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  98204. /**
  98205. * Creates a un-shared specific occurence of the geometry for the mesh.
  98206. * @returns the current mesh
  98207. */
  98208. makeGeometryUnique(): Mesh;
  98209. /**
  98210. * Set the index buffer of this mesh
  98211. * @param indices defines the source data
  98212. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  98213. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  98214. * @returns the current mesh
  98215. */
  98216. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  98217. /**
  98218. * Update the current index buffer
  98219. * @param indices defines the source data
  98220. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98221. * @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)
  98222. * @returns the current mesh
  98223. */
  98224. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98225. /**
  98226. * Invert the geometry to move from a right handed system to a left handed one.
  98227. * @returns the current mesh
  98228. */
  98229. toLeftHanded(): Mesh;
  98230. /** @hidden */
  98231. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98232. /** @hidden */
  98233. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98234. /**
  98235. * Registers for this mesh a javascript function called just before the rendering process
  98236. * @param func defines the function to call before rendering this mesh
  98237. * @returns the current mesh
  98238. */
  98239. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98240. /**
  98241. * Disposes a previously registered javascript function called before the rendering
  98242. * @param func defines the function to remove
  98243. * @returns the current mesh
  98244. */
  98245. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98246. /**
  98247. * Registers for this mesh a javascript function called just after the rendering is complete
  98248. * @param func defines the function to call after rendering this mesh
  98249. * @returns the current mesh
  98250. */
  98251. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98252. /**
  98253. * Disposes a previously registered javascript function called after the rendering.
  98254. * @param func defines the function to remove
  98255. * @returns the current mesh
  98256. */
  98257. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98258. /** @hidden */
  98259. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  98260. /** @hidden */
  98261. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  98262. /** @hidden */
  98263. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  98264. /** @hidden */
  98265. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  98266. /** @hidden */
  98267. _rebuild(): void;
  98268. /** @hidden */
  98269. _freeze(): void;
  98270. /** @hidden */
  98271. _unFreeze(): void;
  98272. /**
  98273. * 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
  98274. * @param subMesh defines the subMesh to render
  98275. * @param enableAlphaMode defines if alpha mode can be changed
  98276. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  98277. * @returns the current mesh
  98278. */
  98279. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  98280. private _onBeforeDraw;
  98281. /**
  98282. * Renormalize the mesh and patch it up if there are no weights
  98283. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98284. * However in the case of zero weights then we set just a single influence to 1.
  98285. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98286. */
  98287. cleanMatrixWeights(): void;
  98288. private normalizeSkinFourWeights;
  98289. private normalizeSkinWeightsAndExtra;
  98290. /**
  98291. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98292. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98293. * the user know there was an issue with importing the mesh
  98294. * @returns a validation object with skinned, valid and report string
  98295. */
  98296. validateSkinning(): {
  98297. skinned: boolean;
  98298. valid: boolean;
  98299. report: string;
  98300. };
  98301. /** @hidden */
  98302. _checkDelayState(): Mesh;
  98303. private _queueLoad;
  98304. /**
  98305. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98306. * A mesh is in the frustum if its bounding box intersects the frustum
  98307. * @param frustumPlanes defines the frustum to test
  98308. * @returns true if the mesh is in the frustum planes
  98309. */
  98310. isInFrustum(frustumPlanes: Plane[]): boolean;
  98311. /**
  98312. * Sets the mesh material by the material or multiMaterial `id` property
  98313. * @param id is a string identifying the material or the multiMaterial
  98314. * @returns the current mesh
  98315. */
  98316. setMaterialByID(id: string): Mesh;
  98317. /**
  98318. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98319. * @returns an array of IAnimatable
  98320. */
  98321. getAnimatables(): IAnimatable[];
  98322. /**
  98323. * Modifies the mesh geometry according to the passed transformation matrix.
  98324. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98325. * The mesh normals are modified using the same transformation.
  98326. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98327. * @param transform defines the transform matrix to use
  98328. * @see http://doc.babylonjs.com/resources/baking_transformations
  98329. * @returns the current mesh
  98330. */
  98331. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98332. /**
  98333. * Modifies the mesh geometry according to its own current World Matrix.
  98334. * The mesh World Matrix is then reset.
  98335. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98336. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98337. * @see http://doc.babylonjs.com/resources/baking_transformations
  98338. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98339. * @returns the current mesh
  98340. */
  98341. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98342. /** @hidden */
  98343. get _positions(): Nullable<Vector3[]>;
  98344. /** @hidden */
  98345. _resetPointsArrayCache(): Mesh;
  98346. /** @hidden */
  98347. _generatePointsArray(): boolean;
  98348. /**
  98349. * Returns a new Mesh object generated from the current mesh properties.
  98350. * This method must not get confused with createInstance()
  98351. * @param name is a string, the name given to the new mesh
  98352. * @param newParent can be any Node object (default `null`)
  98353. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98354. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98355. * @returns a new mesh
  98356. */
  98357. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98358. /**
  98359. * Releases resources associated with this mesh.
  98360. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98361. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98362. */
  98363. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98364. /** @hidden */
  98365. _disposeInstanceSpecificData(): void;
  98366. /**
  98367. * Modifies the mesh geometry according to a displacement map.
  98368. * 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.
  98369. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98370. * @param url is a string, the URL from the image file is to be downloaded.
  98371. * @param minHeight is the lower limit of the displacement.
  98372. * @param maxHeight is the upper limit of the displacement.
  98373. * @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.
  98374. * @param uvOffset is an optional vector2 used to offset UV.
  98375. * @param uvScale is an optional vector2 used to scale UV.
  98376. * @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.
  98377. * @returns the Mesh.
  98378. */
  98379. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98380. /**
  98381. * Modifies the mesh geometry according to a displacementMap buffer.
  98382. * 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.
  98383. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98384. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98385. * @param heightMapWidth is the width of the buffer image.
  98386. * @param heightMapHeight is the height of the buffer image.
  98387. * @param minHeight is the lower limit of the displacement.
  98388. * @param maxHeight is the upper limit of the displacement.
  98389. * @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.
  98390. * @param uvOffset is an optional vector2 used to offset UV.
  98391. * @param uvScale is an optional vector2 used to scale UV.
  98392. * @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.
  98393. * @returns the Mesh.
  98394. */
  98395. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98396. /**
  98397. * Modify the mesh to get a flat shading rendering.
  98398. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98399. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98400. * @returns current mesh
  98401. */
  98402. convertToFlatShadedMesh(): Mesh;
  98403. /**
  98404. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98405. * In other words, more vertices, no more indices and a single bigger VBO.
  98406. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98407. * @returns current mesh
  98408. */
  98409. convertToUnIndexedMesh(): Mesh;
  98410. /**
  98411. * Inverses facet orientations.
  98412. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98413. * @param flipNormals will also inverts the normals
  98414. * @returns current mesh
  98415. */
  98416. flipFaces(flipNormals?: boolean): Mesh;
  98417. /**
  98418. * Increase the number of facets and hence vertices in a mesh
  98419. * Vertex normals are interpolated from existing vertex normals
  98420. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98421. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98422. */
  98423. increaseVertices(numberPerEdge: number): void;
  98424. /**
  98425. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98426. * This will undo any application of covertToFlatShadedMesh
  98427. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98428. */
  98429. forceSharedVertices(): void;
  98430. /** @hidden */
  98431. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98432. /** @hidden */
  98433. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98434. /**
  98435. * Creates a new InstancedMesh object from the mesh model.
  98436. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98437. * @param name defines the name of the new instance
  98438. * @returns a new InstancedMesh
  98439. */
  98440. createInstance(name: string): InstancedMesh;
  98441. /**
  98442. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98443. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98444. * @returns the current mesh
  98445. */
  98446. synchronizeInstances(): Mesh;
  98447. /**
  98448. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98449. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98450. * This should be used together with the simplification to avoid disappearing triangles.
  98451. * @param successCallback an optional success callback to be called after the optimization finished.
  98452. * @returns the current mesh
  98453. */
  98454. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98455. /**
  98456. * Serialize current mesh
  98457. * @param serializationObject defines the object which will receive the serialization data
  98458. */
  98459. serialize(serializationObject: any): void;
  98460. /** @hidden */
  98461. _syncGeometryWithMorphTargetManager(): void;
  98462. /** @hidden */
  98463. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98464. /**
  98465. * Returns a new Mesh object parsed from the source provided.
  98466. * @param parsedMesh is the source
  98467. * @param scene defines the hosting scene
  98468. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98469. * @returns a new Mesh
  98470. */
  98471. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98472. /**
  98473. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98474. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98475. * @param name defines the name of the mesh to create
  98476. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98477. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98478. * @param closePath creates a seam between the first and the last points of each path of the path array
  98479. * @param offset is taken in account only if the `pathArray` is containing a single path
  98480. * @param scene defines the hosting scene
  98481. * @param updatable defines if the mesh must be flagged as updatable
  98482. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98483. * @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)
  98484. * @returns a new Mesh
  98485. */
  98486. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98487. /**
  98488. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98489. * @param name defines the name of the mesh to create
  98490. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98491. * @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
  98492. * @param scene defines the hosting scene
  98493. * @param updatable defines if the mesh must be flagged as updatable
  98494. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98495. * @returns a new Mesh
  98496. */
  98497. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98498. /**
  98499. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98500. * @param name defines the name of the mesh to create
  98501. * @param size sets the size (float) of each box side (default 1)
  98502. * @param scene defines the hosting scene
  98503. * @param updatable defines if the mesh must be flagged as updatable
  98504. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98505. * @returns a new Mesh
  98506. */
  98507. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98508. /**
  98509. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98510. * @param name defines the name of the mesh to create
  98511. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98512. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98513. * @param scene defines the hosting scene
  98514. * @param updatable defines if the mesh must be flagged as updatable
  98515. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98516. * @returns a new Mesh
  98517. */
  98518. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98519. /**
  98520. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98521. * @param name defines the name of the mesh to create
  98522. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98523. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98524. * @param scene defines the hosting scene
  98525. * @returns a new Mesh
  98526. */
  98527. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98528. /**
  98529. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98530. * @param name defines the name of the mesh to create
  98531. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98532. * @param diameterTop set the top cap diameter (floats, default 1)
  98533. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98534. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98535. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98536. * @param scene defines the hosting scene
  98537. * @param updatable defines if the mesh must be flagged as updatable
  98538. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98539. * @returns a new Mesh
  98540. */
  98541. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98542. /**
  98543. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98544. * @param name defines the name of the mesh to create
  98545. * @param diameter sets the diameter size (float) of the torus (default 1)
  98546. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98547. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98548. * @param scene defines the hosting scene
  98549. * @param updatable defines if the mesh must be flagged as updatable
  98550. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98551. * @returns a new Mesh
  98552. */
  98553. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98554. /**
  98555. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98556. * @param name defines the name of the mesh to create
  98557. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98558. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98559. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98560. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98561. * @param p the number of windings on X axis (positive integers, default 2)
  98562. * @param q the number of windings on Y axis (positive integers, default 3)
  98563. * @param scene defines the hosting scene
  98564. * @param updatable defines if the mesh must be flagged as updatable
  98565. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98566. * @returns a new Mesh
  98567. */
  98568. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98569. /**
  98570. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98571. * @param name defines the name of the mesh to create
  98572. * @param points is an array successive Vector3
  98573. * @param scene defines the hosting scene
  98574. * @param updatable defines if the mesh must be flagged as updatable
  98575. * @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).
  98576. * @returns a new Mesh
  98577. */
  98578. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98579. /**
  98580. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98581. * @param name defines the name of the mesh to create
  98582. * @param points is an array successive Vector3
  98583. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98584. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98585. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98586. * @param scene defines the hosting scene
  98587. * @param updatable defines if the mesh must be flagged as updatable
  98588. * @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)
  98589. * @returns a new Mesh
  98590. */
  98591. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98592. /**
  98593. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98594. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98595. * 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.
  98596. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98597. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98598. * Remember you can only change the shape positions, not their number when updating a polygon.
  98599. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98600. * @param name defines the name of the mesh to create
  98601. * @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
  98602. * @param scene defines the hosting scene
  98603. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98604. * @param updatable defines if the mesh must be flagged as updatable
  98605. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98606. * @param earcutInjection can be used to inject your own earcut reference
  98607. * @returns a new Mesh
  98608. */
  98609. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98610. /**
  98611. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98612. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98613. * @param name defines the name of the mesh to create
  98614. * @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
  98615. * @param depth defines the height of extrusion
  98616. * @param scene defines the hosting scene
  98617. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98618. * @param updatable defines if the mesh must be flagged as updatable
  98619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98620. * @param earcutInjection can be used to inject your own earcut reference
  98621. * @returns a new Mesh
  98622. */
  98623. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98624. /**
  98625. * Creates an extruded shape mesh.
  98626. * 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
  98627. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98628. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98629. * @param name defines the name of the mesh to create
  98630. * @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
  98631. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98632. * @param scale is the value to scale the shape
  98633. * @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
  98634. * @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
  98635. * @param scene defines the hosting scene
  98636. * @param updatable defines if the mesh must be flagged as updatable
  98637. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98638. * @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)
  98639. * @returns a new Mesh
  98640. */
  98641. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98642. /**
  98643. * Creates an custom extruded shape mesh.
  98644. * The custom extrusion is a parametric shape.
  98645. * It has no predefined shape. Its final shape will depend on the input parameters.
  98646. * Please consider using the same method from the MeshBuilder class instead
  98647. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98648. * @param name defines the name of the mesh to create
  98649. * @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
  98650. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98651. * @param scaleFunction is a custom Javascript function called on each path point
  98652. * @param rotationFunction is a custom Javascript function called on each path point
  98653. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98654. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98655. * @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
  98656. * @param scene defines the hosting scene
  98657. * @param updatable defines if the mesh must be flagged as updatable
  98658. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98659. * @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)
  98660. * @returns a new Mesh
  98661. */
  98662. 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;
  98663. /**
  98664. * Creates lathe mesh.
  98665. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98666. * Please consider using the same method from the MeshBuilder class instead
  98667. * @param name defines the name of the mesh to create
  98668. * @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
  98669. * @param radius is the radius value of the lathe
  98670. * @param tessellation is the side number of the lathe.
  98671. * @param scene defines the hosting scene
  98672. * @param updatable defines if the mesh must be flagged as updatable
  98673. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98674. * @returns a new Mesh
  98675. */
  98676. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98677. /**
  98678. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98679. * @param name defines the name of the mesh to create
  98680. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98681. * @param scene defines the hosting scene
  98682. * @param updatable defines if the mesh must be flagged as updatable
  98683. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98684. * @returns a new Mesh
  98685. */
  98686. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98687. /**
  98688. * Creates a ground mesh.
  98689. * Please consider using the same method from the MeshBuilder class instead
  98690. * @param name defines the name of the mesh to create
  98691. * @param width set the width of the ground
  98692. * @param height set the height of the ground
  98693. * @param subdivisions sets the number of subdivisions per side
  98694. * @param scene defines the hosting scene
  98695. * @param updatable defines if the mesh must be flagged as updatable
  98696. * @returns a new Mesh
  98697. */
  98698. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98699. /**
  98700. * Creates a tiled ground mesh.
  98701. * Please consider using the same method from the MeshBuilder class instead
  98702. * @param name defines the name of the mesh to create
  98703. * @param xmin set the ground minimum X coordinate
  98704. * @param zmin set the ground minimum Y coordinate
  98705. * @param xmax set the ground maximum X coordinate
  98706. * @param zmax set the ground maximum Z coordinate
  98707. * @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
  98708. * @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
  98709. * @param scene defines the hosting scene
  98710. * @param updatable defines if the mesh must be flagged as updatable
  98711. * @returns a new Mesh
  98712. */
  98713. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98714. w: number;
  98715. h: number;
  98716. }, precision: {
  98717. w: number;
  98718. h: number;
  98719. }, scene: Scene, updatable?: boolean): Mesh;
  98720. /**
  98721. * Creates a ground mesh from a height map.
  98722. * Please consider using the same method from the MeshBuilder class instead
  98723. * @see http://doc.babylonjs.com/babylon101/height_map
  98724. * @param name defines the name of the mesh to create
  98725. * @param url sets the URL of the height map image resource
  98726. * @param width set the ground width size
  98727. * @param height set the ground height size
  98728. * @param subdivisions sets the number of subdivision per side
  98729. * @param minHeight is the minimum altitude on the ground
  98730. * @param maxHeight is the maximum altitude on the ground
  98731. * @param scene defines the hosting scene
  98732. * @param updatable defines if the mesh must be flagged as updatable
  98733. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98734. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98735. * @returns a new Mesh
  98736. */
  98737. 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;
  98738. /**
  98739. * Creates a tube mesh.
  98740. * The tube is a parametric shape.
  98741. * It has no predefined shape. Its final shape will depend on the input parameters.
  98742. * Please consider using the same method from the MeshBuilder class instead
  98743. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98744. * @param name defines the name of the mesh to create
  98745. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98746. * @param radius sets the tube radius size
  98747. * @param tessellation is the number of sides on the tubular surface
  98748. * @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
  98749. * @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
  98750. * @param scene defines the hosting scene
  98751. * @param updatable defines if the mesh must be flagged as updatable
  98752. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98753. * @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)
  98754. * @returns a new Mesh
  98755. */
  98756. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98757. (i: number, distance: number): number;
  98758. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98759. /**
  98760. * Creates a polyhedron mesh.
  98761. * Please consider using the same method from the MeshBuilder class instead.
  98762. * * 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
  98763. * * The parameter `size` (positive float, default 1) sets the polygon size
  98764. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98765. * * 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`
  98766. * * 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
  98767. * * 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)`)
  98768. * * 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
  98769. * * 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
  98770. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98771. * * If you create a double-sided mesh, you can choose what parts of 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
  98772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98773. * @param name defines the name of the mesh to create
  98774. * @param options defines the options used to create the mesh
  98775. * @param scene defines the hosting scene
  98776. * @returns a new Mesh
  98777. */
  98778. static CreatePolyhedron(name: string, options: {
  98779. type?: number;
  98780. size?: number;
  98781. sizeX?: number;
  98782. sizeY?: number;
  98783. sizeZ?: number;
  98784. custom?: any;
  98785. faceUV?: Vector4[];
  98786. faceColors?: Color4[];
  98787. updatable?: boolean;
  98788. sideOrientation?: number;
  98789. }, scene: Scene): Mesh;
  98790. /**
  98791. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98792. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98793. * * 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`)
  98794. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98795. * * 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
  98796. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98797. * * If you create a double-sided mesh, you can choose what parts of 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
  98798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98799. * @param name defines the name of the mesh
  98800. * @param options defines the options used to create the mesh
  98801. * @param scene defines the hosting scene
  98802. * @returns a new Mesh
  98803. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98804. */
  98805. static CreateIcoSphere(name: string, options: {
  98806. radius?: number;
  98807. flat?: boolean;
  98808. subdivisions?: number;
  98809. sideOrientation?: number;
  98810. updatable?: boolean;
  98811. }, scene: Scene): Mesh;
  98812. /**
  98813. * Creates a decal mesh.
  98814. * Please consider using the same method from the MeshBuilder class instead.
  98815. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98816. * @param name defines the name of the mesh
  98817. * @param sourceMesh defines the mesh receiving the decal
  98818. * @param position sets the position of the decal in world coordinates
  98819. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98820. * @param size sets the decal scaling
  98821. * @param angle sets the angle to rotate the decal
  98822. * @returns a new Mesh
  98823. */
  98824. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98825. /**
  98826. * Prepare internal position array for software CPU skinning
  98827. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98828. */
  98829. setPositionsForCPUSkinning(): Float32Array;
  98830. /**
  98831. * Prepare internal normal array for software CPU skinning
  98832. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98833. */
  98834. setNormalsForCPUSkinning(): Float32Array;
  98835. /**
  98836. * Updates the vertex buffer by applying transformation from the bones
  98837. * @param skeleton defines the skeleton to apply to current mesh
  98838. * @returns the current mesh
  98839. */
  98840. applySkeleton(skeleton: Skeleton): Mesh;
  98841. /**
  98842. * 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
  98843. * @param meshes defines the list of meshes to scan
  98844. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98845. */
  98846. static MinMax(meshes: AbstractMesh[]): {
  98847. min: Vector3;
  98848. max: Vector3;
  98849. };
  98850. /**
  98851. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98852. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98853. * @returns a vector3
  98854. */
  98855. static Center(meshesOrMinMaxVector: {
  98856. min: Vector3;
  98857. max: Vector3;
  98858. } | AbstractMesh[]): Vector3;
  98859. /**
  98860. * Merge the array of meshes into a single mesh for performance reasons.
  98861. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98862. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98863. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98864. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98865. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98866. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98867. * @returns a new mesh
  98868. */
  98869. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98870. /** @hidden */
  98871. addInstance(instance: InstancedMesh): void;
  98872. /** @hidden */
  98873. removeInstance(instance: InstancedMesh): void;
  98874. }
  98875. }
  98876. declare module BABYLON {
  98877. /**
  98878. * This is the base class of all the camera used in the application.
  98879. * @see http://doc.babylonjs.com/features/cameras
  98880. */
  98881. export class Camera extends Node {
  98882. /** @hidden */
  98883. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98884. /**
  98885. * This is the default projection mode used by the cameras.
  98886. * It helps recreating a feeling of perspective and better appreciate depth.
  98887. * This is the best way to simulate real life cameras.
  98888. */
  98889. static readonly PERSPECTIVE_CAMERA: number;
  98890. /**
  98891. * This helps creating camera with an orthographic mode.
  98892. * 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.
  98893. */
  98894. static readonly ORTHOGRAPHIC_CAMERA: number;
  98895. /**
  98896. * This is the default FOV mode for perspective cameras.
  98897. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98898. */
  98899. static readonly FOVMODE_VERTICAL_FIXED: number;
  98900. /**
  98901. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98902. */
  98903. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98904. /**
  98905. * This specifies ther is no need for a camera rig.
  98906. * Basically only one eye is rendered corresponding to the camera.
  98907. */
  98908. static readonly RIG_MODE_NONE: number;
  98909. /**
  98910. * Simulates a camera Rig with one blue eye and one red eye.
  98911. * This can be use with 3d blue and red glasses.
  98912. */
  98913. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98914. /**
  98915. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98916. */
  98917. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98918. /**
  98919. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98920. */
  98921. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98922. /**
  98923. * Defines that both eyes of the camera will be rendered over under each other.
  98924. */
  98925. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98926. /**
  98927. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98928. */
  98929. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98930. /**
  98931. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98932. */
  98933. static readonly RIG_MODE_VR: number;
  98934. /**
  98935. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98936. */
  98937. static readonly RIG_MODE_WEBVR: number;
  98938. /**
  98939. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98940. */
  98941. static readonly RIG_MODE_CUSTOM: number;
  98942. /**
  98943. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98944. */
  98945. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98946. /**
  98947. * Define the input manager associated with the camera.
  98948. */
  98949. inputs: CameraInputsManager<Camera>;
  98950. /** @hidden */
  98951. _position: Vector3;
  98952. /**
  98953. * Define the current local position of the camera in the scene
  98954. */
  98955. get position(): Vector3;
  98956. set position(newPosition: Vector3);
  98957. /**
  98958. * The vector the camera should consider as up.
  98959. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98960. */
  98961. upVector: Vector3;
  98962. /**
  98963. * Define the current limit on the left side for an orthographic camera
  98964. * In scene unit
  98965. */
  98966. orthoLeft: Nullable<number>;
  98967. /**
  98968. * Define the current limit on the right side for an orthographic camera
  98969. * In scene unit
  98970. */
  98971. orthoRight: Nullable<number>;
  98972. /**
  98973. * Define the current limit on the bottom side for an orthographic camera
  98974. * In scene unit
  98975. */
  98976. orthoBottom: Nullable<number>;
  98977. /**
  98978. * Define the current limit on the top side for an orthographic camera
  98979. * In scene unit
  98980. */
  98981. orthoTop: Nullable<number>;
  98982. /**
  98983. * Field Of View is set in Radians. (default is 0.8)
  98984. */
  98985. fov: number;
  98986. /**
  98987. * Define the minimum distance the camera can see from.
  98988. * This is important to note that the depth buffer are not infinite and the closer it starts
  98989. * the more your scene might encounter depth fighting issue.
  98990. */
  98991. minZ: number;
  98992. /**
  98993. * Define the maximum distance the camera can see to.
  98994. * This is important to note that the depth buffer are not infinite and the further it end
  98995. * the more your scene might encounter depth fighting issue.
  98996. */
  98997. maxZ: number;
  98998. /**
  98999. * Define the default inertia of the camera.
  99000. * This helps giving a smooth feeling to the camera movement.
  99001. */
  99002. inertia: number;
  99003. /**
  99004. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  99005. */
  99006. mode: number;
  99007. /**
  99008. * Define whether the camera is intermediate.
  99009. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  99010. */
  99011. isIntermediate: boolean;
  99012. /**
  99013. * Define the viewport of the camera.
  99014. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  99015. */
  99016. viewport: Viewport;
  99017. /**
  99018. * Restricts the camera to viewing objects with the same layerMask.
  99019. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  99020. */
  99021. layerMask: number;
  99022. /**
  99023. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  99024. */
  99025. fovMode: number;
  99026. /**
  99027. * Rig mode of the camera.
  99028. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  99029. * This is normally controlled byt the camera themselves as internal use.
  99030. */
  99031. cameraRigMode: number;
  99032. /**
  99033. * Defines the distance between both "eyes" in case of a RIG
  99034. */
  99035. interaxialDistance: number;
  99036. /**
  99037. * Defines if stereoscopic rendering is done side by side or over under.
  99038. */
  99039. isStereoscopicSideBySide: boolean;
  99040. /**
  99041. * 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
  99042. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  99043. * else in the scene. (Eg. security camera)
  99044. *
  99045. * 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)
  99046. */
  99047. customRenderTargets: RenderTargetTexture[];
  99048. /**
  99049. * When set, the camera will render to this render target instead of the default canvas
  99050. *
  99051. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  99052. */
  99053. outputRenderTarget: Nullable<RenderTargetTexture>;
  99054. /**
  99055. * Observable triggered when the camera view matrix has changed.
  99056. */
  99057. onViewMatrixChangedObservable: Observable<Camera>;
  99058. /**
  99059. * Observable triggered when the camera Projection matrix has changed.
  99060. */
  99061. onProjectionMatrixChangedObservable: Observable<Camera>;
  99062. /**
  99063. * Observable triggered when the inputs have been processed.
  99064. */
  99065. onAfterCheckInputsObservable: Observable<Camera>;
  99066. /**
  99067. * Observable triggered when reset has been called and applied to the camera.
  99068. */
  99069. onRestoreStateObservable: Observable<Camera>;
  99070. /**
  99071. * Is this camera a part of a rig system?
  99072. */
  99073. isRigCamera: boolean;
  99074. /**
  99075. * If isRigCamera set to true this will be set with the parent camera.
  99076. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  99077. */
  99078. rigParent?: Camera;
  99079. /** @hidden */
  99080. _cameraRigParams: any;
  99081. /** @hidden */
  99082. _rigCameras: Camera[];
  99083. /** @hidden */
  99084. _rigPostProcess: Nullable<PostProcess>;
  99085. protected _webvrViewMatrix: Matrix;
  99086. /** @hidden */
  99087. _skipRendering: boolean;
  99088. /** @hidden */
  99089. _projectionMatrix: Matrix;
  99090. /** @hidden */
  99091. _postProcesses: Nullable<PostProcess>[];
  99092. /** @hidden */
  99093. _activeMeshes: SmartArray<AbstractMesh>;
  99094. protected _globalPosition: Vector3;
  99095. /** @hidden */
  99096. _computedViewMatrix: Matrix;
  99097. private _doNotComputeProjectionMatrix;
  99098. private _transformMatrix;
  99099. private _frustumPlanes;
  99100. private _refreshFrustumPlanes;
  99101. private _storedFov;
  99102. private _stateStored;
  99103. /**
  99104. * Instantiates a new camera object.
  99105. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  99106. * @see http://doc.babylonjs.com/features/cameras
  99107. * @param name Defines the name of the camera in the scene
  99108. * @param position Defines the position of the camera
  99109. * @param scene Defines the scene the camera belongs too
  99110. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  99111. */
  99112. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99113. /**
  99114. * Store current camera state (fov, position, etc..)
  99115. * @returns the camera
  99116. */
  99117. storeState(): Camera;
  99118. /**
  99119. * Restores the camera state values if it has been stored. You must call storeState() first
  99120. */
  99121. protected _restoreStateValues(): boolean;
  99122. /**
  99123. * Restored camera state. You must call storeState() first.
  99124. * @returns true if restored and false otherwise
  99125. */
  99126. restoreState(): boolean;
  99127. /**
  99128. * Gets the class name of the camera.
  99129. * @returns the class name
  99130. */
  99131. getClassName(): string;
  99132. /** @hidden */
  99133. readonly _isCamera: boolean;
  99134. /**
  99135. * Gets a string representation of the camera useful for debug purpose.
  99136. * @param fullDetails Defines that a more verboe level of logging is required
  99137. * @returns the string representation
  99138. */
  99139. toString(fullDetails?: boolean): string;
  99140. /**
  99141. * Gets the current world space position of the camera.
  99142. */
  99143. get globalPosition(): Vector3;
  99144. /**
  99145. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  99146. * @returns the active meshe list
  99147. */
  99148. getActiveMeshes(): SmartArray<AbstractMesh>;
  99149. /**
  99150. * Check whether a mesh is part of the current active mesh list of the camera
  99151. * @param mesh Defines the mesh to check
  99152. * @returns true if active, false otherwise
  99153. */
  99154. isActiveMesh(mesh: Mesh): boolean;
  99155. /**
  99156. * Is this camera ready to be used/rendered
  99157. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  99158. * @return true if the camera is ready
  99159. */
  99160. isReady(completeCheck?: boolean): boolean;
  99161. /** @hidden */
  99162. _initCache(): void;
  99163. /** @hidden */
  99164. _updateCache(ignoreParentClass?: boolean): void;
  99165. /** @hidden */
  99166. _isSynchronized(): boolean;
  99167. /** @hidden */
  99168. _isSynchronizedViewMatrix(): boolean;
  99169. /** @hidden */
  99170. _isSynchronizedProjectionMatrix(): boolean;
  99171. /**
  99172. * Attach the input controls to a specific dom element to get the input from.
  99173. * @param element Defines the element the controls should be listened from
  99174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99175. */
  99176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99177. /**
  99178. * Detach the current controls from the specified dom element.
  99179. * @param element Defines the element to stop listening the inputs from
  99180. */
  99181. detachControl(element: HTMLElement): void;
  99182. /**
  99183. * Update the camera state according to the different inputs gathered during the frame.
  99184. */
  99185. update(): void;
  99186. /** @hidden */
  99187. _checkInputs(): void;
  99188. /** @hidden */
  99189. get rigCameras(): Camera[];
  99190. /**
  99191. * Gets the post process used by the rig cameras
  99192. */
  99193. get rigPostProcess(): Nullable<PostProcess>;
  99194. /**
  99195. * Internal, gets the first post proces.
  99196. * @returns the first post process to be run on this camera.
  99197. */
  99198. _getFirstPostProcess(): Nullable<PostProcess>;
  99199. private _cascadePostProcessesToRigCams;
  99200. /**
  99201. * Attach a post process to the camera.
  99202. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99203. * @param postProcess The post process to attach to the camera
  99204. * @param insertAt The position of the post process in case several of them are in use in the scene
  99205. * @returns the position the post process has been inserted at
  99206. */
  99207. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  99208. /**
  99209. * Detach a post process to the camera.
  99210. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99211. * @param postProcess The post process to detach from the camera
  99212. */
  99213. detachPostProcess(postProcess: PostProcess): void;
  99214. /**
  99215. * Gets the current world matrix of the camera
  99216. */
  99217. getWorldMatrix(): Matrix;
  99218. /** @hidden */
  99219. _getViewMatrix(): Matrix;
  99220. /**
  99221. * Gets the current view matrix of the camera.
  99222. * @param force forces the camera to recompute the matrix without looking at the cached state
  99223. * @returns the view matrix
  99224. */
  99225. getViewMatrix(force?: boolean): Matrix;
  99226. /**
  99227. * Freeze the projection matrix.
  99228. * It will prevent the cache check of the camera projection compute and can speed up perf
  99229. * if no parameter of the camera are meant to change
  99230. * @param projection Defines manually a projection if necessary
  99231. */
  99232. freezeProjectionMatrix(projection?: Matrix): void;
  99233. /**
  99234. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  99235. */
  99236. unfreezeProjectionMatrix(): void;
  99237. /**
  99238. * Gets the current projection matrix of the camera.
  99239. * @param force forces the camera to recompute the matrix without looking at the cached state
  99240. * @returns the projection matrix
  99241. */
  99242. getProjectionMatrix(force?: boolean): Matrix;
  99243. /**
  99244. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  99245. * @returns a Matrix
  99246. */
  99247. getTransformationMatrix(): Matrix;
  99248. private _updateFrustumPlanes;
  99249. /**
  99250. * Checks if a cullable object (mesh...) is in the camera frustum
  99251. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  99252. * @param target The object to check
  99253. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  99254. * @returns true if the object is in frustum otherwise false
  99255. */
  99256. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  99257. /**
  99258. * Checks if a cullable object (mesh...) is in the camera frustum
  99259. * Unlike isInFrustum this cheks the full bounding box
  99260. * @param target The object to check
  99261. * @returns true if the object is in frustum otherwise false
  99262. */
  99263. isCompletelyInFrustum(target: ICullable): boolean;
  99264. /**
  99265. * Gets a ray in the forward direction from the camera.
  99266. * @param length Defines the length of the ray to create
  99267. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  99268. * @param origin Defines the start point of the ray which defaults to the camera position
  99269. * @returns the forward ray
  99270. */
  99271. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  99272. /**
  99273. * Releases resources associated with this node.
  99274. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99275. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99276. */
  99277. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99278. /** @hidden */
  99279. _isLeftCamera: boolean;
  99280. /**
  99281. * Gets the left camera of a rig setup in case of Rigged Camera
  99282. */
  99283. get isLeftCamera(): boolean;
  99284. /** @hidden */
  99285. _isRightCamera: boolean;
  99286. /**
  99287. * Gets the right camera of a rig setup in case of Rigged Camera
  99288. */
  99289. get isRightCamera(): boolean;
  99290. /**
  99291. * Gets the left camera of a rig setup in case of Rigged Camera
  99292. */
  99293. get leftCamera(): Nullable<FreeCamera>;
  99294. /**
  99295. * Gets the right camera of a rig setup in case of Rigged Camera
  99296. */
  99297. get rightCamera(): Nullable<FreeCamera>;
  99298. /**
  99299. * Gets the left camera target of a rig setup in case of Rigged Camera
  99300. * @returns the target position
  99301. */
  99302. getLeftTarget(): Nullable<Vector3>;
  99303. /**
  99304. * Gets the right camera target of a rig setup in case of Rigged Camera
  99305. * @returns the target position
  99306. */
  99307. getRightTarget(): Nullable<Vector3>;
  99308. /**
  99309. * @hidden
  99310. */
  99311. setCameraRigMode(mode: number, rigParams: any): void;
  99312. /** @hidden */
  99313. static _setStereoscopicRigMode(camera: Camera): void;
  99314. /** @hidden */
  99315. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99316. /** @hidden */
  99317. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99318. /** @hidden */
  99319. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99320. /** @hidden */
  99321. _getVRProjectionMatrix(): Matrix;
  99322. protected _updateCameraRotationMatrix(): void;
  99323. protected _updateWebVRCameraRotationMatrix(): void;
  99324. /**
  99325. * This function MUST be overwritten by the different WebVR cameras available.
  99326. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99327. * @hidden
  99328. */
  99329. _getWebVRProjectionMatrix(): Matrix;
  99330. /**
  99331. * This function MUST be overwritten by the different WebVR cameras available.
  99332. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99333. * @hidden
  99334. */
  99335. _getWebVRViewMatrix(): Matrix;
  99336. /** @hidden */
  99337. setCameraRigParameter(name: string, value: any): void;
  99338. /**
  99339. * needs to be overridden by children so sub has required properties to be copied
  99340. * @hidden
  99341. */
  99342. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99343. /**
  99344. * May need to be overridden by children
  99345. * @hidden
  99346. */
  99347. _updateRigCameras(): void;
  99348. /** @hidden */
  99349. _setupInputs(): void;
  99350. /**
  99351. * Serialiaze the camera setup to a json represention
  99352. * @returns the JSON representation
  99353. */
  99354. serialize(): any;
  99355. /**
  99356. * Clones the current camera.
  99357. * @param name The cloned camera name
  99358. * @returns the cloned camera
  99359. */
  99360. clone(name: string): Camera;
  99361. /**
  99362. * Gets the direction of the camera relative to a given local axis.
  99363. * @param localAxis Defines the reference axis to provide a relative direction.
  99364. * @return the direction
  99365. */
  99366. getDirection(localAxis: Vector3): Vector3;
  99367. /**
  99368. * Returns the current camera absolute rotation
  99369. */
  99370. get absoluteRotation(): Quaternion;
  99371. /**
  99372. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99373. * @param localAxis Defines the reference axis to provide a relative direction.
  99374. * @param result Defines the vector to store the result in
  99375. */
  99376. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99377. /**
  99378. * Gets a camera constructor for a given camera type
  99379. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99380. * @param name The name of the camera the result will be able to instantiate
  99381. * @param scene The scene the result will construct the camera in
  99382. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99383. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99384. * @returns a factory method to construc the camera
  99385. */
  99386. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99387. /**
  99388. * Compute the world matrix of the camera.
  99389. * @returns the camera world matrix
  99390. */
  99391. computeWorldMatrix(): Matrix;
  99392. /**
  99393. * Parse a JSON and creates the camera from the parsed information
  99394. * @param parsedCamera The JSON to parse
  99395. * @param scene The scene to instantiate the camera in
  99396. * @returns the newly constructed camera
  99397. */
  99398. static Parse(parsedCamera: any, scene: Scene): Camera;
  99399. }
  99400. }
  99401. declare module BABYLON {
  99402. /**
  99403. * Class containing static functions to help procedurally build meshes
  99404. */
  99405. export class DiscBuilder {
  99406. /**
  99407. * Creates a plane polygonal mesh. By default, this is a disc
  99408. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99409. * * 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
  99410. * * 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
  99411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99414. * @param name defines the name of the mesh
  99415. * @param options defines the options used to create the mesh
  99416. * @param scene defines the hosting scene
  99417. * @returns the plane polygonal mesh
  99418. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99419. */
  99420. static CreateDisc(name: string, options: {
  99421. radius?: number;
  99422. tessellation?: number;
  99423. arc?: number;
  99424. updatable?: boolean;
  99425. sideOrientation?: number;
  99426. frontUVs?: Vector4;
  99427. backUVs?: Vector4;
  99428. }, scene?: Nullable<Scene>): Mesh;
  99429. }
  99430. }
  99431. declare module BABYLON {
  99432. /**
  99433. * This represents all the required information to add a fresnel effect on a material:
  99434. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99435. */
  99436. export class FresnelParameters {
  99437. private _isEnabled;
  99438. /**
  99439. * Define if the fresnel effect is enable or not.
  99440. */
  99441. get isEnabled(): boolean;
  99442. set isEnabled(value: boolean);
  99443. /**
  99444. * Define the color used on edges (grazing angle)
  99445. */
  99446. leftColor: Color3;
  99447. /**
  99448. * Define the color used on center
  99449. */
  99450. rightColor: Color3;
  99451. /**
  99452. * Define bias applied to computed fresnel term
  99453. */
  99454. bias: number;
  99455. /**
  99456. * Defined the power exponent applied to fresnel term
  99457. */
  99458. power: number;
  99459. /**
  99460. * Clones the current fresnel and its valuues
  99461. * @returns a clone fresnel configuration
  99462. */
  99463. clone(): FresnelParameters;
  99464. /**
  99465. * Serializes the current fresnel parameters to a JSON representation.
  99466. * @return the JSON serialization
  99467. */
  99468. serialize(): any;
  99469. /**
  99470. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99471. * @param parsedFresnelParameters Define the JSON representation
  99472. * @returns the parsed parameters
  99473. */
  99474. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99475. }
  99476. }
  99477. declare module BABYLON {
  99478. /**
  99479. * Base class of materials working in push mode in babylon JS
  99480. * @hidden
  99481. */
  99482. export class PushMaterial extends Material {
  99483. protected _activeEffect: Effect;
  99484. protected _normalMatrix: Matrix;
  99485. /**
  99486. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99487. * This means that the material can keep using a previous shader while a new one is being compiled.
  99488. * This is mostly used when shader parallel compilation is supported (true by default)
  99489. */
  99490. allowShaderHotSwapping: boolean;
  99491. constructor(name: string, scene: Scene);
  99492. getEffect(): Effect;
  99493. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99494. /**
  99495. * Binds the given world matrix to the active effect
  99496. *
  99497. * @param world the matrix to bind
  99498. */
  99499. bindOnlyWorldMatrix(world: Matrix): void;
  99500. /**
  99501. * Binds the given normal matrix to the active effect
  99502. *
  99503. * @param normalMatrix the matrix to bind
  99504. */
  99505. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99506. bind(world: Matrix, mesh?: Mesh): void;
  99507. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99508. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99509. }
  99510. }
  99511. declare module BABYLON {
  99512. /**
  99513. * This groups all the flags used to control the materials channel.
  99514. */
  99515. export class MaterialFlags {
  99516. private static _DiffuseTextureEnabled;
  99517. /**
  99518. * Are diffuse textures enabled in the application.
  99519. */
  99520. static get DiffuseTextureEnabled(): boolean;
  99521. static set DiffuseTextureEnabled(value: boolean);
  99522. private static _AmbientTextureEnabled;
  99523. /**
  99524. * Are ambient textures enabled in the application.
  99525. */
  99526. static get AmbientTextureEnabled(): boolean;
  99527. static set AmbientTextureEnabled(value: boolean);
  99528. private static _OpacityTextureEnabled;
  99529. /**
  99530. * Are opacity textures enabled in the application.
  99531. */
  99532. static get OpacityTextureEnabled(): boolean;
  99533. static set OpacityTextureEnabled(value: boolean);
  99534. private static _ReflectionTextureEnabled;
  99535. /**
  99536. * Are reflection textures enabled in the application.
  99537. */
  99538. static get ReflectionTextureEnabled(): boolean;
  99539. static set ReflectionTextureEnabled(value: boolean);
  99540. private static _EmissiveTextureEnabled;
  99541. /**
  99542. * Are emissive textures enabled in the application.
  99543. */
  99544. static get EmissiveTextureEnabled(): boolean;
  99545. static set EmissiveTextureEnabled(value: boolean);
  99546. private static _SpecularTextureEnabled;
  99547. /**
  99548. * Are specular textures enabled in the application.
  99549. */
  99550. static get SpecularTextureEnabled(): boolean;
  99551. static set SpecularTextureEnabled(value: boolean);
  99552. private static _BumpTextureEnabled;
  99553. /**
  99554. * Are bump textures enabled in the application.
  99555. */
  99556. static get BumpTextureEnabled(): boolean;
  99557. static set BumpTextureEnabled(value: boolean);
  99558. private static _LightmapTextureEnabled;
  99559. /**
  99560. * Are lightmap textures enabled in the application.
  99561. */
  99562. static get LightmapTextureEnabled(): boolean;
  99563. static set LightmapTextureEnabled(value: boolean);
  99564. private static _RefractionTextureEnabled;
  99565. /**
  99566. * Are refraction textures enabled in the application.
  99567. */
  99568. static get RefractionTextureEnabled(): boolean;
  99569. static set RefractionTextureEnabled(value: boolean);
  99570. private static _ColorGradingTextureEnabled;
  99571. /**
  99572. * Are color grading textures enabled in the application.
  99573. */
  99574. static get ColorGradingTextureEnabled(): boolean;
  99575. static set ColorGradingTextureEnabled(value: boolean);
  99576. private static _FresnelEnabled;
  99577. /**
  99578. * Are fresnels enabled in the application.
  99579. */
  99580. static get FresnelEnabled(): boolean;
  99581. static set FresnelEnabled(value: boolean);
  99582. private static _ClearCoatTextureEnabled;
  99583. /**
  99584. * Are clear coat textures enabled in the application.
  99585. */
  99586. static get ClearCoatTextureEnabled(): boolean;
  99587. static set ClearCoatTextureEnabled(value: boolean);
  99588. private static _ClearCoatBumpTextureEnabled;
  99589. /**
  99590. * Are clear coat bump textures enabled in the application.
  99591. */
  99592. static get ClearCoatBumpTextureEnabled(): boolean;
  99593. static set ClearCoatBumpTextureEnabled(value: boolean);
  99594. private static _ClearCoatTintTextureEnabled;
  99595. /**
  99596. * Are clear coat tint textures enabled in the application.
  99597. */
  99598. static get ClearCoatTintTextureEnabled(): boolean;
  99599. static set ClearCoatTintTextureEnabled(value: boolean);
  99600. private static _SheenTextureEnabled;
  99601. /**
  99602. * Are sheen textures enabled in the application.
  99603. */
  99604. static get SheenTextureEnabled(): boolean;
  99605. static set SheenTextureEnabled(value: boolean);
  99606. private static _AnisotropicTextureEnabled;
  99607. /**
  99608. * Are anisotropic textures enabled in the application.
  99609. */
  99610. static get AnisotropicTextureEnabled(): boolean;
  99611. static set AnisotropicTextureEnabled(value: boolean);
  99612. private static _ThicknessTextureEnabled;
  99613. /**
  99614. * Are thickness textures enabled in the application.
  99615. */
  99616. static get ThicknessTextureEnabled(): boolean;
  99617. static set ThicknessTextureEnabled(value: boolean);
  99618. }
  99619. }
  99620. declare module BABYLON {
  99621. /** @hidden */
  99622. export var defaultFragmentDeclaration: {
  99623. name: string;
  99624. shader: string;
  99625. };
  99626. }
  99627. declare module BABYLON {
  99628. /** @hidden */
  99629. export var defaultUboDeclaration: {
  99630. name: string;
  99631. shader: string;
  99632. };
  99633. }
  99634. declare module BABYLON {
  99635. /** @hidden */
  99636. export var lightFragmentDeclaration: {
  99637. name: string;
  99638. shader: string;
  99639. };
  99640. }
  99641. declare module BABYLON {
  99642. /** @hidden */
  99643. export var lightUboDeclaration: {
  99644. name: string;
  99645. shader: string;
  99646. };
  99647. }
  99648. declare module BABYLON {
  99649. /** @hidden */
  99650. export var lightsFragmentFunctions: {
  99651. name: string;
  99652. shader: string;
  99653. };
  99654. }
  99655. declare module BABYLON {
  99656. /** @hidden */
  99657. export var shadowsFragmentFunctions: {
  99658. name: string;
  99659. shader: string;
  99660. };
  99661. }
  99662. declare module BABYLON {
  99663. /** @hidden */
  99664. export var fresnelFunction: {
  99665. name: string;
  99666. shader: string;
  99667. };
  99668. }
  99669. declare module BABYLON {
  99670. /** @hidden */
  99671. export var reflectionFunction: {
  99672. name: string;
  99673. shader: string;
  99674. };
  99675. }
  99676. declare module BABYLON {
  99677. /** @hidden */
  99678. export var bumpFragmentFunctions: {
  99679. name: string;
  99680. shader: string;
  99681. };
  99682. }
  99683. declare module BABYLON {
  99684. /** @hidden */
  99685. export var logDepthDeclaration: {
  99686. name: string;
  99687. shader: string;
  99688. };
  99689. }
  99690. declare module BABYLON {
  99691. /** @hidden */
  99692. export var bumpFragment: {
  99693. name: string;
  99694. shader: string;
  99695. };
  99696. }
  99697. declare module BABYLON {
  99698. /** @hidden */
  99699. export var depthPrePass: {
  99700. name: string;
  99701. shader: string;
  99702. };
  99703. }
  99704. declare module BABYLON {
  99705. /** @hidden */
  99706. export var lightFragment: {
  99707. name: string;
  99708. shader: string;
  99709. };
  99710. }
  99711. declare module BABYLON {
  99712. /** @hidden */
  99713. export var logDepthFragment: {
  99714. name: string;
  99715. shader: string;
  99716. };
  99717. }
  99718. declare module BABYLON {
  99719. /** @hidden */
  99720. export var defaultPixelShader: {
  99721. name: string;
  99722. shader: string;
  99723. };
  99724. }
  99725. declare module BABYLON {
  99726. /** @hidden */
  99727. export var defaultVertexDeclaration: {
  99728. name: string;
  99729. shader: string;
  99730. };
  99731. }
  99732. declare module BABYLON {
  99733. /** @hidden */
  99734. export var bumpVertexDeclaration: {
  99735. name: string;
  99736. shader: string;
  99737. };
  99738. }
  99739. declare module BABYLON {
  99740. /** @hidden */
  99741. export var bumpVertex: {
  99742. name: string;
  99743. shader: string;
  99744. };
  99745. }
  99746. declare module BABYLON {
  99747. /** @hidden */
  99748. export var fogVertex: {
  99749. name: string;
  99750. shader: string;
  99751. };
  99752. }
  99753. declare module BABYLON {
  99754. /** @hidden */
  99755. export var shadowsVertex: {
  99756. name: string;
  99757. shader: string;
  99758. };
  99759. }
  99760. declare module BABYLON {
  99761. /** @hidden */
  99762. export var pointCloudVertex: {
  99763. name: string;
  99764. shader: string;
  99765. };
  99766. }
  99767. declare module BABYLON {
  99768. /** @hidden */
  99769. export var logDepthVertex: {
  99770. name: string;
  99771. shader: string;
  99772. };
  99773. }
  99774. declare module BABYLON {
  99775. /** @hidden */
  99776. export var defaultVertexShader: {
  99777. name: string;
  99778. shader: string;
  99779. };
  99780. }
  99781. declare module BABYLON {
  99782. /** @hidden */
  99783. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99784. MAINUV1: boolean;
  99785. MAINUV2: boolean;
  99786. DIFFUSE: boolean;
  99787. DIFFUSEDIRECTUV: number;
  99788. AMBIENT: boolean;
  99789. AMBIENTDIRECTUV: number;
  99790. OPACITY: boolean;
  99791. OPACITYDIRECTUV: number;
  99792. OPACITYRGB: boolean;
  99793. REFLECTION: boolean;
  99794. EMISSIVE: boolean;
  99795. EMISSIVEDIRECTUV: number;
  99796. SPECULAR: boolean;
  99797. SPECULARDIRECTUV: number;
  99798. BUMP: boolean;
  99799. BUMPDIRECTUV: number;
  99800. PARALLAX: boolean;
  99801. PARALLAXOCCLUSION: boolean;
  99802. SPECULAROVERALPHA: boolean;
  99803. CLIPPLANE: boolean;
  99804. CLIPPLANE2: boolean;
  99805. CLIPPLANE3: boolean;
  99806. CLIPPLANE4: boolean;
  99807. CLIPPLANE5: boolean;
  99808. CLIPPLANE6: boolean;
  99809. ALPHATEST: boolean;
  99810. DEPTHPREPASS: boolean;
  99811. ALPHAFROMDIFFUSE: boolean;
  99812. POINTSIZE: boolean;
  99813. FOG: boolean;
  99814. SPECULARTERM: boolean;
  99815. DIFFUSEFRESNEL: boolean;
  99816. OPACITYFRESNEL: boolean;
  99817. REFLECTIONFRESNEL: boolean;
  99818. REFRACTIONFRESNEL: boolean;
  99819. EMISSIVEFRESNEL: boolean;
  99820. FRESNEL: boolean;
  99821. NORMAL: boolean;
  99822. UV1: boolean;
  99823. UV2: boolean;
  99824. VERTEXCOLOR: boolean;
  99825. VERTEXALPHA: boolean;
  99826. NUM_BONE_INFLUENCERS: number;
  99827. BonesPerMesh: number;
  99828. BONETEXTURE: boolean;
  99829. INSTANCES: boolean;
  99830. GLOSSINESS: boolean;
  99831. ROUGHNESS: boolean;
  99832. EMISSIVEASILLUMINATION: boolean;
  99833. LINKEMISSIVEWITHDIFFUSE: boolean;
  99834. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99835. LIGHTMAP: boolean;
  99836. LIGHTMAPDIRECTUV: number;
  99837. OBJECTSPACE_NORMALMAP: boolean;
  99838. USELIGHTMAPASSHADOWMAP: boolean;
  99839. REFLECTIONMAP_3D: boolean;
  99840. REFLECTIONMAP_SPHERICAL: boolean;
  99841. REFLECTIONMAP_PLANAR: boolean;
  99842. REFLECTIONMAP_CUBIC: boolean;
  99843. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99844. REFLECTIONMAP_PROJECTION: boolean;
  99845. REFLECTIONMAP_SKYBOX: boolean;
  99846. REFLECTIONMAP_EXPLICIT: boolean;
  99847. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99848. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99849. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99850. INVERTCUBICMAP: boolean;
  99851. LOGARITHMICDEPTH: boolean;
  99852. REFRACTION: boolean;
  99853. REFRACTIONMAP_3D: boolean;
  99854. REFLECTIONOVERALPHA: boolean;
  99855. TWOSIDEDLIGHTING: boolean;
  99856. SHADOWFLOAT: boolean;
  99857. MORPHTARGETS: boolean;
  99858. MORPHTARGETS_NORMAL: boolean;
  99859. MORPHTARGETS_TANGENT: boolean;
  99860. MORPHTARGETS_UV: boolean;
  99861. NUM_MORPH_INFLUENCERS: number;
  99862. NONUNIFORMSCALING: boolean;
  99863. PREMULTIPLYALPHA: boolean;
  99864. IMAGEPROCESSING: boolean;
  99865. VIGNETTE: boolean;
  99866. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99867. VIGNETTEBLENDMODEOPAQUE: boolean;
  99868. TONEMAPPING: boolean;
  99869. TONEMAPPING_ACES: boolean;
  99870. CONTRAST: boolean;
  99871. COLORCURVES: boolean;
  99872. COLORGRADING: boolean;
  99873. COLORGRADING3D: boolean;
  99874. SAMPLER3DGREENDEPTH: boolean;
  99875. SAMPLER3DBGRMAP: boolean;
  99876. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99877. MULTIVIEW: boolean;
  99878. /**
  99879. * If the reflection texture on this material is in linear color space
  99880. * @hidden
  99881. */
  99882. IS_REFLECTION_LINEAR: boolean;
  99883. /**
  99884. * If the refraction texture on this material is in linear color space
  99885. * @hidden
  99886. */
  99887. IS_REFRACTION_LINEAR: boolean;
  99888. EXPOSURE: boolean;
  99889. constructor();
  99890. setReflectionMode(modeToEnable: string): void;
  99891. }
  99892. /**
  99893. * This is the default material used in Babylon. It is the best trade off between quality
  99894. * and performances.
  99895. * @see http://doc.babylonjs.com/babylon101/materials
  99896. */
  99897. export class StandardMaterial extends PushMaterial {
  99898. private _diffuseTexture;
  99899. /**
  99900. * The basic texture of the material as viewed under a light.
  99901. */
  99902. diffuseTexture: Nullable<BaseTexture>;
  99903. private _ambientTexture;
  99904. /**
  99905. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99906. */
  99907. ambientTexture: Nullable<BaseTexture>;
  99908. private _opacityTexture;
  99909. /**
  99910. * Define the transparency of the material from a texture.
  99911. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99912. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99913. */
  99914. opacityTexture: Nullable<BaseTexture>;
  99915. private _reflectionTexture;
  99916. /**
  99917. * Define the texture used to display the reflection.
  99918. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99919. */
  99920. reflectionTexture: Nullable<BaseTexture>;
  99921. private _emissiveTexture;
  99922. /**
  99923. * Define texture of the material as if self lit.
  99924. * This will be mixed in the final result even in the absence of light.
  99925. */
  99926. emissiveTexture: Nullable<BaseTexture>;
  99927. private _specularTexture;
  99928. /**
  99929. * Define how the color and intensity of the highlight given by the light in the material.
  99930. */
  99931. specularTexture: Nullable<BaseTexture>;
  99932. private _bumpTexture;
  99933. /**
  99934. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99935. * 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.
  99936. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99937. */
  99938. bumpTexture: Nullable<BaseTexture>;
  99939. private _lightmapTexture;
  99940. /**
  99941. * Complex lighting can be computationally expensive to compute at runtime.
  99942. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99943. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99944. */
  99945. lightmapTexture: Nullable<BaseTexture>;
  99946. private _refractionTexture;
  99947. /**
  99948. * Define the texture used to display the refraction.
  99949. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99950. */
  99951. refractionTexture: Nullable<BaseTexture>;
  99952. /**
  99953. * The color of the material lit by the environmental background lighting.
  99954. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99955. */
  99956. ambientColor: Color3;
  99957. /**
  99958. * The basic color of the material as viewed under a light.
  99959. */
  99960. diffuseColor: Color3;
  99961. /**
  99962. * Define how the color and intensity of the highlight given by the light in the material.
  99963. */
  99964. specularColor: Color3;
  99965. /**
  99966. * Define the color of the material as if self lit.
  99967. * This will be mixed in the final result even in the absence of light.
  99968. */
  99969. emissiveColor: Color3;
  99970. /**
  99971. * Defines how sharp are the highlights in the material.
  99972. * The bigger the value the sharper giving a more glossy feeling to the result.
  99973. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99974. */
  99975. specularPower: number;
  99976. private _useAlphaFromDiffuseTexture;
  99977. /**
  99978. * Does the transparency come from the diffuse texture alpha channel.
  99979. */
  99980. useAlphaFromDiffuseTexture: boolean;
  99981. private _useEmissiveAsIllumination;
  99982. /**
  99983. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99984. */
  99985. useEmissiveAsIllumination: boolean;
  99986. private _linkEmissiveWithDiffuse;
  99987. /**
  99988. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99989. * the emissive level when the final color is close to one.
  99990. */
  99991. linkEmissiveWithDiffuse: boolean;
  99992. private _useSpecularOverAlpha;
  99993. /**
  99994. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99995. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99996. */
  99997. useSpecularOverAlpha: boolean;
  99998. private _useReflectionOverAlpha;
  99999. /**
  100000. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100001. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100002. */
  100003. useReflectionOverAlpha: boolean;
  100004. private _disableLighting;
  100005. /**
  100006. * Does lights from the scene impacts this material.
  100007. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  100008. */
  100009. disableLighting: boolean;
  100010. private _useObjectSpaceNormalMap;
  100011. /**
  100012. * Allows using an object space normal map (instead of tangent space).
  100013. */
  100014. useObjectSpaceNormalMap: boolean;
  100015. private _useParallax;
  100016. /**
  100017. * Is parallax enabled or not.
  100018. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  100019. */
  100020. useParallax: boolean;
  100021. private _useParallaxOcclusion;
  100022. /**
  100023. * Is parallax occlusion enabled or not.
  100024. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  100025. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  100026. */
  100027. useParallaxOcclusion: boolean;
  100028. /**
  100029. * 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.
  100030. */
  100031. parallaxScaleBias: number;
  100032. private _roughness;
  100033. /**
  100034. * Helps to define how blurry the reflections should appears in the material.
  100035. */
  100036. roughness: number;
  100037. /**
  100038. * In case of refraction, define the value of the index of refraction.
  100039. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100040. */
  100041. indexOfRefraction: number;
  100042. /**
  100043. * Invert the refraction texture alongside the y axis.
  100044. * It can be useful with procedural textures or probe for instance.
  100045. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100046. */
  100047. invertRefractionY: boolean;
  100048. /**
  100049. * Defines the alpha limits in alpha test mode.
  100050. */
  100051. alphaCutOff: number;
  100052. private _useLightmapAsShadowmap;
  100053. /**
  100054. * In case of light mapping, define whether the map contains light or shadow informations.
  100055. */
  100056. useLightmapAsShadowmap: boolean;
  100057. private _diffuseFresnelParameters;
  100058. /**
  100059. * Define the diffuse fresnel parameters of the material.
  100060. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100061. */
  100062. diffuseFresnelParameters: FresnelParameters;
  100063. private _opacityFresnelParameters;
  100064. /**
  100065. * Define the opacity fresnel parameters of the material.
  100066. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100067. */
  100068. opacityFresnelParameters: FresnelParameters;
  100069. private _reflectionFresnelParameters;
  100070. /**
  100071. * Define the reflection fresnel parameters of the material.
  100072. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100073. */
  100074. reflectionFresnelParameters: FresnelParameters;
  100075. private _refractionFresnelParameters;
  100076. /**
  100077. * Define the refraction fresnel parameters of the material.
  100078. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100079. */
  100080. refractionFresnelParameters: FresnelParameters;
  100081. private _emissiveFresnelParameters;
  100082. /**
  100083. * Define the emissive fresnel parameters of the material.
  100084. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100085. */
  100086. emissiveFresnelParameters: FresnelParameters;
  100087. private _useReflectionFresnelFromSpecular;
  100088. /**
  100089. * If true automatically deducts the fresnels values from the material specularity.
  100090. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100091. */
  100092. useReflectionFresnelFromSpecular: boolean;
  100093. private _useGlossinessFromSpecularMapAlpha;
  100094. /**
  100095. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  100096. */
  100097. useGlossinessFromSpecularMapAlpha: boolean;
  100098. private _maxSimultaneousLights;
  100099. /**
  100100. * Defines the maximum number of lights that can be used in the material
  100101. */
  100102. maxSimultaneousLights: number;
  100103. private _invertNormalMapX;
  100104. /**
  100105. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100106. */
  100107. invertNormalMapX: boolean;
  100108. private _invertNormalMapY;
  100109. /**
  100110. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100111. */
  100112. invertNormalMapY: boolean;
  100113. private _twoSidedLighting;
  100114. /**
  100115. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100116. */
  100117. twoSidedLighting: boolean;
  100118. /**
  100119. * Default configuration related to image processing available in the standard Material.
  100120. */
  100121. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100122. /**
  100123. * Gets the image processing configuration used either in this material.
  100124. */
  100125. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100126. /**
  100127. * Sets the Default image processing configuration used either in the this material.
  100128. *
  100129. * If sets to null, the scene one is in use.
  100130. */
  100131. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100132. /**
  100133. * Keep track of the image processing observer to allow dispose and replace.
  100134. */
  100135. private _imageProcessingObserver;
  100136. /**
  100137. * Attaches a new image processing configuration to the Standard Material.
  100138. * @param configuration
  100139. */
  100140. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100141. /**
  100142. * Gets wether the color curves effect is enabled.
  100143. */
  100144. get cameraColorCurvesEnabled(): boolean;
  100145. /**
  100146. * Sets wether the color curves effect is enabled.
  100147. */
  100148. set cameraColorCurvesEnabled(value: boolean);
  100149. /**
  100150. * Gets wether the color grading effect is enabled.
  100151. */
  100152. get cameraColorGradingEnabled(): boolean;
  100153. /**
  100154. * Gets wether the color grading effect is enabled.
  100155. */
  100156. set cameraColorGradingEnabled(value: boolean);
  100157. /**
  100158. * Gets wether tonemapping is enabled or not.
  100159. */
  100160. get cameraToneMappingEnabled(): boolean;
  100161. /**
  100162. * Sets wether tonemapping is enabled or not
  100163. */
  100164. set cameraToneMappingEnabled(value: boolean);
  100165. /**
  100166. * The camera exposure used on this material.
  100167. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100168. * This corresponds to a photographic exposure.
  100169. */
  100170. get cameraExposure(): number;
  100171. /**
  100172. * The camera exposure used on this material.
  100173. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100174. * This corresponds to a photographic exposure.
  100175. */
  100176. set cameraExposure(value: number);
  100177. /**
  100178. * Gets The camera contrast used on this material.
  100179. */
  100180. get cameraContrast(): number;
  100181. /**
  100182. * Sets The camera contrast used on this material.
  100183. */
  100184. set cameraContrast(value: number);
  100185. /**
  100186. * Gets the Color Grading 2D Lookup Texture.
  100187. */
  100188. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  100189. /**
  100190. * Sets the Color Grading 2D Lookup Texture.
  100191. */
  100192. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  100193. /**
  100194. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100195. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100196. * 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;
  100197. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100198. */
  100199. get cameraColorCurves(): Nullable<ColorCurves>;
  100200. /**
  100201. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100202. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100203. * 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;
  100204. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100205. */
  100206. set cameraColorCurves(value: Nullable<ColorCurves>);
  100207. /**
  100208. * Custom callback helping to override the default shader used in the material.
  100209. */
  100210. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  100211. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100212. protected _worldViewProjectionMatrix: Matrix;
  100213. protected _globalAmbientColor: Color3;
  100214. protected _useLogarithmicDepth: boolean;
  100215. protected _rebuildInParallel: boolean;
  100216. /**
  100217. * Instantiates a new standard material.
  100218. * This is the default material used in Babylon. It is the best trade off between quality
  100219. * and performances.
  100220. * @see http://doc.babylonjs.com/babylon101/materials
  100221. * @param name Define the name of the material in the scene
  100222. * @param scene Define the scene the material belong to
  100223. */
  100224. constructor(name: string, scene: Scene);
  100225. /**
  100226. * Gets a boolean indicating that current material needs to register RTT
  100227. */
  100228. get hasRenderTargetTextures(): boolean;
  100229. /**
  100230. * Gets the current class name of the material e.g. "StandardMaterial"
  100231. * Mainly use in serialization.
  100232. * @returns the class name
  100233. */
  100234. getClassName(): string;
  100235. /**
  100236. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100237. * You can try switching to logarithmic depth.
  100238. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100239. */
  100240. get useLogarithmicDepth(): boolean;
  100241. set useLogarithmicDepth(value: boolean);
  100242. /**
  100243. * Specifies if the material will require alpha blending
  100244. * @returns a boolean specifying if alpha blending is needed
  100245. */
  100246. needAlphaBlending(): boolean;
  100247. /**
  100248. * Specifies if this material should be rendered in alpha test mode
  100249. * @returns a boolean specifying if an alpha test is needed.
  100250. */
  100251. needAlphaTesting(): boolean;
  100252. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100253. /**
  100254. * Get the texture used for alpha test purpose.
  100255. * @returns the diffuse texture in case of the standard material.
  100256. */
  100257. getAlphaTestTexture(): Nullable<BaseTexture>;
  100258. /**
  100259. * Get if the submesh is ready to be used and all its information available.
  100260. * Child classes can use it to update shaders
  100261. * @param mesh defines the mesh to check
  100262. * @param subMesh defines which submesh to check
  100263. * @param useInstances specifies that instances should be used
  100264. * @returns a boolean indicating that the submesh is ready or not
  100265. */
  100266. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100267. /**
  100268. * Builds the material UBO layouts.
  100269. * Used internally during the effect preparation.
  100270. */
  100271. buildUniformLayout(): void;
  100272. /**
  100273. * Unbinds the material from the mesh
  100274. */
  100275. unbind(): void;
  100276. /**
  100277. * Binds the submesh to this material by preparing the effect and shader to draw
  100278. * @param world defines the world transformation matrix
  100279. * @param mesh defines the mesh containing the submesh
  100280. * @param subMesh defines the submesh to bind the material to
  100281. */
  100282. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100283. /**
  100284. * Get the list of animatables in the material.
  100285. * @returns the list of animatables object used in the material
  100286. */
  100287. getAnimatables(): IAnimatable[];
  100288. /**
  100289. * Gets the active textures from the material
  100290. * @returns an array of textures
  100291. */
  100292. getActiveTextures(): BaseTexture[];
  100293. /**
  100294. * Specifies if the material uses a texture
  100295. * @param texture defines the texture to check against the material
  100296. * @returns a boolean specifying if the material uses the texture
  100297. */
  100298. hasTexture(texture: BaseTexture): boolean;
  100299. /**
  100300. * Disposes the material
  100301. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100302. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100303. */
  100304. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100305. /**
  100306. * Makes a duplicate of the material, and gives it a new name
  100307. * @param name defines the new name for the duplicated material
  100308. * @returns the cloned material
  100309. */
  100310. clone(name: string): StandardMaterial;
  100311. /**
  100312. * Serializes this material in a JSON representation
  100313. * @returns the serialized material object
  100314. */
  100315. serialize(): any;
  100316. /**
  100317. * Creates a standard material from parsed material data
  100318. * @param source defines the JSON representation of the material
  100319. * @param scene defines the hosting scene
  100320. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100321. * @returns a new standard material
  100322. */
  100323. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100324. /**
  100325. * Are diffuse textures enabled in the application.
  100326. */
  100327. static get DiffuseTextureEnabled(): boolean;
  100328. static set DiffuseTextureEnabled(value: boolean);
  100329. /**
  100330. * Are ambient textures enabled in the application.
  100331. */
  100332. static get AmbientTextureEnabled(): boolean;
  100333. static set AmbientTextureEnabled(value: boolean);
  100334. /**
  100335. * Are opacity textures enabled in the application.
  100336. */
  100337. static get OpacityTextureEnabled(): boolean;
  100338. static set OpacityTextureEnabled(value: boolean);
  100339. /**
  100340. * Are reflection textures enabled in the application.
  100341. */
  100342. static get ReflectionTextureEnabled(): boolean;
  100343. static set ReflectionTextureEnabled(value: boolean);
  100344. /**
  100345. * Are emissive textures enabled in the application.
  100346. */
  100347. static get EmissiveTextureEnabled(): boolean;
  100348. static set EmissiveTextureEnabled(value: boolean);
  100349. /**
  100350. * Are specular textures enabled in the application.
  100351. */
  100352. static get SpecularTextureEnabled(): boolean;
  100353. static set SpecularTextureEnabled(value: boolean);
  100354. /**
  100355. * Are bump textures enabled in the application.
  100356. */
  100357. static get BumpTextureEnabled(): boolean;
  100358. static set BumpTextureEnabled(value: boolean);
  100359. /**
  100360. * Are lightmap textures enabled in the application.
  100361. */
  100362. static get LightmapTextureEnabled(): boolean;
  100363. static set LightmapTextureEnabled(value: boolean);
  100364. /**
  100365. * Are refraction textures enabled in the application.
  100366. */
  100367. static get RefractionTextureEnabled(): boolean;
  100368. static set RefractionTextureEnabled(value: boolean);
  100369. /**
  100370. * Are color grading textures enabled in the application.
  100371. */
  100372. static get ColorGradingTextureEnabled(): boolean;
  100373. static set ColorGradingTextureEnabled(value: boolean);
  100374. /**
  100375. * Are fresnels enabled in the application.
  100376. */
  100377. static get FresnelEnabled(): boolean;
  100378. static set FresnelEnabled(value: boolean);
  100379. }
  100380. }
  100381. declare module BABYLON {
  100382. /**
  100383. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100384. *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.
  100385. * The SPS is also a particle system. It provides some methods to manage the particles.
  100386. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100387. *
  100388. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100389. */
  100390. export class SolidParticleSystem implements IDisposable {
  100391. /**
  100392. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100393. * Example : var p = SPS.particles[i];
  100394. */
  100395. particles: SolidParticle[];
  100396. /**
  100397. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100398. */
  100399. nbParticles: number;
  100400. /**
  100401. * If the particles must ever face the camera (default false). Useful for planar particles.
  100402. */
  100403. billboard: boolean;
  100404. /**
  100405. * Recompute normals when adding a shape
  100406. */
  100407. recomputeNormals: boolean;
  100408. /**
  100409. * This a counter ofr your own usage. It's not set by any SPS functions.
  100410. */
  100411. counter: number;
  100412. /**
  100413. * The SPS name. This name is also given to the underlying mesh.
  100414. */
  100415. name: string;
  100416. /**
  100417. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100418. */
  100419. mesh: Mesh;
  100420. /**
  100421. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100422. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100423. */
  100424. vars: any;
  100425. /**
  100426. * This array is populated when the SPS is set as 'pickable'.
  100427. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100428. * Each element of this array is an object `{idx: int, faceId: int}`.
  100429. * `idx` is the picked particle index in the `SPS.particles` array
  100430. * `faceId` is the picked face index counted within this particle.
  100431. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100432. */
  100433. pickedParticles: {
  100434. idx: number;
  100435. faceId: number;
  100436. }[];
  100437. /**
  100438. * This array is populated when `enableDepthSort` is set to true.
  100439. * Each element of this array is an instance of the class DepthSortedParticle.
  100440. */
  100441. depthSortedParticles: DepthSortedParticle[];
  100442. /**
  100443. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100444. * @hidden
  100445. */
  100446. _bSphereOnly: boolean;
  100447. /**
  100448. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100449. * @hidden
  100450. */
  100451. _bSphereRadiusFactor: number;
  100452. private _scene;
  100453. private _positions;
  100454. private _indices;
  100455. private _normals;
  100456. private _colors;
  100457. private _uvs;
  100458. private _indices32;
  100459. private _positions32;
  100460. private _normals32;
  100461. private _fixedNormal32;
  100462. private _colors32;
  100463. private _uvs32;
  100464. private _index;
  100465. private _updatable;
  100466. private _pickable;
  100467. private _isVisibilityBoxLocked;
  100468. private _alwaysVisible;
  100469. private _depthSort;
  100470. private _expandable;
  100471. private _shapeCounter;
  100472. private _copy;
  100473. private _color;
  100474. private _computeParticleColor;
  100475. private _computeParticleTexture;
  100476. private _computeParticleRotation;
  100477. private _computeParticleVertex;
  100478. private _computeBoundingBox;
  100479. private _depthSortParticles;
  100480. private _camera;
  100481. private _mustUnrotateFixedNormals;
  100482. private _particlesIntersect;
  100483. private _needs32Bits;
  100484. private _isNotBuilt;
  100485. private _lastParticleId;
  100486. private _idxOfId;
  100487. private _multimaterialEnabled;
  100488. private _useModelMaterial;
  100489. private _indicesByMaterial;
  100490. private _materialIndexes;
  100491. private _depthSortFunction;
  100492. private _materialSortFunction;
  100493. private _materials;
  100494. private _multimaterial;
  100495. private _materialIndexesById;
  100496. private _defaultMaterial;
  100497. private _autoUpdateSubMeshes;
  100498. /**
  100499. * Creates a SPS (Solid Particle System) object.
  100500. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100501. * @param scene (Scene) is the scene in which the SPS is added.
  100502. * @param options defines the options of the sps e.g.
  100503. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100504. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100505. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100506. * * 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.
  100507. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100508. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100509. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100510. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100511. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100512. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100513. */
  100514. constructor(name: string, scene: Scene, options?: {
  100515. updatable?: boolean;
  100516. isPickable?: boolean;
  100517. enableDepthSort?: boolean;
  100518. particleIntersection?: boolean;
  100519. boundingSphereOnly?: boolean;
  100520. bSphereRadiusFactor?: number;
  100521. expandable?: boolean;
  100522. useModelMaterial?: boolean;
  100523. enableMultiMaterial?: boolean;
  100524. });
  100525. /**
  100526. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100527. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100528. * @returns the created mesh
  100529. */
  100530. buildMesh(): Mesh;
  100531. /**
  100532. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100533. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100534. * Thus the particles generated from `digest()` have their property `position` set yet.
  100535. * @param mesh ( Mesh ) is the mesh to be digested
  100536. * @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
  100537. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100538. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100539. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100540. * @returns the current SPS
  100541. */
  100542. digest(mesh: Mesh, options?: {
  100543. facetNb?: number;
  100544. number?: number;
  100545. delta?: number;
  100546. storage?: [];
  100547. }): SolidParticleSystem;
  100548. /**
  100549. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100550. * @hidden
  100551. */
  100552. private _unrotateFixedNormals;
  100553. /**
  100554. * Resets the temporary working copy particle
  100555. * @hidden
  100556. */
  100557. private _resetCopy;
  100558. /**
  100559. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100560. * @param p the current index in the positions array to be updated
  100561. * @param ind the current index in the indices array
  100562. * @param shape a Vector3 array, the shape geometry
  100563. * @param positions the positions array to be updated
  100564. * @param meshInd the shape indices array
  100565. * @param indices the indices array to be updated
  100566. * @param meshUV the shape uv array
  100567. * @param uvs the uv array to be updated
  100568. * @param meshCol the shape color array
  100569. * @param colors the color array to be updated
  100570. * @param meshNor the shape normals array
  100571. * @param normals the normals array to be updated
  100572. * @param idx the particle index
  100573. * @param idxInShape the particle index in its shape
  100574. * @param options the addShape() method passed options
  100575. * @model the particle model
  100576. * @hidden
  100577. */
  100578. private _meshBuilder;
  100579. /**
  100580. * Returns a shape Vector3 array from positions float array
  100581. * @param positions float array
  100582. * @returns a vector3 array
  100583. * @hidden
  100584. */
  100585. private _posToShape;
  100586. /**
  100587. * Returns a shapeUV array from a float uvs (array deep copy)
  100588. * @param uvs as a float array
  100589. * @returns a shapeUV array
  100590. * @hidden
  100591. */
  100592. private _uvsToShapeUV;
  100593. /**
  100594. * Adds a new particle object in the particles array
  100595. * @param idx particle index in particles array
  100596. * @param id particle id
  100597. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100598. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100599. * @param model particle ModelShape object
  100600. * @param shapeId model shape identifier
  100601. * @param idxInShape index of the particle in the current model
  100602. * @param bInfo model bounding info object
  100603. * @param storage target storage array, if any
  100604. * @hidden
  100605. */
  100606. private _addParticle;
  100607. /**
  100608. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100609. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100610. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100611. * @param nb (positive integer) the number of particles to be created from this model
  100612. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100613. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100614. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100615. * @returns the number of shapes in the system
  100616. */
  100617. addShape(mesh: Mesh, nb: number, options?: {
  100618. positionFunction?: any;
  100619. vertexFunction?: any;
  100620. storage?: [];
  100621. }): number;
  100622. /**
  100623. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100624. * @hidden
  100625. */
  100626. private _rebuildParticle;
  100627. /**
  100628. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100629. * @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.
  100630. * @returns the SPS.
  100631. */
  100632. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100633. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100634. * Returns an array with the removed particles.
  100635. * 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.
  100636. * The SPS can't be empty so at least one particle needs to remain in place.
  100637. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100638. * @param start index of the first particle to remove
  100639. * @param end index of the last particle to remove (included)
  100640. * @returns an array populated with the removed particles
  100641. */
  100642. removeParticles(start: number, end: number): SolidParticle[];
  100643. /**
  100644. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100645. * @param solidParticleArray an array populated with Solid Particles objects
  100646. * @returns the SPS
  100647. */
  100648. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100649. /**
  100650. * Creates a new particle and modifies the SPS mesh geometry :
  100651. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100652. * - calls _addParticle() to populate the particle array
  100653. * factorized code from addShape() and insertParticlesFromArray()
  100654. * @param idx particle index in the particles array
  100655. * @param i particle index in its shape
  100656. * @param modelShape particle ModelShape object
  100657. * @param shape shape vertex array
  100658. * @param meshInd shape indices array
  100659. * @param meshUV shape uv array
  100660. * @param meshCol shape color array
  100661. * @param meshNor shape normals array
  100662. * @param bbInfo shape bounding info
  100663. * @param storage target particle storage
  100664. * @options addShape() passed options
  100665. * @hidden
  100666. */
  100667. private _insertNewParticle;
  100668. /**
  100669. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100670. * This method calls `updateParticle()` for each particle of the SPS.
  100671. * For an animated SPS, it is usually called within the render loop.
  100672. * 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.
  100673. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100674. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100675. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100676. * @returns the SPS.
  100677. */
  100678. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100679. /**
  100680. * Disposes the SPS.
  100681. */
  100682. dispose(): void;
  100683. /**
  100684. * Returns a SolidParticle object from its identifier : particle.id
  100685. * @param id (integer) the particle Id
  100686. * @returns the searched particle or null if not found in the SPS.
  100687. */
  100688. getParticleById(id: number): Nullable<SolidParticle>;
  100689. /**
  100690. * Returns a new array populated with the particles having the passed shapeId.
  100691. * @param shapeId (integer) the shape identifier
  100692. * @returns a new solid particle array
  100693. */
  100694. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100695. /**
  100696. * Populates the passed array "ref" with the particles having the passed shapeId.
  100697. * @param shapeId the shape identifier
  100698. * @returns the SPS
  100699. * @param ref
  100700. */
  100701. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100702. /**
  100703. * Computes the required SubMeshes according the materials assigned to the particles.
  100704. * @returns the solid particle system.
  100705. * Does nothing if called before the SPS mesh is built.
  100706. */
  100707. computeSubMeshes(): SolidParticleSystem;
  100708. /**
  100709. * Sorts the solid particles by material when MultiMaterial is enabled.
  100710. * Updates the indices32 array.
  100711. * Updates the indicesByMaterial array.
  100712. * Updates the mesh indices array.
  100713. * @returns the SPS
  100714. * @hidden
  100715. */
  100716. private _sortParticlesByMaterial;
  100717. /**
  100718. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100719. * @hidden
  100720. */
  100721. private _setMaterialIndexesById;
  100722. /**
  100723. * Returns an array with unique values of Materials from the passed array
  100724. * @param array the material array to be checked and filtered
  100725. * @hidden
  100726. */
  100727. private _filterUniqueMaterialId;
  100728. /**
  100729. * Sets a new Standard Material as _defaultMaterial if not already set.
  100730. * @hidden
  100731. */
  100732. private _setDefaultMaterial;
  100733. /**
  100734. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100735. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100736. * @returns the SPS.
  100737. */
  100738. refreshVisibleSize(): SolidParticleSystem;
  100739. /**
  100740. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100741. * @param size the size (float) of the visibility box
  100742. * note : this doesn't lock the SPS mesh bounding box.
  100743. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100744. */
  100745. setVisibilityBox(size: number): void;
  100746. /**
  100747. * Gets whether the SPS as always visible or not
  100748. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100749. */
  100750. get isAlwaysVisible(): boolean;
  100751. /**
  100752. * Sets the SPS as always visible or not
  100753. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100754. */
  100755. set isAlwaysVisible(val: boolean);
  100756. /**
  100757. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100758. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100759. */
  100760. set isVisibilityBoxLocked(val: boolean);
  100761. /**
  100762. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100763. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100764. */
  100765. get isVisibilityBoxLocked(): boolean;
  100766. /**
  100767. * Tells to `setParticles()` to compute the particle rotations or not.
  100768. * Default value : true. The SPS is faster when it's set to false.
  100769. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100770. */
  100771. set computeParticleRotation(val: boolean);
  100772. /**
  100773. * Tells to `setParticles()` to compute the particle colors or not.
  100774. * Default value : true. The SPS is faster when it's set to false.
  100775. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100776. */
  100777. set computeParticleColor(val: boolean);
  100778. set computeParticleTexture(val: boolean);
  100779. /**
  100780. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100781. * Default value : false. The SPS is faster when it's set to false.
  100782. * Note : the particle custom vertex positions aren't stored values.
  100783. */
  100784. set computeParticleVertex(val: boolean);
  100785. /**
  100786. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100787. */
  100788. set computeBoundingBox(val: boolean);
  100789. /**
  100790. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100791. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100792. * Default : `true`
  100793. */
  100794. set depthSortParticles(val: boolean);
  100795. /**
  100796. * Gets if `setParticles()` computes the particle rotations or not.
  100797. * Default value : true. The SPS is faster when it's set to false.
  100798. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100799. */
  100800. get computeParticleRotation(): boolean;
  100801. /**
  100802. * Gets if `setParticles()` computes the particle colors or not.
  100803. * Default value : true. The SPS is faster when it's set to false.
  100804. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100805. */
  100806. get computeParticleColor(): boolean;
  100807. /**
  100808. * Gets if `setParticles()` computes the particle textures or not.
  100809. * Default value : true. The SPS is faster when it's set to false.
  100810. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100811. */
  100812. get computeParticleTexture(): boolean;
  100813. /**
  100814. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100815. * Default value : false. The SPS is faster when it's set to false.
  100816. * Note : the particle custom vertex positions aren't stored values.
  100817. */
  100818. get computeParticleVertex(): boolean;
  100819. /**
  100820. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100821. */
  100822. get computeBoundingBox(): boolean;
  100823. /**
  100824. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100825. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100826. * Default : `true`
  100827. */
  100828. get depthSortParticles(): boolean;
  100829. /**
  100830. * Gets if the SPS is created as expandable at construction time.
  100831. * Default : `false`
  100832. */
  100833. get expandable(): boolean;
  100834. /**
  100835. * Gets if the SPS supports the Multi Materials
  100836. */
  100837. get multimaterialEnabled(): boolean;
  100838. /**
  100839. * Gets if the SPS uses the model materials for its own multimaterial.
  100840. */
  100841. get useModelMaterial(): boolean;
  100842. /**
  100843. * The SPS used material array.
  100844. */
  100845. get materials(): Material[];
  100846. /**
  100847. * Sets the SPS MultiMaterial from the passed materials.
  100848. * Note : the passed array is internally copied and not used then by reference.
  100849. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100850. */
  100851. setMultiMaterial(materials: Material[]): void;
  100852. /**
  100853. * The SPS computed multimaterial object
  100854. */
  100855. get multimaterial(): MultiMaterial;
  100856. set multimaterial(mm: MultiMaterial);
  100857. /**
  100858. * If the subMeshes must be updated on the next call to setParticles()
  100859. */
  100860. get autoUpdateSubMeshes(): boolean;
  100861. set autoUpdateSubMeshes(val: boolean);
  100862. /**
  100863. * This function does nothing. It may be overwritten to set all the particle first values.
  100864. * The SPS doesn't call this function, you may have to call it by your own.
  100865. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100866. */
  100867. initParticles(): void;
  100868. /**
  100869. * This function does nothing. It may be overwritten to recycle a particle.
  100870. * The SPS doesn't call this function, you may have to call it by your own.
  100871. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100872. * @param particle The particle to recycle
  100873. * @returns the recycled particle
  100874. */
  100875. recycleParticle(particle: SolidParticle): SolidParticle;
  100876. /**
  100877. * Updates a particle : this function should be overwritten by the user.
  100878. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100879. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100880. * @example : just set a particle position or velocity and recycle conditions
  100881. * @param particle The particle to update
  100882. * @returns the updated particle
  100883. */
  100884. updateParticle(particle: SolidParticle): SolidParticle;
  100885. /**
  100886. * Updates a vertex of a particle : it can be overwritten by the user.
  100887. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100888. * @param particle the current particle
  100889. * @param vertex the current index of the current particle
  100890. * @param pt the index of the current vertex in the particle shape
  100891. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100892. * @example : just set a vertex particle position
  100893. * @returns the updated vertex
  100894. */
  100895. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100896. /**
  100897. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100898. * This does nothing and may be overwritten by the user.
  100899. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100900. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100901. * @param update the boolean update value actually passed to setParticles()
  100902. */
  100903. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100904. /**
  100905. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100906. * This will be passed three parameters.
  100907. * This does nothing and may be overwritten by the user.
  100908. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100909. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100910. * @param update the boolean update value actually passed to setParticles()
  100911. */
  100912. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100913. }
  100914. }
  100915. declare module BABYLON {
  100916. /**
  100917. * Represents one particle of a solid particle system.
  100918. */
  100919. export class SolidParticle {
  100920. /**
  100921. * particle global index
  100922. */
  100923. idx: number;
  100924. /**
  100925. * particle identifier
  100926. */
  100927. id: number;
  100928. /**
  100929. * The color of the particle
  100930. */
  100931. color: Nullable<Color4>;
  100932. /**
  100933. * The world space position of the particle.
  100934. */
  100935. position: Vector3;
  100936. /**
  100937. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100938. */
  100939. rotation: Vector3;
  100940. /**
  100941. * The world space rotation quaternion of the particle.
  100942. */
  100943. rotationQuaternion: Nullable<Quaternion>;
  100944. /**
  100945. * The scaling of the particle.
  100946. */
  100947. scaling: Vector3;
  100948. /**
  100949. * The uvs of the particle.
  100950. */
  100951. uvs: Vector4;
  100952. /**
  100953. * The current speed of the particle.
  100954. */
  100955. velocity: Vector3;
  100956. /**
  100957. * The pivot point in the particle local space.
  100958. */
  100959. pivot: Vector3;
  100960. /**
  100961. * Must the particle be translated from its pivot point in its local space ?
  100962. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100963. * Default : false
  100964. */
  100965. translateFromPivot: boolean;
  100966. /**
  100967. * Is the particle active or not ?
  100968. */
  100969. alive: boolean;
  100970. /**
  100971. * Is the particle visible or not ?
  100972. */
  100973. isVisible: boolean;
  100974. /**
  100975. * Index of this particle in the global "positions" array (Internal use)
  100976. * @hidden
  100977. */
  100978. _pos: number;
  100979. /**
  100980. * @hidden Index of this particle in the global "indices" array (Internal use)
  100981. */
  100982. _ind: number;
  100983. /**
  100984. * @hidden ModelShape of this particle (Internal use)
  100985. */
  100986. _model: ModelShape;
  100987. /**
  100988. * ModelShape id of this particle
  100989. */
  100990. shapeId: number;
  100991. /**
  100992. * Index of the particle in its shape id
  100993. */
  100994. idxInShape: number;
  100995. /**
  100996. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100997. */
  100998. _modelBoundingInfo: BoundingInfo;
  100999. /**
  101000. * @hidden Particle BoundingInfo object (Internal use)
  101001. */
  101002. _boundingInfo: BoundingInfo;
  101003. /**
  101004. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  101005. */
  101006. _sps: SolidParticleSystem;
  101007. /**
  101008. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  101009. */
  101010. _stillInvisible: boolean;
  101011. /**
  101012. * @hidden Last computed particle rotation matrix
  101013. */
  101014. _rotationMatrix: number[];
  101015. /**
  101016. * Parent particle Id, if any.
  101017. * Default null.
  101018. */
  101019. parentId: Nullable<number>;
  101020. /**
  101021. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  101022. */
  101023. materialIndex: Nullable<number>;
  101024. /**
  101025. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  101026. * The possible values are :
  101027. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101028. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101029. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101030. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101031. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101032. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  101033. * */
  101034. cullingStrategy: number;
  101035. /**
  101036. * @hidden Internal global position in the SPS.
  101037. */
  101038. _globalPosition: Vector3;
  101039. /**
  101040. * Creates a Solid Particle object.
  101041. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  101042. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  101043. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  101044. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  101045. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  101046. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  101047. * @param shapeId (integer) is the model shape identifier in the SPS.
  101048. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  101049. * @param sps defines the sps it is associated to
  101050. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  101051. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  101052. */
  101053. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  101054. /**
  101055. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  101056. * @param target the particle target
  101057. * @returns the current particle
  101058. */
  101059. copyToRef(target: SolidParticle): SolidParticle;
  101060. /**
  101061. * Legacy support, changed scale to scaling
  101062. */
  101063. get scale(): Vector3;
  101064. /**
  101065. * Legacy support, changed scale to scaling
  101066. */
  101067. set scale(scale: Vector3);
  101068. /**
  101069. * Legacy support, changed quaternion to rotationQuaternion
  101070. */
  101071. get quaternion(): Nullable<Quaternion>;
  101072. /**
  101073. * Legacy support, changed quaternion to rotationQuaternion
  101074. */
  101075. set quaternion(q: Nullable<Quaternion>);
  101076. /**
  101077. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  101078. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  101079. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  101080. * @returns true if it intersects
  101081. */
  101082. intersectsMesh(target: Mesh | SolidParticle): boolean;
  101083. /**
  101084. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  101085. * A particle is in the frustum if its bounding box intersects the frustum
  101086. * @param frustumPlanes defines the frustum to test
  101087. * @returns true if the particle is in the frustum planes
  101088. */
  101089. isInFrustum(frustumPlanes: Plane[]): boolean;
  101090. /**
  101091. * get the rotation matrix of the particle
  101092. * @hidden
  101093. */
  101094. getRotationMatrix(m: Matrix): void;
  101095. }
  101096. /**
  101097. * Represents the shape of the model used by one particle of a solid particle system.
  101098. * SPS internal tool, don't use it manually.
  101099. */
  101100. export class ModelShape {
  101101. /**
  101102. * The shape id
  101103. * @hidden
  101104. */
  101105. shapeID: number;
  101106. /**
  101107. * flat array of model positions (internal use)
  101108. * @hidden
  101109. */
  101110. _shape: Vector3[];
  101111. /**
  101112. * flat array of model UVs (internal use)
  101113. * @hidden
  101114. */
  101115. _shapeUV: number[];
  101116. /**
  101117. * color array of the model
  101118. * @hidden
  101119. */
  101120. _shapeColors: number[];
  101121. /**
  101122. * indices array of the model
  101123. * @hidden
  101124. */
  101125. _indices: number[];
  101126. /**
  101127. * normals array of the model
  101128. * @hidden
  101129. */
  101130. _normals: number[];
  101131. /**
  101132. * length of the shape in the model indices array (internal use)
  101133. * @hidden
  101134. */
  101135. _indicesLength: number;
  101136. /**
  101137. * Custom position function (internal use)
  101138. * @hidden
  101139. */
  101140. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  101141. /**
  101142. * Custom vertex function (internal use)
  101143. * @hidden
  101144. */
  101145. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  101146. /**
  101147. * Model material (internal use)
  101148. * @hidden
  101149. */
  101150. _material: Nullable<Material>;
  101151. /**
  101152. * 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.
  101153. * SPS internal tool, don't use it manually.
  101154. * @hidden
  101155. */
  101156. 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>);
  101157. }
  101158. /**
  101159. * Represents a Depth Sorted Particle in the solid particle system.
  101160. * @hidden
  101161. */
  101162. export class DepthSortedParticle {
  101163. /**
  101164. * Index of the particle in the "indices" array
  101165. */
  101166. ind: number;
  101167. /**
  101168. * Length of the particle shape in the "indices" array
  101169. */
  101170. indicesLength: number;
  101171. /**
  101172. * Squared distance from the particle to the camera
  101173. */
  101174. sqDistance: number;
  101175. /**
  101176. * Material index when used with MultiMaterials
  101177. */
  101178. materialIndex: number;
  101179. /**
  101180. * Creates a new sorted particle
  101181. * @param materialIndex
  101182. */
  101183. constructor(ind: number, indLength: number, materialIndex: number);
  101184. }
  101185. }
  101186. declare module BABYLON {
  101187. /**
  101188. * @hidden
  101189. */
  101190. export class _MeshCollisionData {
  101191. _checkCollisions: boolean;
  101192. _collisionMask: number;
  101193. _collisionGroup: number;
  101194. _collider: Nullable<Collider>;
  101195. _oldPositionForCollisions: Vector3;
  101196. _diffPositionForCollisions: Vector3;
  101197. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  101198. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  101199. }
  101200. }
  101201. declare module BABYLON {
  101202. /** @hidden */
  101203. class _FacetDataStorage {
  101204. facetPositions: Vector3[];
  101205. facetNormals: Vector3[];
  101206. facetPartitioning: number[][];
  101207. facetNb: number;
  101208. partitioningSubdivisions: number;
  101209. partitioningBBoxRatio: number;
  101210. facetDataEnabled: boolean;
  101211. facetParameters: any;
  101212. bbSize: Vector3;
  101213. subDiv: {
  101214. max: number;
  101215. X: number;
  101216. Y: number;
  101217. Z: number;
  101218. };
  101219. facetDepthSort: boolean;
  101220. facetDepthSortEnabled: boolean;
  101221. depthSortedIndices: IndicesArray;
  101222. depthSortedFacets: {
  101223. ind: number;
  101224. sqDistance: number;
  101225. }[];
  101226. facetDepthSortFunction: (f1: {
  101227. ind: number;
  101228. sqDistance: number;
  101229. }, f2: {
  101230. ind: number;
  101231. sqDistance: number;
  101232. }) => number;
  101233. facetDepthSortFrom: Vector3;
  101234. facetDepthSortOrigin: Vector3;
  101235. invertedMatrix: Matrix;
  101236. }
  101237. /**
  101238. * @hidden
  101239. **/
  101240. class _InternalAbstractMeshDataInfo {
  101241. _hasVertexAlpha: boolean;
  101242. _useVertexColors: boolean;
  101243. _numBoneInfluencers: number;
  101244. _applyFog: boolean;
  101245. _receiveShadows: boolean;
  101246. _facetData: _FacetDataStorage;
  101247. _visibility: number;
  101248. _skeleton: Nullable<Skeleton>;
  101249. _layerMask: number;
  101250. _computeBonesUsingShaders: boolean;
  101251. _isActive: boolean;
  101252. _onlyForInstances: boolean;
  101253. _isActiveIntermediate: boolean;
  101254. _onlyForInstancesIntermediate: boolean;
  101255. _actAsRegularMesh: boolean;
  101256. }
  101257. /**
  101258. * Class used to store all common mesh properties
  101259. */
  101260. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  101261. /** No occlusion */
  101262. static OCCLUSION_TYPE_NONE: number;
  101263. /** Occlusion set to optimisitic */
  101264. static OCCLUSION_TYPE_OPTIMISTIC: number;
  101265. /** Occlusion set to strict */
  101266. static OCCLUSION_TYPE_STRICT: number;
  101267. /** Use an accurante occlusion algorithm */
  101268. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  101269. /** Use a conservative occlusion algorithm */
  101270. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  101271. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  101272. * Test order :
  101273. * Is the bounding sphere outside the frustum ?
  101274. * If not, are the bounding box vertices outside the frustum ?
  101275. * It not, then the cullable object is in the frustum.
  101276. */
  101277. static readonly CULLINGSTRATEGY_STANDARD: number;
  101278. /** Culling strategy : Bounding Sphere Only.
  101279. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  101280. * It's also less accurate than the standard because some not visible objects can still be selected.
  101281. * Test : is the bounding sphere outside the frustum ?
  101282. * If not, then the cullable object is in the frustum.
  101283. */
  101284. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101285. /** Culling strategy : Optimistic Inclusion.
  101286. * This in an inclusion test first, then the standard exclusion test.
  101287. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101288. * 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.
  101289. * Anyway, it's as accurate as the standard strategy.
  101290. * Test :
  101291. * Is the cullable object bounding sphere center in the frustum ?
  101292. * If not, apply the default culling strategy.
  101293. */
  101294. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101295. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101296. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101297. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101298. * 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.
  101299. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101300. * Test :
  101301. * Is the cullable object bounding sphere center in the frustum ?
  101302. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101303. */
  101304. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101305. /**
  101306. * No billboard
  101307. */
  101308. static get BILLBOARDMODE_NONE(): number;
  101309. /** Billboard on X axis */
  101310. static get BILLBOARDMODE_X(): number;
  101311. /** Billboard on Y axis */
  101312. static get BILLBOARDMODE_Y(): number;
  101313. /** Billboard on Z axis */
  101314. static get BILLBOARDMODE_Z(): number;
  101315. /** Billboard on all axes */
  101316. static get BILLBOARDMODE_ALL(): number;
  101317. /** Billboard on using position instead of orientation */
  101318. static get BILLBOARDMODE_USE_POSITION(): number;
  101319. /** @hidden */
  101320. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101321. /**
  101322. * The culling strategy to use to check whether the mesh must be rendered or not.
  101323. * This value can be changed at any time and will be used on the next render mesh selection.
  101324. * The possible values are :
  101325. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101326. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101327. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101328. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101329. * Please read each static variable documentation to get details about the culling process.
  101330. * */
  101331. cullingStrategy: number;
  101332. /**
  101333. * Gets the number of facets in the mesh
  101334. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101335. */
  101336. get facetNb(): number;
  101337. /**
  101338. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101339. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101340. */
  101341. get partitioningSubdivisions(): number;
  101342. set partitioningSubdivisions(nb: number);
  101343. /**
  101344. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101345. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101346. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101347. */
  101348. get partitioningBBoxRatio(): number;
  101349. set partitioningBBoxRatio(ratio: number);
  101350. /**
  101351. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101352. * Works only for updatable meshes.
  101353. * Doesn't work with multi-materials
  101354. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101355. */
  101356. get mustDepthSortFacets(): boolean;
  101357. set mustDepthSortFacets(sort: boolean);
  101358. /**
  101359. * The location (Vector3) where the facet depth sort must be computed from.
  101360. * By default, the active camera position.
  101361. * Used only when facet depth sort is enabled
  101362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101363. */
  101364. get facetDepthSortFrom(): Vector3;
  101365. set facetDepthSortFrom(location: Vector3);
  101366. /**
  101367. * gets a boolean indicating if facetData is enabled
  101368. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101369. */
  101370. get isFacetDataEnabled(): boolean;
  101371. /** @hidden */
  101372. _updateNonUniformScalingState(value: boolean): boolean;
  101373. /**
  101374. * An event triggered when this mesh collides with another one
  101375. */
  101376. onCollideObservable: Observable<AbstractMesh>;
  101377. /** Set a function to call when this mesh collides with another one */
  101378. set onCollide(callback: () => void);
  101379. /**
  101380. * An event triggered when the collision's position changes
  101381. */
  101382. onCollisionPositionChangeObservable: Observable<Vector3>;
  101383. /** Set a function to call when the collision's position changes */
  101384. set onCollisionPositionChange(callback: () => void);
  101385. /**
  101386. * An event triggered when material is changed
  101387. */
  101388. onMaterialChangedObservable: Observable<AbstractMesh>;
  101389. /**
  101390. * Gets or sets the orientation for POV movement & rotation
  101391. */
  101392. definedFacingForward: boolean;
  101393. /** @hidden */
  101394. _occlusionQuery: Nullable<WebGLQuery>;
  101395. /** @hidden */
  101396. _renderingGroup: Nullable<RenderingGroup>;
  101397. /**
  101398. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101399. */
  101400. get visibility(): number;
  101401. /**
  101402. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101403. */
  101404. set visibility(value: number);
  101405. /** Gets or sets the alpha index used to sort transparent meshes
  101406. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101407. */
  101408. alphaIndex: number;
  101409. /**
  101410. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101411. */
  101412. isVisible: boolean;
  101413. /**
  101414. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101415. */
  101416. isPickable: boolean;
  101417. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101418. showSubMeshesBoundingBox: boolean;
  101419. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101420. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101421. */
  101422. isBlocker: boolean;
  101423. /**
  101424. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101425. */
  101426. enablePointerMoveEvents: boolean;
  101427. /**
  101428. * Specifies the rendering group id for this mesh (0 by default)
  101429. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101430. */
  101431. renderingGroupId: number;
  101432. private _material;
  101433. /** Gets or sets current material */
  101434. get material(): Nullable<Material>;
  101435. set material(value: Nullable<Material>);
  101436. /**
  101437. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101438. * @see http://doc.babylonjs.com/babylon101/shadows
  101439. */
  101440. get receiveShadows(): boolean;
  101441. set receiveShadows(value: boolean);
  101442. /** Defines color to use when rendering outline */
  101443. outlineColor: Color3;
  101444. /** Define width to use when rendering outline */
  101445. outlineWidth: number;
  101446. /** Defines color to use when rendering overlay */
  101447. overlayColor: Color3;
  101448. /** Defines alpha to use when rendering overlay */
  101449. overlayAlpha: number;
  101450. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101451. get hasVertexAlpha(): boolean;
  101452. set hasVertexAlpha(value: boolean);
  101453. /** 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) */
  101454. get useVertexColors(): boolean;
  101455. set useVertexColors(value: boolean);
  101456. /**
  101457. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101458. */
  101459. get computeBonesUsingShaders(): boolean;
  101460. set computeBonesUsingShaders(value: boolean);
  101461. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101462. get numBoneInfluencers(): number;
  101463. set numBoneInfluencers(value: number);
  101464. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101465. get applyFog(): boolean;
  101466. set applyFog(value: boolean);
  101467. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101468. useOctreeForRenderingSelection: boolean;
  101469. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101470. useOctreeForPicking: boolean;
  101471. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101472. useOctreeForCollisions: boolean;
  101473. /**
  101474. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101475. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101476. */
  101477. get layerMask(): number;
  101478. set layerMask(value: number);
  101479. /**
  101480. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101481. */
  101482. alwaysSelectAsActiveMesh: boolean;
  101483. /**
  101484. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101485. */
  101486. doNotSyncBoundingInfo: boolean;
  101487. /**
  101488. * Gets or sets the current action manager
  101489. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101490. */
  101491. actionManager: Nullable<AbstractActionManager>;
  101492. private _meshCollisionData;
  101493. /**
  101494. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101495. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101496. */
  101497. ellipsoid: Vector3;
  101498. /**
  101499. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101500. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101501. */
  101502. ellipsoidOffset: Vector3;
  101503. /**
  101504. * Gets or sets a collision mask used to mask collisions (default is -1).
  101505. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101506. */
  101507. get collisionMask(): number;
  101508. set collisionMask(mask: number);
  101509. /**
  101510. * Gets or sets the current collision group mask (-1 by default).
  101511. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101512. */
  101513. get collisionGroup(): number;
  101514. set collisionGroup(mask: number);
  101515. /**
  101516. * Defines edge width used when edgesRenderer is enabled
  101517. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101518. */
  101519. edgesWidth: number;
  101520. /**
  101521. * Defines edge color used when edgesRenderer is enabled
  101522. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101523. */
  101524. edgesColor: Color4;
  101525. /** @hidden */
  101526. _edgesRenderer: Nullable<IEdgesRenderer>;
  101527. /** @hidden */
  101528. _masterMesh: Nullable<AbstractMesh>;
  101529. /** @hidden */
  101530. _boundingInfo: Nullable<BoundingInfo>;
  101531. /** @hidden */
  101532. _renderId: number;
  101533. /**
  101534. * Gets or sets the list of subMeshes
  101535. * @see http://doc.babylonjs.com/how_to/multi_materials
  101536. */
  101537. subMeshes: SubMesh[];
  101538. /** @hidden */
  101539. _intersectionsInProgress: AbstractMesh[];
  101540. /** @hidden */
  101541. _unIndexed: boolean;
  101542. /** @hidden */
  101543. _lightSources: Light[];
  101544. /** Gets the list of lights affecting that mesh */
  101545. get lightSources(): Light[];
  101546. /** @hidden */
  101547. get _positions(): Nullable<Vector3[]>;
  101548. /** @hidden */
  101549. _waitingData: {
  101550. lods: Nullable<any>;
  101551. actions: Nullable<any>;
  101552. freezeWorldMatrix: Nullable<boolean>;
  101553. };
  101554. /** @hidden */
  101555. _bonesTransformMatrices: Nullable<Float32Array>;
  101556. /** @hidden */
  101557. _transformMatrixTexture: Nullable<RawTexture>;
  101558. /**
  101559. * Gets or sets a skeleton to apply skining transformations
  101560. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101561. */
  101562. set skeleton(value: Nullable<Skeleton>);
  101563. get skeleton(): Nullable<Skeleton>;
  101564. /**
  101565. * An event triggered when the mesh is rebuilt.
  101566. */
  101567. onRebuildObservable: Observable<AbstractMesh>;
  101568. /**
  101569. * Creates a new AbstractMesh
  101570. * @param name defines the name of the mesh
  101571. * @param scene defines the hosting scene
  101572. */
  101573. constructor(name: string, scene?: Nullable<Scene>);
  101574. /**
  101575. * Returns the string "AbstractMesh"
  101576. * @returns "AbstractMesh"
  101577. */
  101578. getClassName(): string;
  101579. /**
  101580. * Gets a string representation of the current mesh
  101581. * @param fullDetails defines a boolean indicating if full details must be included
  101582. * @returns a string representation of the current mesh
  101583. */
  101584. toString(fullDetails?: boolean): string;
  101585. /**
  101586. * @hidden
  101587. */
  101588. protected _getEffectiveParent(): Nullable<Node>;
  101589. /** @hidden */
  101590. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101591. /** @hidden */
  101592. _rebuild(): void;
  101593. /** @hidden */
  101594. _resyncLightSources(): void;
  101595. /** @hidden */
  101596. _resyncLightSource(light: Light): void;
  101597. /** @hidden */
  101598. _unBindEffect(): void;
  101599. /** @hidden */
  101600. _removeLightSource(light: Light, dispose: boolean): void;
  101601. private _markSubMeshesAsDirty;
  101602. /** @hidden */
  101603. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101604. /** @hidden */
  101605. _markSubMeshesAsAttributesDirty(): void;
  101606. /** @hidden */
  101607. _markSubMeshesAsMiscDirty(): void;
  101608. /**
  101609. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101610. */
  101611. get scaling(): Vector3;
  101612. set scaling(newScaling: Vector3);
  101613. /**
  101614. * Returns true if the mesh is blocked. Implemented by child classes
  101615. */
  101616. get isBlocked(): boolean;
  101617. /**
  101618. * Returns the mesh itself by default. Implemented by child classes
  101619. * @param camera defines the camera to use to pick the right LOD level
  101620. * @returns the currentAbstractMesh
  101621. */
  101622. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101623. /**
  101624. * Returns 0 by default. Implemented by child classes
  101625. * @returns an integer
  101626. */
  101627. getTotalVertices(): number;
  101628. /**
  101629. * Returns a positive integer : the total number of indices in this mesh geometry.
  101630. * @returns the numner of indices or zero if the mesh has no geometry.
  101631. */
  101632. getTotalIndices(): number;
  101633. /**
  101634. * Returns null by default. Implemented by child classes
  101635. * @returns null
  101636. */
  101637. getIndices(): Nullable<IndicesArray>;
  101638. /**
  101639. * Returns the array of the requested vertex data kind. Implemented by child classes
  101640. * @param kind defines the vertex data kind to use
  101641. * @returns null
  101642. */
  101643. getVerticesData(kind: string): Nullable<FloatArray>;
  101644. /**
  101645. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101646. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101647. * Note that a new underlying VertexBuffer object is created each call.
  101648. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101649. * @param kind defines vertex data kind:
  101650. * * VertexBuffer.PositionKind
  101651. * * VertexBuffer.UVKind
  101652. * * VertexBuffer.UV2Kind
  101653. * * VertexBuffer.UV3Kind
  101654. * * VertexBuffer.UV4Kind
  101655. * * VertexBuffer.UV5Kind
  101656. * * VertexBuffer.UV6Kind
  101657. * * VertexBuffer.ColorKind
  101658. * * VertexBuffer.MatricesIndicesKind
  101659. * * VertexBuffer.MatricesIndicesExtraKind
  101660. * * VertexBuffer.MatricesWeightsKind
  101661. * * VertexBuffer.MatricesWeightsExtraKind
  101662. * @param data defines the data source
  101663. * @param updatable defines if the data must be flagged as updatable (or static)
  101664. * @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
  101665. * @returns the current mesh
  101666. */
  101667. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101668. /**
  101669. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101670. * If the mesh has no geometry, it is simply returned as it is.
  101671. * @param kind defines vertex data kind:
  101672. * * VertexBuffer.PositionKind
  101673. * * VertexBuffer.UVKind
  101674. * * VertexBuffer.UV2Kind
  101675. * * VertexBuffer.UV3Kind
  101676. * * VertexBuffer.UV4Kind
  101677. * * VertexBuffer.UV5Kind
  101678. * * VertexBuffer.UV6Kind
  101679. * * VertexBuffer.ColorKind
  101680. * * VertexBuffer.MatricesIndicesKind
  101681. * * VertexBuffer.MatricesIndicesExtraKind
  101682. * * VertexBuffer.MatricesWeightsKind
  101683. * * VertexBuffer.MatricesWeightsExtraKind
  101684. * @param data defines the data source
  101685. * @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
  101686. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101687. * @returns the current mesh
  101688. */
  101689. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101690. /**
  101691. * Sets the mesh indices,
  101692. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101693. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101694. * @param totalVertices Defines the total number of vertices
  101695. * @returns the current mesh
  101696. */
  101697. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101698. /**
  101699. * Gets a boolean indicating if specific vertex data is present
  101700. * @param kind defines the vertex data kind to use
  101701. * @returns true is data kind is present
  101702. */
  101703. isVerticesDataPresent(kind: string): boolean;
  101704. /**
  101705. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101706. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101707. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101708. * @returns a BoundingInfo
  101709. */
  101710. getBoundingInfo(): BoundingInfo;
  101711. /**
  101712. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101713. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101714. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101715. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101716. * @returns the current mesh
  101717. */
  101718. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101719. /**
  101720. * Overwrite the current bounding info
  101721. * @param boundingInfo defines the new bounding info
  101722. * @returns the current mesh
  101723. */
  101724. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101725. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101726. get useBones(): boolean;
  101727. /** @hidden */
  101728. _preActivate(): void;
  101729. /** @hidden */
  101730. _preActivateForIntermediateRendering(renderId: number): void;
  101731. /** @hidden */
  101732. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101733. /** @hidden */
  101734. _postActivate(): void;
  101735. /** @hidden */
  101736. _freeze(): void;
  101737. /** @hidden */
  101738. _unFreeze(): void;
  101739. /**
  101740. * Gets the current world matrix
  101741. * @returns a Matrix
  101742. */
  101743. getWorldMatrix(): Matrix;
  101744. /** @hidden */
  101745. _getWorldMatrixDeterminant(): number;
  101746. /**
  101747. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101748. */
  101749. get isAnInstance(): boolean;
  101750. /**
  101751. * Gets a boolean indicating if this mesh has instances
  101752. */
  101753. get hasInstances(): boolean;
  101754. /**
  101755. * Perform relative position change from the point of view of behind the front of the mesh.
  101756. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101757. * Supports definition of mesh facing forward or backward
  101758. * @param amountRight defines the distance on the right axis
  101759. * @param amountUp defines the distance on the up axis
  101760. * @param amountForward defines the distance on the forward axis
  101761. * @returns the current mesh
  101762. */
  101763. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101764. /**
  101765. * Calculate relative position change from the point of view of behind the front of the mesh.
  101766. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101767. * Supports definition of mesh facing forward or backward
  101768. * @param amountRight defines the distance on the right axis
  101769. * @param amountUp defines the distance on the up axis
  101770. * @param amountForward defines the distance on the forward axis
  101771. * @returns the new displacement vector
  101772. */
  101773. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101774. /**
  101775. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101776. * Supports definition of mesh facing forward or backward
  101777. * @param flipBack defines the flip
  101778. * @param twirlClockwise defines the twirl
  101779. * @param tiltRight defines the tilt
  101780. * @returns the current mesh
  101781. */
  101782. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101783. /**
  101784. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101785. * Supports definition of mesh facing forward or backward.
  101786. * @param flipBack defines the flip
  101787. * @param twirlClockwise defines the twirl
  101788. * @param tiltRight defines the tilt
  101789. * @returns the new rotation vector
  101790. */
  101791. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101792. /**
  101793. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101794. * This means the mesh underlying bounding box and sphere are recomputed.
  101795. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101796. * @returns the current mesh
  101797. */
  101798. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101799. /** @hidden */
  101800. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101801. /** @hidden */
  101802. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101803. /** @hidden */
  101804. _updateBoundingInfo(): AbstractMesh;
  101805. /** @hidden */
  101806. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101807. /** @hidden */
  101808. protected _afterComputeWorldMatrix(): void;
  101809. /** @hidden */
  101810. get _effectiveMesh(): AbstractMesh;
  101811. /**
  101812. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101813. * A mesh is in the frustum if its bounding box intersects the frustum
  101814. * @param frustumPlanes defines the frustum to test
  101815. * @returns true if the mesh is in the frustum planes
  101816. */
  101817. isInFrustum(frustumPlanes: Plane[]): boolean;
  101818. /**
  101819. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101820. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101821. * @param frustumPlanes defines the frustum to test
  101822. * @returns true if the mesh is completely in the frustum planes
  101823. */
  101824. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101825. /**
  101826. * True if the mesh intersects another mesh or a SolidParticle object
  101827. * @param mesh defines a target mesh or SolidParticle to test
  101828. * @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)
  101829. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101830. * @returns true if there is an intersection
  101831. */
  101832. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101833. /**
  101834. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101835. * @param point defines the point to test
  101836. * @returns true if there is an intersection
  101837. */
  101838. intersectsPoint(point: Vector3): boolean;
  101839. /**
  101840. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101841. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101842. */
  101843. get checkCollisions(): boolean;
  101844. set checkCollisions(collisionEnabled: boolean);
  101845. /**
  101846. * Gets Collider object used to compute collisions (not physics)
  101847. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101848. */
  101849. get collider(): Nullable<Collider>;
  101850. /**
  101851. * Move the mesh using collision engine
  101852. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101853. * @param displacement defines the requested displacement vector
  101854. * @returns the current mesh
  101855. */
  101856. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101857. private _onCollisionPositionChange;
  101858. /** @hidden */
  101859. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101860. /** @hidden */
  101861. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101862. /** @hidden */
  101863. _checkCollision(collider: Collider): AbstractMesh;
  101864. /** @hidden */
  101865. _generatePointsArray(): boolean;
  101866. /**
  101867. * Checks if the passed Ray intersects with the mesh
  101868. * @param ray defines the ray to use
  101869. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101870. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101871. * @returns the picking info
  101872. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101873. */
  101874. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101875. /**
  101876. * Clones the current mesh
  101877. * @param name defines the mesh name
  101878. * @param newParent defines the new mesh parent
  101879. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101880. * @returns the new mesh
  101881. */
  101882. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101883. /**
  101884. * Disposes all the submeshes of the current meshnp
  101885. * @returns the current mesh
  101886. */
  101887. releaseSubMeshes(): AbstractMesh;
  101888. /**
  101889. * Releases resources associated with this abstract mesh.
  101890. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101891. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101892. */
  101893. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101894. /**
  101895. * Adds the passed mesh as a child to the current mesh
  101896. * @param mesh defines the child mesh
  101897. * @returns the current mesh
  101898. */
  101899. addChild(mesh: AbstractMesh): AbstractMesh;
  101900. /**
  101901. * Removes the passed mesh from the current mesh children list
  101902. * @param mesh defines the child mesh
  101903. * @returns the current mesh
  101904. */
  101905. removeChild(mesh: AbstractMesh): AbstractMesh;
  101906. /** @hidden */
  101907. private _initFacetData;
  101908. /**
  101909. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101910. * This method can be called within the render loop.
  101911. * 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
  101912. * @returns the current mesh
  101913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101914. */
  101915. updateFacetData(): AbstractMesh;
  101916. /**
  101917. * Returns the facetLocalNormals array.
  101918. * The normals are expressed in the mesh local spac
  101919. * @returns an array of Vector3
  101920. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101921. */
  101922. getFacetLocalNormals(): Vector3[];
  101923. /**
  101924. * Returns the facetLocalPositions array.
  101925. * The facet positions are expressed in the mesh local space
  101926. * @returns an array of Vector3
  101927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101928. */
  101929. getFacetLocalPositions(): Vector3[];
  101930. /**
  101931. * Returns the facetLocalPartioning array
  101932. * @returns an array of array of numbers
  101933. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101934. */
  101935. getFacetLocalPartitioning(): number[][];
  101936. /**
  101937. * Returns the i-th facet position in the world system.
  101938. * This method allocates a new Vector3 per call
  101939. * @param i defines the facet index
  101940. * @returns a new Vector3
  101941. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101942. */
  101943. getFacetPosition(i: number): Vector3;
  101944. /**
  101945. * Sets the reference Vector3 with the i-th facet position in the world system
  101946. * @param i defines the facet index
  101947. * @param ref defines the target vector
  101948. * @returns the current mesh
  101949. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101950. */
  101951. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101952. /**
  101953. * Returns the i-th facet normal in the world system.
  101954. * This method allocates a new Vector3 per call
  101955. * @param i defines the facet index
  101956. * @returns a new Vector3
  101957. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101958. */
  101959. getFacetNormal(i: number): Vector3;
  101960. /**
  101961. * Sets the reference Vector3 with the i-th facet normal in the world system
  101962. * @param i defines the facet index
  101963. * @param ref defines the target vector
  101964. * @returns the current mesh
  101965. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101966. */
  101967. getFacetNormalToRef(i: number, ref: Vector3): this;
  101968. /**
  101969. * 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)
  101970. * @param x defines x coordinate
  101971. * @param y defines y coordinate
  101972. * @param z defines z coordinate
  101973. * @returns the array of facet indexes
  101974. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101975. */
  101976. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101977. /**
  101978. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101979. * @param projected sets as the (x,y,z) world projection on the facet
  101980. * @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
  101981. * @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
  101982. * @param x defines x coordinate
  101983. * @param y defines y coordinate
  101984. * @param z defines z coordinate
  101985. * @returns the face index if found (or null instead)
  101986. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101987. */
  101988. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101989. /**
  101990. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101991. * @param projected sets as the (x,y,z) local projection on the facet
  101992. * @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
  101993. * @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
  101994. * @param x defines x coordinate
  101995. * @param y defines y coordinate
  101996. * @param z defines z coordinate
  101997. * @returns the face index if found (or null instead)
  101998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101999. */
  102000. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  102001. /**
  102002. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  102003. * @returns the parameters
  102004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102005. */
  102006. getFacetDataParameters(): any;
  102007. /**
  102008. * Disables the feature FacetData and frees the related memory
  102009. * @returns the current mesh
  102010. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102011. */
  102012. disableFacetData(): AbstractMesh;
  102013. /**
  102014. * Updates the AbstractMesh indices array
  102015. * @param indices defines the data source
  102016. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  102017. * @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)
  102018. * @returns the current mesh
  102019. */
  102020. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  102021. /**
  102022. * Creates new normals data for the mesh
  102023. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  102024. * @returns the current mesh
  102025. */
  102026. createNormals(updatable: boolean): AbstractMesh;
  102027. /**
  102028. * Align the mesh with a normal
  102029. * @param normal defines the normal to use
  102030. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  102031. * @returns the current mesh
  102032. */
  102033. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  102034. /** @hidden */
  102035. _checkOcclusionQuery(): boolean;
  102036. /**
  102037. * Disables the mesh edge rendering mode
  102038. * @returns the currentAbstractMesh
  102039. */
  102040. disableEdgesRendering(): AbstractMesh;
  102041. /**
  102042. * Enables the edge rendering mode on the mesh.
  102043. * This mode makes the mesh edges visible
  102044. * @param epsilon defines the maximal distance between two angles to detect a face
  102045. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  102046. * @returns the currentAbstractMesh
  102047. * @see https://www.babylonjs-playground.com/#19O9TU#0
  102048. */
  102049. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  102050. }
  102051. }
  102052. declare module BABYLON {
  102053. /**
  102054. * Interface used to define ActionEvent
  102055. */
  102056. export interface IActionEvent {
  102057. /** The mesh or sprite that triggered the action */
  102058. source: any;
  102059. /** The X mouse cursor position at the time of the event */
  102060. pointerX: number;
  102061. /** The Y mouse cursor position at the time of the event */
  102062. pointerY: number;
  102063. /** The mesh that is currently pointed at (can be null) */
  102064. meshUnderPointer: Nullable<AbstractMesh>;
  102065. /** the original (browser) event that triggered the ActionEvent */
  102066. sourceEvent?: any;
  102067. /** additional data for the event */
  102068. additionalData?: any;
  102069. }
  102070. /**
  102071. * ActionEvent is the event being sent when an action is triggered.
  102072. */
  102073. export class ActionEvent implements IActionEvent {
  102074. /** The mesh or sprite that triggered the action */
  102075. source: any;
  102076. /** The X mouse cursor position at the time of the event */
  102077. pointerX: number;
  102078. /** The Y mouse cursor position at the time of the event */
  102079. pointerY: number;
  102080. /** The mesh that is currently pointed at (can be null) */
  102081. meshUnderPointer: Nullable<AbstractMesh>;
  102082. /** the original (browser) event that triggered the ActionEvent */
  102083. sourceEvent?: any;
  102084. /** additional data for the event */
  102085. additionalData?: any;
  102086. /**
  102087. * Creates a new ActionEvent
  102088. * @param source The mesh or sprite that triggered the action
  102089. * @param pointerX The X mouse cursor position at the time of the event
  102090. * @param pointerY The Y mouse cursor position at the time of the event
  102091. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  102092. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  102093. * @param additionalData additional data for the event
  102094. */
  102095. constructor(
  102096. /** The mesh or sprite that triggered the action */
  102097. source: any,
  102098. /** The X mouse cursor position at the time of the event */
  102099. pointerX: number,
  102100. /** The Y mouse cursor position at the time of the event */
  102101. pointerY: number,
  102102. /** The mesh that is currently pointed at (can be null) */
  102103. meshUnderPointer: Nullable<AbstractMesh>,
  102104. /** the original (browser) event that triggered the ActionEvent */
  102105. sourceEvent?: any,
  102106. /** additional data for the event */
  102107. additionalData?: any);
  102108. /**
  102109. * Helper function to auto-create an ActionEvent from a source mesh.
  102110. * @param source The source mesh that triggered the event
  102111. * @param evt The original (browser) event
  102112. * @param additionalData additional data for the event
  102113. * @returns the new ActionEvent
  102114. */
  102115. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  102116. /**
  102117. * Helper function to auto-create an ActionEvent from a source sprite
  102118. * @param source The source sprite that triggered the event
  102119. * @param scene Scene associated with the sprite
  102120. * @param evt The original (browser) event
  102121. * @param additionalData additional data for the event
  102122. * @returns the new ActionEvent
  102123. */
  102124. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  102125. /**
  102126. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  102127. * @param scene the scene where the event occurred
  102128. * @param evt The original (browser) event
  102129. * @returns the new ActionEvent
  102130. */
  102131. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  102132. /**
  102133. * Helper function to auto-create an ActionEvent from a primitive
  102134. * @param prim defines the target primitive
  102135. * @param pointerPos defines the pointer position
  102136. * @param evt The original (browser) event
  102137. * @param additionalData additional data for the event
  102138. * @returns the new ActionEvent
  102139. */
  102140. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  102141. }
  102142. }
  102143. declare module BABYLON {
  102144. /**
  102145. * Abstract class used to decouple action Manager from scene and meshes.
  102146. * Do not instantiate.
  102147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102148. */
  102149. export abstract class AbstractActionManager implements IDisposable {
  102150. /** Gets the list of active triggers */
  102151. static Triggers: {
  102152. [key: string]: number;
  102153. };
  102154. /** Gets the cursor to use when hovering items */
  102155. hoverCursor: string;
  102156. /** Gets the list of actions */
  102157. actions: IAction[];
  102158. /**
  102159. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  102160. */
  102161. isRecursive: boolean;
  102162. /**
  102163. * Releases all associated resources
  102164. */
  102165. abstract dispose(): void;
  102166. /**
  102167. * Does this action manager has pointer triggers
  102168. */
  102169. abstract get hasPointerTriggers(): boolean;
  102170. /**
  102171. * Does this action manager has pick triggers
  102172. */
  102173. abstract get hasPickTriggers(): boolean;
  102174. /**
  102175. * Process a specific trigger
  102176. * @param trigger defines the trigger to process
  102177. * @param evt defines the event details to be processed
  102178. */
  102179. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  102180. /**
  102181. * Does this action manager handles actions of any of the given triggers
  102182. * @param triggers defines the triggers to be tested
  102183. * @return a boolean indicating whether one (or more) of the triggers is handled
  102184. */
  102185. abstract hasSpecificTriggers(triggers: number[]): boolean;
  102186. /**
  102187. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  102188. * speed.
  102189. * @param triggerA defines the trigger to be tested
  102190. * @param triggerB defines the trigger to be tested
  102191. * @return a boolean indicating whether one (or more) of the triggers is handled
  102192. */
  102193. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  102194. /**
  102195. * Does this action manager handles actions of a given trigger
  102196. * @param trigger defines the trigger to be tested
  102197. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  102198. * @return whether the trigger is handled
  102199. */
  102200. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  102201. /**
  102202. * Serialize this manager to a JSON object
  102203. * @param name defines the property name to store this manager
  102204. * @returns a JSON representation of this manager
  102205. */
  102206. abstract serialize(name: string): any;
  102207. /**
  102208. * Registers an action to this action manager
  102209. * @param action defines the action to be registered
  102210. * @return the action amended (prepared) after registration
  102211. */
  102212. abstract registerAction(action: IAction): Nullable<IAction>;
  102213. /**
  102214. * Unregisters an action to this action manager
  102215. * @param action defines the action to be unregistered
  102216. * @return a boolean indicating whether the action has been unregistered
  102217. */
  102218. abstract unregisterAction(action: IAction): Boolean;
  102219. /**
  102220. * Does exist one action manager with at least one trigger
  102221. **/
  102222. static get HasTriggers(): boolean;
  102223. /**
  102224. * Does exist one action manager with at least one pick trigger
  102225. **/
  102226. static get HasPickTriggers(): boolean;
  102227. /**
  102228. * Does exist one action manager that handles actions of a given trigger
  102229. * @param trigger defines the trigger to be tested
  102230. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  102231. **/
  102232. static HasSpecificTrigger(trigger: number): boolean;
  102233. }
  102234. }
  102235. declare module BABYLON {
  102236. /**
  102237. * Defines how a node can be built from a string name.
  102238. */
  102239. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  102240. /**
  102241. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  102242. */
  102243. export class Node implements IBehaviorAware<Node> {
  102244. /** @hidden */
  102245. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  102246. private static _NodeConstructors;
  102247. /**
  102248. * Add a new node constructor
  102249. * @param type defines the type name of the node to construct
  102250. * @param constructorFunc defines the constructor function
  102251. */
  102252. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  102253. /**
  102254. * Returns a node constructor based on type name
  102255. * @param type defines the type name
  102256. * @param name defines the new node name
  102257. * @param scene defines the hosting scene
  102258. * @param options defines optional options to transmit to constructors
  102259. * @returns the new constructor or null
  102260. */
  102261. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  102262. /**
  102263. * Gets or sets the name of the node
  102264. */
  102265. name: string;
  102266. /**
  102267. * Gets or sets the id of the node
  102268. */
  102269. id: string;
  102270. /**
  102271. * Gets or sets the unique id of the node
  102272. */
  102273. uniqueId: number;
  102274. /**
  102275. * Gets or sets a string used to store user defined state for the node
  102276. */
  102277. state: string;
  102278. /**
  102279. * Gets or sets an object used to store user defined information for the node
  102280. */
  102281. metadata: any;
  102282. /**
  102283. * For internal use only. Please do not use.
  102284. */
  102285. reservedDataStore: any;
  102286. /**
  102287. * List of inspectable custom properties (used by the Inspector)
  102288. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102289. */
  102290. inspectableCustomProperties: IInspectable[];
  102291. private _doNotSerialize;
  102292. /**
  102293. * Gets or sets a boolean used to define if the node must be serialized
  102294. */
  102295. get doNotSerialize(): boolean;
  102296. set doNotSerialize(value: boolean);
  102297. /** @hidden */
  102298. _isDisposed: boolean;
  102299. /**
  102300. * Gets a list of Animations associated with the node
  102301. */
  102302. animations: Animation[];
  102303. protected _ranges: {
  102304. [name: string]: Nullable<AnimationRange>;
  102305. };
  102306. /**
  102307. * Callback raised when the node is ready to be used
  102308. */
  102309. onReady: Nullable<(node: Node) => void>;
  102310. private _isEnabled;
  102311. private _isParentEnabled;
  102312. private _isReady;
  102313. /** @hidden */
  102314. _currentRenderId: number;
  102315. private _parentUpdateId;
  102316. /** @hidden */
  102317. _childUpdateId: number;
  102318. /** @hidden */
  102319. _waitingParentId: Nullable<string>;
  102320. /** @hidden */
  102321. _scene: Scene;
  102322. /** @hidden */
  102323. _cache: any;
  102324. private _parentNode;
  102325. private _children;
  102326. /** @hidden */
  102327. _worldMatrix: Matrix;
  102328. /** @hidden */
  102329. _worldMatrixDeterminant: number;
  102330. /** @hidden */
  102331. _worldMatrixDeterminantIsDirty: boolean;
  102332. /** @hidden */
  102333. private _sceneRootNodesIndex;
  102334. /**
  102335. * Gets a boolean indicating if the node has been disposed
  102336. * @returns true if the node was disposed
  102337. */
  102338. isDisposed(): boolean;
  102339. /**
  102340. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102341. * @see https://doc.babylonjs.com/how_to/parenting
  102342. */
  102343. set parent(parent: Nullable<Node>);
  102344. get parent(): Nullable<Node>;
  102345. /** @hidden */
  102346. _addToSceneRootNodes(): void;
  102347. /** @hidden */
  102348. _removeFromSceneRootNodes(): void;
  102349. private _animationPropertiesOverride;
  102350. /**
  102351. * Gets or sets the animation properties override
  102352. */
  102353. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102354. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102355. /**
  102356. * Gets a string idenfifying the name of the class
  102357. * @returns "Node" string
  102358. */
  102359. getClassName(): string;
  102360. /** @hidden */
  102361. readonly _isNode: boolean;
  102362. /**
  102363. * An event triggered when the mesh is disposed
  102364. */
  102365. onDisposeObservable: Observable<Node>;
  102366. private _onDisposeObserver;
  102367. /**
  102368. * Sets a callback that will be raised when the node will be disposed
  102369. */
  102370. set onDispose(callback: () => void);
  102371. /**
  102372. * Creates a new Node
  102373. * @param name the name and id to be given to this node
  102374. * @param scene the scene this node will be added to
  102375. */
  102376. constructor(name: string, scene?: Nullable<Scene>);
  102377. /**
  102378. * Gets the scene of the node
  102379. * @returns a scene
  102380. */
  102381. getScene(): Scene;
  102382. /**
  102383. * Gets the engine of the node
  102384. * @returns a Engine
  102385. */
  102386. getEngine(): Engine;
  102387. private _behaviors;
  102388. /**
  102389. * Attach a behavior to the node
  102390. * @see http://doc.babylonjs.com/features/behaviour
  102391. * @param behavior defines the behavior to attach
  102392. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102393. * @returns the current Node
  102394. */
  102395. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102396. /**
  102397. * Remove an attached behavior
  102398. * @see http://doc.babylonjs.com/features/behaviour
  102399. * @param behavior defines the behavior to attach
  102400. * @returns the current Node
  102401. */
  102402. removeBehavior(behavior: Behavior<Node>): Node;
  102403. /**
  102404. * Gets the list of attached behaviors
  102405. * @see http://doc.babylonjs.com/features/behaviour
  102406. */
  102407. get behaviors(): Behavior<Node>[];
  102408. /**
  102409. * Gets an attached behavior by name
  102410. * @param name defines the name of the behavior to look for
  102411. * @see http://doc.babylonjs.com/features/behaviour
  102412. * @returns null if behavior was not found else the requested behavior
  102413. */
  102414. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102415. /**
  102416. * Returns the latest update of the World matrix
  102417. * @returns a Matrix
  102418. */
  102419. getWorldMatrix(): Matrix;
  102420. /** @hidden */
  102421. _getWorldMatrixDeterminant(): number;
  102422. /**
  102423. * Returns directly the latest state of the mesh World matrix.
  102424. * A Matrix is returned.
  102425. */
  102426. get worldMatrixFromCache(): Matrix;
  102427. /** @hidden */
  102428. _initCache(): void;
  102429. /** @hidden */
  102430. updateCache(force?: boolean): void;
  102431. /** @hidden */
  102432. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102433. /** @hidden */
  102434. _updateCache(ignoreParentClass?: boolean): void;
  102435. /** @hidden */
  102436. _isSynchronized(): boolean;
  102437. /** @hidden */
  102438. _markSyncedWithParent(): void;
  102439. /** @hidden */
  102440. isSynchronizedWithParent(): boolean;
  102441. /** @hidden */
  102442. isSynchronized(): boolean;
  102443. /**
  102444. * Is this node ready to be used/rendered
  102445. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102446. * @return true if the node is ready
  102447. */
  102448. isReady(completeCheck?: boolean): boolean;
  102449. /**
  102450. * Is this node enabled?
  102451. * 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
  102452. * @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
  102453. * @return whether this node (and its parent) is enabled
  102454. */
  102455. isEnabled(checkAncestors?: boolean): boolean;
  102456. /** @hidden */
  102457. protected _syncParentEnabledState(): void;
  102458. /**
  102459. * Set the enabled state of this node
  102460. * @param value defines the new enabled state
  102461. */
  102462. setEnabled(value: boolean): void;
  102463. /**
  102464. * Is this node a descendant of the given node?
  102465. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102466. * @param ancestor defines the parent node to inspect
  102467. * @returns a boolean indicating if this node is a descendant of the given node
  102468. */
  102469. isDescendantOf(ancestor: Node): boolean;
  102470. /** @hidden */
  102471. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102472. /**
  102473. * Will return all nodes that have this node as ascendant
  102474. * @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
  102475. * @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
  102476. * @return all children nodes of all types
  102477. */
  102478. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102479. /**
  102480. * Get all child-meshes of this node
  102481. * @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)
  102482. * @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
  102483. * @returns an array of AbstractMesh
  102484. */
  102485. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102486. /**
  102487. * Get all direct children of this node
  102488. * @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
  102489. * @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)
  102490. * @returns an array of Node
  102491. */
  102492. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102493. /** @hidden */
  102494. _setReady(state: boolean): void;
  102495. /**
  102496. * Get an animation by name
  102497. * @param name defines the name of the animation to look for
  102498. * @returns null if not found else the requested animation
  102499. */
  102500. getAnimationByName(name: string): Nullable<Animation>;
  102501. /**
  102502. * Creates an animation range for this node
  102503. * @param name defines the name of the range
  102504. * @param from defines the starting key
  102505. * @param to defines the end key
  102506. */
  102507. createAnimationRange(name: string, from: number, to: number): void;
  102508. /**
  102509. * Delete a specific animation range
  102510. * @param name defines the name of the range to delete
  102511. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102512. */
  102513. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102514. /**
  102515. * Get an animation range by name
  102516. * @param name defines the name of the animation range to look for
  102517. * @returns null if not found else the requested animation range
  102518. */
  102519. getAnimationRange(name: string): Nullable<AnimationRange>;
  102520. /**
  102521. * Gets the list of all animation ranges defined on this node
  102522. * @returns an array
  102523. */
  102524. getAnimationRanges(): Nullable<AnimationRange>[];
  102525. /**
  102526. * Will start the animation sequence
  102527. * @param name defines the range frames for animation sequence
  102528. * @param loop defines if the animation should loop (false by default)
  102529. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102530. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102531. * @returns the object created for this animation. If range does not exist, it will return null
  102532. */
  102533. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102534. /**
  102535. * Serialize animation ranges into a JSON compatible object
  102536. * @returns serialization object
  102537. */
  102538. serializeAnimationRanges(): any;
  102539. /**
  102540. * Computes the world matrix of the node
  102541. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102542. * @returns the world matrix
  102543. */
  102544. computeWorldMatrix(force?: boolean): Matrix;
  102545. /**
  102546. * Releases resources associated with this node.
  102547. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102548. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102549. */
  102550. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102551. /**
  102552. * Parse animation range data from a serialization object and store them into a given node
  102553. * @param node defines where to store the animation ranges
  102554. * @param parsedNode defines the serialization object to read data from
  102555. * @param scene defines the hosting scene
  102556. */
  102557. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102558. /**
  102559. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102560. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102561. * @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
  102562. * @returns the new bounding vectors
  102563. */
  102564. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102565. min: Vector3;
  102566. max: Vector3;
  102567. };
  102568. }
  102569. }
  102570. declare module BABYLON {
  102571. /**
  102572. * @hidden
  102573. */
  102574. export class _IAnimationState {
  102575. key: number;
  102576. repeatCount: number;
  102577. workValue?: any;
  102578. loopMode?: number;
  102579. offsetValue?: any;
  102580. highLimitValue?: any;
  102581. }
  102582. /**
  102583. * Class used to store any kind of animation
  102584. */
  102585. export class Animation {
  102586. /**Name of the animation */
  102587. name: string;
  102588. /**Property to animate */
  102589. targetProperty: string;
  102590. /**The frames per second of the animation */
  102591. framePerSecond: number;
  102592. /**The data type of the animation */
  102593. dataType: number;
  102594. /**The loop mode of the animation */
  102595. loopMode?: number | undefined;
  102596. /**Specifies if blending should be enabled */
  102597. enableBlending?: boolean | undefined;
  102598. /**
  102599. * Use matrix interpolation instead of using direct key value when animating matrices
  102600. */
  102601. static AllowMatricesInterpolation: boolean;
  102602. /**
  102603. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102604. */
  102605. static AllowMatrixDecomposeForInterpolation: boolean;
  102606. /**
  102607. * Stores the key frames of the animation
  102608. */
  102609. private _keys;
  102610. /**
  102611. * Stores the easing function of the animation
  102612. */
  102613. private _easingFunction;
  102614. /**
  102615. * @hidden Internal use only
  102616. */
  102617. _runtimeAnimations: RuntimeAnimation[];
  102618. /**
  102619. * The set of event that will be linked to this animation
  102620. */
  102621. private _events;
  102622. /**
  102623. * Stores an array of target property paths
  102624. */
  102625. targetPropertyPath: string[];
  102626. /**
  102627. * Stores the blending speed of the animation
  102628. */
  102629. blendingSpeed: number;
  102630. /**
  102631. * Stores the animation ranges for the animation
  102632. */
  102633. private _ranges;
  102634. /**
  102635. * @hidden Internal use
  102636. */
  102637. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102638. /**
  102639. * Sets up an animation
  102640. * @param property The property to animate
  102641. * @param animationType The animation type to apply
  102642. * @param framePerSecond The frames per second of the animation
  102643. * @param easingFunction The easing function used in the animation
  102644. * @returns The created animation
  102645. */
  102646. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102647. /**
  102648. * Create and start an animation on a node
  102649. * @param name defines the name of the global animation that will be run on all nodes
  102650. * @param node defines the root node where the animation will take place
  102651. * @param targetProperty defines property to animate
  102652. * @param framePerSecond defines the number of frame per second yo use
  102653. * @param totalFrame defines the number of frames in total
  102654. * @param from defines the initial value
  102655. * @param to defines the final value
  102656. * @param loopMode defines which loop mode you want to use (off by default)
  102657. * @param easingFunction defines the easing function to use (linear by default)
  102658. * @param onAnimationEnd defines the callback to call when animation end
  102659. * @returns the animatable created for this animation
  102660. */
  102661. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102662. /**
  102663. * Create and start an animation on a node and its descendants
  102664. * @param name defines the name of the global animation that will be run on all nodes
  102665. * @param node defines the root node where the animation will take place
  102666. * @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
  102667. * @param targetProperty defines property to animate
  102668. * @param framePerSecond defines the number of frame per second to use
  102669. * @param totalFrame defines the number of frames in total
  102670. * @param from defines the initial value
  102671. * @param to defines the final value
  102672. * @param loopMode defines which loop mode you want to use (off by default)
  102673. * @param easingFunction defines the easing function to use (linear by default)
  102674. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102675. * @returns the list of animatables created for all nodes
  102676. * @example https://www.babylonjs-playground.com/#MH0VLI
  102677. */
  102678. 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[]>;
  102679. /**
  102680. * Creates a new animation, merges it with the existing animations and starts it
  102681. * @param name Name of the animation
  102682. * @param node Node which contains the scene that begins the animations
  102683. * @param targetProperty Specifies which property to animate
  102684. * @param framePerSecond The frames per second of the animation
  102685. * @param totalFrame The total number of frames
  102686. * @param from The frame at the beginning of the animation
  102687. * @param to The frame at the end of the animation
  102688. * @param loopMode Specifies the loop mode of the animation
  102689. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102690. * @param onAnimationEnd Callback to run once the animation is complete
  102691. * @returns Nullable animation
  102692. */
  102693. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102694. /**
  102695. * Transition property of an host to the target Value
  102696. * @param property The property to transition
  102697. * @param targetValue The target Value of the property
  102698. * @param host The object where the property to animate belongs
  102699. * @param scene Scene used to run the animation
  102700. * @param frameRate Framerate (in frame/s) to use
  102701. * @param transition The transition type we want to use
  102702. * @param duration The duration of the animation, in milliseconds
  102703. * @param onAnimationEnd Callback trigger at the end of the animation
  102704. * @returns Nullable animation
  102705. */
  102706. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102707. /**
  102708. * Return the array of runtime animations currently using this animation
  102709. */
  102710. get runtimeAnimations(): RuntimeAnimation[];
  102711. /**
  102712. * Specifies if any of the runtime animations are currently running
  102713. */
  102714. get hasRunningRuntimeAnimations(): boolean;
  102715. /**
  102716. * Initializes the animation
  102717. * @param name Name of the animation
  102718. * @param targetProperty Property to animate
  102719. * @param framePerSecond The frames per second of the animation
  102720. * @param dataType The data type of the animation
  102721. * @param loopMode The loop mode of the animation
  102722. * @param enableBlending Specifies if blending should be enabled
  102723. */
  102724. constructor(
  102725. /**Name of the animation */
  102726. name: string,
  102727. /**Property to animate */
  102728. targetProperty: string,
  102729. /**The frames per second of the animation */
  102730. framePerSecond: number,
  102731. /**The data type of the animation */
  102732. dataType: number,
  102733. /**The loop mode of the animation */
  102734. loopMode?: number | undefined,
  102735. /**Specifies if blending should be enabled */
  102736. enableBlending?: boolean | undefined);
  102737. /**
  102738. * Converts the animation to a string
  102739. * @param fullDetails support for multiple levels of logging within scene loading
  102740. * @returns String form of the animation
  102741. */
  102742. toString(fullDetails?: boolean): string;
  102743. /**
  102744. * Add an event to this animation
  102745. * @param event Event to add
  102746. */
  102747. addEvent(event: AnimationEvent): void;
  102748. /**
  102749. * Remove all events found at the given frame
  102750. * @param frame The frame to remove events from
  102751. */
  102752. removeEvents(frame: number): void;
  102753. /**
  102754. * Retrieves all the events from the animation
  102755. * @returns Events from the animation
  102756. */
  102757. getEvents(): AnimationEvent[];
  102758. /**
  102759. * Creates an animation range
  102760. * @param name Name of the animation range
  102761. * @param from Starting frame of the animation range
  102762. * @param to Ending frame of the animation
  102763. */
  102764. createRange(name: string, from: number, to: number): void;
  102765. /**
  102766. * Deletes an animation range by name
  102767. * @param name Name of the animation range to delete
  102768. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102769. */
  102770. deleteRange(name: string, deleteFrames?: boolean): void;
  102771. /**
  102772. * Gets the animation range by name, or null if not defined
  102773. * @param name Name of the animation range
  102774. * @returns Nullable animation range
  102775. */
  102776. getRange(name: string): Nullable<AnimationRange>;
  102777. /**
  102778. * Gets the key frames from the animation
  102779. * @returns The key frames of the animation
  102780. */
  102781. getKeys(): Array<IAnimationKey>;
  102782. /**
  102783. * Gets the highest frame rate of the animation
  102784. * @returns Highest frame rate of the animation
  102785. */
  102786. getHighestFrame(): number;
  102787. /**
  102788. * Gets the easing function of the animation
  102789. * @returns Easing function of the animation
  102790. */
  102791. getEasingFunction(): IEasingFunction;
  102792. /**
  102793. * Sets the easing function of the animation
  102794. * @param easingFunction A custom mathematical formula for animation
  102795. */
  102796. setEasingFunction(easingFunction: EasingFunction): void;
  102797. /**
  102798. * Interpolates a scalar linearly
  102799. * @param startValue Start value of the animation curve
  102800. * @param endValue End value of the animation curve
  102801. * @param gradient Scalar amount to interpolate
  102802. * @returns Interpolated scalar value
  102803. */
  102804. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102805. /**
  102806. * Interpolates a scalar cubically
  102807. * @param startValue Start value of the animation curve
  102808. * @param outTangent End tangent of the animation
  102809. * @param endValue End value of the animation curve
  102810. * @param inTangent Start tangent of the animation curve
  102811. * @param gradient Scalar amount to interpolate
  102812. * @returns Interpolated scalar value
  102813. */
  102814. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102815. /**
  102816. * Interpolates a quaternion using a spherical linear interpolation
  102817. * @param startValue Start value of the animation curve
  102818. * @param endValue End value of the animation curve
  102819. * @param gradient Scalar amount to interpolate
  102820. * @returns Interpolated quaternion value
  102821. */
  102822. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102823. /**
  102824. * Interpolates a quaternion cubically
  102825. * @param startValue Start value of the animation curve
  102826. * @param outTangent End tangent of the animation curve
  102827. * @param endValue End value of the animation curve
  102828. * @param inTangent Start tangent of the animation curve
  102829. * @param gradient Scalar amount to interpolate
  102830. * @returns Interpolated quaternion value
  102831. */
  102832. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102833. /**
  102834. * Interpolates a Vector3 linearl
  102835. * @param startValue Start value of the animation curve
  102836. * @param endValue End value of the animation curve
  102837. * @param gradient Scalar amount to interpolate
  102838. * @returns Interpolated scalar value
  102839. */
  102840. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102841. /**
  102842. * Interpolates a Vector3 cubically
  102843. * @param startValue Start value of the animation curve
  102844. * @param outTangent End tangent of the animation
  102845. * @param endValue End value of the animation curve
  102846. * @param inTangent Start tangent of the animation curve
  102847. * @param gradient Scalar amount to interpolate
  102848. * @returns InterpolatedVector3 value
  102849. */
  102850. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102851. /**
  102852. * Interpolates a Vector2 linearly
  102853. * @param startValue Start value of the animation curve
  102854. * @param endValue End value of the animation curve
  102855. * @param gradient Scalar amount to interpolate
  102856. * @returns Interpolated Vector2 value
  102857. */
  102858. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102859. /**
  102860. * Interpolates a Vector2 cubically
  102861. * @param startValue Start value of the animation curve
  102862. * @param outTangent End tangent of the animation
  102863. * @param endValue End value of the animation curve
  102864. * @param inTangent Start tangent of the animation curve
  102865. * @param gradient Scalar amount to interpolate
  102866. * @returns Interpolated Vector2 value
  102867. */
  102868. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102869. /**
  102870. * Interpolates a size linearly
  102871. * @param startValue Start value of the animation curve
  102872. * @param endValue End value of the animation curve
  102873. * @param gradient Scalar amount to interpolate
  102874. * @returns Interpolated Size value
  102875. */
  102876. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102877. /**
  102878. * Interpolates a Color3 linearly
  102879. * @param startValue Start value of the animation curve
  102880. * @param endValue End value of the animation curve
  102881. * @param gradient Scalar amount to interpolate
  102882. * @returns Interpolated Color3 value
  102883. */
  102884. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102885. /**
  102886. * Interpolates a Color4 linearly
  102887. * @param startValue Start value of the animation curve
  102888. * @param endValue End value of the animation curve
  102889. * @param gradient Scalar amount to interpolate
  102890. * @returns Interpolated Color3 value
  102891. */
  102892. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102893. /**
  102894. * @hidden Internal use only
  102895. */
  102896. _getKeyValue(value: any): any;
  102897. /**
  102898. * @hidden Internal use only
  102899. */
  102900. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102901. /**
  102902. * Defines the function to use to interpolate matrices
  102903. * @param startValue defines the start matrix
  102904. * @param endValue defines the end matrix
  102905. * @param gradient defines the gradient between both matrices
  102906. * @param result defines an optional target matrix where to store the interpolation
  102907. * @returns the interpolated matrix
  102908. */
  102909. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102910. /**
  102911. * Makes a copy of the animation
  102912. * @returns Cloned animation
  102913. */
  102914. clone(): Animation;
  102915. /**
  102916. * Sets the key frames of the animation
  102917. * @param values The animation key frames to set
  102918. */
  102919. setKeys(values: Array<IAnimationKey>): void;
  102920. /**
  102921. * Serializes the animation to an object
  102922. * @returns Serialized object
  102923. */
  102924. serialize(): any;
  102925. /**
  102926. * Float animation type
  102927. */
  102928. static readonly ANIMATIONTYPE_FLOAT: number;
  102929. /**
  102930. * Vector3 animation type
  102931. */
  102932. static readonly ANIMATIONTYPE_VECTOR3: number;
  102933. /**
  102934. * Quaternion animation type
  102935. */
  102936. static readonly ANIMATIONTYPE_QUATERNION: number;
  102937. /**
  102938. * Matrix animation type
  102939. */
  102940. static readonly ANIMATIONTYPE_MATRIX: number;
  102941. /**
  102942. * Color3 animation type
  102943. */
  102944. static readonly ANIMATIONTYPE_COLOR3: number;
  102945. /**
  102946. * Color3 animation type
  102947. */
  102948. static readonly ANIMATIONTYPE_COLOR4: number;
  102949. /**
  102950. * Vector2 animation type
  102951. */
  102952. static readonly ANIMATIONTYPE_VECTOR2: number;
  102953. /**
  102954. * Size animation type
  102955. */
  102956. static readonly ANIMATIONTYPE_SIZE: number;
  102957. /**
  102958. * Relative Loop Mode
  102959. */
  102960. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102961. /**
  102962. * Cycle Loop Mode
  102963. */
  102964. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102965. /**
  102966. * Constant Loop Mode
  102967. */
  102968. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102969. /** @hidden */
  102970. static _UniversalLerp(left: any, right: any, amount: number): any;
  102971. /**
  102972. * Parses an animation object and creates an animation
  102973. * @param parsedAnimation Parsed animation object
  102974. * @returns Animation object
  102975. */
  102976. static Parse(parsedAnimation: any): Animation;
  102977. /**
  102978. * Appends the serialized animations from the source animations
  102979. * @param source Source containing the animations
  102980. * @param destination Target to store the animations
  102981. */
  102982. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102983. }
  102984. }
  102985. declare module BABYLON {
  102986. /**
  102987. * Interface containing an array of animations
  102988. */
  102989. export interface IAnimatable {
  102990. /**
  102991. * Array of animations
  102992. */
  102993. animations: Nullable<Array<Animation>>;
  102994. }
  102995. }
  102996. declare module BABYLON {
  102997. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102998. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102999. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103000. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103001. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103002. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103003. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103004. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103005. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103006. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103007. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103008. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103009. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103010. /**
  103011. * Decorator used to define property that can be serialized as reference to a camera
  103012. * @param sourceName defines the name of the property to decorate
  103013. */
  103014. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103015. /**
  103016. * Class used to help serialization objects
  103017. */
  103018. export class SerializationHelper {
  103019. /** @hidden */
  103020. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  103021. /** @hidden */
  103022. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  103023. /** @hidden */
  103024. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  103025. /** @hidden */
  103026. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  103027. /**
  103028. * Appends the serialized animations from the source animations
  103029. * @param source Source containing the animations
  103030. * @param destination Target to store the animations
  103031. */
  103032. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  103033. /**
  103034. * Static function used to serialized a specific entity
  103035. * @param entity defines the entity to serialize
  103036. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  103037. * @returns a JSON compatible object representing the serialization of the entity
  103038. */
  103039. static Serialize<T>(entity: T, serializationObject?: any): any;
  103040. /**
  103041. * Creates a new entity from a serialization data object
  103042. * @param creationFunction defines a function used to instanciated the new entity
  103043. * @param source defines the source serialization data
  103044. * @param scene defines the hosting scene
  103045. * @param rootUrl defines the root url for resources
  103046. * @returns a new entity
  103047. */
  103048. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  103049. /**
  103050. * Clones an object
  103051. * @param creationFunction defines the function used to instanciate the new object
  103052. * @param source defines the source object
  103053. * @returns the cloned object
  103054. */
  103055. static Clone<T>(creationFunction: () => T, source: T): T;
  103056. /**
  103057. * Instanciates a new object based on a source one (some data will be shared between both object)
  103058. * @param creationFunction defines the function used to instanciate the new object
  103059. * @param source defines the source object
  103060. * @returns the new object
  103061. */
  103062. static Instanciate<T>(creationFunction: () => T, source: T): T;
  103063. }
  103064. }
  103065. declare module BABYLON {
  103066. /**
  103067. * Class used to manipulate GUIDs
  103068. */
  103069. export class GUID {
  103070. /**
  103071. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103072. * Be aware Math.random() could cause collisions, but:
  103073. * "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"
  103074. * @returns a pseudo random id
  103075. */
  103076. static RandomId(): string;
  103077. }
  103078. }
  103079. declare module BABYLON {
  103080. /**
  103081. * Base class of all the textures in babylon.
  103082. * It groups all the common properties the materials, post process, lights... might need
  103083. * in order to make a correct use of the texture.
  103084. */
  103085. export class BaseTexture implements IAnimatable {
  103086. /**
  103087. * Default anisotropic filtering level for the application.
  103088. * It is set to 4 as a good tradeoff between perf and quality.
  103089. */
  103090. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  103091. /**
  103092. * Gets or sets the unique id of the texture
  103093. */
  103094. uniqueId: number;
  103095. /**
  103096. * Define the name of the texture.
  103097. */
  103098. name: string;
  103099. /**
  103100. * Gets or sets an object used to store user defined information.
  103101. */
  103102. metadata: any;
  103103. /**
  103104. * For internal use only. Please do not use.
  103105. */
  103106. reservedDataStore: any;
  103107. private _hasAlpha;
  103108. /**
  103109. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  103110. */
  103111. set hasAlpha(value: boolean);
  103112. get hasAlpha(): boolean;
  103113. /**
  103114. * Defines if the alpha value should be determined via the rgb values.
  103115. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  103116. */
  103117. getAlphaFromRGB: boolean;
  103118. /**
  103119. * Intensity or strength of the texture.
  103120. * It is commonly used by materials to fine tune the intensity of the texture
  103121. */
  103122. level: number;
  103123. /**
  103124. * Define the UV chanel to use starting from 0 and defaulting to 0.
  103125. * This is part of the texture as textures usually maps to one uv set.
  103126. */
  103127. coordinatesIndex: number;
  103128. private _coordinatesMode;
  103129. /**
  103130. * How a texture is mapped.
  103131. *
  103132. * | Value | Type | Description |
  103133. * | ----- | ----------------------------------- | ----------- |
  103134. * | 0 | EXPLICIT_MODE | |
  103135. * | 1 | SPHERICAL_MODE | |
  103136. * | 2 | PLANAR_MODE | |
  103137. * | 3 | CUBIC_MODE | |
  103138. * | 4 | PROJECTION_MODE | |
  103139. * | 5 | SKYBOX_MODE | |
  103140. * | 6 | INVCUBIC_MODE | |
  103141. * | 7 | EQUIRECTANGULAR_MODE | |
  103142. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  103143. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  103144. */
  103145. set coordinatesMode(value: number);
  103146. get coordinatesMode(): number;
  103147. /**
  103148. * | Value | Type | Description |
  103149. * | ----- | ------------------ | ----------- |
  103150. * | 0 | CLAMP_ADDRESSMODE | |
  103151. * | 1 | WRAP_ADDRESSMODE | |
  103152. * | 2 | MIRROR_ADDRESSMODE | |
  103153. */
  103154. wrapU: number;
  103155. /**
  103156. * | Value | Type | Description |
  103157. * | ----- | ------------------ | ----------- |
  103158. * | 0 | CLAMP_ADDRESSMODE | |
  103159. * | 1 | WRAP_ADDRESSMODE | |
  103160. * | 2 | MIRROR_ADDRESSMODE | |
  103161. */
  103162. wrapV: number;
  103163. /**
  103164. * | Value | Type | Description |
  103165. * | ----- | ------------------ | ----------- |
  103166. * | 0 | CLAMP_ADDRESSMODE | |
  103167. * | 1 | WRAP_ADDRESSMODE | |
  103168. * | 2 | MIRROR_ADDRESSMODE | |
  103169. */
  103170. wrapR: number;
  103171. /**
  103172. * With compliant hardware and browser (supporting anisotropic filtering)
  103173. * this defines the level of anisotropic filtering in the texture.
  103174. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  103175. */
  103176. anisotropicFilteringLevel: number;
  103177. /**
  103178. * Define if the texture is a cube texture or if false a 2d texture.
  103179. */
  103180. get isCube(): boolean;
  103181. set isCube(value: boolean);
  103182. /**
  103183. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  103184. */
  103185. get is3D(): boolean;
  103186. set is3D(value: boolean);
  103187. /**
  103188. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  103189. */
  103190. get is2DArray(): boolean;
  103191. set is2DArray(value: boolean);
  103192. /**
  103193. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  103194. * HDR texture are usually stored in linear space.
  103195. * This only impacts the PBR and Background materials
  103196. */
  103197. gammaSpace: boolean;
  103198. /**
  103199. * Gets or sets whether or not the texture contains RGBD data.
  103200. */
  103201. get isRGBD(): boolean;
  103202. set isRGBD(value: boolean);
  103203. /**
  103204. * Is Z inverted in the texture (useful in a cube texture).
  103205. */
  103206. invertZ: boolean;
  103207. /**
  103208. * Are mip maps generated for this texture or not.
  103209. */
  103210. get noMipmap(): boolean;
  103211. /**
  103212. * @hidden
  103213. */
  103214. lodLevelInAlpha: boolean;
  103215. /**
  103216. * With prefiltered texture, defined the offset used during the prefiltering steps.
  103217. */
  103218. get lodGenerationOffset(): number;
  103219. set lodGenerationOffset(value: number);
  103220. /**
  103221. * With prefiltered texture, defined the scale used during the prefiltering steps.
  103222. */
  103223. get lodGenerationScale(): number;
  103224. set lodGenerationScale(value: number);
  103225. /**
  103226. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  103227. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  103228. * average roughness values.
  103229. */
  103230. get linearSpecularLOD(): boolean;
  103231. set linearSpecularLOD(value: boolean);
  103232. /**
  103233. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  103234. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  103235. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  103236. */
  103237. get irradianceTexture(): Nullable<BaseTexture>;
  103238. set irradianceTexture(value: Nullable<BaseTexture>);
  103239. /**
  103240. * Define if the texture is a render target.
  103241. */
  103242. isRenderTarget: boolean;
  103243. /**
  103244. * Define the unique id of the texture in the scene.
  103245. */
  103246. get uid(): string;
  103247. /**
  103248. * Return a string representation of the texture.
  103249. * @returns the texture as a string
  103250. */
  103251. toString(): string;
  103252. /**
  103253. * Get the class name of the texture.
  103254. * @returns "BaseTexture"
  103255. */
  103256. getClassName(): string;
  103257. /**
  103258. * Define the list of animation attached to the texture.
  103259. */
  103260. animations: Animation[];
  103261. /**
  103262. * An event triggered when the texture is disposed.
  103263. */
  103264. onDisposeObservable: Observable<BaseTexture>;
  103265. private _onDisposeObserver;
  103266. /**
  103267. * Callback triggered when the texture has been disposed.
  103268. * Kept for back compatibility, you can use the onDisposeObservable instead.
  103269. */
  103270. set onDispose(callback: () => void);
  103271. /**
  103272. * Define the current state of the loading sequence when in delayed load mode.
  103273. */
  103274. delayLoadState: number;
  103275. private _scene;
  103276. /** @hidden */
  103277. _texture: Nullable<InternalTexture>;
  103278. private _uid;
  103279. /**
  103280. * Define if the texture is preventinga material to render or not.
  103281. * If not and the texture is not ready, the engine will use a default black texture instead.
  103282. */
  103283. get isBlocking(): boolean;
  103284. /**
  103285. * Instantiates a new BaseTexture.
  103286. * Base class of all the textures in babylon.
  103287. * It groups all the common properties the materials, post process, lights... might need
  103288. * in order to make a correct use of the texture.
  103289. * @param scene Define the scene the texture blongs to
  103290. */
  103291. constructor(scene: Nullable<Scene>);
  103292. /**
  103293. * Get the scene the texture belongs to.
  103294. * @returns the scene or null if undefined
  103295. */
  103296. getScene(): Nullable<Scene>;
  103297. /**
  103298. * Get the texture transform matrix used to offset tile the texture for istance.
  103299. * @returns the transformation matrix
  103300. */
  103301. getTextureMatrix(): Matrix;
  103302. /**
  103303. * Get the texture reflection matrix used to rotate/transform the reflection.
  103304. * @returns the reflection matrix
  103305. */
  103306. getReflectionTextureMatrix(): Matrix;
  103307. /**
  103308. * Get the underlying lower level texture from Babylon.
  103309. * @returns the insternal texture
  103310. */
  103311. getInternalTexture(): Nullable<InternalTexture>;
  103312. /**
  103313. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103314. * @returns true if ready or not blocking
  103315. */
  103316. isReadyOrNotBlocking(): boolean;
  103317. /**
  103318. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103319. * @returns true if fully ready
  103320. */
  103321. isReady(): boolean;
  103322. private _cachedSize;
  103323. /**
  103324. * Get the size of the texture.
  103325. * @returns the texture size.
  103326. */
  103327. getSize(): ISize;
  103328. /**
  103329. * Get the base size of the texture.
  103330. * It can be different from the size if the texture has been resized for POT for instance
  103331. * @returns the base size
  103332. */
  103333. getBaseSize(): ISize;
  103334. /**
  103335. * Update the sampling mode of the texture.
  103336. * Default is Trilinear mode.
  103337. *
  103338. * | Value | Type | Description |
  103339. * | ----- | ------------------ | ----------- |
  103340. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103341. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103342. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103343. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103344. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103345. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103346. * | 7 | NEAREST_LINEAR | |
  103347. * | 8 | NEAREST_NEAREST | |
  103348. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103349. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103350. * | 11 | LINEAR_LINEAR | |
  103351. * | 12 | LINEAR_NEAREST | |
  103352. *
  103353. * > _mag_: magnification filter (close to the viewer)
  103354. * > _min_: minification filter (far from the viewer)
  103355. * > _mip_: filter used between mip map levels
  103356. *@param samplingMode Define the new sampling mode of the texture
  103357. */
  103358. updateSamplingMode(samplingMode: number): void;
  103359. /**
  103360. * Scales the texture if is `canRescale()`
  103361. * @param ratio the resize factor we want to use to rescale
  103362. */
  103363. scale(ratio: number): void;
  103364. /**
  103365. * Get if the texture can rescale.
  103366. */
  103367. get canRescale(): boolean;
  103368. /** @hidden */
  103369. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103370. /** @hidden */
  103371. _rebuild(): void;
  103372. /**
  103373. * Triggers the load sequence in delayed load mode.
  103374. */
  103375. delayLoad(): void;
  103376. /**
  103377. * Clones the texture.
  103378. * @returns the cloned texture
  103379. */
  103380. clone(): Nullable<BaseTexture>;
  103381. /**
  103382. * Get the texture underlying type (INT, FLOAT...)
  103383. */
  103384. get textureType(): number;
  103385. /**
  103386. * Get the texture underlying format (RGB, RGBA...)
  103387. */
  103388. get textureFormat(): number;
  103389. /**
  103390. * Indicates that textures need to be re-calculated for all materials
  103391. */
  103392. protected _markAllSubMeshesAsTexturesDirty(): void;
  103393. /**
  103394. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103395. * This will returns an RGBA array buffer containing either in values (0-255) or
  103396. * float values (0-1) depending of the underlying buffer type.
  103397. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103398. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103399. * @param buffer defines a user defined buffer to fill with data (can be null)
  103400. * @returns The Array buffer containing the pixels data.
  103401. */
  103402. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103403. /**
  103404. * Release and destroy the underlying lower level texture aka internalTexture.
  103405. */
  103406. releaseInternalTexture(): void;
  103407. /** @hidden */
  103408. get _lodTextureHigh(): Nullable<BaseTexture>;
  103409. /** @hidden */
  103410. get _lodTextureMid(): Nullable<BaseTexture>;
  103411. /** @hidden */
  103412. get _lodTextureLow(): Nullable<BaseTexture>;
  103413. /**
  103414. * Dispose the texture and release its associated resources.
  103415. */
  103416. dispose(): void;
  103417. /**
  103418. * Serialize the texture into a JSON representation that can be parsed later on.
  103419. * @returns the JSON representation of the texture
  103420. */
  103421. serialize(): any;
  103422. /**
  103423. * Helper function to be called back once a list of texture contains only ready textures.
  103424. * @param textures Define the list of textures to wait for
  103425. * @param callback Define the callback triggered once the entire list will be ready
  103426. */
  103427. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103428. }
  103429. }
  103430. declare module BABYLON {
  103431. /**
  103432. * Options to be used when creating an effect.
  103433. */
  103434. export interface IEffectCreationOptions {
  103435. /**
  103436. * Atrributes that will be used in the shader.
  103437. */
  103438. attributes: string[];
  103439. /**
  103440. * Uniform varible names that will be set in the shader.
  103441. */
  103442. uniformsNames: string[];
  103443. /**
  103444. * Uniform buffer variable names that will be set in the shader.
  103445. */
  103446. uniformBuffersNames: string[];
  103447. /**
  103448. * Sampler texture variable names that will be set in the shader.
  103449. */
  103450. samplers: string[];
  103451. /**
  103452. * Define statements that will be set in the shader.
  103453. */
  103454. defines: any;
  103455. /**
  103456. * Possible fallbacks for this effect to improve performance when needed.
  103457. */
  103458. fallbacks: Nullable<IEffectFallbacks>;
  103459. /**
  103460. * Callback that will be called when the shader is compiled.
  103461. */
  103462. onCompiled: Nullable<(effect: Effect) => void>;
  103463. /**
  103464. * Callback that will be called if an error occurs during shader compilation.
  103465. */
  103466. onError: Nullable<(effect: Effect, errors: string) => void>;
  103467. /**
  103468. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103469. */
  103470. indexParameters?: any;
  103471. /**
  103472. * Max number of lights that can be used in the shader.
  103473. */
  103474. maxSimultaneousLights?: number;
  103475. /**
  103476. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103477. */
  103478. transformFeedbackVaryings?: Nullable<string[]>;
  103479. }
  103480. /**
  103481. * Effect containing vertex and fragment shader that can be executed on an object.
  103482. */
  103483. export class Effect implements IDisposable {
  103484. /**
  103485. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103486. */
  103487. static ShadersRepository: string;
  103488. /**
  103489. * Enable logging of the shader code when a compilation error occurs
  103490. */
  103491. static LogShaderCodeOnCompilationError: boolean;
  103492. /**
  103493. * Name of the effect.
  103494. */
  103495. name: any;
  103496. /**
  103497. * String container all the define statements that should be set on the shader.
  103498. */
  103499. defines: string;
  103500. /**
  103501. * Callback that will be called when the shader is compiled.
  103502. */
  103503. onCompiled: Nullable<(effect: Effect) => void>;
  103504. /**
  103505. * Callback that will be called if an error occurs during shader compilation.
  103506. */
  103507. onError: Nullable<(effect: Effect, errors: string) => void>;
  103508. /**
  103509. * Callback that will be called when effect is bound.
  103510. */
  103511. onBind: Nullable<(effect: Effect) => void>;
  103512. /**
  103513. * Unique ID of the effect.
  103514. */
  103515. uniqueId: number;
  103516. /**
  103517. * Observable that will be called when the shader is compiled.
  103518. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103519. */
  103520. onCompileObservable: Observable<Effect>;
  103521. /**
  103522. * Observable that will be called if an error occurs during shader compilation.
  103523. */
  103524. onErrorObservable: Observable<Effect>;
  103525. /** @hidden */
  103526. _onBindObservable: Nullable<Observable<Effect>>;
  103527. /**
  103528. * @hidden
  103529. * Specifies if the effect was previously ready
  103530. */
  103531. _wasPreviouslyReady: boolean;
  103532. /**
  103533. * Observable that will be called when effect is bound.
  103534. */
  103535. get onBindObservable(): Observable<Effect>;
  103536. /** @hidden */
  103537. _bonesComputationForcedToCPU: boolean;
  103538. private static _uniqueIdSeed;
  103539. private _engine;
  103540. private _uniformBuffersNames;
  103541. private _uniformsNames;
  103542. private _samplerList;
  103543. private _samplers;
  103544. private _isReady;
  103545. private _compilationError;
  103546. private _allFallbacksProcessed;
  103547. private _attributesNames;
  103548. private _attributes;
  103549. private _attributeLocationByName;
  103550. private _uniforms;
  103551. /**
  103552. * Key for the effect.
  103553. * @hidden
  103554. */
  103555. _key: string;
  103556. private _indexParameters;
  103557. private _fallbacks;
  103558. private _vertexSourceCode;
  103559. private _fragmentSourceCode;
  103560. private _vertexSourceCodeOverride;
  103561. private _fragmentSourceCodeOverride;
  103562. private _transformFeedbackVaryings;
  103563. /**
  103564. * Compiled shader to webGL program.
  103565. * @hidden
  103566. */
  103567. _pipelineContext: Nullable<IPipelineContext>;
  103568. private _valueCache;
  103569. private static _baseCache;
  103570. /**
  103571. * Instantiates an effect.
  103572. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103573. * @param baseName Name of the effect.
  103574. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103575. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103576. * @param samplers List of sampler variables that will be passed to the shader.
  103577. * @param engine Engine to be used to render the effect
  103578. * @param defines Define statements to be added to the shader.
  103579. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103580. * @param onCompiled Callback that will be called when the shader is compiled.
  103581. * @param onError Callback that will be called if an error occurs during shader compilation.
  103582. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103583. */
  103584. 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);
  103585. private _useFinalCode;
  103586. /**
  103587. * Unique key for this effect
  103588. */
  103589. get key(): string;
  103590. /**
  103591. * If the effect has been compiled and prepared.
  103592. * @returns if the effect is compiled and prepared.
  103593. */
  103594. isReady(): boolean;
  103595. private _isReadyInternal;
  103596. /**
  103597. * The engine the effect was initialized with.
  103598. * @returns the engine.
  103599. */
  103600. getEngine(): Engine;
  103601. /**
  103602. * The pipeline context for this effect
  103603. * @returns the associated pipeline context
  103604. */
  103605. getPipelineContext(): Nullable<IPipelineContext>;
  103606. /**
  103607. * The set of names of attribute variables for the shader.
  103608. * @returns An array of attribute names.
  103609. */
  103610. getAttributesNames(): string[];
  103611. /**
  103612. * Returns the attribute at the given index.
  103613. * @param index The index of the attribute.
  103614. * @returns The location of the attribute.
  103615. */
  103616. getAttributeLocation(index: number): number;
  103617. /**
  103618. * Returns the attribute based on the name of the variable.
  103619. * @param name of the attribute to look up.
  103620. * @returns the attribute location.
  103621. */
  103622. getAttributeLocationByName(name: string): number;
  103623. /**
  103624. * The number of attributes.
  103625. * @returns the numnber of attributes.
  103626. */
  103627. getAttributesCount(): number;
  103628. /**
  103629. * Gets the index of a uniform variable.
  103630. * @param uniformName of the uniform to look up.
  103631. * @returns the index.
  103632. */
  103633. getUniformIndex(uniformName: string): number;
  103634. /**
  103635. * Returns the attribute based on the name of the variable.
  103636. * @param uniformName of the uniform to look up.
  103637. * @returns the location of the uniform.
  103638. */
  103639. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103640. /**
  103641. * Returns an array of sampler variable names
  103642. * @returns The array of sampler variable neames.
  103643. */
  103644. getSamplers(): string[];
  103645. /**
  103646. * The error from the last compilation.
  103647. * @returns the error string.
  103648. */
  103649. getCompilationError(): string;
  103650. /**
  103651. * Gets a boolean indicating that all fallbacks were used during compilation
  103652. * @returns true if all fallbacks were used
  103653. */
  103654. allFallbacksProcessed(): boolean;
  103655. /**
  103656. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103657. * @param func The callback to be used.
  103658. */
  103659. executeWhenCompiled(func: (effect: Effect) => void): void;
  103660. private _checkIsReady;
  103661. private _loadShader;
  103662. /**
  103663. * Recompiles the webGL program
  103664. * @param vertexSourceCode The source code for the vertex shader.
  103665. * @param fragmentSourceCode The source code for the fragment shader.
  103666. * @param onCompiled Callback called when completed.
  103667. * @param onError Callback called on error.
  103668. * @hidden
  103669. */
  103670. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103671. /**
  103672. * Prepares the effect
  103673. * @hidden
  103674. */
  103675. _prepareEffect(): void;
  103676. private _getShaderCodeAndErrorLine;
  103677. private _processCompilationErrors;
  103678. /**
  103679. * Checks if the effect is supported. (Must be called after compilation)
  103680. */
  103681. get isSupported(): boolean;
  103682. /**
  103683. * Binds a texture to the engine to be used as output of the shader.
  103684. * @param channel Name of the output variable.
  103685. * @param texture Texture to bind.
  103686. * @hidden
  103687. */
  103688. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103689. /**
  103690. * Sets a texture on the engine to be used in the shader.
  103691. * @param channel Name of the sampler variable.
  103692. * @param texture Texture to set.
  103693. */
  103694. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103695. /**
  103696. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103697. * @param channel Name of the sampler variable.
  103698. * @param texture Texture to set.
  103699. */
  103700. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103701. /**
  103702. * Sets an array of textures on the engine to be used in the shader.
  103703. * @param channel Name of the variable.
  103704. * @param textures Textures to set.
  103705. */
  103706. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103707. /**
  103708. * 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)
  103709. * @param channel Name of the sampler variable.
  103710. * @param postProcess Post process to get the input texture from.
  103711. */
  103712. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103713. /**
  103714. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103715. * 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)
  103716. * @param channel Name of the sampler variable.
  103717. * @param postProcess Post process to get the output texture from.
  103718. */
  103719. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103720. /** @hidden */
  103721. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103722. /** @hidden */
  103723. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103724. /** @hidden */
  103725. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103726. /** @hidden */
  103727. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103728. /**
  103729. * Binds a buffer to a uniform.
  103730. * @param buffer Buffer to bind.
  103731. * @param name Name of the uniform variable to bind to.
  103732. */
  103733. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103734. /**
  103735. * Binds block to a uniform.
  103736. * @param blockName Name of the block to bind.
  103737. * @param index Index to bind.
  103738. */
  103739. bindUniformBlock(blockName: string, index: number): void;
  103740. /**
  103741. * Sets an interger value on a uniform variable.
  103742. * @param uniformName Name of the variable.
  103743. * @param value Value to be set.
  103744. * @returns this effect.
  103745. */
  103746. setInt(uniformName: string, value: number): Effect;
  103747. /**
  103748. * Sets an int array on a uniform variable.
  103749. * @param uniformName Name of the variable.
  103750. * @param array array to be set.
  103751. * @returns this effect.
  103752. */
  103753. setIntArray(uniformName: string, array: Int32Array): Effect;
  103754. /**
  103755. * 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)
  103756. * @param uniformName Name of the variable.
  103757. * @param array array to be set.
  103758. * @returns this effect.
  103759. */
  103760. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103761. /**
  103762. * 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)
  103763. * @param uniformName Name of the variable.
  103764. * @param array array to be set.
  103765. * @returns this effect.
  103766. */
  103767. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103768. /**
  103769. * 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)
  103770. * @param uniformName Name of the variable.
  103771. * @param array array to be set.
  103772. * @returns this effect.
  103773. */
  103774. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103775. /**
  103776. * Sets an float array on a uniform variable.
  103777. * @param uniformName Name of the variable.
  103778. * @param array array to be set.
  103779. * @returns this effect.
  103780. */
  103781. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103782. /**
  103783. * 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)
  103784. * @param uniformName Name of the variable.
  103785. * @param array array to be set.
  103786. * @returns this effect.
  103787. */
  103788. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103789. /**
  103790. * 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)
  103791. * @param uniformName Name of the variable.
  103792. * @param array array to be set.
  103793. * @returns this effect.
  103794. */
  103795. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103796. /**
  103797. * 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)
  103798. * @param uniformName Name of the variable.
  103799. * @param array array to be set.
  103800. * @returns this effect.
  103801. */
  103802. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103803. /**
  103804. * Sets an array on a uniform variable.
  103805. * @param uniformName Name of the variable.
  103806. * @param array array to be set.
  103807. * @returns this effect.
  103808. */
  103809. setArray(uniformName: string, array: number[]): Effect;
  103810. /**
  103811. * 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)
  103812. * @param uniformName Name of the variable.
  103813. * @param array array to be set.
  103814. * @returns this effect.
  103815. */
  103816. setArray2(uniformName: string, array: number[]): Effect;
  103817. /**
  103818. * 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)
  103819. * @param uniformName Name of the variable.
  103820. * @param array array to be set.
  103821. * @returns this effect.
  103822. */
  103823. setArray3(uniformName: string, array: number[]): Effect;
  103824. /**
  103825. * 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)
  103826. * @param uniformName Name of the variable.
  103827. * @param array array to be set.
  103828. * @returns this effect.
  103829. */
  103830. setArray4(uniformName: string, array: number[]): Effect;
  103831. /**
  103832. * Sets matrices on a uniform variable.
  103833. * @param uniformName Name of the variable.
  103834. * @param matrices matrices to be set.
  103835. * @returns this effect.
  103836. */
  103837. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103838. /**
  103839. * Sets matrix on a uniform variable.
  103840. * @param uniformName Name of the variable.
  103841. * @param matrix matrix to be set.
  103842. * @returns this effect.
  103843. */
  103844. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103845. /**
  103846. * 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)
  103847. * @param uniformName Name of the variable.
  103848. * @param matrix matrix to be set.
  103849. * @returns this effect.
  103850. */
  103851. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103852. /**
  103853. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103854. * @param uniformName Name of the variable.
  103855. * @param matrix matrix to be set.
  103856. * @returns this effect.
  103857. */
  103858. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103859. /**
  103860. * Sets a float on a uniform variable.
  103861. * @param uniformName Name of the variable.
  103862. * @param value value to be set.
  103863. * @returns this effect.
  103864. */
  103865. setFloat(uniformName: string, value: number): Effect;
  103866. /**
  103867. * Sets a boolean on a uniform variable.
  103868. * @param uniformName Name of the variable.
  103869. * @param bool value to be set.
  103870. * @returns this effect.
  103871. */
  103872. setBool(uniformName: string, bool: boolean): Effect;
  103873. /**
  103874. * Sets a Vector2 on a uniform variable.
  103875. * @param uniformName Name of the variable.
  103876. * @param vector2 vector2 to be set.
  103877. * @returns this effect.
  103878. */
  103879. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103880. /**
  103881. * Sets a float2 on a uniform variable.
  103882. * @param uniformName Name of the variable.
  103883. * @param x First float in float2.
  103884. * @param y Second float in float2.
  103885. * @returns this effect.
  103886. */
  103887. setFloat2(uniformName: string, x: number, y: number): Effect;
  103888. /**
  103889. * Sets a Vector3 on a uniform variable.
  103890. * @param uniformName Name of the variable.
  103891. * @param vector3 Value to be set.
  103892. * @returns this effect.
  103893. */
  103894. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103895. /**
  103896. * Sets a float3 on a uniform variable.
  103897. * @param uniformName Name of the variable.
  103898. * @param x First float in float3.
  103899. * @param y Second float in float3.
  103900. * @param z Third float in float3.
  103901. * @returns this effect.
  103902. */
  103903. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103904. /**
  103905. * Sets a Vector4 on a uniform variable.
  103906. * @param uniformName Name of the variable.
  103907. * @param vector4 Value to be set.
  103908. * @returns this effect.
  103909. */
  103910. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103911. /**
  103912. * Sets a float4 on a uniform variable.
  103913. * @param uniformName Name of the variable.
  103914. * @param x First float in float4.
  103915. * @param y Second float in float4.
  103916. * @param z Third float in float4.
  103917. * @param w Fourth float in float4.
  103918. * @returns this effect.
  103919. */
  103920. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103921. /**
  103922. * Sets a Color3 on a uniform variable.
  103923. * @param uniformName Name of the variable.
  103924. * @param color3 Value to be set.
  103925. * @returns this effect.
  103926. */
  103927. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103928. /**
  103929. * Sets a Color4 on a uniform variable.
  103930. * @param uniformName Name of the variable.
  103931. * @param color3 Value to be set.
  103932. * @param alpha Alpha value to be set.
  103933. * @returns this effect.
  103934. */
  103935. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103936. /**
  103937. * Sets a Color4 on a uniform variable
  103938. * @param uniformName defines the name of the variable
  103939. * @param color4 defines the value to be set
  103940. * @returns this effect.
  103941. */
  103942. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103943. /** Release all associated resources */
  103944. dispose(): void;
  103945. /**
  103946. * This function will add a new shader to the shader store
  103947. * @param name the name of the shader
  103948. * @param pixelShader optional pixel shader content
  103949. * @param vertexShader optional vertex shader content
  103950. */
  103951. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103952. /**
  103953. * Store of each shader (The can be looked up using effect.key)
  103954. */
  103955. static ShadersStore: {
  103956. [key: string]: string;
  103957. };
  103958. /**
  103959. * Store of each included file for a shader (The can be looked up using effect.key)
  103960. */
  103961. static IncludesShadersStore: {
  103962. [key: string]: string;
  103963. };
  103964. /**
  103965. * Resets the cache of effects.
  103966. */
  103967. static ResetCache(): void;
  103968. }
  103969. }
  103970. declare module BABYLON {
  103971. /**
  103972. * Interface used to describe the capabilities of the engine relatively to the current browser
  103973. */
  103974. export interface EngineCapabilities {
  103975. /** Maximum textures units per fragment shader */
  103976. maxTexturesImageUnits: number;
  103977. /** Maximum texture units per vertex shader */
  103978. maxVertexTextureImageUnits: number;
  103979. /** Maximum textures units in the entire pipeline */
  103980. maxCombinedTexturesImageUnits: number;
  103981. /** Maximum texture size */
  103982. maxTextureSize: number;
  103983. /** Maximum texture samples */
  103984. maxSamples?: number;
  103985. /** Maximum cube texture size */
  103986. maxCubemapTextureSize: number;
  103987. /** Maximum render texture size */
  103988. maxRenderTextureSize: number;
  103989. /** Maximum number of vertex attributes */
  103990. maxVertexAttribs: number;
  103991. /** Maximum number of varyings */
  103992. maxVaryingVectors: number;
  103993. /** Maximum number of uniforms per vertex shader */
  103994. maxVertexUniformVectors: number;
  103995. /** Maximum number of uniforms per fragment shader */
  103996. maxFragmentUniformVectors: number;
  103997. /** Defines if standard derivates (dx/dy) are supported */
  103998. standardDerivatives: boolean;
  103999. /** Defines if s3tc texture compression is supported */
  104000. s3tc?: WEBGL_compressed_texture_s3tc;
  104001. /** Defines if pvrtc texture compression is supported */
  104002. pvrtc: any;
  104003. /** Defines if etc1 texture compression is supported */
  104004. etc1: any;
  104005. /** Defines if etc2 texture compression is supported */
  104006. etc2: any;
  104007. /** Defines if astc texture compression is supported */
  104008. astc: any;
  104009. /** Defines if float textures are supported */
  104010. textureFloat: boolean;
  104011. /** Defines if vertex array objects are supported */
  104012. vertexArrayObject: boolean;
  104013. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  104014. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  104015. /** Gets the maximum level of anisotropy supported */
  104016. maxAnisotropy: number;
  104017. /** Defines if instancing is supported */
  104018. instancedArrays: boolean;
  104019. /** Defines if 32 bits indices are supported */
  104020. uintIndices: boolean;
  104021. /** Defines if high precision shaders are supported */
  104022. highPrecisionShaderSupported: boolean;
  104023. /** Defines if depth reading in the fragment shader is supported */
  104024. fragmentDepthSupported: boolean;
  104025. /** Defines if float texture linear filtering is supported*/
  104026. textureFloatLinearFiltering: boolean;
  104027. /** Defines if rendering to float textures is supported */
  104028. textureFloatRender: boolean;
  104029. /** Defines if half float textures are supported*/
  104030. textureHalfFloat: boolean;
  104031. /** Defines if half float texture linear filtering is supported*/
  104032. textureHalfFloatLinearFiltering: boolean;
  104033. /** Defines if rendering to half float textures is supported */
  104034. textureHalfFloatRender: boolean;
  104035. /** Defines if textureLOD shader command is supported */
  104036. textureLOD: boolean;
  104037. /** Defines if draw buffers extension is supported */
  104038. drawBuffersExtension: boolean;
  104039. /** Defines if depth textures are supported */
  104040. depthTextureExtension: boolean;
  104041. /** Defines if float color buffer are supported */
  104042. colorBufferFloat: boolean;
  104043. /** Gets disjoint timer query extension (null if not supported) */
  104044. timerQuery?: EXT_disjoint_timer_query;
  104045. /** Defines if timestamp can be used with timer query */
  104046. canUseTimestampForTimerQuery: boolean;
  104047. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  104048. multiview?: any;
  104049. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  104050. oculusMultiview?: any;
  104051. /** Function used to let the system compiles shaders in background */
  104052. parallelShaderCompile?: {
  104053. COMPLETION_STATUS_KHR: number;
  104054. };
  104055. /** Max number of texture samples for MSAA */
  104056. maxMSAASamples: number;
  104057. /** Defines if the blend min max extension is supported */
  104058. blendMinMax: boolean;
  104059. }
  104060. }
  104061. declare module BABYLON {
  104062. /**
  104063. * @hidden
  104064. **/
  104065. export class DepthCullingState {
  104066. private _isDepthTestDirty;
  104067. private _isDepthMaskDirty;
  104068. private _isDepthFuncDirty;
  104069. private _isCullFaceDirty;
  104070. private _isCullDirty;
  104071. private _isZOffsetDirty;
  104072. private _isFrontFaceDirty;
  104073. private _depthTest;
  104074. private _depthMask;
  104075. private _depthFunc;
  104076. private _cull;
  104077. private _cullFace;
  104078. private _zOffset;
  104079. private _frontFace;
  104080. /**
  104081. * Initializes the state.
  104082. */
  104083. constructor();
  104084. get isDirty(): boolean;
  104085. get zOffset(): number;
  104086. set zOffset(value: number);
  104087. get cullFace(): Nullable<number>;
  104088. set cullFace(value: Nullable<number>);
  104089. get cull(): Nullable<boolean>;
  104090. set cull(value: Nullable<boolean>);
  104091. get depthFunc(): Nullable<number>;
  104092. set depthFunc(value: Nullable<number>);
  104093. get depthMask(): boolean;
  104094. set depthMask(value: boolean);
  104095. get depthTest(): boolean;
  104096. set depthTest(value: boolean);
  104097. get frontFace(): Nullable<number>;
  104098. set frontFace(value: Nullable<number>);
  104099. reset(): void;
  104100. apply(gl: WebGLRenderingContext): void;
  104101. }
  104102. }
  104103. declare module BABYLON {
  104104. /**
  104105. * @hidden
  104106. **/
  104107. export class StencilState {
  104108. /** 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 */
  104109. static readonly ALWAYS: number;
  104110. /** Passed to stencilOperation to specify that stencil value must be kept */
  104111. static readonly KEEP: number;
  104112. /** Passed to stencilOperation to specify that stencil value must be replaced */
  104113. static readonly REPLACE: number;
  104114. private _isStencilTestDirty;
  104115. private _isStencilMaskDirty;
  104116. private _isStencilFuncDirty;
  104117. private _isStencilOpDirty;
  104118. private _stencilTest;
  104119. private _stencilMask;
  104120. private _stencilFunc;
  104121. private _stencilFuncRef;
  104122. private _stencilFuncMask;
  104123. private _stencilOpStencilFail;
  104124. private _stencilOpDepthFail;
  104125. private _stencilOpStencilDepthPass;
  104126. get isDirty(): boolean;
  104127. get stencilFunc(): number;
  104128. set stencilFunc(value: number);
  104129. get stencilFuncRef(): number;
  104130. set stencilFuncRef(value: number);
  104131. get stencilFuncMask(): number;
  104132. set stencilFuncMask(value: number);
  104133. get stencilOpStencilFail(): number;
  104134. set stencilOpStencilFail(value: number);
  104135. get stencilOpDepthFail(): number;
  104136. set stencilOpDepthFail(value: number);
  104137. get stencilOpStencilDepthPass(): number;
  104138. set stencilOpStencilDepthPass(value: number);
  104139. get stencilMask(): number;
  104140. set stencilMask(value: number);
  104141. get stencilTest(): boolean;
  104142. set stencilTest(value: boolean);
  104143. constructor();
  104144. reset(): void;
  104145. apply(gl: WebGLRenderingContext): void;
  104146. }
  104147. }
  104148. declare module BABYLON {
  104149. /**
  104150. * @hidden
  104151. **/
  104152. export class AlphaState {
  104153. private _isAlphaBlendDirty;
  104154. private _isBlendFunctionParametersDirty;
  104155. private _isBlendEquationParametersDirty;
  104156. private _isBlendConstantsDirty;
  104157. private _alphaBlend;
  104158. private _blendFunctionParameters;
  104159. private _blendEquationParameters;
  104160. private _blendConstants;
  104161. /**
  104162. * Initializes the state.
  104163. */
  104164. constructor();
  104165. get isDirty(): boolean;
  104166. get alphaBlend(): boolean;
  104167. set alphaBlend(value: boolean);
  104168. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  104169. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  104170. setAlphaEquationParameters(rgb: number, alpha: number): void;
  104171. reset(): void;
  104172. apply(gl: WebGLRenderingContext): void;
  104173. }
  104174. }
  104175. declare module BABYLON {
  104176. /** @hidden */
  104177. export class WebGL2ShaderProcessor implements IShaderProcessor {
  104178. attributeProcessor(attribute: string): string;
  104179. varyingProcessor(varying: string, isFragment: boolean): string;
  104180. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  104181. }
  104182. }
  104183. declare module BABYLON {
  104184. /**
  104185. * Interface for attribute information associated with buffer instanciation
  104186. */
  104187. export interface InstancingAttributeInfo {
  104188. /**
  104189. * Name of the GLSL attribute
  104190. * if attribute index is not specified, this is used to retrieve the index from the effect
  104191. */
  104192. attributeName: string;
  104193. /**
  104194. * Index/offset of the attribute in the vertex shader
  104195. * if not specified, this will be computes from the name.
  104196. */
  104197. index?: number;
  104198. /**
  104199. * size of the attribute, 1, 2, 3 or 4
  104200. */
  104201. attributeSize: number;
  104202. /**
  104203. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  104204. */
  104205. offset: number;
  104206. /**
  104207. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  104208. * default to 1
  104209. */
  104210. divisor?: number;
  104211. /**
  104212. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  104213. * default is FLOAT
  104214. */
  104215. attributeType?: number;
  104216. /**
  104217. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  104218. */
  104219. normalized?: boolean;
  104220. }
  104221. }
  104222. declare module BABYLON {
  104223. interface ThinEngine {
  104224. /**
  104225. * Update a video texture
  104226. * @param texture defines the texture to update
  104227. * @param video defines the video element to use
  104228. * @param invertY defines if data must be stored with Y axis inverted
  104229. */
  104230. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  104231. }
  104232. }
  104233. declare module BABYLON {
  104234. /**
  104235. * Settings for finer control over video usage
  104236. */
  104237. export interface VideoTextureSettings {
  104238. /**
  104239. * Applies `autoplay` to video, if specified
  104240. */
  104241. autoPlay?: boolean;
  104242. /**
  104243. * Applies `loop` to video, if specified
  104244. */
  104245. loop?: boolean;
  104246. /**
  104247. * Automatically updates internal texture from video at every frame in the render loop
  104248. */
  104249. autoUpdateTexture: boolean;
  104250. /**
  104251. * Image src displayed during the video loading or until the user interacts with the video.
  104252. */
  104253. poster?: string;
  104254. }
  104255. /**
  104256. * If you want to display a video in your scene, this is the special texture for that.
  104257. * This special texture works similar to other textures, with the exception of a few parameters.
  104258. * @see https://doc.babylonjs.com/how_to/video_texture
  104259. */
  104260. export class VideoTexture extends Texture {
  104261. /**
  104262. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  104263. */
  104264. readonly autoUpdateTexture: boolean;
  104265. /**
  104266. * The video instance used by the texture internally
  104267. */
  104268. readonly video: HTMLVideoElement;
  104269. private _onUserActionRequestedObservable;
  104270. /**
  104271. * Event triggerd when a dom action is required by the user to play the video.
  104272. * This happens due to recent changes in browser policies preventing video to auto start.
  104273. */
  104274. get onUserActionRequestedObservable(): Observable<Texture>;
  104275. private _generateMipMaps;
  104276. private _engine;
  104277. private _stillImageCaptured;
  104278. private _displayingPosterTexture;
  104279. private _settings;
  104280. private _createInternalTextureOnEvent;
  104281. private _frameId;
  104282. private _currentSrc;
  104283. /**
  104284. * Creates a video texture.
  104285. * If you want to display a video in your scene, this is the special texture for that.
  104286. * This special texture works similar to other textures, with the exception of a few parameters.
  104287. * @see https://doc.babylonjs.com/how_to/video_texture
  104288. * @param name optional name, will detect from video source, if not defined
  104289. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104290. * @param scene is obviously the current scene.
  104291. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104292. * @param invertY is false by default but can be used to invert video on Y axis
  104293. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104294. * @param settings allows finer control over video usage
  104295. */
  104296. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104297. private _getName;
  104298. private _getVideo;
  104299. private _createInternalTexture;
  104300. private reset;
  104301. /**
  104302. * @hidden Internal method to initiate `update`.
  104303. */
  104304. _rebuild(): void;
  104305. /**
  104306. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104307. */
  104308. update(): void;
  104309. /**
  104310. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104311. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104312. */
  104313. updateTexture(isVisible: boolean): void;
  104314. protected _updateInternalTexture: () => void;
  104315. /**
  104316. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104317. * @param url New url.
  104318. */
  104319. updateURL(url: string): void;
  104320. /**
  104321. * Clones the texture.
  104322. * @returns the cloned texture
  104323. */
  104324. clone(): VideoTexture;
  104325. /**
  104326. * Dispose the texture and release its associated resources.
  104327. */
  104328. dispose(): void;
  104329. /**
  104330. * Creates a video texture straight from a stream.
  104331. * @param scene Define the scene the texture should be created in
  104332. * @param stream Define the stream the texture should be created from
  104333. * @returns The created video texture as a promise
  104334. */
  104335. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104336. /**
  104337. * Creates a video texture straight from your WebCam video feed.
  104338. * @param scene Define the scene the texture should be created in
  104339. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104340. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104341. * @returns The created video texture as a promise
  104342. */
  104343. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104344. minWidth: number;
  104345. maxWidth: number;
  104346. minHeight: number;
  104347. maxHeight: number;
  104348. deviceId: string;
  104349. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104350. /**
  104351. * Creates a video texture straight from your WebCam video feed.
  104352. * @param scene Define the scene the texture should be created in
  104353. * @param onReady Define a callback to triggered once the texture will be ready
  104354. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104355. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104356. */
  104357. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104358. minWidth: number;
  104359. maxWidth: number;
  104360. minHeight: number;
  104361. maxHeight: number;
  104362. deviceId: string;
  104363. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104364. }
  104365. }
  104366. declare module BABYLON {
  104367. /**
  104368. * Defines the interface used by objects working like Scene
  104369. * @hidden
  104370. */
  104371. export interface ISceneLike {
  104372. _addPendingData(data: any): void;
  104373. _removePendingData(data: any): void;
  104374. offlineProvider: IOfflineProvider;
  104375. }
  104376. /** Interface defining initialization parameters for Engine class */
  104377. export interface EngineOptions extends WebGLContextAttributes {
  104378. /**
  104379. * Defines if the engine should no exceed a specified device ratio
  104380. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104381. */
  104382. limitDeviceRatio?: number;
  104383. /**
  104384. * Defines if webvr should be enabled automatically
  104385. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104386. */
  104387. autoEnableWebVR?: boolean;
  104388. /**
  104389. * Defines if webgl2 should be turned off even if supported
  104390. * @see http://doc.babylonjs.com/features/webgl2
  104391. */
  104392. disableWebGL2Support?: boolean;
  104393. /**
  104394. * Defines if webaudio should be initialized as well
  104395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104396. */
  104397. audioEngine?: boolean;
  104398. /**
  104399. * Defines if animations should run using a deterministic lock step
  104400. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104401. */
  104402. deterministicLockstep?: boolean;
  104403. /** Defines the maximum steps to use with deterministic lock step mode */
  104404. lockstepMaxSteps?: number;
  104405. /** Defines the seconds between each deterministic lock step */
  104406. timeStep?: number;
  104407. /**
  104408. * Defines that engine should ignore context lost events
  104409. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104410. */
  104411. doNotHandleContextLost?: boolean;
  104412. /**
  104413. * Defines that engine should ignore modifying touch action attribute and style
  104414. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104415. */
  104416. doNotHandleTouchAction?: boolean;
  104417. /**
  104418. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104419. */
  104420. useHighPrecisionFloats?: boolean;
  104421. }
  104422. /**
  104423. * The base engine class (root of all engines)
  104424. */
  104425. export class ThinEngine {
  104426. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104427. static ExceptionList: ({
  104428. key: string;
  104429. capture: string;
  104430. captureConstraint: number;
  104431. targets: string[];
  104432. } | {
  104433. key: string;
  104434. capture: null;
  104435. captureConstraint: null;
  104436. targets: string[];
  104437. })[];
  104438. /** @hidden */
  104439. static _TextureLoaders: IInternalTextureLoader[];
  104440. /**
  104441. * Returns the current npm package of the sdk
  104442. */
  104443. static get NpmPackage(): string;
  104444. /**
  104445. * Returns the current version of the framework
  104446. */
  104447. static get Version(): string;
  104448. /**
  104449. * Returns a string describing the current engine
  104450. */
  104451. get description(): string;
  104452. /**
  104453. * Gets or sets the epsilon value used by collision engine
  104454. */
  104455. static CollisionsEpsilon: number;
  104456. /**
  104457. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104458. */
  104459. static get ShadersRepository(): string;
  104460. static set ShadersRepository(value: string);
  104461. /** @hidden */
  104462. _shaderProcessor: IShaderProcessor;
  104463. /**
  104464. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104465. */
  104466. forcePOTTextures: boolean;
  104467. /**
  104468. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104469. */
  104470. isFullscreen: boolean;
  104471. /**
  104472. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104473. */
  104474. cullBackFaces: boolean;
  104475. /**
  104476. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104477. */
  104478. renderEvenInBackground: boolean;
  104479. /**
  104480. * Gets or sets a boolean indicating that cache can be kept between frames
  104481. */
  104482. preventCacheWipeBetweenFrames: boolean;
  104483. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104484. validateShaderPrograms: boolean;
  104485. /**
  104486. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104487. * This can provide greater z depth for distant objects.
  104488. */
  104489. useReverseDepthBuffer: boolean;
  104490. /**
  104491. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104492. */
  104493. disableUniformBuffers: boolean;
  104494. /** @hidden */
  104495. _uniformBuffers: UniformBuffer[];
  104496. /**
  104497. * Gets a boolean indicating that the engine supports uniform buffers
  104498. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104499. */
  104500. get supportsUniformBuffers(): boolean;
  104501. /** @hidden */
  104502. _gl: WebGLRenderingContext;
  104503. /** @hidden */
  104504. _webGLVersion: number;
  104505. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104506. protected _windowIsBackground: boolean;
  104507. protected _creationOptions: EngineOptions;
  104508. protected _highPrecisionShadersAllowed: boolean;
  104509. /** @hidden */
  104510. get _shouldUseHighPrecisionShader(): boolean;
  104511. /**
  104512. * Gets a boolean indicating that only power of 2 textures are supported
  104513. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104514. */
  104515. get needPOTTextures(): boolean;
  104516. /** @hidden */
  104517. _badOS: boolean;
  104518. /** @hidden */
  104519. _badDesktopOS: boolean;
  104520. private _hardwareScalingLevel;
  104521. /** @hidden */
  104522. _caps: EngineCapabilities;
  104523. private _isStencilEnable;
  104524. private _glVersion;
  104525. private _glRenderer;
  104526. private _glVendor;
  104527. /** @hidden */
  104528. _videoTextureSupported: boolean;
  104529. protected _renderingQueueLaunched: boolean;
  104530. protected _activeRenderLoops: (() => void)[];
  104531. /**
  104532. * Observable signaled when a context lost event is raised
  104533. */
  104534. onContextLostObservable: Observable<ThinEngine>;
  104535. /**
  104536. * Observable signaled when a context restored event is raised
  104537. */
  104538. onContextRestoredObservable: Observable<ThinEngine>;
  104539. private _onContextLost;
  104540. private _onContextRestored;
  104541. protected _contextWasLost: boolean;
  104542. /** @hidden */
  104543. _doNotHandleContextLost: boolean;
  104544. /**
  104545. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104546. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104547. */
  104548. get doNotHandleContextLost(): boolean;
  104549. set doNotHandleContextLost(value: boolean);
  104550. /**
  104551. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104552. */
  104553. disableVertexArrayObjects: boolean;
  104554. /** @hidden */
  104555. protected _colorWrite: boolean;
  104556. /** @hidden */
  104557. protected _colorWriteChanged: boolean;
  104558. /** @hidden */
  104559. protected _depthCullingState: DepthCullingState;
  104560. /** @hidden */
  104561. protected _stencilState: StencilState;
  104562. /** @hidden */
  104563. _alphaState: AlphaState;
  104564. /** @hidden */
  104565. _alphaMode: number;
  104566. /** @hidden */
  104567. _alphaEquation: number;
  104568. /** @hidden */
  104569. _internalTexturesCache: InternalTexture[];
  104570. /** @hidden */
  104571. protected _activeChannel: number;
  104572. private _currentTextureChannel;
  104573. /** @hidden */
  104574. protected _boundTexturesCache: {
  104575. [key: string]: Nullable<InternalTexture>;
  104576. };
  104577. /** @hidden */
  104578. protected _currentEffect: Nullable<Effect>;
  104579. /** @hidden */
  104580. protected _currentProgram: Nullable<WebGLProgram>;
  104581. private _compiledEffects;
  104582. private _vertexAttribArraysEnabled;
  104583. /** @hidden */
  104584. protected _cachedViewport: Nullable<IViewportLike>;
  104585. private _cachedVertexArrayObject;
  104586. /** @hidden */
  104587. protected _cachedVertexBuffers: any;
  104588. /** @hidden */
  104589. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104590. /** @hidden */
  104591. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104592. /** @hidden */
  104593. _currentRenderTarget: Nullable<InternalTexture>;
  104594. private _uintIndicesCurrentlySet;
  104595. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104596. /** @hidden */
  104597. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104598. private _currentBufferPointers;
  104599. private _currentInstanceLocations;
  104600. private _currentInstanceBuffers;
  104601. private _textureUnits;
  104602. /** @hidden */
  104603. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104604. /** @hidden */
  104605. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104606. /** @hidden */
  104607. _boundRenderFunction: any;
  104608. private _vaoRecordInProgress;
  104609. private _mustWipeVertexAttributes;
  104610. private _emptyTexture;
  104611. private _emptyCubeTexture;
  104612. private _emptyTexture3D;
  104613. private _emptyTexture2DArray;
  104614. /** @hidden */
  104615. _frameHandler: number;
  104616. private _nextFreeTextureSlots;
  104617. private _maxSimultaneousTextures;
  104618. private _activeRequests;
  104619. protected _texturesSupported: string[];
  104620. /** @hidden */
  104621. _textureFormatInUse: Nullable<string>;
  104622. protected get _supportsHardwareTextureRescaling(): boolean;
  104623. private _framebufferDimensionsObject;
  104624. /**
  104625. * sets the object from which width and height will be taken from when getting render width and height
  104626. * Will fallback to the gl object
  104627. * @param dimensions the framebuffer width and height that will be used.
  104628. */
  104629. set framebufferDimensionsObject(dimensions: Nullable<{
  104630. framebufferWidth: number;
  104631. framebufferHeight: number;
  104632. }>);
  104633. /**
  104634. * Gets the list of texture formats supported
  104635. */
  104636. get texturesSupported(): Array<string>;
  104637. /**
  104638. * Gets the list of texture formats in use
  104639. */
  104640. get textureFormatInUse(): Nullable<string>;
  104641. /**
  104642. * Gets the current viewport
  104643. */
  104644. get currentViewport(): Nullable<IViewportLike>;
  104645. /**
  104646. * Gets the default empty texture
  104647. */
  104648. get emptyTexture(): InternalTexture;
  104649. /**
  104650. * Gets the default empty 3D texture
  104651. */
  104652. get emptyTexture3D(): InternalTexture;
  104653. /**
  104654. * Gets the default empty 2D array texture
  104655. */
  104656. get emptyTexture2DArray(): InternalTexture;
  104657. /**
  104658. * Gets the default empty cube texture
  104659. */
  104660. get emptyCubeTexture(): InternalTexture;
  104661. /**
  104662. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104663. */
  104664. readonly premultipliedAlpha: boolean;
  104665. /**
  104666. * Observable event triggered before each texture is initialized
  104667. */
  104668. onBeforeTextureInitObservable: Observable<Texture>;
  104669. /**
  104670. * Creates a new engine
  104671. * @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
  104672. * @param antialias defines enable antialiasing (default: false)
  104673. * @param options defines further options to be sent to the getContext() function
  104674. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104675. */
  104676. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104677. private _rebuildInternalTextures;
  104678. private _rebuildEffects;
  104679. /**
  104680. * Gets a boolean indicating if all created effects are ready
  104681. * @returns true if all effects are ready
  104682. */
  104683. areAllEffectsReady(): boolean;
  104684. protected _rebuildBuffers(): void;
  104685. private _initGLContext;
  104686. /**
  104687. * Gets version of the current webGL context
  104688. */
  104689. get webGLVersion(): number;
  104690. /**
  104691. * Gets a string idenfifying the name of the class
  104692. * @returns "Engine" string
  104693. */
  104694. getClassName(): string;
  104695. /**
  104696. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104697. */
  104698. get isStencilEnable(): boolean;
  104699. /** @hidden */
  104700. _prepareWorkingCanvas(): void;
  104701. /**
  104702. * Reset the texture cache to empty state
  104703. */
  104704. resetTextureCache(): void;
  104705. /**
  104706. * Gets an object containing information about the current webGL context
  104707. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104708. */
  104709. getGlInfo(): {
  104710. vendor: string;
  104711. renderer: string;
  104712. version: string;
  104713. };
  104714. /**
  104715. * Defines the hardware scaling level.
  104716. * By default the hardware scaling level is computed from the window device ratio.
  104717. * 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.
  104718. * @param level defines the level to use
  104719. */
  104720. setHardwareScalingLevel(level: number): void;
  104721. /**
  104722. * Gets the current hardware scaling level.
  104723. * By default the hardware scaling level is computed from the window device ratio.
  104724. * 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.
  104725. * @returns a number indicating the current hardware scaling level
  104726. */
  104727. getHardwareScalingLevel(): number;
  104728. /**
  104729. * Gets the list of loaded textures
  104730. * @returns an array containing all loaded textures
  104731. */
  104732. getLoadedTexturesCache(): InternalTexture[];
  104733. /**
  104734. * Gets the object containing all engine capabilities
  104735. * @returns the EngineCapabilities object
  104736. */
  104737. getCaps(): EngineCapabilities;
  104738. /**
  104739. * stop executing a render loop function and remove it from the execution array
  104740. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104741. */
  104742. stopRenderLoop(renderFunction?: () => void): void;
  104743. /** @hidden */
  104744. _renderLoop(): void;
  104745. /**
  104746. * Gets the HTML canvas attached with the current webGL context
  104747. * @returns a HTML canvas
  104748. */
  104749. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104750. /**
  104751. * Gets host window
  104752. * @returns the host window object
  104753. */
  104754. getHostWindow(): Nullable<Window>;
  104755. /**
  104756. * Gets the current render width
  104757. * @param useScreen defines if screen size must be used (or the current render target if any)
  104758. * @returns a number defining the current render width
  104759. */
  104760. getRenderWidth(useScreen?: boolean): number;
  104761. /**
  104762. * Gets the current render height
  104763. * @param useScreen defines if screen size must be used (or the current render target if any)
  104764. * @returns a number defining the current render height
  104765. */
  104766. getRenderHeight(useScreen?: boolean): number;
  104767. /**
  104768. * Can be used to override the current requestAnimationFrame requester.
  104769. * @hidden
  104770. */
  104771. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104772. /**
  104773. * Register and execute a render loop. The engine can have more than one render function
  104774. * @param renderFunction defines the function to continuously execute
  104775. */
  104776. runRenderLoop(renderFunction: () => void): void;
  104777. /**
  104778. * Clear the current render buffer or the current render target (if any is set up)
  104779. * @param color defines the color to use
  104780. * @param backBuffer defines if the back buffer must be cleared
  104781. * @param depth defines if the depth buffer must be cleared
  104782. * @param stencil defines if the stencil buffer must be cleared
  104783. */
  104784. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104785. private _viewportCached;
  104786. /** @hidden */
  104787. _viewport(x: number, y: number, width: number, height: number): void;
  104788. /**
  104789. * Set the WebGL's viewport
  104790. * @param viewport defines the viewport element to be used
  104791. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104792. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104793. */
  104794. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104795. /**
  104796. * Begin a new frame
  104797. */
  104798. beginFrame(): void;
  104799. /**
  104800. * Enf the current frame
  104801. */
  104802. endFrame(): void;
  104803. /**
  104804. * Resize the view according to the canvas' size
  104805. */
  104806. resize(): void;
  104807. /**
  104808. * Force a specific size of the canvas
  104809. * @param width defines the new canvas' width
  104810. * @param height defines the new canvas' height
  104811. */
  104812. setSize(width: number, height: number): void;
  104813. /**
  104814. * Binds the frame buffer to the specified texture.
  104815. * @param texture The texture to render to or null for the default canvas
  104816. * @param faceIndex The face of the texture to render to in case of cube texture
  104817. * @param requiredWidth The width of the target to render to
  104818. * @param requiredHeight The height of the target to render to
  104819. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104820. * @param lodLevel defines the lod level to bind to the frame buffer
  104821. * @param layer defines the 2d array index to bind to frame buffer to
  104822. */
  104823. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104824. /** @hidden */
  104825. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104826. /**
  104827. * Unbind the current render target texture from the webGL context
  104828. * @param texture defines the render target texture to unbind
  104829. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104830. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104831. */
  104832. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104833. /**
  104834. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104835. */
  104836. flushFramebuffer(): void;
  104837. /**
  104838. * Unbind the current render target and bind the default framebuffer
  104839. */
  104840. restoreDefaultFramebuffer(): void;
  104841. /** @hidden */
  104842. protected _resetVertexBufferBinding(): void;
  104843. /**
  104844. * Creates a vertex buffer
  104845. * @param data the data for the vertex buffer
  104846. * @returns the new WebGL static buffer
  104847. */
  104848. createVertexBuffer(data: DataArray): DataBuffer;
  104849. private _createVertexBuffer;
  104850. /**
  104851. * Creates a dynamic vertex buffer
  104852. * @param data the data for the dynamic vertex buffer
  104853. * @returns the new WebGL dynamic buffer
  104854. */
  104855. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104856. protected _resetIndexBufferBinding(): void;
  104857. /**
  104858. * Creates a new index buffer
  104859. * @param indices defines the content of the index buffer
  104860. * @param updatable defines if the index buffer must be updatable
  104861. * @returns a new webGL buffer
  104862. */
  104863. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104864. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104865. /**
  104866. * Bind a webGL buffer to the webGL context
  104867. * @param buffer defines the buffer to bind
  104868. */
  104869. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104870. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104871. private bindBuffer;
  104872. /**
  104873. * update the bound buffer with the given data
  104874. * @param data defines the data to update
  104875. */
  104876. updateArrayBuffer(data: Float32Array): void;
  104877. private _vertexAttribPointer;
  104878. /** @hidden */
  104879. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104880. private _bindVertexBuffersAttributes;
  104881. /**
  104882. * Records a vertex array object
  104883. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104884. * @param vertexBuffers defines the list of vertex buffers to store
  104885. * @param indexBuffer defines the index buffer to store
  104886. * @param effect defines the effect to store
  104887. * @returns the new vertex array object
  104888. */
  104889. recordVertexArrayObject(vertexBuffers: {
  104890. [key: string]: VertexBuffer;
  104891. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104892. /**
  104893. * Bind a specific vertex array object
  104894. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104895. * @param vertexArrayObject defines the vertex array object to bind
  104896. * @param indexBuffer defines the index buffer to bind
  104897. */
  104898. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104899. /**
  104900. * Bind webGl buffers directly to the webGL context
  104901. * @param vertexBuffer defines the vertex buffer to bind
  104902. * @param indexBuffer defines the index buffer to bind
  104903. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104904. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104905. * @param effect defines the effect associated with the vertex buffer
  104906. */
  104907. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104908. private _unbindVertexArrayObject;
  104909. /**
  104910. * Bind a list of vertex buffers to the webGL context
  104911. * @param vertexBuffers defines the list of vertex buffers to bind
  104912. * @param indexBuffer defines the index buffer to bind
  104913. * @param effect defines the effect associated with the vertex buffers
  104914. */
  104915. bindBuffers(vertexBuffers: {
  104916. [key: string]: Nullable<VertexBuffer>;
  104917. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104918. /**
  104919. * Unbind all instance attributes
  104920. */
  104921. unbindInstanceAttributes(): void;
  104922. /**
  104923. * Release and free the memory of a vertex array object
  104924. * @param vao defines the vertex array object to delete
  104925. */
  104926. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104927. /** @hidden */
  104928. _releaseBuffer(buffer: DataBuffer): boolean;
  104929. protected _deleteBuffer(buffer: DataBuffer): void;
  104930. /**
  104931. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104932. * @param instancesBuffer defines the webGL buffer to update and bind
  104933. * @param data defines the data to store in the buffer
  104934. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104935. */
  104936. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104937. /**
  104938. * Bind the content of a webGL buffer used with instantiation
  104939. * @param instancesBuffer defines the webGL buffer to bind
  104940. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104941. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104942. */
  104943. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104944. /**
  104945. * Disable the instance attribute corresponding to the name in parameter
  104946. * @param name defines the name of the attribute to disable
  104947. */
  104948. disableInstanceAttributeByName(name: string): void;
  104949. /**
  104950. * Disable the instance attribute corresponding to the location in parameter
  104951. * @param attributeLocation defines the attribute location of the attribute to disable
  104952. */
  104953. disableInstanceAttribute(attributeLocation: number): void;
  104954. /**
  104955. * Disable the attribute corresponding to the location in parameter
  104956. * @param attributeLocation defines the attribute location of the attribute to disable
  104957. */
  104958. disableAttributeByIndex(attributeLocation: number): void;
  104959. /**
  104960. * Send a draw order
  104961. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104962. * @param indexStart defines the starting index
  104963. * @param indexCount defines the number of index to draw
  104964. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104965. */
  104966. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104967. /**
  104968. * Draw a list of points
  104969. * @param verticesStart defines the index of first vertex to draw
  104970. * @param verticesCount defines the count of vertices to draw
  104971. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104972. */
  104973. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104974. /**
  104975. * Draw a list of unindexed primitives
  104976. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104977. * @param verticesStart defines the index of first vertex to draw
  104978. * @param verticesCount defines the count of vertices to draw
  104979. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104980. */
  104981. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104982. /**
  104983. * Draw a list of indexed primitives
  104984. * @param fillMode defines the primitive to use
  104985. * @param indexStart defines the starting index
  104986. * @param indexCount defines the number of index to draw
  104987. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104988. */
  104989. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104990. /**
  104991. * Draw a list of unindexed primitives
  104992. * @param fillMode defines the primitive to use
  104993. * @param verticesStart defines the index of first vertex to draw
  104994. * @param verticesCount defines the count of vertices to draw
  104995. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104996. */
  104997. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104998. private _drawMode;
  104999. /** @hidden */
  105000. protected _reportDrawCall(): void;
  105001. /** @hidden */
  105002. _releaseEffect(effect: Effect): void;
  105003. /** @hidden */
  105004. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  105005. /**
  105006. * Create a new effect (used to store vertex/fragment shaders)
  105007. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  105008. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  105009. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  105010. * @param samplers defines an array of string used to represent textures
  105011. * @param defines defines the string containing the defines to use to compile the shaders
  105012. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  105013. * @param onCompiled defines a function to call when the effect creation is successful
  105014. * @param onError defines a function to call when the effect creation has failed
  105015. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  105016. * @returns the new Effect
  105017. */
  105018. 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;
  105019. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  105020. private _compileShader;
  105021. private _compileRawShader;
  105022. /** @hidden */
  105023. _getShaderSource(shader: WebGLShader): Nullable<string>;
  105024. /**
  105025. * Directly creates a webGL program
  105026. * @param pipelineContext defines the pipeline context to attach to
  105027. * @param vertexCode defines the vertex shader code to use
  105028. * @param fragmentCode defines the fragment shader code to use
  105029. * @param context defines the webGL context to use (if not set, the current one will be used)
  105030. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  105031. * @returns the new webGL program
  105032. */
  105033. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105034. /**
  105035. * Creates a webGL program
  105036. * @param pipelineContext defines the pipeline context to attach to
  105037. * @param vertexCode defines the vertex shader code to use
  105038. * @param fragmentCode defines the fragment shader code to use
  105039. * @param defines defines the string containing the defines to use to compile the shaders
  105040. * @param context defines the webGL context to use (if not set, the current one will be used)
  105041. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  105042. * @returns the new webGL program
  105043. */
  105044. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105045. /**
  105046. * Creates a new pipeline context
  105047. * @returns the new pipeline
  105048. */
  105049. createPipelineContext(): IPipelineContext;
  105050. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105051. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  105052. /** @hidden */
  105053. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  105054. /** @hidden */
  105055. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  105056. /** @hidden */
  105057. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  105058. /**
  105059. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  105060. * @param pipelineContext defines the pipeline context to use
  105061. * @param uniformsNames defines the list of uniform names
  105062. * @returns an array of webGL uniform locations
  105063. */
  105064. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  105065. /**
  105066. * Gets the lsit of active attributes for a given webGL program
  105067. * @param pipelineContext defines the pipeline context to use
  105068. * @param attributesNames defines the list of attribute names to get
  105069. * @returns an array of indices indicating the offset of each attribute
  105070. */
  105071. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  105072. /**
  105073. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  105074. * @param effect defines the effect to activate
  105075. */
  105076. enableEffect(effect: Nullable<Effect>): void;
  105077. /**
  105078. * Set the value of an uniform to a number (int)
  105079. * @param uniform defines the webGL uniform location where to store the value
  105080. * @param value defines the int number to store
  105081. */
  105082. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  105083. /**
  105084. * Set the value of an uniform to an array of int32
  105085. * @param uniform defines the webGL uniform location where to store the value
  105086. * @param array defines the array of int32 to store
  105087. */
  105088. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105089. /**
  105090. * Set the value of an uniform to an array of int32 (stored as vec2)
  105091. * @param uniform defines the webGL uniform location where to store the value
  105092. * @param array defines the array of int32 to store
  105093. */
  105094. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105095. /**
  105096. * Set the value of an uniform to an array of int32 (stored as vec3)
  105097. * @param uniform defines the webGL uniform location where to store the value
  105098. * @param array defines the array of int32 to store
  105099. */
  105100. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105101. /**
  105102. * Set the value of an uniform to an array of int32 (stored as vec4)
  105103. * @param uniform defines the webGL uniform location where to store the value
  105104. * @param array defines the array of int32 to store
  105105. */
  105106. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105107. /**
  105108. * Set the value of an uniform to an array of number
  105109. * @param uniform defines the webGL uniform location where to store the value
  105110. * @param array defines the array of number to store
  105111. */
  105112. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105113. /**
  105114. * Set the value of an uniform to an array of number (stored as vec2)
  105115. * @param uniform defines the webGL uniform location where to store the value
  105116. * @param array defines the array of number to store
  105117. */
  105118. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105119. /**
  105120. * Set the value of an uniform to an array of number (stored as vec3)
  105121. * @param uniform defines the webGL uniform location where to store the value
  105122. * @param array defines the array of number to store
  105123. */
  105124. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105125. /**
  105126. * Set the value of an uniform to an array of number (stored as vec4)
  105127. * @param uniform defines the webGL uniform location where to store the value
  105128. * @param array defines the array of number to store
  105129. */
  105130. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105131. /**
  105132. * Set the value of an uniform to an array of float32 (stored as matrices)
  105133. * @param uniform defines the webGL uniform location where to store the value
  105134. * @param matrices defines the array of float32 to store
  105135. */
  105136. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  105137. /**
  105138. * Set the value of an uniform to a matrix (3x3)
  105139. * @param uniform defines the webGL uniform location where to store the value
  105140. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  105141. */
  105142. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  105143. /**
  105144. * Set the value of an uniform to a matrix (2x2)
  105145. * @param uniform defines the webGL uniform location where to store the value
  105146. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  105147. */
  105148. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  105149. /**
  105150. * Set the value of an uniform to a number (float)
  105151. * @param uniform defines the webGL uniform location where to store the value
  105152. * @param value defines the float number to store
  105153. */
  105154. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  105155. /**
  105156. * Set the value of an uniform to a vec2
  105157. * @param uniform defines the webGL uniform location where to store the value
  105158. * @param x defines the 1st component of the value
  105159. * @param y defines the 2nd component of the value
  105160. */
  105161. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  105162. /**
  105163. * Set the value of an uniform to a vec3
  105164. * @param uniform defines the webGL uniform location where to store the value
  105165. * @param x defines the 1st component of the value
  105166. * @param y defines the 2nd component of the value
  105167. * @param z defines the 3rd component of the value
  105168. */
  105169. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  105170. /**
  105171. * Set the value of an uniform to a vec4
  105172. * @param uniform defines the webGL uniform location where to store the value
  105173. * @param x defines the 1st component of the value
  105174. * @param y defines the 2nd component of the value
  105175. * @param z defines the 3rd component of the value
  105176. * @param w defines the 4th component of the value
  105177. */
  105178. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  105179. /**
  105180. * Apply all cached states (depth, culling, stencil and alpha)
  105181. */
  105182. applyStates(): void;
  105183. /**
  105184. * Enable or disable color writing
  105185. * @param enable defines the state to set
  105186. */
  105187. setColorWrite(enable: boolean): void;
  105188. /**
  105189. * Gets a boolean indicating if color writing is enabled
  105190. * @returns the current color writing state
  105191. */
  105192. getColorWrite(): boolean;
  105193. /**
  105194. * Gets the depth culling state manager
  105195. */
  105196. get depthCullingState(): DepthCullingState;
  105197. /**
  105198. * Gets the alpha state manager
  105199. */
  105200. get alphaState(): AlphaState;
  105201. /**
  105202. * Gets the stencil state manager
  105203. */
  105204. get stencilState(): StencilState;
  105205. /**
  105206. * Clears the list of texture accessible through engine.
  105207. * This can help preventing texture load conflict due to name collision.
  105208. */
  105209. clearInternalTexturesCache(): void;
  105210. /**
  105211. * Force the entire cache to be cleared
  105212. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  105213. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  105214. */
  105215. wipeCaches(bruteForce?: boolean): void;
  105216. /** @hidden */
  105217. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  105218. min: number;
  105219. mag: number;
  105220. };
  105221. /** @hidden */
  105222. _createTexture(): WebGLTexture;
  105223. /**
  105224. * Usually called from Texture.ts.
  105225. * Passed information to create a WebGLTexture
  105226. * @param urlArg defines a value which contains one of the following:
  105227. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  105228. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  105229. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  105230. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  105231. * @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)
  105232. * @param scene needed for loading to the correct scene
  105233. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  105234. * @param onLoad optional callback to be called upon successful completion
  105235. * @param onError optional callback to be called upon failure
  105236. * @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
  105237. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  105238. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  105239. * @param forcedExtension defines the extension to use to pick the right loader
  105240. * @param mimeType defines an optional mime type
  105241. * @returns a InternalTexture for assignment back into BABYLON.Texture
  105242. */
  105243. 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>, mimeType?: string): InternalTexture;
  105244. /**
  105245. * Loads an image as an HTMLImageElement.
  105246. * @param input url string, ArrayBuffer, or Blob to load
  105247. * @param onLoad callback called when the image successfully loads
  105248. * @param onError callback called when the image fails to load
  105249. * @param offlineProvider offline provider for caching
  105250. * @param mimeType optional mime type
  105251. * @returns the HTMLImageElement of the loaded image
  105252. * @hidden
  105253. */
  105254. 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>;
  105255. /**
  105256. * @hidden
  105257. */
  105258. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  105259. /**
  105260. * Creates a raw texture
  105261. * @param data defines the data to store in the texture
  105262. * @param width defines the width of the texture
  105263. * @param height defines the height of the texture
  105264. * @param format defines the format of the data
  105265. * @param generateMipMaps defines if the engine should generate the mip levels
  105266. * @param invertY defines if data must be stored with Y axis inverted
  105267. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  105268. * @param compression defines the compression used (null by default)
  105269. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105270. * @returns the raw texture inside an InternalTexture
  105271. */
  105272. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  105273. /**
  105274. * Creates a new raw cube texture
  105275. * @param data defines the array of data to use to create each face
  105276. * @param size defines the size of the textures
  105277. * @param format defines the format of the data
  105278. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105279. * @param generateMipMaps defines if the engine should generate the mip levels
  105280. * @param invertY defines if data must be stored with Y axis inverted
  105281. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105282. * @param compression defines the compression used (null by default)
  105283. * @returns the cube texture as an InternalTexture
  105284. */
  105285. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105286. /**
  105287. * Creates a new raw 3D texture
  105288. * @param data defines the data used to create the texture
  105289. * @param width defines the width of the texture
  105290. * @param height defines the height of the texture
  105291. * @param depth defines the depth of the texture
  105292. * @param format defines the format of the texture
  105293. * @param generateMipMaps defines if the engine must generate mip levels
  105294. * @param invertY defines if data must be stored with Y axis inverted
  105295. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105296. * @param compression defines the compressed used (can be null)
  105297. * @param textureType defines the compressed used (can be null)
  105298. * @returns a new raw 3D texture (stored in an InternalTexture)
  105299. */
  105300. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105301. /**
  105302. * Creates a new raw 2D array texture
  105303. * @param data defines the data used to create the texture
  105304. * @param width defines the width of the texture
  105305. * @param height defines the height of the texture
  105306. * @param depth defines the number of layers of the texture
  105307. * @param format defines the format of the texture
  105308. * @param generateMipMaps defines if the engine must generate mip levels
  105309. * @param invertY defines if data must be stored with Y axis inverted
  105310. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105311. * @param compression defines the compressed used (can be null)
  105312. * @param textureType defines the compressed used (can be null)
  105313. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105314. */
  105315. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105316. private _unpackFlipYCached;
  105317. /**
  105318. * In case you are sharing the context with other applications, it might
  105319. * be interested to not cache the unpack flip y state to ensure a consistent
  105320. * value would be set.
  105321. */
  105322. enableUnpackFlipYCached: boolean;
  105323. /** @hidden */
  105324. _unpackFlipY(value: boolean): void;
  105325. /** @hidden */
  105326. _getUnpackAlignement(): number;
  105327. private _getTextureTarget;
  105328. /**
  105329. * Update the sampling mode of a given texture
  105330. * @param samplingMode defines the required sampling mode
  105331. * @param texture defines the texture to update
  105332. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105333. */
  105334. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105335. /**
  105336. * Update the sampling mode of a given texture
  105337. * @param texture defines the texture to update
  105338. * @param wrapU defines the texture wrap mode of the u coordinates
  105339. * @param wrapV defines the texture wrap mode of the v coordinates
  105340. * @param wrapR defines the texture wrap mode of the r coordinates
  105341. */
  105342. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105343. /** @hidden */
  105344. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105345. width: number;
  105346. height: number;
  105347. layers?: number;
  105348. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105349. /** @hidden */
  105350. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105351. /** @hidden */
  105352. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105353. /**
  105354. * Update a portion of an internal texture
  105355. * @param texture defines the texture to update
  105356. * @param imageData defines the data to store into the texture
  105357. * @param xOffset defines the x coordinates of the update rectangle
  105358. * @param yOffset defines the y coordinates of the update rectangle
  105359. * @param width defines the width of the update rectangle
  105360. * @param height defines the height of the update rectangle
  105361. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105362. * @param lod defines the lod level to update (0 by default)
  105363. */
  105364. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105365. /** @hidden */
  105366. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105367. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105368. private _prepareWebGLTexture;
  105369. /** @hidden */
  105370. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105371. private _getDepthStencilBuffer;
  105372. /** @hidden */
  105373. _releaseFramebufferObjects(texture: InternalTexture): void;
  105374. /** @hidden */
  105375. _releaseTexture(texture: InternalTexture): void;
  105376. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105377. protected _setProgram(program: WebGLProgram): void;
  105378. protected _boundUniforms: {
  105379. [key: number]: WebGLUniformLocation;
  105380. };
  105381. /**
  105382. * Binds an effect to the webGL context
  105383. * @param effect defines the effect to bind
  105384. */
  105385. bindSamplers(effect: Effect): void;
  105386. private _activateCurrentTexture;
  105387. /** @hidden */
  105388. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105389. /** @hidden */
  105390. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105391. /**
  105392. * Unbind all textures from the webGL context
  105393. */
  105394. unbindAllTextures(): void;
  105395. /**
  105396. * Sets a texture to the according uniform.
  105397. * @param channel The texture channel
  105398. * @param uniform The uniform to set
  105399. * @param texture The texture to apply
  105400. */
  105401. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105402. private _bindSamplerUniformToChannel;
  105403. private _getTextureWrapMode;
  105404. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105405. /**
  105406. * Sets an array of texture to the webGL context
  105407. * @param channel defines the channel where the texture array must be set
  105408. * @param uniform defines the associated uniform location
  105409. * @param textures defines the array of textures to bind
  105410. */
  105411. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105412. /** @hidden */
  105413. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105414. private _setTextureParameterFloat;
  105415. private _setTextureParameterInteger;
  105416. /**
  105417. * Unbind all vertex attributes from the webGL context
  105418. */
  105419. unbindAllAttributes(): void;
  105420. /**
  105421. * 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
  105422. */
  105423. releaseEffects(): void;
  105424. /**
  105425. * Dispose and release all associated resources
  105426. */
  105427. dispose(): void;
  105428. /**
  105429. * Attach a new callback raised when context lost event is fired
  105430. * @param callback defines the callback to call
  105431. */
  105432. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105433. /**
  105434. * Attach a new callback raised when context restored event is fired
  105435. * @param callback defines the callback to call
  105436. */
  105437. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105438. /**
  105439. * Get the current error code of the webGL context
  105440. * @returns the error code
  105441. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105442. */
  105443. getError(): number;
  105444. private _canRenderToFloatFramebuffer;
  105445. private _canRenderToHalfFloatFramebuffer;
  105446. private _canRenderToFramebuffer;
  105447. /** @hidden */
  105448. _getWebGLTextureType(type: number): number;
  105449. /** @hidden */
  105450. _getInternalFormat(format: number): number;
  105451. /** @hidden */
  105452. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105453. /** @hidden */
  105454. _getRGBAMultiSampleBufferFormat(type: number): number;
  105455. /** @hidden */
  105456. _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;
  105457. /**
  105458. * Loads a file from a url
  105459. * @param url url to load
  105460. * @param onSuccess callback called when the file successfully loads
  105461. * @param onProgress callback called while file is loading (if the server supports this mode)
  105462. * @param offlineProvider defines the offline provider for caching
  105463. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105464. * @param onError callback called when the file fails to load
  105465. * @returns a file request object
  105466. * @hidden
  105467. */
  105468. 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;
  105469. /**
  105470. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105471. * @param x defines the x coordinate of the rectangle where pixels must be read
  105472. * @param y defines the y coordinate of the rectangle where pixels must be read
  105473. * @param width defines the width of the rectangle where pixels must be read
  105474. * @param height defines the height of the rectangle where pixels must be read
  105475. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105476. * @returns a Uint8Array containing RGBA colors
  105477. */
  105478. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105479. private static _isSupported;
  105480. /**
  105481. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105482. * @returns true if the engine can be created
  105483. * @ignorenaming
  105484. */
  105485. static isSupported(): boolean;
  105486. /**
  105487. * Find the next highest power of two.
  105488. * @param x Number to start search from.
  105489. * @return Next highest power of two.
  105490. */
  105491. static CeilingPOT(x: number): number;
  105492. /**
  105493. * Find the next lowest power of two.
  105494. * @param x Number to start search from.
  105495. * @return Next lowest power of two.
  105496. */
  105497. static FloorPOT(x: number): number;
  105498. /**
  105499. * Find the nearest power of two.
  105500. * @param x Number to start search from.
  105501. * @return Next nearest power of two.
  105502. */
  105503. static NearestPOT(x: number): number;
  105504. /**
  105505. * Get the closest exponent of two
  105506. * @param value defines the value to approximate
  105507. * @param max defines the maximum value to return
  105508. * @param mode defines how to define the closest value
  105509. * @returns closest exponent of two of the given value
  105510. */
  105511. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105512. /**
  105513. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105514. * @param func - the function to be called
  105515. * @param requester - the object that will request the next frame. Falls back to window.
  105516. * @returns frame number
  105517. */
  105518. static QueueNewFrame(func: () => void, requester?: any): number;
  105519. /**
  105520. * Gets host document
  105521. * @returns the host document object
  105522. */
  105523. getHostDocument(): Nullable<Document>;
  105524. }
  105525. }
  105526. declare module BABYLON {
  105527. /**
  105528. * Class representing spherical harmonics coefficients to the 3rd degree
  105529. */
  105530. export class SphericalHarmonics {
  105531. /**
  105532. * Defines whether or not the harmonics have been prescaled for rendering.
  105533. */
  105534. preScaled: boolean;
  105535. /**
  105536. * The l0,0 coefficients of the spherical harmonics
  105537. */
  105538. l00: Vector3;
  105539. /**
  105540. * The l1,-1 coefficients of the spherical harmonics
  105541. */
  105542. l1_1: Vector3;
  105543. /**
  105544. * The l1,0 coefficients of the spherical harmonics
  105545. */
  105546. l10: Vector3;
  105547. /**
  105548. * The l1,1 coefficients of the spherical harmonics
  105549. */
  105550. l11: Vector3;
  105551. /**
  105552. * The l2,-2 coefficients of the spherical harmonics
  105553. */
  105554. l2_2: Vector3;
  105555. /**
  105556. * The l2,-1 coefficients of the spherical harmonics
  105557. */
  105558. l2_1: Vector3;
  105559. /**
  105560. * The l2,0 coefficients of the spherical harmonics
  105561. */
  105562. l20: Vector3;
  105563. /**
  105564. * The l2,1 coefficients of the spherical harmonics
  105565. */
  105566. l21: Vector3;
  105567. /**
  105568. * The l2,2 coefficients of the spherical harmonics
  105569. */
  105570. l22: Vector3;
  105571. /**
  105572. * Adds a light to the spherical harmonics
  105573. * @param direction the direction of the light
  105574. * @param color the color of the light
  105575. * @param deltaSolidAngle the delta solid angle of the light
  105576. */
  105577. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105578. /**
  105579. * Scales the spherical harmonics by the given amount
  105580. * @param scale the amount to scale
  105581. */
  105582. scaleInPlace(scale: number): void;
  105583. /**
  105584. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105585. *
  105586. * ```
  105587. * E_lm = A_l * L_lm
  105588. * ```
  105589. *
  105590. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105591. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105592. * the scaling factors are given in equation 9.
  105593. */
  105594. convertIncidentRadianceToIrradiance(): void;
  105595. /**
  105596. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105597. *
  105598. * ```
  105599. * L = (1/pi) * E * rho
  105600. * ```
  105601. *
  105602. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105603. */
  105604. convertIrradianceToLambertianRadiance(): void;
  105605. /**
  105606. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105607. * required operations at run time.
  105608. *
  105609. * This is simply done by scaling back the SH with Ylm constants parameter.
  105610. * The trigonometric part being applied by the shader at run time.
  105611. */
  105612. preScaleForRendering(): void;
  105613. /**
  105614. * Constructs a spherical harmonics from an array.
  105615. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105616. * @returns the spherical harmonics
  105617. */
  105618. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105619. /**
  105620. * Gets the spherical harmonics from polynomial
  105621. * @param polynomial the spherical polynomial
  105622. * @returns the spherical harmonics
  105623. */
  105624. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105625. }
  105626. /**
  105627. * Class representing spherical polynomial coefficients to the 3rd degree
  105628. */
  105629. export class SphericalPolynomial {
  105630. private _harmonics;
  105631. /**
  105632. * The spherical harmonics used to create the polynomials.
  105633. */
  105634. get preScaledHarmonics(): SphericalHarmonics;
  105635. /**
  105636. * The x coefficients of the spherical polynomial
  105637. */
  105638. x: Vector3;
  105639. /**
  105640. * The y coefficients of the spherical polynomial
  105641. */
  105642. y: Vector3;
  105643. /**
  105644. * The z coefficients of the spherical polynomial
  105645. */
  105646. z: Vector3;
  105647. /**
  105648. * The xx coefficients of the spherical polynomial
  105649. */
  105650. xx: Vector3;
  105651. /**
  105652. * The yy coefficients of the spherical polynomial
  105653. */
  105654. yy: Vector3;
  105655. /**
  105656. * The zz coefficients of the spherical polynomial
  105657. */
  105658. zz: Vector3;
  105659. /**
  105660. * The xy coefficients of the spherical polynomial
  105661. */
  105662. xy: Vector3;
  105663. /**
  105664. * The yz coefficients of the spherical polynomial
  105665. */
  105666. yz: Vector3;
  105667. /**
  105668. * The zx coefficients of the spherical polynomial
  105669. */
  105670. zx: Vector3;
  105671. /**
  105672. * Adds an ambient color to the spherical polynomial
  105673. * @param color the color to add
  105674. */
  105675. addAmbient(color: Color3): void;
  105676. /**
  105677. * Scales the spherical polynomial by the given amount
  105678. * @param scale the amount to scale
  105679. */
  105680. scaleInPlace(scale: number): void;
  105681. /**
  105682. * Gets the spherical polynomial from harmonics
  105683. * @param harmonics the spherical harmonics
  105684. * @returns the spherical polynomial
  105685. */
  105686. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105687. /**
  105688. * Constructs a spherical polynomial from an array.
  105689. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105690. * @returns the spherical polynomial
  105691. */
  105692. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105693. }
  105694. }
  105695. declare module BABYLON {
  105696. /**
  105697. * Defines the source of the internal texture
  105698. */
  105699. export enum InternalTextureSource {
  105700. /**
  105701. * The source of the texture data is unknown
  105702. */
  105703. Unknown = 0,
  105704. /**
  105705. * Texture data comes from an URL
  105706. */
  105707. Url = 1,
  105708. /**
  105709. * Texture data is only used for temporary storage
  105710. */
  105711. Temp = 2,
  105712. /**
  105713. * Texture data comes from raw data (ArrayBuffer)
  105714. */
  105715. Raw = 3,
  105716. /**
  105717. * Texture content is dynamic (video or dynamic texture)
  105718. */
  105719. Dynamic = 4,
  105720. /**
  105721. * Texture content is generated by rendering to it
  105722. */
  105723. RenderTarget = 5,
  105724. /**
  105725. * Texture content is part of a multi render target process
  105726. */
  105727. MultiRenderTarget = 6,
  105728. /**
  105729. * Texture data comes from a cube data file
  105730. */
  105731. Cube = 7,
  105732. /**
  105733. * Texture data comes from a raw cube data
  105734. */
  105735. CubeRaw = 8,
  105736. /**
  105737. * Texture data come from a prefiltered cube data file
  105738. */
  105739. CubePrefiltered = 9,
  105740. /**
  105741. * Texture content is raw 3D data
  105742. */
  105743. Raw3D = 10,
  105744. /**
  105745. * Texture content is raw 2D array data
  105746. */
  105747. Raw2DArray = 11,
  105748. /**
  105749. * Texture content is a depth texture
  105750. */
  105751. Depth = 12,
  105752. /**
  105753. * Texture data comes from a raw cube data encoded with RGBD
  105754. */
  105755. CubeRawRGBD = 13
  105756. }
  105757. /**
  105758. * Class used to store data associated with WebGL texture data for the engine
  105759. * This class should not be used directly
  105760. */
  105761. export class InternalTexture {
  105762. /** @hidden */
  105763. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105764. /**
  105765. * Defines if the texture is ready
  105766. */
  105767. isReady: boolean;
  105768. /**
  105769. * Defines if the texture is a cube texture
  105770. */
  105771. isCube: boolean;
  105772. /**
  105773. * Defines if the texture contains 3D data
  105774. */
  105775. is3D: boolean;
  105776. /**
  105777. * Defines if the texture contains 2D array data
  105778. */
  105779. is2DArray: boolean;
  105780. /**
  105781. * Defines if the texture contains multiview data
  105782. */
  105783. isMultiview: boolean;
  105784. /**
  105785. * Gets the URL used to load this texture
  105786. */
  105787. url: string;
  105788. /**
  105789. * Gets the sampling mode of the texture
  105790. */
  105791. samplingMode: number;
  105792. /**
  105793. * Gets a boolean indicating if the texture needs mipmaps generation
  105794. */
  105795. generateMipMaps: boolean;
  105796. /**
  105797. * Gets the number of samples used by the texture (WebGL2+ only)
  105798. */
  105799. samples: number;
  105800. /**
  105801. * Gets the type of the texture (int, float...)
  105802. */
  105803. type: number;
  105804. /**
  105805. * Gets the format of the texture (RGB, RGBA...)
  105806. */
  105807. format: number;
  105808. /**
  105809. * Observable called when the texture is loaded
  105810. */
  105811. onLoadedObservable: Observable<InternalTexture>;
  105812. /**
  105813. * Gets the width of the texture
  105814. */
  105815. width: number;
  105816. /**
  105817. * Gets the height of the texture
  105818. */
  105819. height: number;
  105820. /**
  105821. * Gets the depth of the texture
  105822. */
  105823. depth: number;
  105824. /**
  105825. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105826. */
  105827. baseWidth: number;
  105828. /**
  105829. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105830. */
  105831. baseHeight: number;
  105832. /**
  105833. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105834. */
  105835. baseDepth: number;
  105836. /**
  105837. * Gets a boolean indicating if the texture is inverted on Y axis
  105838. */
  105839. invertY: boolean;
  105840. /** @hidden */
  105841. _invertVScale: boolean;
  105842. /** @hidden */
  105843. _associatedChannel: number;
  105844. /** @hidden */
  105845. _source: InternalTextureSource;
  105846. /** @hidden */
  105847. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105848. /** @hidden */
  105849. _bufferView: Nullable<ArrayBufferView>;
  105850. /** @hidden */
  105851. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105852. /** @hidden */
  105853. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105854. /** @hidden */
  105855. _size: number;
  105856. /** @hidden */
  105857. _extension: string;
  105858. /** @hidden */
  105859. _files: Nullable<string[]>;
  105860. /** @hidden */
  105861. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105862. /** @hidden */
  105863. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105864. /** @hidden */
  105865. _framebuffer: Nullable<WebGLFramebuffer>;
  105866. /** @hidden */
  105867. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105868. /** @hidden */
  105869. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105870. /** @hidden */
  105871. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105872. /** @hidden */
  105873. _attachments: Nullable<number[]>;
  105874. /** @hidden */
  105875. _cachedCoordinatesMode: Nullable<number>;
  105876. /** @hidden */
  105877. _cachedWrapU: Nullable<number>;
  105878. /** @hidden */
  105879. _cachedWrapV: Nullable<number>;
  105880. /** @hidden */
  105881. _cachedWrapR: Nullable<number>;
  105882. /** @hidden */
  105883. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105884. /** @hidden */
  105885. _isDisabled: boolean;
  105886. /** @hidden */
  105887. _compression: Nullable<string>;
  105888. /** @hidden */
  105889. _generateStencilBuffer: boolean;
  105890. /** @hidden */
  105891. _generateDepthBuffer: boolean;
  105892. /** @hidden */
  105893. _comparisonFunction: number;
  105894. /** @hidden */
  105895. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105896. /** @hidden */
  105897. _lodGenerationScale: number;
  105898. /** @hidden */
  105899. _lodGenerationOffset: number;
  105900. /** @hidden */
  105901. _depthStencilTexture: Nullable<InternalTexture>;
  105902. /** @hidden */
  105903. _colorTextureArray: Nullable<WebGLTexture>;
  105904. /** @hidden */
  105905. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105906. /** @hidden */
  105907. _lodTextureHigh: Nullable<BaseTexture>;
  105908. /** @hidden */
  105909. _lodTextureMid: Nullable<BaseTexture>;
  105910. /** @hidden */
  105911. _lodTextureLow: Nullable<BaseTexture>;
  105912. /** @hidden */
  105913. _isRGBD: boolean;
  105914. /** @hidden */
  105915. _linearSpecularLOD: boolean;
  105916. /** @hidden */
  105917. _irradianceTexture: Nullable<BaseTexture>;
  105918. /** @hidden */
  105919. _webGLTexture: Nullable<WebGLTexture>;
  105920. /** @hidden */
  105921. _references: number;
  105922. private _engine;
  105923. /**
  105924. * Gets the Engine the texture belongs to.
  105925. * @returns The babylon engine
  105926. */
  105927. getEngine(): ThinEngine;
  105928. /**
  105929. * Gets the data source type of the texture
  105930. */
  105931. get source(): InternalTextureSource;
  105932. /**
  105933. * Creates a new InternalTexture
  105934. * @param engine defines the engine to use
  105935. * @param source defines the type of data that will be used
  105936. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105937. */
  105938. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105939. /**
  105940. * Increments the number of references (ie. the number of Texture that point to it)
  105941. */
  105942. incrementReferences(): void;
  105943. /**
  105944. * Change the size of the texture (not the size of the content)
  105945. * @param width defines the new width
  105946. * @param height defines the new height
  105947. * @param depth defines the new depth (1 by default)
  105948. */
  105949. updateSize(width: int, height: int, depth?: int): void;
  105950. /** @hidden */
  105951. _rebuild(): void;
  105952. /** @hidden */
  105953. _swapAndDie(target: InternalTexture): void;
  105954. /**
  105955. * Dispose the current allocated resources
  105956. */
  105957. dispose(): void;
  105958. }
  105959. }
  105960. declare module BABYLON {
  105961. /**
  105962. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105963. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105964. */
  105965. export class Analyser {
  105966. /**
  105967. * Gets or sets the smoothing
  105968. * @ignorenaming
  105969. */
  105970. SMOOTHING: number;
  105971. /**
  105972. * Gets or sets the FFT table size
  105973. * @ignorenaming
  105974. */
  105975. FFT_SIZE: number;
  105976. /**
  105977. * Gets or sets the bar graph amplitude
  105978. * @ignorenaming
  105979. */
  105980. BARGRAPHAMPLITUDE: number;
  105981. /**
  105982. * Gets or sets the position of the debug canvas
  105983. * @ignorenaming
  105984. */
  105985. DEBUGCANVASPOS: {
  105986. x: number;
  105987. y: number;
  105988. };
  105989. /**
  105990. * Gets or sets the debug canvas size
  105991. * @ignorenaming
  105992. */
  105993. DEBUGCANVASSIZE: {
  105994. width: number;
  105995. height: number;
  105996. };
  105997. private _byteFreqs;
  105998. private _byteTime;
  105999. private _floatFreqs;
  106000. private _webAudioAnalyser;
  106001. private _debugCanvas;
  106002. private _debugCanvasContext;
  106003. private _scene;
  106004. private _registerFunc;
  106005. private _audioEngine;
  106006. /**
  106007. * Creates a new analyser
  106008. * @param scene defines hosting scene
  106009. */
  106010. constructor(scene: Scene);
  106011. /**
  106012. * Get the number of data values you will have to play with for the visualization
  106013. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  106014. * @returns a number
  106015. */
  106016. getFrequencyBinCount(): number;
  106017. /**
  106018. * Gets the current frequency data as a byte array
  106019. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  106020. * @returns a Uint8Array
  106021. */
  106022. getByteFrequencyData(): Uint8Array;
  106023. /**
  106024. * Gets the current waveform as a byte array
  106025. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  106026. * @returns a Uint8Array
  106027. */
  106028. getByteTimeDomainData(): Uint8Array;
  106029. /**
  106030. * Gets the current frequency data as a float array
  106031. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  106032. * @returns a Float32Array
  106033. */
  106034. getFloatFrequencyData(): Float32Array;
  106035. /**
  106036. * Renders the debug canvas
  106037. */
  106038. drawDebugCanvas(): void;
  106039. /**
  106040. * Stops rendering the debug canvas and removes it
  106041. */
  106042. stopDebugCanvas(): void;
  106043. /**
  106044. * Connects two audio nodes
  106045. * @param inputAudioNode defines first node to connect
  106046. * @param outputAudioNode defines second node to connect
  106047. */
  106048. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  106049. /**
  106050. * Releases all associated resources
  106051. */
  106052. dispose(): void;
  106053. }
  106054. }
  106055. declare module BABYLON {
  106056. /**
  106057. * This represents an audio engine and it is responsible
  106058. * to play, synchronize and analyse sounds throughout the application.
  106059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106060. */
  106061. export interface IAudioEngine extends IDisposable {
  106062. /**
  106063. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  106064. */
  106065. readonly canUseWebAudio: boolean;
  106066. /**
  106067. * Gets the current AudioContext if available.
  106068. */
  106069. readonly audioContext: Nullable<AudioContext>;
  106070. /**
  106071. * The master gain node defines the global audio volume of your audio engine.
  106072. */
  106073. readonly masterGain: GainNode;
  106074. /**
  106075. * Gets whether or not mp3 are supported by your browser.
  106076. */
  106077. readonly isMP3supported: boolean;
  106078. /**
  106079. * Gets whether or not ogg are supported by your browser.
  106080. */
  106081. readonly isOGGsupported: boolean;
  106082. /**
  106083. * Defines if Babylon should emit a warning if WebAudio is not supported.
  106084. * @ignoreNaming
  106085. */
  106086. WarnedWebAudioUnsupported: boolean;
  106087. /**
  106088. * Defines if the audio engine relies on a custom unlocked button.
  106089. * In this case, the embedded button will not be displayed.
  106090. */
  106091. useCustomUnlockedButton: boolean;
  106092. /**
  106093. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  106094. */
  106095. readonly unlocked: boolean;
  106096. /**
  106097. * Event raised when audio has been unlocked on the browser.
  106098. */
  106099. onAudioUnlockedObservable: Observable<AudioEngine>;
  106100. /**
  106101. * Event raised when audio has been locked on the browser.
  106102. */
  106103. onAudioLockedObservable: Observable<AudioEngine>;
  106104. /**
  106105. * Flags the audio engine in Locked state.
  106106. * This happens due to new browser policies preventing audio to autoplay.
  106107. */
  106108. lock(): void;
  106109. /**
  106110. * Unlocks the audio engine once a user action has been done on the dom.
  106111. * This is helpful to resume play once browser policies have been satisfied.
  106112. */
  106113. unlock(): void;
  106114. /**
  106115. * Gets the global volume sets on the master gain.
  106116. * @returns the global volume if set or -1 otherwise
  106117. */
  106118. getGlobalVolume(): number;
  106119. /**
  106120. * Sets the global volume of your experience (sets on the master gain).
  106121. * @param newVolume Defines the new global volume of the application
  106122. */
  106123. setGlobalVolume(newVolume: number): void;
  106124. /**
  106125. * Connect the audio engine to an audio analyser allowing some amazing
  106126. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106127. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106128. * @param analyser The analyser to connect to the engine
  106129. */
  106130. connectToAnalyser(analyser: Analyser): void;
  106131. }
  106132. /**
  106133. * This represents the default audio engine used in babylon.
  106134. * It is responsible to play, synchronize and analyse sounds throughout the application.
  106135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106136. */
  106137. export class AudioEngine implements IAudioEngine {
  106138. private _audioContext;
  106139. private _audioContextInitialized;
  106140. private _muteButton;
  106141. private _hostElement;
  106142. /**
  106143. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  106144. */
  106145. canUseWebAudio: boolean;
  106146. /**
  106147. * The master gain node defines the global audio volume of your audio engine.
  106148. */
  106149. masterGain: GainNode;
  106150. /**
  106151. * Defines if Babylon should emit a warning if WebAudio is not supported.
  106152. * @ignoreNaming
  106153. */
  106154. WarnedWebAudioUnsupported: boolean;
  106155. /**
  106156. * Gets whether or not mp3 are supported by your browser.
  106157. */
  106158. isMP3supported: boolean;
  106159. /**
  106160. * Gets whether or not ogg are supported by your browser.
  106161. */
  106162. isOGGsupported: boolean;
  106163. /**
  106164. * Gets whether audio has been unlocked on the device.
  106165. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  106166. * a user interaction has happened.
  106167. */
  106168. unlocked: boolean;
  106169. /**
  106170. * Defines if the audio engine relies on a custom unlocked button.
  106171. * In this case, the embedded button will not be displayed.
  106172. */
  106173. useCustomUnlockedButton: boolean;
  106174. /**
  106175. * Event raised when audio has been unlocked on the browser.
  106176. */
  106177. onAudioUnlockedObservable: Observable<AudioEngine>;
  106178. /**
  106179. * Event raised when audio has been locked on the browser.
  106180. */
  106181. onAudioLockedObservable: Observable<AudioEngine>;
  106182. /**
  106183. * Gets the current AudioContext if available.
  106184. */
  106185. get audioContext(): Nullable<AudioContext>;
  106186. private _connectedAnalyser;
  106187. /**
  106188. * Instantiates a new audio engine.
  106189. *
  106190. * There should be only one per page as some browsers restrict the number
  106191. * of audio contexts you can create.
  106192. * @param hostElement defines the host element where to display the mute icon if necessary
  106193. */
  106194. constructor(hostElement?: Nullable<HTMLElement>);
  106195. /**
  106196. * Flags the audio engine in Locked state.
  106197. * This happens due to new browser policies preventing audio to autoplay.
  106198. */
  106199. lock(): void;
  106200. /**
  106201. * Unlocks the audio engine once a user action has been done on the dom.
  106202. * This is helpful to resume play once browser policies have been satisfied.
  106203. */
  106204. unlock(): void;
  106205. private _resumeAudioContext;
  106206. private _initializeAudioContext;
  106207. private _tryToRun;
  106208. private _triggerRunningState;
  106209. private _triggerSuspendedState;
  106210. private _displayMuteButton;
  106211. private _moveButtonToTopLeft;
  106212. private _onResize;
  106213. private _hideMuteButton;
  106214. /**
  106215. * Destroy and release the resources associated with the audio ccontext.
  106216. */
  106217. dispose(): void;
  106218. /**
  106219. * Gets the global volume sets on the master gain.
  106220. * @returns the global volume if set or -1 otherwise
  106221. */
  106222. getGlobalVolume(): number;
  106223. /**
  106224. * Sets the global volume of your experience (sets on the master gain).
  106225. * @param newVolume Defines the new global volume of the application
  106226. */
  106227. setGlobalVolume(newVolume: number): void;
  106228. /**
  106229. * Connect the audio engine to an audio analyser allowing some amazing
  106230. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106232. * @param analyser The analyser to connect to the engine
  106233. */
  106234. connectToAnalyser(analyser: Analyser): void;
  106235. }
  106236. }
  106237. declare module BABYLON {
  106238. /**
  106239. * Interface used to present a loading screen while loading a scene
  106240. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106241. */
  106242. export interface ILoadingScreen {
  106243. /**
  106244. * Function called to display the loading screen
  106245. */
  106246. displayLoadingUI: () => void;
  106247. /**
  106248. * Function called to hide the loading screen
  106249. */
  106250. hideLoadingUI: () => void;
  106251. /**
  106252. * Gets or sets the color to use for the background
  106253. */
  106254. loadingUIBackgroundColor: string;
  106255. /**
  106256. * Gets or sets the text to display while loading
  106257. */
  106258. loadingUIText: string;
  106259. }
  106260. /**
  106261. * Class used for the default loading screen
  106262. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106263. */
  106264. export class DefaultLoadingScreen implements ILoadingScreen {
  106265. private _renderingCanvas;
  106266. private _loadingText;
  106267. private _loadingDivBackgroundColor;
  106268. private _loadingDiv;
  106269. private _loadingTextDiv;
  106270. /** Gets or sets the logo url to use for the default loading screen */
  106271. static DefaultLogoUrl: string;
  106272. /** Gets or sets the spinner url to use for the default loading screen */
  106273. static DefaultSpinnerUrl: string;
  106274. /**
  106275. * Creates a new default loading screen
  106276. * @param _renderingCanvas defines the canvas used to render the scene
  106277. * @param _loadingText defines the default text to display
  106278. * @param _loadingDivBackgroundColor defines the default background color
  106279. */
  106280. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  106281. /**
  106282. * Function called to display the loading screen
  106283. */
  106284. displayLoadingUI(): void;
  106285. /**
  106286. * Function called to hide the loading screen
  106287. */
  106288. hideLoadingUI(): void;
  106289. /**
  106290. * Gets or sets the text to display while loading
  106291. */
  106292. set loadingUIText(text: string);
  106293. get loadingUIText(): string;
  106294. /**
  106295. * Gets or sets the color to use for the background
  106296. */
  106297. get loadingUIBackgroundColor(): string;
  106298. set loadingUIBackgroundColor(color: string);
  106299. private _resizeLoadingUI;
  106300. }
  106301. }
  106302. declare module BABYLON {
  106303. /**
  106304. * Interface for any object that can request an animation frame
  106305. */
  106306. export interface ICustomAnimationFrameRequester {
  106307. /**
  106308. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106309. */
  106310. renderFunction?: Function;
  106311. /**
  106312. * Called to request the next frame to render to
  106313. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106314. */
  106315. requestAnimationFrame: Function;
  106316. /**
  106317. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106318. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106319. */
  106320. requestID?: number;
  106321. }
  106322. }
  106323. declare module BABYLON {
  106324. /**
  106325. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106326. */
  106327. export class PerformanceMonitor {
  106328. private _enabled;
  106329. private _rollingFrameTime;
  106330. private _lastFrameTimeMs;
  106331. /**
  106332. * constructor
  106333. * @param frameSampleSize The number of samples required to saturate the sliding window
  106334. */
  106335. constructor(frameSampleSize?: number);
  106336. /**
  106337. * Samples current frame
  106338. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106339. */
  106340. sampleFrame(timeMs?: number): void;
  106341. /**
  106342. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106343. */
  106344. get averageFrameTime(): number;
  106345. /**
  106346. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106347. */
  106348. get averageFrameTimeVariance(): number;
  106349. /**
  106350. * Returns the frame time of the most recent frame
  106351. */
  106352. get instantaneousFrameTime(): number;
  106353. /**
  106354. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106355. */
  106356. get averageFPS(): number;
  106357. /**
  106358. * Returns the average framerate in frames per second using the most recent frame time
  106359. */
  106360. get instantaneousFPS(): number;
  106361. /**
  106362. * Returns true if enough samples have been taken to completely fill the sliding window
  106363. */
  106364. get isSaturated(): boolean;
  106365. /**
  106366. * Enables contributions to the sliding window sample set
  106367. */
  106368. enable(): void;
  106369. /**
  106370. * Disables contributions to the sliding window sample set
  106371. * Samples will not be interpolated over the disabled period
  106372. */
  106373. disable(): void;
  106374. /**
  106375. * Returns true if sampling is enabled
  106376. */
  106377. get isEnabled(): boolean;
  106378. /**
  106379. * Resets performance monitor
  106380. */
  106381. reset(): void;
  106382. }
  106383. /**
  106384. * RollingAverage
  106385. *
  106386. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106387. */
  106388. export class RollingAverage {
  106389. /**
  106390. * Current average
  106391. */
  106392. average: number;
  106393. /**
  106394. * Current variance
  106395. */
  106396. variance: number;
  106397. protected _samples: Array<number>;
  106398. protected _sampleCount: number;
  106399. protected _pos: number;
  106400. protected _m2: number;
  106401. /**
  106402. * constructor
  106403. * @param length The number of samples required to saturate the sliding window
  106404. */
  106405. constructor(length: number);
  106406. /**
  106407. * Adds a sample to the sample set
  106408. * @param v The sample value
  106409. */
  106410. add(v: number): void;
  106411. /**
  106412. * Returns previously added values or null if outside of history or outside the sliding window domain
  106413. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106414. * @return Value previously recorded with add() or null if outside of range
  106415. */
  106416. history(i: number): number;
  106417. /**
  106418. * Returns true if enough samples have been taken to completely fill the sliding window
  106419. * @return true if sample-set saturated
  106420. */
  106421. isSaturated(): boolean;
  106422. /**
  106423. * Resets the rolling average (equivalent to 0 samples taken so far)
  106424. */
  106425. reset(): void;
  106426. /**
  106427. * Wraps a value around the sample range boundaries
  106428. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106429. * @return Wrapped position in sample range
  106430. */
  106431. protected _wrapPosition(i: number): number;
  106432. }
  106433. }
  106434. declare module BABYLON {
  106435. /**
  106436. * This class is used to track a performance counter which is number based.
  106437. * The user has access to many properties which give statistics of different nature.
  106438. *
  106439. * The implementer can track two kinds of Performance Counter: time and count.
  106440. * 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.
  106441. * 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.
  106442. */
  106443. export class PerfCounter {
  106444. /**
  106445. * Gets or sets a global boolean to turn on and off all the counters
  106446. */
  106447. static Enabled: boolean;
  106448. /**
  106449. * Returns the smallest value ever
  106450. */
  106451. get min(): number;
  106452. /**
  106453. * Returns the biggest value ever
  106454. */
  106455. get max(): number;
  106456. /**
  106457. * Returns the average value since the performance counter is running
  106458. */
  106459. get average(): number;
  106460. /**
  106461. * Returns the average value of the last second the counter was monitored
  106462. */
  106463. get lastSecAverage(): number;
  106464. /**
  106465. * Returns the current value
  106466. */
  106467. get current(): number;
  106468. /**
  106469. * Gets the accumulated total
  106470. */
  106471. get total(): number;
  106472. /**
  106473. * Gets the total value count
  106474. */
  106475. get count(): number;
  106476. /**
  106477. * Creates a new counter
  106478. */
  106479. constructor();
  106480. /**
  106481. * Call this method to start monitoring a new frame.
  106482. * 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.
  106483. */
  106484. fetchNewFrame(): void;
  106485. /**
  106486. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106487. * @param newCount the count value to add to the monitored count
  106488. * @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.
  106489. */
  106490. addCount(newCount: number, fetchResult: boolean): void;
  106491. /**
  106492. * Start monitoring this performance counter
  106493. */
  106494. beginMonitoring(): void;
  106495. /**
  106496. * Compute the time lapsed since the previous beginMonitoring() call.
  106497. * @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
  106498. */
  106499. endMonitoring(newFrame?: boolean): void;
  106500. private _fetchResult;
  106501. private _startMonitoringTime;
  106502. private _min;
  106503. private _max;
  106504. private _average;
  106505. private _current;
  106506. private _totalValueCount;
  106507. private _totalAccumulated;
  106508. private _lastSecAverage;
  106509. private _lastSecAccumulated;
  106510. private _lastSecTime;
  106511. private _lastSecValueCount;
  106512. }
  106513. }
  106514. declare module BABYLON {
  106515. interface ThinEngine {
  106516. /**
  106517. * Sets alpha constants used by some alpha blending modes
  106518. * @param r defines the red component
  106519. * @param g defines the green component
  106520. * @param b defines the blue component
  106521. * @param a defines the alpha component
  106522. */
  106523. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106524. /**
  106525. * Sets the current alpha mode
  106526. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106527. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106528. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106529. */
  106530. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106531. /**
  106532. * Gets the current alpha mode
  106533. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106534. * @returns the current alpha mode
  106535. */
  106536. getAlphaMode(): number;
  106537. /**
  106538. * Sets the current alpha equation
  106539. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106540. */
  106541. setAlphaEquation(equation: number): void;
  106542. /**
  106543. * Gets the current alpha equation.
  106544. * @returns the current alpha equation
  106545. */
  106546. getAlphaEquation(): number;
  106547. }
  106548. }
  106549. declare module BABYLON {
  106550. /**
  106551. * Defines the interface used by display changed events
  106552. */
  106553. export interface IDisplayChangedEventArgs {
  106554. /** Gets the vrDisplay object (if any) */
  106555. vrDisplay: Nullable<any>;
  106556. /** Gets a boolean indicating if webVR is supported */
  106557. vrSupported: boolean;
  106558. }
  106559. /**
  106560. * Defines the interface used by objects containing a viewport (like a camera)
  106561. */
  106562. interface IViewportOwnerLike {
  106563. /**
  106564. * Gets or sets the viewport
  106565. */
  106566. viewport: IViewportLike;
  106567. }
  106568. /**
  106569. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106570. */
  106571. export class Engine extends ThinEngine {
  106572. /** Defines that alpha blending is disabled */
  106573. static readonly ALPHA_DISABLE: number;
  106574. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106575. static readonly ALPHA_ADD: number;
  106576. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106577. static readonly ALPHA_COMBINE: number;
  106578. /** Defines that alpha blending to DEST - SRC * DEST */
  106579. static readonly ALPHA_SUBTRACT: number;
  106580. /** Defines that alpha blending to SRC * DEST */
  106581. static readonly ALPHA_MULTIPLY: number;
  106582. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106583. static readonly ALPHA_MAXIMIZED: number;
  106584. /** Defines that alpha blending to SRC + DEST */
  106585. static readonly ALPHA_ONEONE: number;
  106586. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106587. static readonly ALPHA_PREMULTIPLIED: number;
  106588. /**
  106589. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106590. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106591. */
  106592. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106593. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106594. static readonly ALPHA_INTERPOLATE: number;
  106595. /**
  106596. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106597. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106598. */
  106599. static readonly ALPHA_SCREENMODE: number;
  106600. /** Defines that the ressource is not delayed*/
  106601. static readonly DELAYLOADSTATE_NONE: number;
  106602. /** Defines that the ressource was successfully delay loaded */
  106603. static readonly DELAYLOADSTATE_LOADED: number;
  106604. /** Defines that the ressource is currently delay loading */
  106605. static readonly DELAYLOADSTATE_LOADING: number;
  106606. /** Defines that the ressource is delayed and has not started loading */
  106607. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106608. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106609. static readonly NEVER: number;
  106610. /** 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 */
  106611. static readonly ALWAYS: number;
  106612. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106613. static readonly LESS: number;
  106614. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106615. static readonly EQUAL: number;
  106616. /** 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 */
  106617. static readonly LEQUAL: number;
  106618. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106619. static readonly GREATER: number;
  106620. /** 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 */
  106621. static readonly GEQUAL: number;
  106622. /** 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 */
  106623. static readonly NOTEQUAL: number;
  106624. /** Passed to stencilOperation to specify that stencil value must be kept */
  106625. static readonly KEEP: number;
  106626. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106627. static readonly REPLACE: number;
  106628. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106629. static readonly INCR: number;
  106630. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106631. static readonly DECR: number;
  106632. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106633. static readonly INVERT: number;
  106634. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106635. static readonly INCR_WRAP: number;
  106636. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106637. static readonly DECR_WRAP: number;
  106638. /** Texture is not repeating outside of 0..1 UVs */
  106639. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106640. /** Texture is repeating outside of 0..1 UVs */
  106641. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106642. /** Texture is repeating and mirrored */
  106643. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106644. /** ALPHA */
  106645. static readonly TEXTUREFORMAT_ALPHA: number;
  106646. /** LUMINANCE */
  106647. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106648. /** LUMINANCE_ALPHA */
  106649. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106650. /** RGB */
  106651. static readonly TEXTUREFORMAT_RGB: number;
  106652. /** RGBA */
  106653. static readonly TEXTUREFORMAT_RGBA: number;
  106654. /** RED */
  106655. static readonly TEXTUREFORMAT_RED: number;
  106656. /** RED (2nd reference) */
  106657. static readonly TEXTUREFORMAT_R: number;
  106658. /** RG */
  106659. static readonly TEXTUREFORMAT_RG: number;
  106660. /** RED_INTEGER */
  106661. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106662. /** RED_INTEGER (2nd reference) */
  106663. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106664. /** RG_INTEGER */
  106665. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106666. /** RGB_INTEGER */
  106667. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106668. /** RGBA_INTEGER */
  106669. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106670. /** UNSIGNED_BYTE */
  106671. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106672. /** UNSIGNED_BYTE (2nd reference) */
  106673. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106674. /** FLOAT */
  106675. static readonly TEXTURETYPE_FLOAT: number;
  106676. /** HALF_FLOAT */
  106677. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106678. /** BYTE */
  106679. static readonly TEXTURETYPE_BYTE: number;
  106680. /** SHORT */
  106681. static readonly TEXTURETYPE_SHORT: number;
  106682. /** UNSIGNED_SHORT */
  106683. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106684. /** INT */
  106685. static readonly TEXTURETYPE_INT: number;
  106686. /** UNSIGNED_INT */
  106687. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106688. /** UNSIGNED_SHORT_4_4_4_4 */
  106689. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106690. /** UNSIGNED_SHORT_5_5_5_1 */
  106691. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106692. /** UNSIGNED_SHORT_5_6_5 */
  106693. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106694. /** UNSIGNED_INT_2_10_10_10_REV */
  106695. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106696. /** UNSIGNED_INT_24_8 */
  106697. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106698. /** UNSIGNED_INT_10F_11F_11F_REV */
  106699. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106700. /** UNSIGNED_INT_5_9_9_9_REV */
  106701. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106702. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106703. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106704. /** nearest is mag = nearest and min = nearest and mip = linear */
  106705. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106706. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106707. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106708. /** Trilinear is mag = linear and min = linear and mip = linear */
  106709. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106710. /** nearest is mag = nearest and min = nearest and mip = linear */
  106711. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106712. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106713. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106714. /** Trilinear is mag = linear and min = linear and mip = linear */
  106715. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106716. /** mag = nearest and min = nearest and mip = nearest */
  106717. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106718. /** mag = nearest and min = linear and mip = nearest */
  106719. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106720. /** mag = nearest and min = linear and mip = linear */
  106721. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106722. /** mag = nearest and min = linear and mip = none */
  106723. static readonly TEXTURE_NEAREST_LINEAR: number;
  106724. /** mag = nearest and min = nearest and mip = none */
  106725. static readonly TEXTURE_NEAREST_NEAREST: number;
  106726. /** mag = linear and min = nearest and mip = nearest */
  106727. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106728. /** mag = linear and min = nearest and mip = linear */
  106729. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106730. /** mag = linear and min = linear and mip = none */
  106731. static readonly TEXTURE_LINEAR_LINEAR: number;
  106732. /** mag = linear and min = nearest and mip = none */
  106733. static readonly TEXTURE_LINEAR_NEAREST: number;
  106734. /** Explicit coordinates mode */
  106735. static readonly TEXTURE_EXPLICIT_MODE: number;
  106736. /** Spherical coordinates mode */
  106737. static readonly TEXTURE_SPHERICAL_MODE: number;
  106738. /** Planar coordinates mode */
  106739. static readonly TEXTURE_PLANAR_MODE: number;
  106740. /** Cubic coordinates mode */
  106741. static readonly TEXTURE_CUBIC_MODE: number;
  106742. /** Projection coordinates mode */
  106743. static readonly TEXTURE_PROJECTION_MODE: number;
  106744. /** Skybox coordinates mode */
  106745. static readonly TEXTURE_SKYBOX_MODE: number;
  106746. /** Inverse Cubic coordinates mode */
  106747. static readonly TEXTURE_INVCUBIC_MODE: number;
  106748. /** Equirectangular coordinates mode */
  106749. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106750. /** Equirectangular Fixed coordinates mode */
  106751. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106752. /** Equirectangular Fixed Mirrored coordinates mode */
  106753. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106754. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106755. static readonly SCALEMODE_FLOOR: number;
  106756. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106757. static readonly SCALEMODE_NEAREST: number;
  106758. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106759. static readonly SCALEMODE_CEILING: number;
  106760. /**
  106761. * Returns the current npm package of the sdk
  106762. */
  106763. static get NpmPackage(): string;
  106764. /**
  106765. * Returns the current version of the framework
  106766. */
  106767. static get Version(): string;
  106768. /** Gets the list of created engines */
  106769. static get Instances(): Engine[];
  106770. /**
  106771. * Gets the latest created engine
  106772. */
  106773. static get LastCreatedEngine(): Nullable<Engine>;
  106774. /**
  106775. * Gets the latest created scene
  106776. */
  106777. static get LastCreatedScene(): Nullable<Scene>;
  106778. /**
  106779. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106780. * @param flag defines which part of the materials must be marked as dirty
  106781. * @param predicate defines a predicate used to filter which materials should be affected
  106782. */
  106783. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106784. /**
  106785. * Method called to create the default loading screen.
  106786. * This can be overriden in your own app.
  106787. * @param canvas The rendering canvas element
  106788. * @returns The loading screen
  106789. */
  106790. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106791. /**
  106792. * Method called to create the default rescale post process on each engine.
  106793. */
  106794. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106795. /**
  106796. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106797. **/
  106798. enableOfflineSupport: boolean;
  106799. /**
  106800. * 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)
  106801. **/
  106802. disableManifestCheck: boolean;
  106803. /**
  106804. * Gets the list of created scenes
  106805. */
  106806. scenes: Scene[];
  106807. /**
  106808. * Event raised when a new scene is created
  106809. */
  106810. onNewSceneAddedObservable: Observable<Scene>;
  106811. /**
  106812. * Gets the list of created postprocesses
  106813. */
  106814. postProcesses: PostProcess[];
  106815. /**
  106816. * Gets a boolean indicating if the pointer is currently locked
  106817. */
  106818. isPointerLock: boolean;
  106819. /**
  106820. * Observable event triggered each time the rendering canvas is resized
  106821. */
  106822. onResizeObservable: Observable<Engine>;
  106823. /**
  106824. * Observable event triggered each time the canvas loses focus
  106825. */
  106826. onCanvasBlurObservable: Observable<Engine>;
  106827. /**
  106828. * Observable event triggered each time the canvas gains focus
  106829. */
  106830. onCanvasFocusObservable: Observable<Engine>;
  106831. /**
  106832. * Observable event triggered each time the canvas receives pointerout event
  106833. */
  106834. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106835. /**
  106836. * Observable raised when the engine begins a new frame
  106837. */
  106838. onBeginFrameObservable: Observable<Engine>;
  106839. /**
  106840. * If set, will be used to request the next animation frame for the render loop
  106841. */
  106842. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106843. /**
  106844. * Observable raised when the engine ends the current frame
  106845. */
  106846. onEndFrameObservable: Observable<Engine>;
  106847. /**
  106848. * Observable raised when the engine is about to compile a shader
  106849. */
  106850. onBeforeShaderCompilationObservable: Observable<Engine>;
  106851. /**
  106852. * Observable raised when the engine has jsut compiled a shader
  106853. */
  106854. onAfterShaderCompilationObservable: Observable<Engine>;
  106855. /**
  106856. * Gets the audio engine
  106857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106858. * @ignorenaming
  106859. */
  106860. static audioEngine: IAudioEngine;
  106861. /**
  106862. * Default AudioEngine factory responsible of creating the Audio Engine.
  106863. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106864. */
  106865. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106866. /**
  106867. * Default offline support factory responsible of creating a tool used to store data locally.
  106868. * By default, this will create a Database object if the workload has been embedded.
  106869. */
  106870. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106871. private _loadingScreen;
  106872. private _pointerLockRequested;
  106873. private _dummyFramebuffer;
  106874. private _rescalePostProcess;
  106875. private _deterministicLockstep;
  106876. private _lockstepMaxSteps;
  106877. private _timeStep;
  106878. protected get _supportsHardwareTextureRescaling(): boolean;
  106879. private _fps;
  106880. private _deltaTime;
  106881. /** @hidden */
  106882. _drawCalls: PerfCounter;
  106883. /** 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 */
  106884. canvasTabIndex: number;
  106885. /**
  106886. * Turn this value on if you want to pause FPS computation when in background
  106887. */
  106888. disablePerformanceMonitorInBackground: boolean;
  106889. private _performanceMonitor;
  106890. /**
  106891. * Gets the performance monitor attached to this engine
  106892. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106893. */
  106894. get performanceMonitor(): PerformanceMonitor;
  106895. private _onFocus;
  106896. private _onBlur;
  106897. private _onCanvasPointerOut;
  106898. private _onCanvasBlur;
  106899. private _onCanvasFocus;
  106900. private _onFullscreenChange;
  106901. private _onPointerLockChange;
  106902. /**
  106903. * Gets the HTML element used to attach event listeners
  106904. * @returns a HTML element
  106905. */
  106906. getInputElement(): Nullable<HTMLElement>;
  106907. /**
  106908. * Creates a new engine
  106909. * @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
  106910. * @param antialias defines enable antialiasing (default: false)
  106911. * @param options defines further options to be sent to the getContext() function
  106912. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106913. */
  106914. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106915. /**
  106916. * Gets current aspect ratio
  106917. * @param viewportOwner defines the camera to use to get the aspect ratio
  106918. * @param useScreen defines if screen size must be used (or the current render target if any)
  106919. * @returns a number defining the aspect ratio
  106920. */
  106921. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106922. /**
  106923. * Gets current screen aspect ratio
  106924. * @returns a number defining the aspect ratio
  106925. */
  106926. getScreenAspectRatio(): number;
  106927. /**
  106928. * Gets the client rect of the HTML canvas attached with the current webGL context
  106929. * @returns a client rectanglee
  106930. */
  106931. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106932. /**
  106933. * Gets the client rect of the HTML element used for events
  106934. * @returns a client rectanglee
  106935. */
  106936. getInputElementClientRect(): Nullable<ClientRect>;
  106937. /**
  106938. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106939. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106940. * @returns true if engine is in deterministic lock step mode
  106941. */
  106942. isDeterministicLockStep(): boolean;
  106943. /**
  106944. * Gets the max steps when engine is running in deterministic lock step
  106945. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106946. * @returns the max steps
  106947. */
  106948. getLockstepMaxSteps(): number;
  106949. /**
  106950. * Returns the time in ms between steps when using deterministic lock step.
  106951. * @returns time step in (ms)
  106952. */
  106953. getTimeStep(): number;
  106954. /**
  106955. * Force the mipmap generation for the given render target texture
  106956. * @param texture defines the render target texture to use
  106957. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106958. */
  106959. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106960. /** States */
  106961. /**
  106962. * Set various states to the webGL context
  106963. * @param culling defines backface culling state
  106964. * @param zOffset defines the value to apply to zOffset (0 by default)
  106965. * @param force defines if states must be applied even if cache is up to date
  106966. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106967. */
  106968. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106969. /**
  106970. * Set the z offset to apply to current rendering
  106971. * @param value defines the offset to apply
  106972. */
  106973. setZOffset(value: number): void;
  106974. /**
  106975. * Gets the current value of the zOffset
  106976. * @returns the current zOffset state
  106977. */
  106978. getZOffset(): number;
  106979. /**
  106980. * Enable or disable depth buffering
  106981. * @param enable defines the state to set
  106982. */
  106983. setDepthBuffer(enable: boolean): void;
  106984. /**
  106985. * Gets a boolean indicating if depth writing is enabled
  106986. * @returns the current depth writing state
  106987. */
  106988. getDepthWrite(): boolean;
  106989. /**
  106990. * Enable or disable depth writing
  106991. * @param enable defines the state to set
  106992. */
  106993. setDepthWrite(enable: boolean): void;
  106994. /**
  106995. * Gets a boolean indicating if stencil buffer is enabled
  106996. * @returns the current stencil buffer state
  106997. */
  106998. getStencilBuffer(): boolean;
  106999. /**
  107000. * Enable or disable the stencil buffer
  107001. * @param enable defines if the stencil buffer must be enabled or disabled
  107002. */
  107003. setStencilBuffer(enable: boolean): void;
  107004. /**
  107005. * Gets the current stencil mask
  107006. * @returns a number defining the new stencil mask to use
  107007. */
  107008. getStencilMask(): number;
  107009. /**
  107010. * Sets the current stencil mask
  107011. * @param mask defines the new stencil mask to use
  107012. */
  107013. setStencilMask(mask: number): void;
  107014. /**
  107015. * Gets the current stencil function
  107016. * @returns a number defining the stencil function to use
  107017. */
  107018. getStencilFunction(): number;
  107019. /**
  107020. * Gets the current stencil reference value
  107021. * @returns a number defining the stencil reference value to use
  107022. */
  107023. getStencilFunctionReference(): number;
  107024. /**
  107025. * Gets the current stencil mask
  107026. * @returns a number defining the stencil mask to use
  107027. */
  107028. getStencilFunctionMask(): number;
  107029. /**
  107030. * Sets the current stencil function
  107031. * @param stencilFunc defines the new stencil function to use
  107032. */
  107033. setStencilFunction(stencilFunc: number): void;
  107034. /**
  107035. * Sets the current stencil reference
  107036. * @param reference defines the new stencil reference to use
  107037. */
  107038. setStencilFunctionReference(reference: number): void;
  107039. /**
  107040. * Sets the current stencil mask
  107041. * @param mask defines the new stencil mask to use
  107042. */
  107043. setStencilFunctionMask(mask: number): void;
  107044. /**
  107045. * Gets the current stencil operation when stencil fails
  107046. * @returns a number defining stencil operation to use when stencil fails
  107047. */
  107048. getStencilOperationFail(): number;
  107049. /**
  107050. * Gets the current stencil operation when depth fails
  107051. * @returns a number defining stencil operation to use when depth fails
  107052. */
  107053. getStencilOperationDepthFail(): number;
  107054. /**
  107055. * Gets the current stencil operation when stencil passes
  107056. * @returns a number defining stencil operation to use when stencil passes
  107057. */
  107058. getStencilOperationPass(): number;
  107059. /**
  107060. * Sets the stencil operation to use when stencil fails
  107061. * @param operation defines the stencil operation to use when stencil fails
  107062. */
  107063. setStencilOperationFail(operation: number): void;
  107064. /**
  107065. * Sets the stencil operation to use when depth fails
  107066. * @param operation defines the stencil operation to use when depth fails
  107067. */
  107068. setStencilOperationDepthFail(operation: number): void;
  107069. /**
  107070. * Sets the stencil operation to use when stencil passes
  107071. * @param operation defines the stencil operation to use when stencil passes
  107072. */
  107073. setStencilOperationPass(operation: number): void;
  107074. /**
  107075. * Sets a boolean indicating if the dithering state is enabled or disabled
  107076. * @param value defines the dithering state
  107077. */
  107078. setDitheringState(value: boolean): void;
  107079. /**
  107080. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  107081. * @param value defines the rasterizer state
  107082. */
  107083. setRasterizerState(value: boolean): void;
  107084. /**
  107085. * Gets the current depth function
  107086. * @returns a number defining the depth function
  107087. */
  107088. getDepthFunction(): Nullable<number>;
  107089. /**
  107090. * Sets the current depth function
  107091. * @param depthFunc defines the function to use
  107092. */
  107093. setDepthFunction(depthFunc: number): void;
  107094. /**
  107095. * Sets the current depth function to GREATER
  107096. */
  107097. setDepthFunctionToGreater(): void;
  107098. /**
  107099. * Sets the current depth function to GEQUAL
  107100. */
  107101. setDepthFunctionToGreaterOrEqual(): void;
  107102. /**
  107103. * Sets the current depth function to LESS
  107104. */
  107105. setDepthFunctionToLess(): void;
  107106. /**
  107107. * Sets the current depth function to LEQUAL
  107108. */
  107109. setDepthFunctionToLessOrEqual(): void;
  107110. private _cachedStencilBuffer;
  107111. private _cachedStencilFunction;
  107112. private _cachedStencilMask;
  107113. private _cachedStencilOperationPass;
  107114. private _cachedStencilOperationFail;
  107115. private _cachedStencilOperationDepthFail;
  107116. private _cachedStencilReference;
  107117. /**
  107118. * Caches the the state of the stencil buffer
  107119. */
  107120. cacheStencilState(): void;
  107121. /**
  107122. * Restores the state of the stencil buffer
  107123. */
  107124. restoreStencilState(): void;
  107125. /**
  107126. * Directly set the WebGL Viewport
  107127. * @param x defines the x coordinate of the viewport (in screen space)
  107128. * @param y defines the y coordinate of the viewport (in screen space)
  107129. * @param width defines the width of the viewport (in screen space)
  107130. * @param height defines the height of the viewport (in screen space)
  107131. * @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
  107132. */
  107133. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  107134. /**
  107135. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  107136. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  107137. * @param y defines the y-coordinate of the corner of the clear rectangle
  107138. * @param width defines the width of the clear rectangle
  107139. * @param height defines the height of the clear rectangle
  107140. * @param clearColor defines the clear color
  107141. */
  107142. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  107143. /**
  107144. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  107145. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  107146. * @param y defines the y-coordinate of the corner of the clear rectangle
  107147. * @param width defines the width of the clear rectangle
  107148. * @param height defines the height of the clear rectangle
  107149. */
  107150. enableScissor(x: number, y: number, width: number, height: number): void;
  107151. /**
  107152. * Disable previously set scissor test rectangle
  107153. */
  107154. disableScissor(): void;
  107155. protected _reportDrawCall(): void;
  107156. /**
  107157. * Initializes a webVR display and starts listening to display change events
  107158. * The onVRDisplayChangedObservable will be notified upon these changes
  107159. * @returns The onVRDisplayChangedObservable
  107160. */
  107161. initWebVR(): Observable<IDisplayChangedEventArgs>;
  107162. /** @hidden */
  107163. _prepareVRComponent(): void;
  107164. /** @hidden */
  107165. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  107166. /** @hidden */
  107167. _submitVRFrame(): void;
  107168. /**
  107169. * Call this function to leave webVR mode
  107170. * Will do nothing if webVR is not supported or if there is no webVR device
  107171. * @see http://doc.babylonjs.com/how_to/webvr_camera
  107172. */
  107173. disableVR(): void;
  107174. /**
  107175. * Gets a boolean indicating that the system is in VR mode and is presenting
  107176. * @returns true if VR mode is engaged
  107177. */
  107178. isVRPresenting(): boolean;
  107179. /** @hidden */
  107180. _requestVRFrame(): void;
  107181. /** @hidden */
  107182. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107183. /**
  107184. * Gets the source code of the vertex shader associated with a specific webGL program
  107185. * @param program defines the program to use
  107186. * @returns a string containing the source code of the vertex shader associated with the program
  107187. */
  107188. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  107189. /**
  107190. * Gets the source code of the fragment shader associated with a specific webGL program
  107191. * @param program defines the program to use
  107192. * @returns a string containing the source code of the fragment shader associated with the program
  107193. */
  107194. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  107195. /**
  107196. * Sets a depth stencil texture from a render target to the according uniform.
  107197. * @param channel The texture channel
  107198. * @param uniform The uniform to set
  107199. * @param texture The render target texture containing the depth stencil texture to apply
  107200. */
  107201. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  107202. /**
  107203. * Sets a texture to the webGL context from a postprocess
  107204. * @param channel defines the channel to use
  107205. * @param postProcess defines the source postprocess
  107206. */
  107207. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  107208. /**
  107209. * Binds the output of the passed in post process to the texture channel specified
  107210. * @param channel The channel the texture should be bound to
  107211. * @param postProcess The post process which's output should be bound
  107212. */
  107213. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  107214. /** @hidden */
  107215. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  107216. protected _rebuildBuffers(): void;
  107217. /** @hidden */
  107218. _renderFrame(): void;
  107219. _renderLoop(): void;
  107220. /** @hidden */
  107221. _renderViews(): boolean;
  107222. /**
  107223. * Toggle full screen mode
  107224. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107225. */
  107226. switchFullscreen(requestPointerLock: boolean): void;
  107227. /**
  107228. * Enters full screen mode
  107229. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107230. */
  107231. enterFullscreen(requestPointerLock: boolean): void;
  107232. /**
  107233. * Exits full screen mode
  107234. */
  107235. exitFullscreen(): void;
  107236. /**
  107237. * Enters Pointerlock mode
  107238. */
  107239. enterPointerlock(): void;
  107240. /**
  107241. * Exits Pointerlock mode
  107242. */
  107243. exitPointerlock(): void;
  107244. /**
  107245. * Begin a new frame
  107246. */
  107247. beginFrame(): void;
  107248. /**
  107249. * Enf the current frame
  107250. */
  107251. endFrame(): void;
  107252. resize(): void;
  107253. /**
  107254. * Force a specific size of the canvas
  107255. * @param width defines the new canvas' width
  107256. * @param height defines the new canvas' height
  107257. */
  107258. setSize(width: number, height: number): void;
  107259. /**
  107260. * Updates a dynamic vertex buffer.
  107261. * @param vertexBuffer the vertex buffer to update
  107262. * @param data the data used to update the vertex buffer
  107263. * @param byteOffset the byte offset of the data
  107264. * @param byteLength the byte length of the data
  107265. */
  107266. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  107267. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107268. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107269. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107270. _releaseTexture(texture: InternalTexture): void;
  107271. /**
  107272. * @hidden
  107273. * Rescales a texture
  107274. * @param source input texutre
  107275. * @param destination destination texture
  107276. * @param scene scene to use to render the resize
  107277. * @param internalFormat format to use when resizing
  107278. * @param onComplete callback to be called when resize has completed
  107279. */
  107280. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107281. /**
  107282. * Gets the current framerate
  107283. * @returns a number representing the framerate
  107284. */
  107285. getFps(): number;
  107286. /**
  107287. * Gets the time spent between current and previous frame
  107288. * @returns a number representing the delta time in ms
  107289. */
  107290. getDeltaTime(): number;
  107291. private _measureFps;
  107292. /** @hidden */
  107293. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107294. /**
  107295. * Update a dynamic index buffer
  107296. * @param indexBuffer defines the target index buffer
  107297. * @param indices defines the data to update
  107298. * @param offset defines the offset in the target index buffer where update should start
  107299. */
  107300. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107301. /**
  107302. * Updates the sample count of a render target texture
  107303. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107304. * @param texture defines the texture to update
  107305. * @param samples defines the sample count to set
  107306. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107307. */
  107308. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107309. /**
  107310. * Updates a depth texture Comparison Mode and Function.
  107311. * If the comparison Function is equal to 0, the mode will be set to none.
  107312. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107313. * @param texture The texture to set the comparison function for
  107314. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107315. */
  107316. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107317. /**
  107318. * Creates a webGL buffer to use with instanciation
  107319. * @param capacity defines the size of the buffer
  107320. * @returns the webGL buffer
  107321. */
  107322. createInstancesBuffer(capacity: number): DataBuffer;
  107323. /**
  107324. * Delete a webGL buffer used with instanciation
  107325. * @param buffer defines the webGL buffer to delete
  107326. */
  107327. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107328. private _clientWaitAsync;
  107329. /** @hidden */
  107330. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  107331. /** @hidden */
  107332. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107333. dispose(): void;
  107334. private _disableTouchAction;
  107335. /**
  107336. * Display the loading screen
  107337. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107338. */
  107339. displayLoadingUI(): void;
  107340. /**
  107341. * Hide the loading screen
  107342. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107343. */
  107344. hideLoadingUI(): void;
  107345. /**
  107346. * Gets the current loading screen object
  107347. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107348. */
  107349. get loadingScreen(): ILoadingScreen;
  107350. /**
  107351. * Sets the current loading screen object
  107352. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107353. */
  107354. set loadingScreen(loadingScreen: ILoadingScreen);
  107355. /**
  107356. * Sets the current loading screen text
  107357. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107358. */
  107359. set loadingUIText(text: string);
  107360. /**
  107361. * Sets the current loading screen background color
  107362. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107363. */
  107364. set loadingUIBackgroundColor(color: string);
  107365. /** Pointerlock and fullscreen */
  107366. /**
  107367. * Ask the browser to promote the current element to pointerlock mode
  107368. * @param element defines the DOM element to promote
  107369. */
  107370. static _RequestPointerlock(element: HTMLElement): void;
  107371. /**
  107372. * Asks the browser to exit pointerlock mode
  107373. */
  107374. static _ExitPointerlock(): void;
  107375. /**
  107376. * Ask the browser to promote the current element to fullscreen rendering mode
  107377. * @param element defines the DOM element to promote
  107378. */
  107379. static _RequestFullscreen(element: HTMLElement): void;
  107380. /**
  107381. * Asks the browser to exit fullscreen mode
  107382. */
  107383. static _ExitFullscreen(): void;
  107384. }
  107385. }
  107386. declare module BABYLON {
  107387. /**
  107388. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107389. * during the life time of the application.
  107390. */
  107391. export class EngineStore {
  107392. /** Gets the list of created engines */
  107393. static Instances: Engine[];
  107394. /** @hidden */
  107395. static _LastCreatedScene: Nullable<Scene>;
  107396. /**
  107397. * Gets the latest created engine
  107398. */
  107399. static get LastCreatedEngine(): Nullable<Engine>;
  107400. /**
  107401. * Gets the latest created scene
  107402. */
  107403. static get LastCreatedScene(): Nullable<Scene>;
  107404. /**
  107405. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107406. * @ignorenaming
  107407. */
  107408. static UseFallbackTexture: boolean;
  107409. /**
  107410. * Texture content used if a texture cannot loaded
  107411. * @ignorenaming
  107412. */
  107413. static FallbackTexture: string;
  107414. }
  107415. }
  107416. declare module BABYLON {
  107417. /**
  107418. * Helper class that provides a small promise polyfill
  107419. */
  107420. export class PromisePolyfill {
  107421. /**
  107422. * Static function used to check if the polyfill is required
  107423. * If this is the case then the function will inject the polyfill to window.Promise
  107424. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107425. */
  107426. static Apply(force?: boolean): void;
  107427. }
  107428. }
  107429. declare module BABYLON {
  107430. /**
  107431. * Interface for screenshot methods with describe argument called `size` as object with options
  107432. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107433. */
  107434. export interface IScreenshotSize {
  107435. /**
  107436. * number in pixels for canvas height
  107437. */
  107438. height?: number;
  107439. /**
  107440. * multiplier allowing render at a higher or lower resolution
  107441. * If value is defined then height and width will be ignored and taken from camera
  107442. */
  107443. precision?: number;
  107444. /**
  107445. * number in pixels for canvas width
  107446. */
  107447. width?: number;
  107448. }
  107449. }
  107450. declare module BABYLON {
  107451. interface IColor4Like {
  107452. r: float;
  107453. g: float;
  107454. b: float;
  107455. a: float;
  107456. }
  107457. /**
  107458. * Class containing a set of static utilities functions
  107459. */
  107460. export class Tools {
  107461. /**
  107462. * Gets or sets the base URL to use to load assets
  107463. */
  107464. static get BaseUrl(): string;
  107465. static set BaseUrl(value: string);
  107466. /**
  107467. * Enable/Disable Custom HTTP Request Headers globally.
  107468. * default = false
  107469. * @see CustomRequestHeaders
  107470. */
  107471. static UseCustomRequestHeaders: boolean;
  107472. /**
  107473. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107474. * i.e. when loading files, where the server/service expects an Authorization header
  107475. */
  107476. static CustomRequestHeaders: {
  107477. [key: string]: string;
  107478. };
  107479. /**
  107480. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107481. */
  107482. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107483. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107484. /**
  107485. * Default behaviour for cors in the application.
  107486. * It can be a string if the expected behavior is identical in the entire app.
  107487. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107488. */
  107489. static get CorsBehavior(): string | ((url: string | string[]) => string);
  107490. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  107491. /**
  107492. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107493. * @ignorenaming
  107494. */
  107495. static get UseFallbackTexture(): boolean;
  107496. static set UseFallbackTexture(value: boolean);
  107497. /**
  107498. * Use this object to register external classes like custom textures or material
  107499. * to allow the laoders to instantiate them
  107500. */
  107501. static get RegisteredExternalClasses(): {
  107502. [key: string]: Object;
  107503. };
  107504. static set RegisteredExternalClasses(classes: {
  107505. [key: string]: Object;
  107506. });
  107507. /**
  107508. * Texture content used if a texture cannot loaded
  107509. * @ignorenaming
  107510. */
  107511. static get fallbackTexture(): string;
  107512. static set fallbackTexture(value: string);
  107513. /**
  107514. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107515. * @param u defines the coordinate on X axis
  107516. * @param v defines the coordinate on Y axis
  107517. * @param width defines the width of the source data
  107518. * @param height defines the height of the source data
  107519. * @param pixels defines the source byte array
  107520. * @param color defines the output color
  107521. */
  107522. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107523. /**
  107524. * Interpolates between a and b via alpha
  107525. * @param a The lower value (returned when alpha = 0)
  107526. * @param b The upper value (returned when alpha = 1)
  107527. * @param alpha The interpolation-factor
  107528. * @return The mixed value
  107529. */
  107530. static Mix(a: number, b: number, alpha: number): number;
  107531. /**
  107532. * Tries to instantiate a new object from a given class name
  107533. * @param className defines the class name to instantiate
  107534. * @returns the new object or null if the system was not able to do the instantiation
  107535. */
  107536. static Instantiate(className: string): any;
  107537. /**
  107538. * Provides a slice function that will work even on IE
  107539. * @param data defines the array to slice
  107540. * @param start defines the start of the data (optional)
  107541. * @param end defines the end of the data (optional)
  107542. * @returns the new sliced array
  107543. */
  107544. static Slice<T>(data: T, start?: number, end?: number): T;
  107545. /**
  107546. * Polyfill for setImmediate
  107547. * @param action defines the action to execute after the current execution block
  107548. */
  107549. static SetImmediate(action: () => void): void;
  107550. /**
  107551. * Function indicating if a number is an exponent of 2
  107552. * @param value defines the value to test
  107553. * @returns true if the value is an exponent of 2
  107554. */
  107555. static IsExponentOfTwo(value: number): boolean;
  107556. private static _tmpFloatArray;
  107557. /**
  107558. * Returns the nearest 32-bit single precision float representation of a Number
  107559. * @param value A Number. If the parameter is of a different type, it will get converted
  107560. * to a number or to NaN if it cannot be converted
  107561. * @returns number
  107562. */
  107563. static FloatRound(value: number): number;
  107564. /**
  107565. * Extracts the filename from a path
  107566. * @param path defines the path to use
  107567. * @returns the filename
  107568. */
  107569. static GetFilename(path: string): string;
  107570. /**
  107571. * Extracts the "folder" part of a path (everything before the filename).
  107572. * @param uri The URI to extract the info from
  107573. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107574. * @returns The "folder" part of the path
  107575. */
  107576. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107577. /**
  107578. * Extracts text content from a DOM element hierarchy
  107579. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107580. */
  107581. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107582. /**
  107583. * Convert an angle in radians to degrees
  107584. * @param angle defines the angle to convert
  107585. * @returns the angle in degrees
  107586. */
  107587. static ToDegrees(angle: number): number;
  107588. /**
  107589. * Convert an angle in degrees to radians
  107590. * @param angle defines the angle to convert
  107591. * @returns the angle in radians
  107592. */
  107593. static ToRadians(angle: number): number;
  107594. /**
  107595. * Returns an array if obj is not an array
  107596. * @param obj defines the object to evaluate as an array
  107597. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107598. * @returns either obj directly if obj is an array or a new array containing obj
  107599. */
  107600. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107601. /**
  107602. * Gets the pointer prefix to use
  107603. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107604. */
  107605. static GetPointerPrefix(): string;
  107606. /**
  107607. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107608. * @param url define the url we are trying
  107609. * @param element define the dom element where to configure the cors policy
  107610. */
  107611. static SetCorsBehavior(url: string | string[], element: {
  107612. crossOrigin: string | null;
  107613. }): void;
  107614. /**
  107615. * Removes unwanted characters from an url
  107616. * @param url defines the url to clean
  107617. * @returns the cleaned url
  107618. */
  107619. static CleanUrl(url: string): string;
  107620. /**
  107621. * Gets or sets a function used to pre-process url before using them to load assets
  107622. */
  107623. static get PreprocessUrl(): (url: string) => string;
  107624. static set PreprocessUrl(processor: (url: string) => string);
  107625. /**
  107626. * Loads an image as an HTMLImageElement.
  107627. * @param input url string, ArrayBuffer, or Blob to load
  107628. * @param onLoad callback called when the image successfully loads
  107629. * @param onError callback called when the image fails to load
  107630. * @param offlineProvider offline provider for caching
  107631. * @param mimeType optional mime type
  107632. * @returns the HTMLImageElement of the loaded image
  107633. */
  107634. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107635. /**
  107636. * Loads a file from a url
  107637. * @param url url string, ArrayBuffer, or Blob to load
  107638. * @param onSuccess callback called when the file successfully loads
  107639. * @param onProgress callback called while file is loading (if the server supports this mode)
  107640. * @param offlineProvider defines the offline provider for caching
  107641. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107642. * @param onError callback called when the file fails to load
  107643. * @returns a file request object
  107644. */
  107645. 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;
  107646. /**
  107647. * Loads a file from a url
  107648. * @param url the file url to load
  107649. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107650. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107651. */
  107652. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107653. /**
  107654. * Load a script (identified by an url). When the url returns, the
  107655. * content of this file is added into a new script element, attached to the DOM (body element)
  107656. * @param scriptUrl defines the url of the script to laod
  107657. * @param onSuccess defines the callback called when the script is loaded
  107658. * @param onError defines the callback to call if an error occurs
  107659. * @param scriptId defines the id of the script element
  107660. */
  107661. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107662. /**
  107663. * Load an asynchronous script (identified by an url). When the url returns, the
  107664. * content of this file is added into a new script element, attached to the DOM (body element)
  107665. * @param scriptUrl defines the url of the script to laod
  107666. * @param scriptId defines the id of the script element
  107667. * @returns a promise request object
  107668. */
  107669. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107670. /**
  107671. * Loads a file from a blob
  107672. * @param fileToLoad defines the blob to use
  107673. * @param callback defines the callback to call when data is loaded
  107674. * @param progressCallback defines the callback to call during loading process
  107675. * @returns a file request object
  107676. */
  107677. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107678. /**
  107679. * Reads a file from a File object
  107680. * @param file defines the file to load
  107681. * @param onSuccess defines the callback to call when data is loaded
  107682. * @param onProgress defines the callback to call during loading process
  107683. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107684. * @param onError defines the callback to call when an error occurs
  107685. * @returns a file request object
  107686. */
  107687. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107688. /**
  107689. * Creates a data url from a given string content
  107690. * @param content defines the content to convert
  107691. * @returns the new data url link
  107692. */
  107693. static FileAsURL(content: string): string;
  107694. /**
  107695. * Format the given number to a specific decimal format
  107696. * @param value defines the number to format
  107697. * @param decimals defines the number of decimals to use
  107698. * @returns the formatted string
  107699. */
  107700. static Format(value: number, decimals?: number): string;
  107701. /**
  107702. * Tries to copy an object by duplicating every property
  107703. * @param source defines the source object
  107704. * @param destination defines the target object
  107705. * @param doNotCopyList defines a list of properties to avoid
  107706. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107707. */
  107708. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107709. /**
  107710. * Gets a boolean indicating if the given object has no own property
  107711. * @param obj defines the object to test
  107712. * @returns true if object has no own property
  107713. */
  107714. static IsEmpty(obj: any): boolean;
  107715. /**
  107716. * Function used to register events at window level
  107717. * @param windowElement defines the Window object to use
  107718. * @param events defines the events to register
  107719. */
  107720. static RegisterTopRootEvents(windowElement: Window, events: {
  107721. name: string;
  107722. handler: Nullable<(e: FocusEvent) => any>;
  107723. }[]): void;
  107724. /**
  107725. * Function used to unregister events from window level
  107726. * @param windowElement defines the Window object to use
  107727. * @param events defines the events to unregister
  107728. */
  107729. static UnregisterTopRootEvents(windowElement: Window, events: {
  107730. name: string;
  107731. handler: Nullable<(e: FocusEvent) => any>;
  107732. }[]): void;
  107733. /**
  107734. * @ignore
  107735. */
  107736. static _ScreenshotCanvas: HTMLCanvasElement;
  107737. /**
  107738. * Dumps the current bound framebuffer
  107739. * @param width defines the rendering width
  107740. * @param height defines the rendering height
  107741. * @param engine defines the hosting engine
  107742. * @param successCallback defines the callback triggered once the data are available
  107743. * @param mimeType defines the mime type of the result
  107744. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107745. */
  107746. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107747. /**
  107748. * Converts the canvas data to blob.
  107749. * This acts as a polyfill for browsers not supporting the to blob function.
  107750. * @param canvas Defines the canvas to extract the data from
  107751. * @param successCallback Defines the callback triggered once the data are available
  107752. * @param mimeType Defines the mime type of the result
  107753. */
  107754. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107755. /**
  107756. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107757. * @param successCallback defines the callback triggered once the data are available
  107758. * @param mimeType defines the mime type of the result
  107759. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107760. */
  107761. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107762. /**
  107763. * Downloads a blob in the browser
  107764. * @param blob defines the blob to download
  107765. * @param fileName defines the name of the downloaded file
  107766. */
  107767. static Download(blob: Blob, fileName: string): void;
  107768. /**
  107769. * Captures a screenshot of the current rendering
  107770. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107771. * @param engine defines the rendering engine
  107772. * @param camera defines the source camera
  107773. * @param size This parameter can be set to a single number or to an object with the
  107774. * following (optional) properties: precision, width, height. If a single number is passed,
  107775. * it will be used for both width and height. If an object is passed, the screenshot size
  107776. * will be derived from the parameters. The precision property is a multiplier allowing
  107777. * rendering at a higher or lower resolution
  107778. * @param successCallback defines the callback receives a single parameter which contains the
  107779. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107780. * src parameter of an <img> to display it
  107781. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107782. * Check your browser for supported MIME types
  107783. */
  107784. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107785. /**
  107786. * Captures a screenshot of the current rendering
  107787. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107788. * @param engine defines the rendering engine
  107789. * @param camera defines the source camera
  107790. * @param size This parameter can be set to a single number or to an object with the
  107791. * following (optional) properties: precision, width, height. If a single number is passed,
  107792. * it will be used for both width and height. If an object is passed, the screenshot size
  107793. * will be derived from the parameters. The precision property is a multiplier allowing
  107794. * rendering at a higher or lower resolution
  107795. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107796. * Check your browser for supported MIME types
  107797. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107798. * to the src parameter of an <img> to display it
  107799. */
  107800. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107801. /**
  107802. * Generates an image screenshot from the specified camera.
  107803. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107804. * @param engine The engine to use for rendering
  107805. * @param camera The camera to use for rendering
  107806. * @param size This parameter can be set to a single number or to an object with the
  107807. * following (optional) properties: precision, width, height. If a single number is passed,
  107808. * it will be used for both width and height. If an object is passed, the screenshot size
  107809. * will be derived from the parameters. The precision property is a multiplier allowing
  107810. * rendering at a higher or lower resolution
  107811. * @param successCallback The callback receives a single parameter which contains the
  107812. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107813. * src parameter of an <img> to display it
  107814. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107815. * Check your browser for supported MIME types
  107816. * @param samples Texture samples (default: 1)
  107817. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107818. * @param fileName A name for for the downloaded file.
  107819. */
  107820. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107821. /**
  107822. * Generates an image screenshot from the specified camera.
  107823. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107824. * @param engine The engine to use for rendering
  107825. * @param camera The camera to use for rendering
  107826. * @param size This parameter can be set to a single number or to an object with the
  107827. * following (optional) properties: precision, width, height. If a single number is passed,
  107828. * it will be used for both width and height. If an object is passed, the screenshot size
  107829. * will be derived from the parameters. The precision property is a multiplier allowing
  107830. * rendering at a higher or lower resolution
  107831. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107832. * Check your browser for supported MIME types
  107833. * @param samples Texture samples (default: 1)
  107834. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107835. * @param fileName A name for for the downloaded file.
  107836. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107837. * to the src parameter of an <img> to display it
  107838. */
  107839. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107840. /**
  107841. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107842. * Be aware Math.random() could cause collisions, but:
  107843. * "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"
  107844. * @returns a pseudo random id
  107845. */
  107846. static RandomId(): string;
  107847. /**
  107848. * Test if the given uri is a base64 string
  107849. * @param uri The uri to test
  107850. * @return True if the uri is a base64 string or false otherwise
  107851. */
  107852. static IsBase64(uri: string): boolean;
  107853. /**
  107854. * Decode the given base64 uri.
  107855. * @param uri The uri to decode
  107856. * @return The decoded base64 data.
  107857. */
  107858. static DecodeBase64(uri: string): ArrayBuffer;
  107859. /**
  107860. * Gets the absolute url.
  107861. * @param url the input url
  107862. * @return the absolute url
  107863. */
  107864. static GetAbsoluteUrl(url: string): string;
  107865. /**
  107866. * No log
  107867. */
  107868. static readonly NoneLogLevel: number;
  107869. /**
  107870. * Only message logs
  107871. */
  107872. static readonly MessageLogLevel: number;
  107873. /**
  107874. * Only warning logs
  107875. */
  107876. static readonly WarningLogLevel: number;
  107877. /**
  107878. * Only error logs
  107879. */
  107880. static readonly ErrorLogLevel: number;
  107881. /**
  107882. * All logs
  107883. */
  107884. static readonly AllLogLevel: number;
  107885. /**
  107886. * Gets a value indicating the number of loading errors
  107887. * @ignorenaming
  107888. */
  107889. static get errorsCount(): number;
  107890. /**
  107891. * Callback called when a new log is added
  107892. */
  107893. static OnNewCacheEntry: (entry: string) => void;
  107894. /**
  107895. * Log a message to the console
  107896. * @param message defines the message to log
  107897. */
  107898. static Log(message: string): void;
  107899. /**
  107900. * Write a warning message to the console
  107901. * @param message defines the message to log
  107902. */
  107903. static Warn(message: string): void;
  107904. /**
  107905. * Write an error message to the console
  107906. * @param message defines the message to log
  107907. */
  107908. static Error(message: string): void;
  107909. /**
  107910. * Gets current log cache (list of logs)
  107911. */
  107912. static get LogCache(): string;
  107913. /**
  107914. * Clears the log cache
  107915. */
  107916. static ClearLogCache(): void;
  107917. /**
  107918. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107919. */
  107920. static set LogLevels(level: number);
  107921. /**
  107922. * Checks if the window object exists
  107923. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107924. */
  107925. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107926. /**
  107927. * No performance log
  107928. */
  107929. static readonly PerformanceNoneLogLevel: number;
  107930. /**
  107931. * Use user marks to log performance
  107932. */
  107933. static readonly PerformanceUserMarkLogLevel: number;
  107934. /**
  107935. * Log performance to the console
  107936. */
  107937. static readonly PerformanceConsoleLogLevel: number;
  107938. private static _performance;
  107939. /**
  107940. * Sets the current performance log level
  107941. */
  107942. static set PerformanceLogLevel(level: number);
  107943. private static _StartPerformanceCounterDisabled;
  107944. private static _EndPerformanceCounterDisabled;
  107945. private static _StartUserMark;
  107946. private static _EndUserMark;
  107947. private static _StartPerformanceConsole;
  107948. private static _EndPerformanceConsole;
  107949. /**
  107950. * Starts a performance counter
  107951. */
  107952. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107953. /**
  107954. * Ends a specific performance coutner
  107955. */
  107956. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107957. /**
  107958. * Gets either window.performance.now() if supported or Date.now() else
  107959. */
  107960. static get Now(): number;
  107961. /**
  107962. * This method will return the name of the class used to create the instance of the given object.
  107963. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107964. * @param object the object to get the class name from
  107965. * @param isType defines if the object is actually a type
  107966. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107967. */
  107968. static GetClassName(object: any, isType?: boolean): string;
  107969. /**
  107970. * Gets the first element of an array satisfying a given predicate
  107971. * @param array defines the array to browse
  107972. * @param predicate defines the predicate to use
  107973. * @returns null if not found or the element
  107974. */
  107975. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107976. /**
  107977. * This method will return the name of the full name of the class, including its owning module (if any).
  107978. * 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).
  107979. * @param object the object to get the class name from
  107980. * @param isType defines if the object is actually a type
  107981. * @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.
  107982. * @ignorenaming
  107983. */
  107984. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107985. /**
  107986. * Returns a promise that resolves after the given amount of time.
  107987. * @param delay Number of milliseconds to delay
  107988. * @returns Promise that resolves after the given amount of time
  107989. */
  107990. static DelayAsync(delay: number): Promise<void>;
  107991. /**
  107992. * Utility function to detect if the current user agent is Safari
  107993. * @returns whether or not the current user agent is safari
  107994. */
  107995. static IsSafari(): boolean;
  107996. }
  107997. /**
  107998. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107999. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  108000. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  108001. * @param name The name of the class, case should be preserved
  108002. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  108003. */
  108004. export function className(name: string, module?: string): (target: Object) => void;
  108005. /**
  108006. * An implementation of a loop for asynchronous functions.
  108007. */
  108008. export class AsyncLoop {
  108009. /**
  108010. * Defines the number of iterations for the loop
  108011. */
  108012. iterations: number;
  108013. /**
  108014. * Defines the current index of the loop.
  108015. */
  108016. index: number;
  108017. private _done;
  108018. private _fn;
  108019. private _successCallback;
  108020. /**
  108021. * Constructor.
  108022. * @param iterations the number of iterations.
  108023. * @param func the function to run each iteration
  108024. * @param successCallback the callback that will be called upon succesful execution
  108025. * @param offset starting offset.
  108026. */
  108027. constructor(
  108028. /**
  108029. * Defines the number of iterations for the loop
  108030. */
  108031. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  108032. /**
  108033. * Execute the next iteration. Must be called after the last iteration was finished.
  108034. */
  108035. executeNext(): void;
  108036. /**
  108037. * Break the loop and run the success callback.
  108038. */
  108039. breakLoop(): void;
  108040. /**
  108041. * Create and run an async loop.
  108042. * @param iterations the number of iterations.
  108043. * @param fn the function to run each iteration
  108044. * @param successCallback the callback that will be called upon succesful execution
  108045. * @param offset starting offset.
  108046. * @returns the created async loop object
  108047. */
  108048. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  108049. /**
  108050. * A for-loop that will run a given number of iterations synchronous and the rest async.
  108051. * @param iterations total number of iterations
  108052. * @param syncedIterations number of synchronous iterations in each async iteration.
  108053. * @param fn the function to call each iteration.
  108054. * @param callback a success call back that will be called when iterating stops.
  108055. * @param breakFunction a break condition (optional)
  108056. * @param timeout timeout settings for the setTimeout function. default - 0.
  108057. * @returns the created async loop object
  108058. */
  108059. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  108060. }
  108061. }
  108062. declare module BABYLON {
  108063. /**
  108064. * This class implement a typical dictionary using a string as key and the generic type T as value.
  108065. * The underlying implementation relies on an associative array to ensure the best performances.
  108066. * The value can be anything including 'null' but except 'undefined'
  108067. */
  108068. export class StringDictionary<T> {
  108069. /**
  108070. * This will clear this dictionary and copy the content from the 'source' one.
  108071. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  108072. * @param source the dictionary to take the content from and copy to this dictionary
  108073. */
  108074. copyFrom(source: StringDictionary<T>): void;
  108075. /**
  108076. * Get a value based from its key
  108077. * @param key the given key to get the matching value from
  108078. * @return the value if found, otherwise undefined is returned
  108079. */
  108080. get(key: string): T | undefined;
  108081. /**
  108082. * Get a value from its key or add it if it doesn't exist.
  108083. * This method will ensure you that a given key/data will be present in the dictionary.
  108084. * @param key the given key to get the matching value from
  108085. * @param factory the factory that will create the value if the key is not present in the dictionary.
  108086. * The factory will only be invoked if there's no data for the given key.
  108087. * @return the value corresponding to the key.
  108088. */
  108089. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  108090. /**
  108091. * Get a value from its key if present in the dictionary otherwise add it
  108092. * @param key the key to get the value from
  108093. * @param val if there's no such key/value pair in the dictionary add it with this value
  108094. * @return the value corresponding to the key
  108095. */
  108096. getOrAdd(key: string, val: T): T;
  108097. /**
  108098. * Check if there's a given key in the dictionary
  108099. * @param key the key to check for
  108100. * @return true if the key is present, false otherwise
  108101. */
  108102. contains(key: string): boolean;
  108103. /**
  108104. * Add a new key and its corresponding value
  108105. * @param key the key to add
  108106. * @param value the value corresponding to the key
  108107. * @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
  108108. */
  108109. add(key: string, value: T): boolean;
  108110. /**
  108111. * Update a specific value associated to a key
  108112. * @param key defines the key to use
  108113. * @param value defines the value to store
  108114. * @returns true if the value was updated (or false if the key was not found)
  108115. */
  108116. set(key: string, value: T): boolean;
  108117. /**
  108118. * Get the element of the given key and remove it from the dictionary
  108119. * @param key defines the key to search
  108120. * @returns the value associated with the key or null if not found
  108121. */
  108122. getAndRemove(key: string): Nullable<T>;
  108123. /**
  108124. * Remove a key/value from the dictionary.
  108125. * @param key the key to remove
  108126. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  108127. */
  108128. remove(key: string): boolean;
  108129. /**
  108130. * Clear the whole content of the dictionary
  108131. */
  108132. clear(): void;
  108133. /**
  108134. * Gets the current count
  108135. */
  108136. get count(): number;
  108137. /**
  108138. * Execute a callback on each key/val of the dictionary.
  108139. * Note that you can remove any element in this dictionary in the callback implementation
  108140. * @param callback the callback to execute on a given key/value pair
  108141. */
  108142. forEach(callback: (key: string, val: T) => void): void;
  108143. /**
  108144. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  108145. * If the callback returns null or undefined the method will iterate to the next key/value pair
  108146. * Note that you can remove any element in this dictionary in the callback implementation
  108147. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  108148. * @returns the first item
  108149. */
  108150. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  108151. private _count;
  108152. private _data;
  108153. }
  108154. }
  108155. declare module BABYLON {
  108156. /** @hidden */
  108157. export interface ICollisionCoordinator {
  108158. createCollider(): Collider;
  108159. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  108160. init(scene: Scene): void;
  108161. }
  108162. /** @hidden */
  108163. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  108164. private _scene;
  108165. private _scaledPosition;
  108166. private _scaledVelocity;
  108167. private _finalPosition;
  108168. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  108169. createCollider(): Collider;
  108170. init(scene: Scene): void;
  108171. private _collideWithWorld;
  108172. }
  108173. }
  108174. declare module BABYLON {
  108175. /**
  108176. * Class used to manage all inputs for the scene.
  108177. */
  108178. export class InputManager {
  108179. /** The distance in pixel that you have to move to prevent some events */
  108180. static DragMovementThreshold: number;
  108181. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  108182. static LongPressDelay: number;
  108183. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  108184. static DoubleClickDelay: number;
  108185. /** If you need to check double click without raising a single click at first click, enable this flag */
  108186. static ExclusiveDoubleClickMode: boolean;
  108187. private _wheelEventName;
  108188. private _onPointerMove;
  108189. private _onPointerDown;
  108190. private _onPointerUp;
  108191. private _initClickEvent;
  108192. private _initActionManager;
  108193. private _delayedSimpleClick;
  108194. private _delayedSimpleClickTimeout;
  108195. private _previousDelayedSimpleClickTimeout;
  108196. private _meshPickProceed;
  108197. private _previousButtonPressed;
  108198. private _currentPickResult;
  108199. private _previousPickResult;
  108200. private _totalPointersPressed;
  108201. private _doubleClickOccured;
  108202. private _pointerOverMesh;
  108203. private _pickedDownMesh;
  108204. private _pickedUpMesh;
  108205. private _pointerX;
  108206. private _pointerY;
  108207. private _unTranslatedPointerX;
  108208. private _unTranslatedPointerY;
  108209. private _startingPointerPosition;
  108210. private _previousStartingPointerPosition;
  108211. private _startingPointerTime;
  108212. private _previousStartingPointerTime;
  108213. private _pointerCaptures;
  108214. private _onKeyDown;
  108215. private _onKeyUp;
  108216. private _onCanvasFocusObserver;
  108217. private _onCanvasBlurObserver;
  108218. private _scene;
  108219. /**
  108220. * Creates a new InputManager
  108221. * @param scene defines the hosting scene
  108222. */
  108223. constructor(scene: Scene);
  108224. /**
  108225. * Gets the mesh that is currently under the pointer
  108226. */
  108227. get meshUnderPointer(): Nullable<AbstractMesh>;
  108228. /**
  108229. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  108230. */
  108231. get unTranslatedPointer(): Vector2;
  108232. /**
  108233. * Gets or sets the current on-screen X position of the pointer
  108234. */
  108235. get pointerX(): number;
  108236. set pointerX(value: number);
  108237. /**
  108238. * Gets or sets the current on-screen Y position of the pointer
  108239. */
  108240. get pointerY(): number;
  108241. set pointerY(value: number);
  108242. private _updatePointerPosition;
  108243. private _processPointerMove;
  108244. private _setRayOnPointerInfo;
  108245. private _checkPrePointerObservable;
  108246. /**
  108247. * Use this method to simulate a pointer move on a mesh
  108248. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108249. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108250. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108251. */
  108252. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108253. /**
  108254. * Use this method to simulate a pointer down on a mesh
  108255. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108256. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108257. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108258. */
  108259. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108260. private _processPointerDown;
  108261. /** @hidden */
  108262. _isPointerSwiping(): boolean;
  108263. /**
  108264. * Use this method to simulate a pointer up on a mesh
  108265. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108266. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108267. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108268. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108269. */
  108270. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  108271. private _processPointerUp;
  108272. /**
  108273. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108274. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108275. * @returns true if the pointer was captured
  108276. */
  108277. isPointerCaptured(pointerId?: number): boolean;
  108278. /**
  108279. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108280. * @param attachUp defines if you want to attach events to pointerup
  108281. * @param attachDown defines if you want to attach events to pointerdown
  108282. * @param attachMove defines if you want to attach events to pointermove
  108283. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108284. */
  108285. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108286. /**
  108287. * Detaches all event handlers
  108288. */
  108289. detachControl(): void;
  108290. /**
  108291. * Force the value of meshUnderPointer
  108292. * @param mesh defines the mesh to use
  108293. */
  108294. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108295. /**
  108296. * Gets the mesh under the pointer
  108297. * @returns a Mesh or null if no mesh is under the pointer
  108298. */
  108299. getPointerOverMesh(): Nullable<AbstractMesh>;
  108300. }
  108301. }
  108302. declare module BABYLON {
  108303. /**
  108304. * Helper class used to generate session unique ID
  108305. */
  108306. export class UniqueIdGenerator {
  108307. private static _UniqueIdCounter;
  108308. /**
  108309. * Gets an unique (relatively to the current scene) Id
  108310. */
  108311. static get UniqueId(): number;
  108312. }
  108313. }
  108314. declare module BABYLON {
  108315. /**
  108316. * This class defines the direct association between an animation and a target
  108317. */
  108318. export class TargetedAnimation {
  108319. /**
  108320. * Animation to perform
  108321. */
  108322. animation: Animation;
  108323. /**
  108324. * Target to animate
  108325. */
  108326. target: any;
  108327. /**
  108328. * Serialize the object
  108329. * @returns the JSON object representing the current entity
  108330. */
  108331. serialize(): any;
  108332. }
  108333. /**
  108334. * Use this class to create coordinated animations on multiple targets
  108335. */
  108336. export class AnimationGroup implements IDisposable {
  108337. /** The name of the animation group */
  108338. name: string;
  108339. private _scene;
  108340. private _targetedAnimations;
  108341. private _animatables;
  108342. private _from;
  108343. private _to;
  108344. private _isStarted;
  108345. private _isPaused;
  108346. private _speedRatio;
  108347. private _loopAnimation;
  108348. /**
  108349. * Gets or sets the unique id of the node
  108350. */
  108351. uniqueId: number;
  108352. /**
  108353. * This observable will notify when one animation have ended
  108354. */
  108355. onAnimationEndObservable: Observable<TargetedAnimation>;
  108356. /**
  108357. * Observer raised when one animation loops
  108358. */
  108359. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108360. /**
  108361. * Observer raised when all animations have looped
  108362. */
  108363. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108364. /**
  108365. * This observable will notify when all animations have ended.
  108366. */
  108367. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108368. /**
  108369. * This observable will notify when all animations have paused.
  108370. */
  108371. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108372. /**
  108373. * This observable will notify when all animations are playing.
  108374. */
  108375. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108376. /**
  108377. * Gets the first frame
  108378. */
  108379. get from(): number;
  108380. /**
  108381. * Gets the last frame
  108382. */
  108383. get to(): number;
  108384. /**
  108385. * Define if the animations are started
  108386. */
  108387. get isStarted(): boolean;
  108388. /**
  108389. * Gets a value indicating that the current group is playing
  108390. */
  108391. get isPlaying(): boolean;
  108392. /**
  108393. * Gets or sets the speed ratio to use for all animations
  108394. */
  108395. get speedRatio(): number;
  108396. /**
  108397. * Gets or sets the speed ratio to use for all animations
  108398. */
  108399. set speedRatio(value: number);
  108400. /**
  108401. * Gets or sets if all animations should loop or not
  108402. */
  108403. get loopAnimation(): boolean;
  108404. set loopAnimation(value: boolean);
  108405. /**
  108406. * Gets the targeted animations for this animation group
  108407. */
  108408. get targetedAnimations(): Array<TargetedAnimation>;
  108409. /**
  108410. * returning the list of animatables controlled by this animation group.
  108411. */
  108412. get animatables(): Array<Animatable>;
  108413. /**
  108414. * Instantiates a new Animation Group.
  108415. * This helps managing several animations at once.
  108416. * @see http://doc.babylonjs.com/how_to/group
  108417. * @param name Defines the name of the group
  108418. * @param scene Defines the scene the group belongs to
  108419. */
  108420. constructor(
  108421. /** The name of the animation group */
  108422. name: string, scene?: Nullable<Scene>);
  108423. /**
  108424. * Add an animation (with its target) in the group
  108425. * @param animation defines the animation we want to add
  108426. * @param target defines the target of the animation
  108427. * @returns the TargetedAnimation object
  108428. */
  108429. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108430. /**
  108431. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108432. * It can add constant keys at begin or end
  108433. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108434. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108435. * @returns the animation group
  108436. */
  108437. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108438. private _animationLoopCount;
  108439. private _animationLoopFlags;
  108440. private _processLoop;
  108441. /**
  108442. * Start all animations on given targets
  108443. * @param loop defines if animations must loop
  108444. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108445. * @param from defines the from key (optional)
  108446. * @param to defines the to key (optional)
  108447. * @returns the current animation group
  108448. */
  108449. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108450. /**
  108451. * Pause all animations
  108452. * @returns the animation group
  108453. */
  108454. pause(): AnimationGroup;
  108455. /**
  108456. * Play all animations to initial state
  108457. * This function will start() the animations if they were not started or will restart() them if they were paused
  108458. * @param loop defines if animations must loop
  108459. * @returns the animation group
  108460. */
  108461. play(loop?: boolean): AnimationGroup;
  108462. /**
  108463. * Reset all animations to initial state
  108464. * @returns the animation group
  108465. */
  108466. reset(): AnimationGroup;
  108467. /**
  108468. * Restart animations from key 0
  108469. * @returns the animation group
  108470. */
  108471. restart(): AnimationGroup;
  108472. /**
  108473. * Stop all animations
  108474. * @returns the animation group
  108475. */
  108476. stop(): AnimationGroup;
  108477. /**
  108478. * Set animation weight for all animatables
  108479. * @param weight defines the weight to use
  108480. * @return the animationGroup
  108481. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108482. */
  108483. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108484. /**
  108485. * Synchronize and normalize all animatables with a source animatable
  108486. * @param root defines the root animatable to synchronize with
  108487. * @return the animationGroup
  108488. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108489. */
  108490. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108491. /**
  108492. * Goes to a specific frame in this animation group
  108493. * @param frame the frame number to go to
  108494. * @return the animationGroup
  108495. */
  108496. goToFrame(frame: number): AnimationGroup;
  108497. /**
  108498. * Dispose all associated resources
  108499. */
  108500. dispose(): void;
  108501. private _checkAnimationGroupEnded;
  108502. /**
  108503. * Clone the current animation group and returns a copy
  108504. * @param newName defines the name of the new group
  108505. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108506. * @returns the new aniamtion group
  108507. */
  108508. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108509. /**
  108510. * Serializes the animationGroup to an object
  108511. * @returns Serialized object
  108512. */
  108513. serialize(): any;
  108514. /**
  108515. * Returns a new AnimationGroup object parsed from the source provided.
  108516. * @param parsedAnimationGroup defines the source
  108517. * @param scene defines the scene that will receive the animationGroup
  108518. * @returns a new AnimationGroup
  108519. */
  108520. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108521. /**
  108522. * Returns the string "AnimationGroup"
  108523. * @returns "AnimationGroup"
  108524. */
  108525. getClassName(): string;
  108526. /**
  108527. * Creates a detailled string about the object
  108528. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108529. * @returns a string representing the object
  108530. */
  108531. toString(fullDetails?: boolean): string;
  108532. }
  108533. }
  108534. declare module BABYLON {
  108535. /**
  108536. * Define an interface for all classes that will hold resources
  108537. */
  108538. export interface IDisposable {
  108539. /**
  108540. * Releases all held resources
  108541. */
  108542. dispose(): void;
  108543. }
  108544. /** Interface defining initialization parameters for Scene class */
  108545. export interface SceneOptions {
  108546. /**
  108547. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108548. * It will improve performance when the number of geometries becomes important.
  108549. */
  108550. useGeometryUniqueIdsMap?: boolean;
  108551. /**
  108552. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108553. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108554. */
  108555. useMaterialMeshMap?: boolean;
  108556. /**
  108557. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108558. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108559. */
  108560. useClonedMeshMap?: boolean;
  108561. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108562. virtual?: boolean;
  108563. }
  108564. /**
  108565. * Represents a scene to be rendered by the engine.
  108566. * @see http://doc.babylonjs.com/features/scene
  108567. */
  108568. export class Scene extends AbstractScene implements IAnimatable {
  108569. /** The fog is deactivated */
  108570. static readonly FOGMODE_NONE: number;
  108571. /** The fog density is following an exponential function */
  108572. static readonly FOGMODE_EXP: number;
  108573. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108574. static readonly FOGMODE_EXP2: number;
  108575. /** The fog density is following a linear function. */
  108576. static readonly FOGMODE_LINEAR: number;
  108577. /**
  108578. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108579. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108580. */
  108581. static MinDeltaTime: number;
  108582. /**
  108583. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108584. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108585. */
  108586. static MaxDeltaTime: number;
  108587. /**
  108588. * Factory used to create the default material.
  108589. * @param name The name of the material to create
  108590. * @param scene The scene to create the material for
  108591. * @returns The default material
  108592. */
  108593. static DefaultMaterialFactory(scene: Scene): Material;
  108594. /**
  108595. * Factory used to create the a collision coordinator.
  108596. * @returns The collision coordinator
  108597. */
  108598. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108599. /** @hidden */
  108600. _inputManager: InputManager;
  108601. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108602. cameraToUseForPointers: Nullable<Camera>;
  108603. /** @hidden */
  108604. readonly _isScene: boolean;
  108605. /** @hidden */
  108606. _blockEntityCollection: boolean;
  108607. /**
  108608. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108609. */
  108610. autoClear: boolean;
  108611. /**
  108612. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108613. */
  108614. autoClearDepthAndStencil: boolean;
  108615. /**
  108616. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108617. */
  108618. clearColor: Color4;
  108619. /**
  108620. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108621. */
  108622. ambientColor: Color3;
  108623. /**
  108624. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108625. * It should only be one of the following (if not the default embedded one):
  108626. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108627. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108628. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108629. * The material properties need to be setup according to the type of texture in use.
  108630. */
  108631. environmentBRDFTexture: BaseTexture;
  108632. /** @hidden */
  108633. protected _environmentTexture: Nullable<BaseTexture>;
  108634. /**
  108635. * Texture used in all pbr material as the reflection texture.
  108636. * As in the majority of the scene they are the same (exception for multi room and so on),
  108637. * this is easier to reference from here than from all the materials.
  108638. */
  108639. get environmentTexture(): Nullable<BaseTexture>;
  108640. /**
  108641. * Texture used in all pbr material as the reflection texture.
  108642. * As in the majority of the scene they are the same (exception for multi room and so on),
  108643. * this is easier to set here than in all the materials.
  108644. */
  108645. set environmentTexture(value: Nullable<BaseTexture>);
  108646. /** @hidden */
  108647. protected _environmentIntensity: number;
  108648. /**
  108649. * Intensity of the environment in all pbr material.
  108650. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108651. * As in the majority of the scene they are the same (exception for multi room and so on),
  108652. * this is easier to reference from here than from all the materials.
  108653. */
  108654. get environmentIntensity(): number;
  108655. /**
  108656. * Intensity of the environment in all pbr material.
  108657. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108658. * As in the majority of the scene they are the same (exception for multi room and so on),
  108659. * this is easier to set here than in all the materials.
  108660. */
  108661. set environmentIntensity(value: number);
  108662. /** @hidden */
  108663. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108664. /**
  108665. * Default image processing configuration used either in the rendering
  108666. * Forward main pass or through the imageProcessingPostProcess if present.
  108667. * As in the majority of the scene they are the same (exception for multi camera),
  108668. * this is easier to reference from here than from all the materials and post process.
  108669. *
  108670. * No setter as we it is a shared configuration, you can set the values instead.
  108671. */
  108672. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108673. private _forceWireframe;
  108674. /**
  108675. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108676. */
  108677. set forceWireframe(value: boolean);
  108678. get forceWireframe(): boolean;
  108679. private _skipFrustumClipping;
  108680. /**
  108681. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108682. */
  108683. set skipFrustumClipping(value: boolean);
  108684. get skipFrustumClipping(): boolean;
  108685. private _forcePointsCloud;
  108686. /**
  108687. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108688. */
  108689. set forcePointsCloud(value: boolean);
  108690. get forcePointsCloud(): boolean;
  108691. /**
  108692. * Gets or sets the active clipplane 1
  108693. */
  108694. clipPlane: Nullable<Plane>;
  108695. /**
  108696. * Gets or sets the active clipplane 2
  108697. */
  108698. clipPlane2: Nullable<Plane>;
  108699. /**
  108700. * Gets or sets the active clipplane 3
  108701. */
  108702. clipPlane3: Nullable<Plane>;
  108703. /**
  108704. * Gets or sets the active clipplane 4
  108705. */
  108706. clipPlane4: Nullable<Plane>;
  108707. /**
  108708. * Gets or sets the active clipplane 5
  108709. */
  108710. clipPlane5: Nullable<Plane>;
  108711. /**
  108712. * Gets or sets the active clipplane 6
  108713. */
  108714. clipPlane6: Nullable<Plane>;
  108715. /**
  108716. * Gets or sets a boolean indicating if animations are enabled
  108717. */
  108718. animationsEnabled: boolean;
  108719. private _animationPropertiesOverride;
  108720. /**
  108721. * Gets or sets the animation properties override
  108722. */
  108723. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108724. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108725. /**
  108726. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108727. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108728. */
  108729. useConstantAnimationDeltaTime: boolean;
  108730. /**
  108731. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108732. * Please note that it requires to run a ray cast through the scene on every frame
  108733. */
  108734. constantlyUpdateMeshUnderPointer: boolean;
  108735. /**
  108736. * Defines the HTML cursor to use when hovering over interactive elements
  108737. */
  108738. hoverCursor: string;
  108739. /**
  108740. * Defines the HTML default cursor to use (empty by default)
  108741. */
  108742. defaultCursor: string;
  108743. /**
  108744. * Defines whether cursors are handled by the scene.
  108745. */
  108746. doNotHandleCursors: boolean;
  108747. /**
  108748. * This is used to call preventDefault() on pointer down
  108749. * in order to block unwanted artifacts like system double clicks
  108750. */
  108751. preventDefaultOnPointerDown: boolean;
  108752. /**
  108753. * This is used to call preventDefault() on pointer up
  108754. * in order to block unwanted artifacts like system double clicks
  108755. */
  108756. preventDefaultOnPointerUp: boolean;
  108757. /**
  108758. * Gets or sets user defined metadata
  108759. */
  108760. metadata: any;
  108761. /**
  108762. * For internal use only. Please do not use.
  108763. */
  108764. reservedDataStore: any;
  108765. /**
  108766. * Gets the name of the plugin used to load this scene (null by default)
  108767. */
  108768. loadingPluginName: string;
  108769. /**
  108770. * Use this array to add regular expressions used to disable offline support for specific urls
  108771. */
  108772. disableOfflineSupportExceptionRules: RegExp[];
  108773. /**
  108774. * An event triggered when the scene is disposed.
  108775. */
  108776. onDisposeObservable: Observable<Scene>;
  108777. private _onDisposeObserver;
  108778. /** Sets a function to be executed when this scene is disposed. */
  108779. set onDispose(callback: () => void);
  108780. /**
  108781. * An event triggered before rendering the scene (right after animations and physics)
  108782. */
  108783. onBeforeRenderObservable: Observable<Scene>;
  108784. private _onBeforeRenderObserver;
  108785. /** Sets a function to be executed before rendering this scene */
  108786. set beforeRender(callback: Nullable<() => void>);
  108787. /**
  108788. * An event triggered after rendering the scene
  108789. */
  108790. onAfterRenderObservable: Observable<Scene>;
  108791. /**
  108792. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108793. */
  108794. onAfterRenderCameraObservable: Observable<Camera>;
  108795. private _onAfterRenderObserver;
  108796. /** Sets a function to be executed after rendering this scene */
  108797. set afterRender(callback: Nullable<() => void>);
  108798. /**
  108799. * An event triggered before animating the scene
  108800. */
  108801. onBeforeAnimationsObservable: Observable<Scene>;
  108802. /**
  108803. * An event triggered after animations processing
  108804. */
  108805. onAfterAnimationsObservable: Observable<Scene>;
  108806. /**
  108807. * An event triggered before draw calls are ready to be sent
  108808. */
  108809. onBeforeDrawPhaseObservable: Observable<Scene>;
  108810. /**
  108811. * An event triggered after draw calls have been sent
  108812. */
  108813. onAfterDrawPhaseObservable: Observable<Scene>;
  108814. /**
  108815. * An event triggered when the scene is ready
  108816. */
  108817. onReadyObservable: Observable<Scene>;
  108818. /**
  108819. * An event triggered before rendering a camera
  108820. */
  108821. onBeforeCameraRenderObservable: Observable<Camera>;
  108822. private _onBeforeCameraRenderObserver;
  108823. /** Sets a function to be executed before rendering a camera*/
  108824. set beforeCameraRender(callback: () => void);
  108825. /**
  108826. * An event triggered after rendering a camera
  108827. */
  108828. onAfterCameraRenderObservable: Observable<Camera>;
  108829. private _onAfterCameraRenderObserver;
  108830. /** Sets a function to be executed after rendering a camera*/
  108831. set afterCameraRender(callback: () => void);
  108832. /**
  108833. * An event triggered when active meshes evaluation is about to start
  108834. */
  108835. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108836. /**
  108837. * An event triggered when active meshes evaluation is done
  108838. */
  108839. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108840. /**
  108841. * An event triggered when particles rendering is about to start
  108842. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108843. */
  108844. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108845. /**
  108846. * An event triggered when particles rendering is done
  108847. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108848. */
  108849. onAfterParticlesRenderingObservable: Observable<Scene>;
  108850. /**
  108851. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108852. */
  108853. onDataLoadedObservable: Observable<Scene>;
  108854. /**
  108855. * An event triggered when a camera is created
  108856. */
  108857. onNewCameraAddedObservable: Observable<Camera>;
  108858. /**
  108859. * An event triggered when a camera is removed
  108860. */
  108861. onCameraRemovedObservable: Observable<Camera>;
  108862. /**
  108863. * An event triggered when a light is created
  108864. */
  108865. onNewLightAddedObservable: Observable<Light>;
  108866. /**
  108867. * An event triggered when a light is removed
  108868. */
  108869. onLightRemovedObservable: Observable<Light>;
  108870. /**
  108871. * An event triggered when a geometry is created
  108872. */
  108873. onNewGeometryAddedObservable: Observable<Geometry>;
  108874. /**
  108875. * An event triggered when a geometry is removed
  108876. */
  108877. onGeometryRemovedObservable: Observable<Geometry>;
  108878. /**
  108879. * An event triggered when a transform node is created
  108880. */
  108881. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108882. /**
  108883. * An event triggered when a transform node is removed
  108884. */
  108885. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108886. /**
  108887. * An event triggered when a mesh is created
  108888. */
  108889. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108890. /**
  108891. * An event triggered when a mesh is removed
  108892. */
  108893. onMeshRemovedObservable: Observable<AbstractMesh>;
  108894. /**
  108895. * An event triggered when a skeleton is created
  108896. */
  108897. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108898. /**
  108899. * An event triggered when a skeleton is removed
  108900. */
  108901. onSkeletonRemovedObservable: Observable<Skeleton>;
  108902. /**
  108903. * An event triggered when a material is created
  108904. */
  108905. onNewMaterialAddedObservable: Observable<Material>;
  108906. /**
  108907. * An event triggered when a material is removed
  108908. */
  108909. onMaterialRemovedObservable: Observable<Material>;
  108910. /**
  108911. * An event triggered when a texture is created
  108912. */
  108913. onNewTextureAddedObservable: Observable<BaseTexture>;
  108914. /**
  108915. * An event triggered when a texture is removed
  108916. */
  108917. onTextureRemovedObservable: Observable<BaseTexture>;
  108918. /**
  108919. * An event triggered when render targets are about to be rendered
  108920. * Can happen multiple times per frame.
  108921. */
  108922. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108923. /**
  108924. * An event triggered when render targets were rendered.
  108925. * Can happen multiple times per frame.
  108926. */
  108927. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108928. /**
  108929. * An event triggered before calculating deterministic simulation step
  108930. */
  108931. onBeforeStepObservable: Observable<Scene>;
  108932. /**
  108933. * An event triggered after calculating deterministic simulation step
  108934. */
  108935. onAfterStepObservable: Observable<Scene>;
  108936. /**
  108937. * An event triggered when the activeCamera property is updated
  108938. */
  108939. onActiveCameraChanged: Observable<Scene>;
  108940. /**
  108941. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108942. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108943. * 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)
  108944. */
  108945. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108946. /**
  108947. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108948. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108949. * 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)
  108950. */
  108951. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108952. /**
  108953. * This Observable will when a mesh has been imported into the scene.
  108954. */
  108955. onMeshImportedObservable: Observable<AbstractMesh>;
  108956. /**
  108957. * This Observable will when an animation file has been imported into the scene.
  108958. */
  108959. onAnimationFileImportedObservable: Observable<Scene>;
  108960. /**
  108961. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108962. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108963. */
  108964. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108965. /** @hidden */
  108966. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108967. /**
  108968. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108969. */
  108970. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108971. /**
  108972. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108973. */
  108974. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108975. /**
  108976. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108977. */
  108978. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108979. /** Callback called when a pointer move is detected */
  108980. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108981. /** Callback called when a pointer down is detected */
  108982. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108983. /** Callback called when a pointer up is detected */
  108984. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108985. /** Callback called when a pointer pick is detected */
  108986. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108987. /**
  108988. * 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).
  108989. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108990. */
  108991. onPrePointerObservable: Observable<PointerInfoPre>;
  108992. /**
  108993. * Observable event triggered each time an input event is received from the rendering canvas
  108994. */
  108995. onPointerObservable: Observable<PointerInfo>;
  108996. /**
  108997. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108998. */
  108999. get unTranslatedPointer(): Vector2;
  109000. /**
  109001. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  109002. */
  109003. static get DragMovementThreshold(): number;
  109004. static set DragMovementThreshold(value: number);
  109005. /**
  109006. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  109007. */
  109008. static get LongPressDelay(): number;
  109009. static set LongPressDelay(value: number);
  109010. /**
  109011. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  109012. */
  109013. static get DoubleClickDelay(): number;
  109014. static set DoubleClickDelay(value: number);
  109015. /** If you need to check double click without raising a single click at first click, enable this flag */
  109016. static get ExclusiveDoubleClickMode(): boolean;
  109017. static set ExclusiveDoubleClickMode(value: boolean);
  109018. /** @hidden */
  109019. _mirroredCameraPosition: Nullable<Vector3>;
  109020. /**
  109021. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  109022. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  109023. */
  109024. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  109025. /**
  109026. * Observable event triggered each time an keyboard event is received from the hosting window
  109027. */
  109028. onKeyboardObservable: Observable<KeyboardInfo>;
  109029. private _useRightHandedSystem;
  109030. /**
  109031. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  109032. */
  109033. set useRightHandedSystem(value: boolean);
  109034. get useRightHandedSystem(): boolean;
  109035. private _timeAccumulator;
  109036. private _currentStepId;
  109037. private _currentInternalStep;
  109038. /**
  109039. * Sets the step Id used by deterministic lock step
  109040. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109041. * @param newStepId defines the step Id
  109042. */
  109043. setStepId(newStepId: number): void;
  109044. /**
  109045. * Gets the step Id used by deterministic lock step
  109046. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109047. * @returns the step Id
  109048. */
  109049. getStepId(): number;
  109050. /**
  109051. * Gets the internal step used by deterministic lock step
  109052. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109053. * @returns the internal step
  109054. */
  109055. getInternalStep(): number;
  109056. private _fogEnabled;
  109057. /**
  109058. * Gets or sets a boolean indicating if fog is enabled on this scene
  109059. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109060. * (Default is true)
  109061. */
  109062. set fogEnabled(value: boolean);
  109063. get fogEnabled(): boolean;
  109064. private _fogMode;
  109065. /**
  109066. * Gets or sets the fog mode to use
  109067. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109068. * | mode | value |
  109069. * | --- | --- |
  109070. * | FOGMODE_NONE | 0 |
  109071. * | FOGMODE_EXP | 1 |
  109072. * | FOGMODE_EXP2 | 2 |
  109073. * | FOGMODE_LINEAR | 3 |
  109074. */
  109075. set fogMode(value: number);
  109076. get fogMode(): number;
  109077. /**
  109078. * Gets or sets the fog color to use
  109079. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109080. * (Default is Color3(0.2, 0.2, 0.3))
  109081. */
  109082. fogColor: Color3;
  109083. /**
  109084. * Gets or sets the fog density to use
  109085. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109086. * (Default is 0.1)
  109087. */
  109088. fogDensity: number;
  109089. /**
  109090. * Gets or sets the fog start distance to use
  109091. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109092. * (Default is 0)
  109093. */
  109094. fogStart: number;
  109095. /**
  109096. * Gets or sets the fog end distance to use
  109097. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109098. * (Default is 1000)
  109099. */
  109100. fogEnd: number;
  109101. private _shadowsEnabled;
  109102. /**
  109103. * Gets or sets a boolean indicating if shadows are enabled on this scene
  109104. */
  109105. set shadowsEnabled(value: boolean);
  109106. get shadowsEnabled(): boolean;
  109107. private _lightsEnabled;
  109108. /**
  109109. * Gets or sets a boolean indicating if lights are enabled on this scene
  109110. */
  109111. set lightsEnabled(value: boolean);
  109112. get lightsEnabled(): boolean;
  109113. /** All of the active cameras added to this scene. */
  109114. activeCameras: Camera[];
  109115. /** @hidden */
  109116. _activeCamera: Nullable<Camera>;
  109117. /** Gets or sets the current active camera */
  109118. get activeCamera(): Nullable<Camera>;
  109119. set activeCamera(value: Nullable<Camera>);
  109120. private _defaultMaterial;
  109121. /** The default material used on meshes when no material is affected */
  109122. get defaultMaterial(): Material;
  109123. /** The default material used on meshes when no material is affected */
  109124. set defaultMaterial(value: Material);
  109125. private _texturesEnabled;
  109126. /**
  109127. * Gets or sets a boolean indicating if textures are enabled on this scene
  109128. */
  109129. set texturesEnabled(value: boolean);
  109130. get texturesEnabled(): boolean;
  109131. /**
  109132. * Gets or sets a boolean indicating if particles are enabled on this scene
  109133. */
  109134. particlesEnabled: boolean;
  109135. /**
  109136. * Gets or sets a boolean indicating if sprites are enabled on this scene
  109137. */
  109138. spritesEnabled: boolean;
  109139. private _skeletonsEnabled;
  109140. /**
  109141. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  109142. */
  109143. set skeletonsEnabled(value: boolean);
  109144. get skeletonsEnabled(): boolean;
  109145. /**
  109146. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  109147. */
  109148. lensFlaresEnabled: boolean;
  109149. /**
  109150. * Gets or sets a boolean indicating if collisions are enabled on this scene
  109151. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109152. */
  109153. collisionsEnabled: boolean;
  109154. private _collisionCoordinator;
  109155. /** @hidden */
  109156. get collisionCoordinator(): ICollisionCoordinator;
  109157. /**
  109158. * Defines the gravity applied to this scene (used only for collisions)
  109159. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109160. */
  109161. gravity: Vector3;
  109162. /**
  109163. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  109164. */
  109165. postProcessesEnabled: boolean;
  109166. /**
  109167. * The list of postprocesses added to the scene
  109168. */
  109169. postProcesses: PostProcess[];
  109170. /**
  109171. * Gets the current postprocess manager
  109172. */
  109173. postProcessManager: PostProcessManager;
  109174. /**
  109175. * Gets or sets a boolean indicating if render targets are enabled on this scene
  109176. */
  109177. renderTargetsEnabled: boolean;
  109178. /**
  109179. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  109180. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  109181. */
  109182. dumpNextRenderTargets: boolean;
  109183. /**
  109184. * The list of user defined render targets added to the scene
  109185. */
  109186. customRenderTargets: RenderTargetTexture[];
  109187. /**
  109188. * Defines if texture loading must be delayed
  109189. * If true, textures will only be loaded when they need to be rendered
  109190. */
  109191. useDelayedTextureLoading: boolean;
  109192. /**
  109193. * Gets the list of meshes imported to the scene through SceneLoader
  109194. */
  109195. importedMeshesFiles: String[];
  109196. /**
  109197. * Gets or sets a boolean indicating if probes are enabled on this scene
  109198. */
  109199. probesEnabled: boolean;
  109200. /**
  109201. * Gets or sets the current offline provider to use to store scene data
  109202. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  109203. */
  109204. offlineProvider: IOfflineProvider;
  109205. /**
  109206. * Gets or sets the action manager associated with the scene
  109207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109208. */
  109209. actionManager: AbstractActionManager;
  109210. private _meshesForIntersections;
  109211. /**
  109212. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  109213. */
  109214. proceduralTexturesEnabled: boolean;
  109215. private _engine;
  109216. private _totalVertices;
  109217. /** @hidden */
  109218. _activeIndices: PerfCounter;
  109219. /** @hidden */
  109220. _activeParticles: PerfCounter;
  109221. /** @hidden */
  109222. _activeBones: PerfCounter;
  109223. private _animationRatio;
  109224. /** @hidden */
  109225. _animationTimeLast: number;
  109226. /** @hidden */
  109227. _animationTime: number;
  109228. /**
  109229. * Gets or sets a general scale for animation speed
  109230. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  109231. */
  109232. animationTimeScale: number;
  109233. /** @hidden */
  109234. _cachedMaterial: Nullable<Material>;
  109235. /** @hidden */
  109236. _cachedEffect: Nullable<Effect>;
  109237. /** @hidden */
  109238. _cachedVisibility: Nullable<number>;
  109239. private _renderId;
  109240. private _frameId;
  109241. private _executeWhenReadyTimeoutId;
  109242. private _intermediateRendering;
  109243. private _viewUpdateFlag;
  109244. private _projectionUpdateFlag;
  109245. /** @hidden */
  109246. _toBeDisposed: Nullable<IDisposable>[];
  109247. private _activeRequests;
  109248. /** @hidden */
  109249. _pendingData: any[];
  109250. private _isDisposed;
  109251. /**
  109252. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  109253. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  109254. */
  109255. dispatchAllSubMeshesOfActiveMeshes: boolean;
  109256. private _activeMeshes;
  109257. private _processedMaterials;
  109258. private _renderTargets;
  109259. /** @hidden */
  109260. _activeParticleSystems: SmartArray<IParticleSystem>;
  109261. private _activeSkeletons;
  109262. private _softwareSkinnedMeshes;
  109263. private _renderingManager;
  109264. /** @hidden */
  109265. _activeAnimatables: Animatable[];
  109266. private _transformMatrix;
  109267. private _sceneUbo;
  109268. /** @hidden */
  109269. _viewMatrix: Matrix;
  109270. private _projectionMatrix;
  109271. /** @hidden */
  109272. _forcedViewPosition: Nullable<Vector3>;
  109273. /** @hidden */
  109274. _frustumPlanes: Plane[];
  109275. /**
  109276. * Gets the list of frustum planes (built from the active camera)
  109277. */
  109278. get frustumPlanes(): Plane[];
  109279. /**
  109280. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109281. * This is useful if there are more lights that the maximum simulteanous authorized
  109282. */
  109283. requireLightSorting: boolean;
  109284. /** @hidden */
  109285. readonly useMaterialMeshMap: boolean;
  109286. /** @hidden */
  109287. readonly useClonedMeshMap: boolean;
  109288. private _externalData;
  109289. private _uid;
  109290. /**
  109291. * @hidden
  109292. * Backing store of defined scene components.
  109293. */
  109294. _components: ISceneComponent[];
  109295. /**
  109296. * @hidden
  109297. * Backing store of defined scene components.
  109298. */
  109299. _serializableComponents: ISceneSerializableComponent[];
  109300. /**
  109301. * List of components to register on the next registration step.
  109302. */
  109303. private _transientComponents;
  109304. /**
  109305. * Registers the transient components if needed.
  109306. */
  109307. private _registerTransientComponents;
  109308. /**
  109309. * @hidden
  109310. * Add a component to the scene.
  109311. * Note that the ccomponent could be registered on th next frame if this is called after
  109312. * the register component stage.
  109313. * @param component Defines the component to add to the scene
  109314. */
  109315. _addComponent(component: ISceneComponent): void;
  109316. /**
  109317. * @hidden
  109318. * Gets a component from the scene.
  109319. * @param name defines the name of the component to retrieve
  109320. * @returns the component or null if not present
  109321. */
  109322. _getComponent(name: string): Nullable<ISceneComponent>;
  109323. /**
  109324. * @hidden
  109325. * Defines the actions happening before camera updates.
  109326. */
  109327. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109328. /**
  109329. * @hidden
  109330. * Defines the actions happening before clear the canvas.
  109331. */
  109332. _beforeClearStage: Stage<SimpleStageAction>;
  109333. /**
  109334. * @hidden
  109335. * Defines the actions when collecting render targets for the frame.
  109336. */
  109337. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109338. /**
  109339. * @hidden
  109340. * Defines the actions happening for one camera in the frame.
  109341. */
  109342. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109343. /**
  109344. * @hidden
  109345. * Defines the actions happening during the per mesh ready checks.
  109346. */
  109347. _isReadyForMeshStage: Stage<MeshStageAction>;
  109348. /**
  109349. * @hidden
  109350. * Defines the actions happening before evaluate active mesh checks.
  109351. */
  109352. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109353. /**
  109354. * @hidden
  109355. * Defines the actions happening during the evaluate sub mesh checks.
  109356. */
  109357. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109358. /**
  109359. * @hidden
  109360. * Defines the actions happening during the active mesh stage.
  109361. */
  109362. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109363. /**
  109364. * @hidden
  109365. * Defines the actions happening during the per camera render target step.
  109366. */
  109367. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109368. /**
  109369. * @hidden
  109370. * Defines the actions happening just before the active camera is drawing.
  109371. */
  109372. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109373. /**
  109374. * @hidden
  109375. * Defines the actions happening just before a render target is drawing.
  109376. */
  109377. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109378. /**
  109379. * @hidden
  109380. * Defines the actions happening just before a rendering group is drawing.
  109381. */
  109382. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109383. /**
  109384. * @hidden
  109385. * Defines the actions happening just before a mesh is drawing.
  109386. */
  109387. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109388. /**
  109389. * @hidden
  109390. * Defines the actions happening just after a mesh has been drawn.
  109391. */
  109392. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109393. /**
  109394. * @hidden
  109395. * Defines the actions happening just after a rendering group has been drawn.
  109396. */
  109397. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109398. /**
  109399. * @hidden
  109400. * Defines the actions happening just after the active camera has been drawn.
  109401. */
  109402. _afterCameraDrawStage: Stage<CameraStageAction>;
  109403. /**
  109404. * @hidden
  109405. * Defines the actions happening just after a render target has been drawn.
  109406. */
  109407. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109408. /**
  109409. * @hidden
  109410. * Defines the actions happening just after rendering all cameras and computing intersections.
  109411. */
  109412. _afterRenderStage: Stage<SimpleStageAction>;
  109413. /**
  109414. * @hidden
  109415. * Defines the actions happening when a pointer move event happens.
  109416. */
  109417. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109418. /**
  109419. * @hidden
  109420. * Defines the actions happening when a pointer down event happens.
  109421. */
  109422. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109423. /**
  109424. * @hidden
  109425. * Defines the actions happening when a pointer up event happens.
  109426. */
  109427. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109428. /**
  109429. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109430. */
  109431. private geometriesByUniqueId;
  109432. /**
  109433. * Creates a new Scene
  109434. * @param engine defines the engine to use to render this scene
  109435. * @param options defines the scene options
  109436. */
  109437. constructor(engine: Engine, options?: SceneOptions);
  109438. /**
  109439. * Gets a string idenfifying the name of the class
  109440. * @returns "Scene" string
  109441. */
  109442. getClassName(): string;
  109443. private _defaultMeshCandidates;
  109444. /**
  109445. * @hidden
  109446. */
  109447. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109448. private _defaultSubMeshCandidates;
  109449. /**
  109450. * @hidden
  109451. */
  109452. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109453. /**
  109454. * Sets the default candidate providers for the scene.
  109455. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109456. * and getCollidingSubMeshCandidates to their default function
  109457. */
  109458. setDefaultCandidateProviders(): void;
  109459. /**
  109460. * Gets the mesh that is currently under the pointer
  109461. */
  109462. get meshUnderPointer(): Nullable<AbstractMesh>;
  109463. /**
  109464. * Gets or sets the current on-screen X position of the pointer
  109465. */
  109466. get pointerX(): number;
  109467. set pointerX(value: number);
  109468. /**
  109469. * Gets or sets the current on-screen Y position of the pointer
  109470. */
  109471. get pointerY(): number;
  109472. set pointerY(value: number);
  109473. /**
  109474. * Gets the cached material (ie. the latest rendered one)
  109475. * @returns the cached material
  109476. */
  109477. getCachedMaterial(): Nullable<Material>;
  109478. /**
  109479. * Gets the cached effect (ie. the latest rendered one)
  109480. * @returns the cached effect
  109481. */
  109482. getCachedEffect(): Nullable<Effect>;
  109483. /**
  109484. * Gets the cached visibility state (ie. the latest rendered one)
  109485. * @returns the cached visibility state
  109486. */
  109487. getCachedVisibility(): Nullable<number>;
  109488. /**
  109489. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109490. * @param material defines the current material
  109491. * @param effect defines the current effect
  109492. * @param visibility defines the current visibility state
  109493. * @returns true if one parameter is not cached
  109494. */
  109495. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109496. /**
  109497. * Gets the engine associated with the scene
  109498. * @returns an Engine
  109499. */
  109500. getEngine(): Engine;
  109501. /**
  109502. * Gets the total number of vertices rendered per frame
  109503. * @returns the total number of vertices rendered per frame
  109504. */
  109505. getTotalVertices(): number;
  109506. /**
  109507. * Gets the performance counter for total vertices
  109508. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109509. */
  109510. get totalVerticesPerfCounter(): PerfCounter;
  109511. /**
  109512. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109513. * @returns the total number of active indices rendered per frame
  109514. */
  109515. getActiveIndices(): number;
  109516. /**
  109517. * Gets the performance counter for active indices
  109518. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109519. */
  109520. get totalActiveIndicesPerfCounter(): PerfCounter;
  109521. /**
  109522. * Gets the total number of active particles rendered per frame
  109523. * @returns the total number of active particles rendered per frame
  109524. */
  109525. getActiveParticles(): number;
  109526. /**
  109527. * Gets the performance counter for active particles
  109528. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109529. */
  109530. get activeParticlesPerfCounter(): PerfCounter;
  109531. /**
  109532. * Gets the total number of active bones rendered per frame
  109533. * @returns the total number of active bones rendered per frame
  109534. */
  109535. getActiveBones(): number;
  109536. /**
  109537. * Gets the performance counter for active bones
  109538. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109539. */
  109540. get activeBonesPerfCounter(): PerfCounter;
  109541. /**
  109542. * Gets the array of active meshes
  109543. * @returns an array of AbstractMesh
  109544. */
  109545. getActiveMeshes(): SmartArray<AbstractMesh>;
  109546. /**
  109547. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109548. * @returns a number
  109549. */
  109550. getAnimationRatio(): number;
  109551. /**
  109552. * Gets an unique Id for the current render phase
  109553. * @returns a number
  109554. */
  109555. getRenderId(): number;
  109556. /**
  109557. * Gets an unique Id for the current frame
  109558. * @returns a number
  109559. */
  109560. getFrameId(): number;
  109561. /** Call this function if you want to manually increment the render Id*/
  109562. incrementRenderId(): void;
  109563. private _createUbo;
  109564. /**
  109565. * Use this method to simulate a pointer move on a mesh
  109566. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109567. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109568. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109569. * @returns the current scene
  109570. */
  109571. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109572. /**
  109573. * Use this method to simulate a pointer down on a mesh
  109574. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109575. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109576. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109577. * @returns the current scene
  109578. */
  109579. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109580. /**
  109581. * Use this method to simulate a pointer up on a mesh
  109582. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109583. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109584. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109585. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109586. * @returns the current scene
  109587. */
  109588. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109589. /**
  109590. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109591. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109592. * @returns true if the pointer was captured
  109593. */
  109594. isPointerCaptured(pointerId?: number): boolean;
  109595. /**
  109596. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109597. * @param attachUp defines if you want to attach events to pointerup
  109598. * @param attachDown defines if you want to attach events to pointerdown
  109599. * @param attachMove defines if you want to attach events to pointermove
  109600. */
  109601. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109602. /** Detaches all event handlers*/
  109603. detachControl(): void;
  109604. /**
  109605. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109606. * Delay loaded resources are not taking in account
  109607. * @return true if all required resources are ready
  109608. */
  109609. isReady(): boolean;
  109610. /** Resets all cached information relative to material (including effect and visibility) */
  109611. resetCachedMaterial(): void;
  109612. /**
  109613. * Registers a function to be called before every frame render
  109614. * @param func defines the function to register
  109615. */
  109616. registerBeforeRender(func: () => void): void;
  109617. /**
  109618. * Unregisters a function called before every frame render
  109619. * @param func defines the function to unregister
  109620. */
  109621. unregisterBeforeRender(func: () => void): void;
  109622. /**
  109623. * Registers a function to be called after every frame render
  109624. * @param func defines the function to register
  109625. */
  109626. registerAfterRender(func: () => void): void;
  109627. /**
  109628. * Unregisters a function called after every frame render
  109629. * @param func defines the function to unregister
  109630. */
  109631. unregisterAfterRender(func: () => void): void;
  109632. private _executeOnceBeforeRender;
  109633. /**
  109634. * The provided function will run before render once and will be disposed afterwards.
  109635. * A timeout delay can be provided so that the function will be executed in N ms.
  109636. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109637. * @param func The function to be executed.
  109638. * @param timeout optional delay in ms
  109639. */
  109640. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109641. /** @hidden */
  109642. _addPendingData(data: any): void;
  109643. /** @hidden */
  109644. _removePendingData(data: any): void;
  109645. /**
  109646. * Returns the number of items waiting to be loaded
  109647. * @returns the number of items waiting to be loaded
  109648. */
  109649. getWaitingItemsCount(): number;
  109650. /**
  109651. * Returns a boolean indicating if the scene is still loading data
  109652. */
  109653. get isLoading(): boolean;
  109654. /**
  109655. * Registers a function to be executed when the scene is ready
  109656. * @param {Function} func - the function to be executed
  109657. */
  109658. executeWhenReady(func: () => void): void;
  109659. /**
  109660. * Returns a promise that resolves when the scene is ready
  109661. * @returns A promise that resolves when the scene is ready
  109662. */
  109663. whenReadyAsync(): Promise<void>;
  109664. /** @hidden */
  109665. _checkIsReady(): void;
  109666. /**
  109667. * Gets all animatable attached to the scene
  109668. */
  109669. get animatables(): Animatable[];
  109670. /**
  109671. * Resets the last animation time frame.
  109672. * Useful to override when animations start running when loading a scene for the first time.
  109673. */
  109674. resetLastAnimationTimeFrame(): void;
  109675. /**
  109676. * Gets the current view matrix
  109677. * @returns a Matrix
  109678. */
  109679. getViewMatrix(): Matrix;
  109680. /**
  109681. * Gets the current projection matrix
  109682. * @returns a Matrix
  109683. */
  109684. getProjectionMatrix(): Matrix;
  109685. /**
  109686. * Gets the current transform matrix
  109687. * @returns a Matrix made of View * Projection
  109688. */
  109689. getTransformMatrix(): Matrix;
  109690. /**
  109691. * Sets the current transform matrix
  109692. * @param viewL defines the View matrix to use
  109693. * @param projectionL defines the Projection matrix to use
  109694. * @param viewR defines the right View matrix to use (if provided)
  109695. * @param projectionR defines the right Projection matrix to use (if provided)
  109696. */
  109697. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109698. /**
  109699. * Gets the uniform buffer used to store scene data
  109700. * @returns a UniformBuffer
  109701. */
  109702. getSceneUniformBuffer(): UniformBuffer;
  109703. /**
  109704. * Gets an unique (relatively to the current scene) Id
  109705. * @returns an unique number for the scene
  109706. */
  109707. getUniqueId(): number;
  109708. /**
  109709. * Add a mesh to the list of scene's meshes
  109710. * @param newMesh defines the mesh to add
  109711. * @param recursive if all child meshes should also be added to the scene
  109712. */
  109713. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109714. /**
  109715. * Remove a mesh for the list of scene's meshes
  109716. * @param toRemove defines the mesh to remove
  109717. * @param recursive if all child meshes should also be removed from the scene
  109718. * @returns the index where the mesh was in the mesh list
  109719. */
  109720. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109721. /**
  109722. * Add a transform node to the list of scene's transform nodes
  109723. * @param newTransformNode defines the transform node to add
  109724. */
  109725. addTransformNode(newTransformNode: TransformNode): void;
  109726. /**
  109727. * Remove a transform node for the list of scene's transform nodes
  109728. * @param toRemove defines the transform node to remove
  109729. * @returns the index where the transform node was in the transform node list
  109730. */
  109731. removeTransformNode(toRemove: TransformNode): number;
  109732. /**
  109733. * Remove a skeleton for the list of scene's skeletons
  109734. * @param toRemove defines the skeleton to remove
  109735. * @returns the index where the skeleton was in the skeleton list
  109736. */
  109737. removeSkeleton(toRemove: Skeleton): number;
  109738. /**
  109739. * Remove a morph target for the list of scene's morph targets
  109740. * @param toRemove defines the morph target to remove
  109741. * @returns the index where the morph target was in the morph target list
  109742. */
  109743. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109744. /**
  109745. * Remove a light for the list of scene's lights
  109746. * @param toRemove defines the light to remove
  109747. * @returns the index where the light was in the light list
  109748. */
  109749. removeLight(toRemove: Light): number;
  109750. /**
  109751. * Remove a camera for the list of scene's cameras
  109752. * @param toRemove defines the camera to remove
  109753. * @returns the index where the camera was in the camera list
  109754. */
  109755. removeCamera(toRemove: Camera): number;
  109756. /**
  109757. * Remove a particle system for the list of scene's particle systems
  109758. * @param toRemove defines the particle system to remove
  109759. * @returns the index where the particle system was in the particle system list
  109760. */
  109761. removeParticleSystem(toRemove: IParticleSystem): number;
  109762. /**
  109763. * Remove a animation for the list of scene's animations
  109764. * @param toRemove defines the animation to remove
  109765. * @returns the index where the animation was in the animation list
  109766. */
  109767. removeAnimation(toRemove: Animation): number;
  109768. /**
  109769. * Will stop the animation of the given target
  109770. * @param target - the target
  109771. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109772. * @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)
  109773. */
  109774. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109775. /**
  109776. * Removes the given animation group from this scene.
  109777. * @param toRemove The animation group to remove
  109778. * @returns The index of the removed animation group
  109779. */
  109780. removeAnimationGroup(toRemove: AnimationGroup): number;
  109781. /**
  109782. * Removes the given multi-material from this scene.
  109783. * @param toRemove The multi-material to remove
  109784. * @returns The index of the removed multi-material
  109785. */
  109786. removeMultiMaterial(toRemove: MultiMaterial): number;
  109787. /**
  109788. * Removes the given material from this scene.
  109789. * @param toRemove The material to remove
  109790. * @returns The index of the removed material
  109791. */
  109792. removeMaterial(toRemove: Material): number;
  109793. /**
  109794. * Removes the given action manager from this scene.
  109795. * @param toRemove The action manager to remove
  109796. * @returns The index of the removed action manager
  109797. */
  109798. removeActionManager(toRemove: AbstractActionManager): number;
  109799. /**
  109800. * Removes the given texture from this scene.
  109801. * @param toRemove The texture to remove
  109802. * @returns The index of the removed texture
  109803. */
  109804. removeTexture(toRemove: BaseTexture): number;
  109805. /**
  109806. * Adds the given light to this scene
  109807. * @param newLight The light to add
  109808. */
  109809. addLight(newLight: Light): void;
  109810. /**
  109811. * Sorts the list list based on light priorities
  109812. */
  109813. sortLightsByPriority(): void;
  109814. /**
  109815. * Adds the given camera to this scene
  109816. * @param newCamera The camera to add
  109817. */
  109818. addCamera(newCamera: Camera): void;
  109819. /**
  109820. * Adds the given skeleton to this scene
  109821. * @param newSkeleton The skeleton to add
  109822. */
  109823. addSkeleton(newSkeleton: Skeleton): void;
  109824. /**
  109825. * Adds the given particle system to this scene
  109826. * @param newParticleSystem The particle system to add
  109827. */
  109828. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109829. /**
  109830. * Adds the given animation to this scene
  109831. * @param newAnimation The animation to add
  109832. */
  109833. addAnimation(newAnimation: Animation): void;
  109834. /**
  109835. * Adds the given animation group to this scene.
  109836. * @param newAnimationGroup The animation group to add
  109837. */
  109838. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109839. /**
  109840. * Adds the given multi-material to this scene
  109841. * @param newMultiMaterial The multi-material to add
  109842. */
  109843. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109844. /**
  109845. * Adds the given material to this scene
  109846. * @param newMaterial The material to add
  109847. */
  109848. addMaterial(newMaterial: Material): void;
  109849. /**
  109850. * Adds the given morph target to this scene
  109851. * @param newMorphTargetManager The morph target to add
  109852. */
  109853. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109854. /**
  109855. * Adds the given geometry to this scene
  109856. * @param newGeometry The geometry to add
  109857. */
  109858. addGeometry(newGeometry: Geometry): void;
  109859. /**
  109860. * Adds the given action manager to this scene
  109861. * @param newActionManager The action manager to add
  109862. */
  109863. addActionManager(newActionManager: AbstractActionManager): void;
  109864. /**
  109865. * Adds the given texture to this scene.
  109866. * @param newTexture The texture to add
  109867. */
  109868. addTexture(newTexture: BaseTexture): void;
  109869. /**
  109870. * Switch active camera
  109871. * @param newCamera defines the new active camera
  109872. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109873. */
  109874. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109875. /**
  109876. * sets the active camera of the scene using its ID
  109877. * @param id defines the camera's ID
  109878. * @return the new active camera or null if none found.
  109879. */
  109880. setActiveCameraByID(id: string): Nullable<Camera>;
  109881. /**
  109882. * sets the active camera of the scene using its name
  109883. * @param name defines the camera's name
  109884. * @returns the new active camera or null if none found.
  109885. */
  109886. setActiveCameraByName(name: string): Nullable<Camera>;
  109887. /**
  109888. * get an animation group using its name
  109889. * @param name defines the material's name
  109890. * @return the animation group or null if none found.
  109891. */
  109892. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109893. /**
  109894. * Get a material using its unique id
  109895. * @param uniqueId defines the material's unique id
  109896. * @return the material or null if none found.
  109897. */
  109898. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109899. /**
  109900. * get a material using its id
  109901. * @param id defines the material's ID
  109902. * @return the material or null if none found.
  109903. */
  109904. getMaterialByID(id: string): Nullable<Material>;
  109905. /**
  109906. * Gets a the last added material using a given id
  109907. * @param id defines the material's ID
  109908. * @return the last material with the given id or null if none found.
  109909. */
  109910. getLastMaterialByID(id: string): Nullable<Material>;
  109911. /**
  109912. * Gets a material using its name
  109913. * @param name defines the material's name
  109914. * @return the material or null if none found.
  109915. */
  109916. getMaterialByName(name: string): Nullable<Material>;
  109917. /**
  109918. * Get a texture using its unique id
  109919. * @param uniqueId defines the texture's unique id
  109920. * @return the texture or null if none found.
  109921. */
  109922. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109923. /**
  109924. * Gets a camera using its id
  109925. * @param id defines the id to look for
  109926. * @returns the camera or null if not found
  109927. */
  109928. getCameraByID(id: string): Nullable<Camera>;
  109929. /**
  109930. * Gets a camera using its unique id
  109931. * @param uniqueId defines the unique id to look for
  109932. * @returns the camera or null if not found
  109933. */
  109934. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109935. /**
  109936. * Gets a camera using its name
  109937. * @param name defines the camera's name
  109938. * @return the camera or null if none found.
  109939. */
  109940. getCameraByName(name: string): Nullable<Camera>;
  109941. /**
  109942. * Gets a bone using its id
  109943. * @param id defines the bone's id
  109944. * @return the bone or null if not found
  109945. */
  109946. getBoneByID(id: string): Nullable<Bone>;
  109947. /**
  109948. * Gets a bone using its id
  109949. * @param name defines the bone's name
  109950. * @return the bone or null if not found
  109951. */
  109952. getBoneByName(name: string): Nullable<Bone>;
  109953. /**
  109954. * Gets a light node using its name
  109955. * @param name defines the the light's name
  109956. * @return the light or null if none found.
  109957. */
  109958. getLightByName(name: string): Nullable<Light>;
  109959. /**
  109960. * Gets a light node using its id
  109961. * @param id defines the light's id
  109962. * @return the light or null if none found.
  109963. */
  109964. getLightByID(id: string): Nullable<Light>;
  109965. /**
  109966. * Gets a light node using its scene-generated unique ID
  109967. * @param uniqueId defines the light's unique id
  109968. * @return the light or null if none found.
  109969. */
  109970. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109971. /**
  109972. * Gets a particle system by id
  109973. * @param id defines the particle system id
  109974. * @return the corresponding system or null if none found
  109975. */
  109976. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109977. /**
  109978. * Gets a geometry using its ID
  109979. * @param id defines the geometry's id
  109980. * @return the geometry or null if none found.
  109981. */
  109982. getGeometryByID(id: string): Nullable<Geometry>;
  109983. private _getGeometryByUniqueID;
  109984. /**
  109985. * Add a new geometry to this scene
  109986. * @param geometry defines the geometry to be added to the scene.
  109987. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109988. * @return a boolean defining if the geometry was added or not
  109989. */
  109990. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109991. /**
  109992. * Removes an existing geometry
  109993. * @param geometry defines the geometry to be removed from the scene
  109994. * @return a boolean defining if the geometry was removed or not
  109995. */
  109996. removeGeometry(geometry: Geometry): boolean;
  109997. /**
  109998. * Gets the list of geometries attached to the scene
  109999. * @returns an array of Geometry
  110000. */
  110001. getGeometries(): Geometry[];
  110002. /**
  110003. * Gets the first added mesh found of a given ID
  110004. * @param id defines the id to search for
  110005. * @return the mesh found or null if not found at all
  110006. */
  110007. getMeshByID(id: string): Nullable<AbstractMesh>;
  110008. /**
  110009. * Gets a list of meshes using their id
  110010. * @param id defines the id to search for
  110011. * @returns a list of meshes
  110012. */
  110013. getMeshesByID(id: string): Array<AbstractMesh>;
  110014. /**
  110015. * Gets the first added transform node found of a given ID
  110016. * @param id defines the id to search for
  110017. * @return the found transform node or null if not found at all.
  110018. */
  110019. getTransformNodeByID(id: string): Nullable<TransformNode>;
  110020. /**
  110021. * Gets a transform node with its auto-generated unique id
  110022. * @param uniqueId efines the unique id to search for
  110023. * @return the found transform node or null if not found at all.
  110024. */
  110025. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  110026. /**
  110027. * Gets a list of transform nodes using their id
  110028. * @param id defines the id to search for
  110029. * @returns a list of transform nodes
  110030. */
  110031. getTransformNodesByID(id: string): Array<TransformNode>;
  110032. /**
  110033. * Gets a mesh with its auto-generated unique id
  110034. * @param uniqueId defines the unique id to search for
  110035. * @return the found mesh or null if not found at all.
  110036. */
  110037. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  110038. /**
  110039. * Gets a the last added mesh using a given id
  110040. * @param id defines the id to search for
  110041. * @return the found mesh or null if not found at all.
  110042. */
  110043. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  110044. /**
  110045. * Gets a the last added node (Mesh, Camera, Light) using a given id
  110046. * @param id defines the id to search for
  110047. * @return the found node or null if not found at all
  110048. */
  110049. getLastEntryByID(id: string): Nullable<Node>;
  110050. /**
  110051. * Gets a node (Mesh, Camera, Light) using a given id
  110052. * @param id defines the id to search for
  110053. * @return the found node or null if not found at all
  110054. */
  110055. getNodeByID(id: string): Nullable<Node>;
  110056. /**
  110057. * Gets a node (Mesh, Camera, Light) using a given name
  110058. * @param name defines the name to search for
  110059. * @return the found node or null if not found at all.
  110060. */
  110061. getNodeByName(name: string): Nullable<Node>;
  110062. /**
  110063. * Gets a mesh using a given name
  110064. * @param name defines the name to search for
  110065. * @return the found mesh or null if not found at all.
  110066. */
  110067. getMeshByName(name: string): Nullable<AbstractMesh>;
  110068. /**
  110069. * Gets a transform node using a given name
  110070. * @param name defines the name to search for
  110071. * @return the found transform node or null if not found at all.
  110072. */
  110073. getTransformNodeByName(name: string): Nullable<TransformNode>;
  110074. /**
  110075. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  110076. * @param id defines the id to search for
  110077. * @return the found skeleton or null if not found at all.
  110078. */
  110079. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  110080. /**
  110081. * Gets a skeleton using a given auto generated unique id
  110082. * @param uniqueId defines the unique id to search for
  110083. * @return the found skeleton or null if not found at all.
  110084. */
  110085. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  110086. /**
  110087. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  110088. * @param id defines the id to search for
  110089. * @return the found skeleton or null if not found at all.
  110090. */
  110091. getSkeletonById(id: string): Nullable<Skeleton>;
  110092. /**
  110093. * Gets a skeleton using a given name
  110094. * @param name defines the name to search for
  110095. * @return the found skeleton or null if not found at all.
  110096. */
  110097. getSkeletonByName(name: string): Nullable<Skeleton>;
  110098. /**
  110099. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  110100. * @param id defines the id to search for
  110101. * @return the found morph target manager or null if not found at all.
  110102. */
  110103. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  110104. /**
  110105. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  110106. * @param id defines the id to search for
  110107. * @return the found morph target or null if not found at all.
  110108. */
  110109. getMorphTargetById(id: string): Nullable<MorphTarget>;
  110110. /**
  110111. * Gets a boolean indicating if the given mesh is active
  110112. * @param mesh defines the mesh to look for
  110113. * @returns true if the mesh is in the active list
  110114. */
  110115. isActiveMesh(mesh: AbstractMesh): boolean;
  110116. /**
  110117. * Return a unique id as a string which can serve as an identifier for the scene
  110118. */
  110119. get uid(): string;
  110120. /**
  110121. * Add an externaly attached data from its key.
  110122. * This method call will fail and return false, if such key already exists.
  110123. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  110124. * @param key the unique key that identifies the data
  110125. * @param data the data object to associate to the key for this Engine instance
  110126. * @return true if no such key were already present and the data was added successfully, false otherwise
  110127. */
  110128. addExternalData<T>(key: string, data: T): boolean;
  110129. /**
  110130. * Get an externaly attached data from its key
  110131. * @param key the unique key that identifies the data
  110132. * @return the associated data, if present (can be null), or undefined if not present
  110133. */
  110134. getExternalData<T>(key: string): Nullable<T>;
  110135. /**
  110136. * Get an externaly attached data from its key, create it using a factory if it's not already present
  110137. * @param key the unique key that identifies the data
  110138. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  110139. * @return the associated data, can be null if the factory returned null.
  110140. */
  110141. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  110142. /**
  110143. * Remove an externaly attached data from the Engine instance
  110144. * @param key the unique key that identifies the data
  110145. * @return true if the data was successfully removed, false if it doesn't exist
  110146. */
  110147. removeExternalData(key: string): boolean;
  110148. private _evaluateSubMesh;
  110149. /**
  110150. * Clear the processed materials smart array preventing retention point in material dispose.
  110151. */
  110152. freeProcessedMaterials(): void;
  110153. private _preventFreeActiveMeshesAndRenderingGroups;
  110154. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  110155. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  110156. * when disposing several meshes in a row or a hierarchy of meshes.
  110157. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  110158. */
  110159. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  110160. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  110161. /**
  110162. * Clear the active meshes smart array preventing retention point in mesh dispose.
  110163. */
  110164. freeActiveMeshes(): void;
  110165. /**
  110166. * Clear the info related to rendering groups preventing retention points during dispose.
  110167. */
  110168. freeRenderingGroups(): void;
  110169. /** @hidden */
  110170. _isInIntermediateRendering(): boolean;
  110171. /**
  110172. * Lambda returning the list of potentially active meshes.
  110173. */
  110174. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  110175. /**
  110176. * Lambda returning the list of potentially active sub meshes.
  110177. */
  110178. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  110179. /**
  110180. * Lambda returning the list of potentially intersecting sub meshes.
  110181. */
  110182. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  110183. /**
  110184. * Lambda returning the list of potentially colliding sub meshes.
  110185. */
  110186. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  110187. private _activeMeshesFrozen;
  110188. private _skipEvaluateActiveMeshesCompletely;
  110189. /**
  110190. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  110191. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  110192. * @returns the current scene
  110193. */
  110194. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  110195. /**
  110196. * Use this function to restart evaluating active meshes on every frame
  110197. * @returns the current scene
  110198. */
  110199. unfreezeActiveMeshes(): Scene;
  110200. private _evaluateActiveMeshes;
  110201. private _activeMesh;
  110202. /**
  110203. * Update the transform matrix to update from the current active camera
  110204. * @param force defines a boolean used to force the update even if cache is up to date
  110205. */
  110206. updateTransformMatrix(force?: boolean): void;
  110207. private _bindFrameBuffer;
  110208. /** @hidden */
  110209. _allowPostProcessClearColor: boolean;
  110210. /** @hidden */
  110211. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  110212. private _processSubCameras;
  110213. private _checkIntersections;
  110214. /** @hidden */
  110215. _advancePhysicsEngineStep(step: number): void;
  110216. /**
  110217. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  110218. */
  110219. getDeterministicFrameTime: () => number;
  110220. /** @hidden */
  110221. _animate(): void;
  110222. /** Execute all animations (for a frame) */
  110223. animate(): void;
  110224. /**
  110225. * Render the scene
  110226. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  110227. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  110228. */
  110229. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  110230. /**
  110231. * Freeze all materials
  110232. * A frozen material will not be updatable but should be faster to render
  110233. */
  110234. freezeMaterials(): void;
  110235. /**
  110236. * Unfreeze all materials
  110237. * A frozen material will not be updatable but should be faster to render
  110238. */
  110239. unfreezeMaterials(): void;
  110240. /**
  110241. * Releases all held ressources
  110242. */
  110243. dispose(): void;
  110244. /**
  110245. * Gets if the scene is already disposed
  110246. */
  110247. get isDisposed(): boolean;
  110248. /**
  110249. * Call this function to reduce memory footprint of the scene.
  110250. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  110251. */
  110252. clearCachedVertexData(): void;
  110253. /**
  110254. * This function will remove the local cached buffer data from texture.
  110255. * It will save memory but will prevent the texture from being rebuilt
  110256. */
  110257. cleanCachedTextureBuffer(): void;
  110258. /**
  110259. * Get the world extend vectors with an optional filter
  110260. *
  110261. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  110262. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  110263. */
  110264. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  110265. min: Vector3;
  110266. max: Vector3;
  110267. };
  110268. /**
  110269. * Creates a ray that can be used to pick in the scene
  110270. * @param x defines the x coordinate of the origin (on-screen)
  110271. * @param y defines the y coordinate of the origin (on-screen)
  110272. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110273. * @param camera defines the camera to use for the picking
  110274. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110275. * @returns a Ray
  110276. */
  110277. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  110278. /**
  110279. * Creates a ray that can be used to pick in the scene
  110280. * @param x defines the x coordinate of the origin (on-screen)
  110281. * @param y defines the y coordinate of the origin (on-screen)
  110282. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110283. * @param result defines the ray where to store the picking ray
  110284. * @param camera defines the camera to use for the picking
  110285. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110286. * @returns the current scene
  110287. */
  110288. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110289. /**
  110290. * Creates a ray that can be used to pick in the scene
  110291. * @param x defines the x coordinate of the origin (on-screen)
  110292. * @param y defines the y coordinate of the origin (on-screen)
  110293. * @param camera defines the camera to use for the picking
  110294. * @returns a Ray
  110295. */
  110296. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110297. /**
  110298. * Creates a ray that can be used to pick in the scene
  110299. * @param x defines the x coordinate of the origin (on-screen)
  110300. * @param y defines the y coordinate of the origin (on-screen)
  110301. * @param result defines the ray where to store the picking ray
  110302. * @param camera defines the camera to use for the picking
  110303. * @returns the current scene
  110304. */
  110305. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110306. /** Launch a ray to try to pick a mesh in the scene
  110307. * @param x position on screen
  110308. * @param y position on screen
  110309. * @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
  110310. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110311. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110312. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110313. * @returns a PickingInfo
  110314. */
  110315. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110316. /** Use the given ray to pick a mesh in the scene
  110317. * @param ray The ray to use to pick meshes
  110318. * @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
  110319. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110320. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110321. * @returns a PickingInfo
  110322. */
  110323. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110324. /**
  110325. * Launch a ray to try to pick a mesh in the scene
  110326. * @param x X position on screen
  110327. * @param y Y position on screen
  110328. * @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
  110329. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110330. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110331. * @returns an array of PickingInfo
  110332. */
  110333. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110334. /**
  110335. * Launch a ray to try to pick a mesh in the scene
  110336. * @param ray Ray to use
  110337. * @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
  110338. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110339. * @returns an array of PickingInfo
  110340. */
  110341. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110342. /**
  110343. * Force the value of meshUnderPointer
  110344. * @param mesh defines the mesh to use
  110345. */
  110346. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110347. /**
  110348. * Gets the mesh under the pointer
  110349. * @returns a Mesh or null if no mesh is under the pointer
  110350. */
  110351. getPointerOverMesh(): Nullable<AbstractMesh>;
  110352. /** @hidden */
  110353. _rebuildGeometries(): void;
  110354. /** @hidden */
  110355. _rebuildTextures(): void;
  110356. private _getByTags;
  110357. /**
  110358. * Get a list of meshes by tags
  110359. * @param tagsQuery defines the tags query to use
  110360. * @param forEach defines a predicate used to filter results
  110361. * @returns an array of Mesh
  110362. */
  110363. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110364. /**
  110365. * Get a list of cameras by tags
  110366. * @param tagsQuery defines the tags query to use
  110367. * @param forEach defines a predicate used to filter results
  110368. * @returns an array of Camera
  110369. */
  110370. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110371. /**
  110372. * Get a list of lights by tags
  110373. * @param tagsQuery defines the tags query to use
  110374. * @param forEach defines a predicate used to filter results
  110375. * @returns an array of Light
  110376. */
  110377. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110378. /**
  110379. * Get a list of materials by tags
  110380. * @param tagsQuery defines the tags query to use
  110381. * @param forEach defines a predicate used to filter results
  110382. * @returns an array of Material
  110383. */
  110384. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110385. /**
  110386. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110387. * This allowed control for front to back rendering or reversly depending of the special needs.
  110388. *
  110389. * @param renderingGroupId The rendering group id corresponding to its index
  110390. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110391. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110392. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110393. */
  110394. 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;
  110395. /**
  110396. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110397. *
  110398. * @param renderingGroupId The rendering group id corresponding to its index
  110399. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110400. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110401. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110402. */
  110403. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110404. /**
  110405. * Gets the current auto clear configuration for one rendering group of the rendering
  110406. * manager.
  110407. * @param index the rendering group index to get the information for
  110408. * @returns The auto clear setup for the requested rendering group
  110409. */
  110410. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110411. private _blockMaterialDirtyMechanism;
  110412. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110413. get blockMaterialDirtyMechanism(): boolean;
  110414. set blockMaterialDirtyMechanism(value: boolean);
  110415. /**
  110416. * Will flag all materials as dirty to trigger new shader compilation
  110417. * @param flag defines the flag used to specify which material part must be marked as dirty
  110418. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110419. */
  110420. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110421. /** @hidden */
  110422. _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;
  110423. /** @hidden */
  110424. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110425. /** @hidden */
  110426. _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;
  110427. /** @hidden */
  110428. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110429. /** @hidden */
  110430. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110431. /** @hidden */
  110432. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110433. }
  110434. }
  110435. declare module BABYLON {
  110436. /**
  110437. * Set of assets to keep when moving a scene into an asset container.
  110438. */
  110439. export class KeepAssets extends AbstractScene {
  110440. }
  110441. /**
  110442. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110443. */
  110444. export class InstantiatedEntries {
  110445. /**
  110446. * List of new root nodes (eg. nodes with no parent)
  110447. */
  110448. rootNodes: TransformNode[];
  110449. /**
  110450. * List of new skeletons
  110451. */
  110452. skeletons: Skeleton[];
  110453. /**
  110454. * List of new animation groups
  110455. */
  110456. animationGroups: AnimationGroup[];
  110457. }
  110458. /**
  110459. * Container with a set of assets that can be added or removed from a scene.
  110460. */
  110461. export class AssetContainer extends AbstractScene {
  110462. private _wasAddedToScene;
  110463. /**
  110464. * The scene the AssetContainer belongs to.
  110465. */
  110466. scene: Scene;
  110467. /**
  110468. * Instantiates an AssetContainer.
  110469. * @param scene The scene the AssetContainer belongs to.
  110470. */
  110471. constructor(scene: Scene);
  110472. /**
  110473. * Instantiate or clone all meshes and add the new ones to the scene.
  110474. * Skeletons and animation groups will all be cloned
  110475. * @param nameFunction defines an optional function used to get new names for clones
  110476. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110477. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110478. */
  110479. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110480. /**
  110481. * Adds all the assets from the container to the scene.
  110482. */
  110483. addAllToScene(): void;
  110484. /**
  110485. * Removes all the assets in the container from the scene
  110486. */
  110487. removeAllFromScene(): void;
  110488. /**
  110489. * Disposes all the assets in the container
  110490. */
  110491. dispose(): void;
  110492. private _moveAssets;
  110493. /**
  110494. * Removes all the assets contained in the scene and adds them to the container.
  110495. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110496. */
  110497. moveAllFromScene(keepAssets?: KeepAssets): void;
  110498. /**
  110499. * 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.
  110500. * @returns the root mesh
  110501. */
  110502. createRootMesh(): Mesh;
  110503. /**
  110504. * Merge animations from this asset container into a scene
  110505. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110506. * @param animatables set of animatables to retarget to a node from the scene
  110507. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110508. */
  110509. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110510. }
  110511. }
  110512. declare module BABYLON {
  110513. /**
  110514. * Defines how the parser contract is defined.
  110515. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110516. */
  110517. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110518. /**
  110519. * Defines how the individual parser contract is defined.
  110520. * These parser can parse an individual asset
  110521. */
  110522. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110523. /**
  110524. * Base class of the scene acting as a container for the different elements composing a scene.
  110525. * This class is dynamically extended by the different components of the scene increasing
  110526. * flexibility and reducing coupling
  110527. */
  110528. export abstract class AbstractScene {
  110529. /**
  110530. * Stores the list of available parsers in the application.
  110531. */
  110532. private static _BabylonFileParsers;
  110533. /**
  110534. * Stores the list of available individual parsers in the application.
  110535. */
  110536. private static _IndividualBabylonFileParsers;
  110537. /**
  110538. * Adds a parser in the list of available ones
  110539. * @param name Defines the name of the parser
  110540. * @param parser Defines the parser to add
  110541. */
  110542. static AddParser(name: string, parser: BabylonFileParser): void;
  110543. /**
  110544. * Gets a general parser from the list of avaialble ones
  110545. * @param name Defines the name of the parser
  110546. * @returns the requested parser or null
  110547. */
  110548. static GetParser(name: string): Nullable<BabylonFileParser>;
  110549. /**
  110550. * Adds n individual parser in the list of available ones
  110551. * @param name Defines the name of the parser
  110552. * @param parser Defines the parser to add
  110553. */
  110554. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110555. /**
  110556. * Gets an individual parser from the list of avaialble ones
  110557. * @param name Defines the name of the parser
  110558. * @returns the requested parser or null
  110559. */
  110560. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110561. /**
  110562. * Parser json data and populate both a scene and its associated container object
  110563. * @param jsonData Defines the data to parse
  110564. * @param scene Defines the scene to parse the data for
  110565. * @param container Defines the container attached to the parsing sequence
  110566. * @param rootUrl Defines the root url of the data
  110567. */
  110568. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110569. /**
  110570. * Gets the list of root nodes (ie. nodes with no parent)
  110571. */
  110572. rootNodes: Node[];
  110573. /** All of the cameras added to this scene
  110574. * @see http://doc.babylonjs.com/babylon101/cameras
  110575. */
  110576. cameras: Camera[];
  110577. /**
  110578. * All of the lights added to this scene
  110579. * @see http://doc.babylonjs.com/babylon101/lights
  110580. */
  110581. lights: Light[];
  110582. /**
  110583. * All of the (abstract) meshes added to this scene
  110584. */
  110585. meshes: AbstractMesh[];
  110586. /**
  110587. * The list of skeletons added to the scene
  110588. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110589. */
  110590. skeletons: Skeleton[];
  110591. /**
  110592. * All of the particle systems added to this scene
  110593. * @see http://doc.babylonjs.com/babylon101/particles
  110594. */
  110595. particleSystems: IParticleSystem[];
  110596. /**
  110597. * Gets a list of Animations associated with the scene
  110598. */
  110599. animations: Animation[];
  110600. /**
  110601. * All of the animation groups added to this scene
  110602. * @see http://doc.babylonjs.com/how_to/group
  110603. */
  110604. animationGroups: AnimationGroup[];
  110605. /**
  110606. * All of the multi-materials added to this scene
  110607. * @see http://doc.babylonjs.com/how_to/multi_materials
  110608. */
  110609. multiMaterials: MultiMaterial[];
  110610. /**
  110611. * All of the materials added to this scene
  110612. * In the context of a Scene, it is not supposed to be modified manually.
  110613. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110614. * Note also that the order of the Material within the array is not significant and might change.
  110615. * @see http://doc.babylonjs.com/babylon101/materials
  110616. */
  110617. materials: Material[];
  110618. /**
  110619. * The list of morph target managers added to the scene
  110620. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110621. */
  110622. morphTargetManagers: MorphTargetManager[];
  110623. /**
  110624. * The list of geometries used in the scene.
  110625. */
  110626. geometries: Geometry[];
  110627. /**
  110628. * All of the tranform nodes added to this scene
  110629. * In the context of a Scene, it is not supposed to be modified manually.
  110630. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110631. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110632. * @see http://doc.babylonjs.com/how_to/transformnode
  110633. */
  110634. transformNodes: TransformNode[];
  110635. /**
  110636. * ActionManagers available on the scene.
  110637. */
  110638. actionManagers: AbstractActionManager[];
  110639. /**
  110640. * Textures to keep.
  110641. */
  110642. textures: BaseTexture[];
  110643. /**
  110644. * Environment texture for the scene
  110645. */
  110646. environmentTexture: Nullable<BaseTexture>;
  110647. /**
  110648. * @returns all meshes, lights, cameras, transformNodes and bones
  110649. */
  110650. getNodes(): Array<Node>;
  110651. }
  110652. }
  110653. declare module BABYLON {
  110654. /**
  110655. * Interface used to define options for Sound class
  110656. */
  110657. export interface ISoundOptions {
  110658. /**
  110659. * Does the sound autoplay once loaded.
  110660. */
  110661. autoplay?: boolean;
  110662. /**
  110663. * Does the sound loop after it finishes playing once.
  110664. */
  110665. loop?: boolean;
  110666. /**
  110667. * Sound's volume
  110668. */
  110669. volume?: number;
  110670. /**
  110671. * Is it a spatial sound?
  110672. */
  110673. spatialSound?: boolean;
  110674. /**
  110675. * Maximum distance to hear that sound
  110676. */
  110677. maxDistance?: number;
  110678. /**
  110679. * Uses user defined attenuation function
  110680. */
  110681. useCustomAttenuation?: boolean;
  110682. /**
  110683. * Define the roll off factor of spatial sounds.
  110684. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110685. */
  110686. rolloffFactor?: number;
  110687. /**
  110688. * Define the reference distance the sound should be heard perfectly.
  110689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110690. */
  110691. refDistance?: number;
  110692. /**
  110693. * Define the distance attenuation model the sound will follow.
  110694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110695. */
  110696. distanceModel?: string;
  110697. /**
  110698. * Defines the playback speed (1 by default)
  110699. */
  110700. playbackRate?: number;
  110701. /**
  110702. * Defines if the sound is from a streaming source
  110703. */
  110704. streaming?: boolean;
  110705. /**
  110706. * Defines an optional length (in seconds) inside the sound file
  110707. */
  110708. length?: number;
  110709. /**
  110710. * Defines an optional offset (in seconds) inside the sound file
  110711. */
  110712. offset?: number;
  110713. /**
  110714. * If true, URLs will not be required to state the audio file codec to use.
  110715. */
  110716. skipCodecCheck?: boolean;
  110717. }
  110718. /**
  110719. * Defines a sound that can be played in the application.
  110720. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110722. */
  110723. export class Sound {
  110724. /**
  110725. * The name of the sound in the scene.
  110726. */
  110727. name: string;
  110728. /**
  110729. * Does the sound autoplay once loaded.
  110730. */
  110731. autoplay: boolean;
  110732. /**
  110733. * Does the sound loop after it finishes playing once.
  110734. */
  110735. loop: boolean;
  110736. /**
  110737. * Does the sound use a custom attenuation curve to simulate the falloff
  110738. * happening when the source gets further away from the camera.
  110739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110740. */
  110741. useCustomAttenuation: boolean;
  110742. /**
  110743. * The sound track id this sound belongs to.
  110744. */
  110745. soundTrackId: number;
  110746. /**
  110747. * Is this sound currently played.
  110748. */
  110749. isPlaying: boolean;
  110750. /**
  110751. * Is this sound currently paused.
  110752. */
  110753. isPaused: boolean;
  110754. /**
  110755. * Does this sound enables spatial sound.
  110756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110757. */
  110758. spatialSound: boolean;
  110759. /**
  110760. * Define the reference distance the sound should be heard perfectly.
  110761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110762. */
  110763. refDistance: number;
  110764. /**
  110765. * Define the roll off factor of spatial sounds.
  110766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110767. */
  110768. rolloffFactor: number;
  110769. /**
  110770. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110771. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110772. */
  110773. maxDistance: number;
  110774. /**
  110775. * Define the distance attenuation model the sound will follow.
  110776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110777. */
  110778. distanceModel: string;
  110779. /**
  110780. * @hidden
  110781. * Back Compat
  110782. **/
  110783. onended: () => any;
  110784. /**
  110785. * Observable event when the current playing sound finishes.
  110786. */
  110787. onEndedObservable: Observable<Sound>;
  110788. private _panningModel;
  110789. private _playbackRate;
  110790. private _streaming;
  110791. private _startTime;
  110792. private _startOffset;
  110793. private _position;
  110794. /** @hidden */
  110795. _positionInEmitterSpace: boolean;
  110796. private _localDirection;
  110797. private _volume;
  110798. private _isReadyToPlay;
  110799. private _isDirectional;
  110800. private _readyToPlayCallback;
  110801. private _audioBuffer;
  110802. private _soundSource;
  110803. private _streamingSource;
  110804. private _soundPanner;
  110805. private _soundGain;
  110806. private _inputAudioNode;
  110807. private _outputAudioNode;
  110808. private _coneInnerAngle;
  110809. private _coneOuterAngle;
  110810. private _coneOuterGain;
  110811. private _scene;
  110812. private _connectedTransformNode;
  110813. private _customAttenuationFunction;
  110814. private _registerFunc;
  110815. private _isOutputConnected;
  110816. private _htmlAudioElement;
  110817. private _urlType;
  110818. private _length?;
  110819. private _offset?;
  110820. /** @hidden */
  110821. static _SceneComponentInitialization: (scene: Scene) => void;
  110822. /**
  110823. * Create a sound and attach it to a scene
  110824. * @param name Name of your sound
  110825. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110826. * @param scene defines the scene the sound belongs to
  110827. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110828. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110829. */
  110830. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110831. /**
  110832. * Release the sound and its associated resources
  110833. */
  110834. dispose(): void;
  110835. /**
  110836. * Gets if the sounds is ready to be played or not.
  110837. * @returns true if ready, otherwise false
  110838. */
  110839. isReady(): boolean;
  110840. private _soundLoaded;
  110841. /**
  110842. * Sets the data of the sound from an audiobuffer
  110843. * @param audioBuffer The audioBuffer containing the data
  110844. */
  110845. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110846. /**
  110847. * Updates the current sounds options such as maxdistance, loop...
  110848. * @param options A JSON object containing values named as the object properties
  110849. */
  110850. updateOptions(options: ISoundOptions): void;
  110851. private _createSpatialParameters;
  110852. private _updateSpatialParameters;
  110853. /**
  110854. * Switch the panning model to HRTF:
  110855. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110857. */
  110858. switchPanningModelToHRTF(): void;
  110859. /**
  110860. * Switch the panning model to Equal Power:
  110861. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110863. */
  110864. switchPanningModelToEqualPower(): void;
  110865. private _switchPanningModel;
  110866. /**
  110867. * Connect this sound to a sound track audio node like gain...
  110868. * @param soundTrackAudioNode the sound track audio node to connect to
  110869. */
  110870. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110871. /**
  110872. * Transform this sound into a directional source
  110873. * @param coneInnerAngle Size of the inner cone in degree
  110874. * @param coneOuterAngle Size of the outer cone in degree
  110875. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110876. */
  110877. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110878. /**
  110879. * Gets or sets the inner angle for the directional cone.
  110880. */
  110881. get directionalConeInnerAngle(): number;
  110882. /**
  110883. * Gets or sets the inner angle for the directional cone.
  110884. */
  110885. set directionalConeInnerAngle(value: number);
  110886. /**
  110887. * Gets or sets the outer angle for the directional cone.
  110888. */
  110889. get directionalConeOuterAngle(): number;
  110890. /**
  110891. * Gets or sets the outer angle for the directional cone.
  110892. */
  110893. set directionalConeOuterAngle(value: number);
  110894. /**
  110895. * Sets the position of the emitter if spatial sound is enabled
  110896. * @param newPosition Defines the new posisiton
  110897. */
  110898. setPosition(newPosition: Vector3): void;
  110899. /**
  110900. * Sets the local direction of the emitter if spatial sound is enabled
  110901. * @param newLocalDirection Defines the new local direction
  110902. */
  110903. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110904. private _updateDirection;
  110905. /** @hidden */
  110906. updateDistanceFromListener(): void;
  110907. /**
  110908. * Sets a new custom attenuation function for the sound.
  110909. * @param callback Defines the function used for the attenuation
  110910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110911. */
  110912. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110913. /**
  110914. * Play the sound
  110915. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110916. * @param offset (optional) Start the sound at a specific time in seconds
  110917. * @param length (optional) Sound duration (in seconds)
  110918. */
  110919. play(time?: number, offset?: number, length?: number): void;
  110920. private _onended;
  110921. /**
  110922. * Stop the sound
  110923. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110924. */
  110925. stop(time?: number): void;
  110926. /**
  110927. * Put the sound in pause
  110928. */
  110929. pause(): void;
  110930. /**
  110931. * Sets a dedicated volume for this sounds
  110932. * @param newVolume Define the new volume of the sound
  110933. * @param time Define time for gradual change to new volume
  110934. */
  110935. setVolume(newVolume: number, time?: number): void;
  110936. /**
  110937. * Set the sound play back rate
  110938. * @param newPlaybackRate Define the playback rate the sound should be played at
  110939. */
  110940. setPlaybackRate(newPlaybackRate: number): void;
  110941. /**
  110942. * Gets the volume of the sound.
  110943. * @returns the volume of the sound
  110944. */
  110945. getVolume(): number;
  110946. /**
  110947. * Attach the sound to a dedicated mesh
  110948. * @param transformNode The transform node to connect the sound with
  110949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110950. */
  110951. attachToMesh(transformNode: TransformNode): void;
  110952. /**
  110953. * Detach the sound from the previously attached mesh
  110954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110955. */
  110956. detachFromMesh(): void;
  110957. private _onRegisterAfterWorldMatrixUpdate;
  110958. /**
  110959. * Clone the current sound in the scene.
  110960. * @returns the new sound clone
  110961. */
  110962. clone(): Nullable<Sound>;
  110963. /**
  110964. * Gets the current underlying audio buffer containing the data
  110965. * @returns the audio buffer
  110966. */
  110967. getAudioBuffer(): Nullable<AudioBuffer>;
  110968. /**
  110969. * Serializes the Sound in a JSON representation
  110970. * @returns the JSON representation of the sound
  110971. */
  110972. serialize(): any;
  110973. /**
  110974. * Parse a JSON representation of a sound to innstantiate in a given scene
  110975. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110976. * @param scene Define the scene the new parsed sound should be created in
  110977. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110978. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110979. * @returns the newly parsed sound
  110980. */
  110981. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110982. }
  110983. }
  110984. declare module BABYLON {
  110985. /**
  110986. * This defines an action helpful to play a defined sound on a triggered action.
  110987. */
  110988. export class PlaySoundAction extends Action {
  110989. private _sound;
  110990. /**
  110991. * Instantiate the action
  110992. * @param triggerOptions defines the trigger options
  110993. * @param sound defines the sound to play
  110994. * @param condition defines the trigger related conditions
  110995. */
  110996. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110997. /** @hidden */
  110998. _prepare(): void;
  110999. /**
  111000. * Execute the action and play the sound.
  111001. */
  111002. execute(): void;
  111003. /**
  111004. * Serializes the actions and its related information.
  111005. * @param parent defines the object to serialize in
  111006. * @returns the serialized object
  111007. */
  111008. serialize(parent: any): any;
  111009. }
  111010. /**
  111011. * This defines an action helpful to stop a defined sound on a triggered action.
  111012. */
  111013. export class StopSoundAction extends Action {
  111014. private _sound;
  111015. /**
  111016. * Instantiate the action
  111017. * @param triggerOptions defines the trigger options
  111018. * @param sound defines the sound to stop
  111019. * @param condition defines the trigger related conditions
  111020. */
  111021. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  111022. /** @hidden */
  111023. _prepare(): void;
  111024. /**
  111025. * Execute the action and stop the sound.
  111026. */
  111027. execute(): void;
  111028. /**
  111029. * Serializes the actions and its related information.
  111030. * @param parent defines the object to serialize in
  111031. * @returns the serialized object
  111032. */
  111033. serialize(parent: any): any;
  111034. }
  111035. }
  111036. declare module BABYLON {
  111037. /**
  111038. * This defines an action responsible to change the value of a property
  111039. * by interpolating between its current value and the newly set one once triggered.
  111040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  111041. */
  111042. export class InterpolateValueAction extends Action {
  111043. /**
  111044. * Defines the path of the property where the value should be interpolated
  111045. */
  111046. propertyPath: string;
  111047. /**
  111048. * Defines the target value at the end of the interpolation.
  111049. */
  111050. value: any;
  111051. /**
  111052. * Defines the time it will take for the property to interpolate to the value.
  111053. */
  111054. duration: number;
  111055. /**
  111056. * Defines if the other scene animations should be stopped when the action has been triggered
  111057. */
  111058. stopOtherAnimations?: boolean;
  111059. /**
  111060. * Defines a callback raised once the interpolation animation has been done.
  111061. */
  111062. onInterpolationDone?: () => void;
  111063. /**
  111064. * Observable triggered once the interpolation animation has been done.
  111065. */
  111066. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  111067. private _target;
  111068. private _effectiveTarget;
  111069. private _property;
  111070. /**
  111071. * Instantiate the action
  111072. * @param triggerOptions defines the trigger options
  111073. * @param target defines the object containing the value to interpolate
  111074. * @param propertyPath defines the path to the property in the target object
  111075. * @param value defines the target value at the end of the interpolation
  111076. * @param duration deines the time it will take for the property to interpolate to the value.
  111077. * @param condition defines the trigger related conditions
  111078. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  111079. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  111080. */
  111081. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  111082. /** @hidden */
  111083. _prepare(): void;
  111084. /**
  111085. * Execute the action starts the value interpolation.
  111086. */
  111087. execute(): void;
  111088. /**
  111089. * Serializes the actions and its related information.
  111090. * @param parent defines the object to serialize in
  111091. * @returns the serialized object
  111092. */
  111093. serialize(parent: any): any;
  111094. }
  111095. }
  111096. declare module BABYLON {
  111097. /**
  111098. * Options allowed during the creation of a sound track.
  111099. */
  111100. export interface ISoundTrackOptions {
  111101. /**
  111102. * The volume the sound track should take during creation
  111103. */
  111104. volume?: number;
  111105. /**
  111106. * Define if the sound track is the main sound track of the scene
  111107. */
  111108. mainTrack?: boolean;
  111109. }
  111110. /**
  111111. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  111112. * It will be also used in a future release to apply effects on a specific track.
  111113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  111114. */
  111115. export class SoundTrack {
  111116. /**
  111117. * The unique identifier of the sound track in the scene.
  111118. */
  111119. id: number;
  111120. /**
  111121. * The list of sounds included in the sound track.
  111122. */
  111123. soundCollection: Array<Sound>;
  111124. private _outputAudioNode;
  111125. private _scene;
  111126. private _connectedAnalyser;
  111127. private _options;
  111128. private _isInitialized;
  111129. /**
  111130. * Creates a new sound track.
  111131. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  111132. * @param scene Define the scene the sound track belongs to
  111133. * @param options
  111134. */
  111135. constructor(scene: Scene, options?: ISoundTrackOptions);
  111136. private _initializeSoundTrackAudioGraph;
  111137. /**
  111138. * Release the sound track and its associated resources
  111139. */
  111140. dispose(): void;
  111141. /**
  111142. * Adds a sound to this sound track
  111143. * @param sound define the cound to add
  111144. * @ignoreNaming
  111145. */
  111146. AddSound(sound: Sound): void;
  111147. /**
  111148. * Removes a sound to this sound track
  111149. * @param sound define the cound to remove
  111150. * @ignoreNaming
  111151. */
  111152. RemoveSound(sound: Sound): void;
  111153. /**
  111154. * Set a global volume for the full sound track.
  111155. * @param newVolume Define the new volume of the sound track
  111156. */
  111157. setVolume(newVolume: number): void;
  111158. /**
  111159. * Switch the panning model to HRTF:
  111160. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  111161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111162. */
  111163. switchPanningModelToHRTF(): void;
  111164. /**
  111165. * Switch the panning model to Equal Power:
  111166. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  111167. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111168. */
  111169. switchPanningModelToEqualPower(): void;
  111170. /**
  111171. * Connect the sound track to an audio analyser allowing some amazing
  111172. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  111173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  111174. * @param analyser The analyser to connect to the engine
  111175. */
  111176. connectToAnalyser(analyser: Analyser): void;
  111177. }
  111178. }
  111179. declare module BABYLON {
  111180. interface AbstractScene {
  111181. /**
  111182. * The list of sounds used in the scene.
  111183. */
  111184. sounds: Nullable<Array<Sound>>;
  111185. }
  111186. interface Scene {
  111187. /**
  111188. * @hidden
  111189. * Backing field
  111190. */
  111191. _mainSoundTrack: SoundTrack;
  111192. /**
  111193. * The main sound track played by the scene.
  111194. * It cotains your primary collection of sounds.
  111195. */
  111196. mainSoundTrack: SoundTrack;
  111197. /**
  111198. * The list of sound tracks added to the scene
  111199. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111200. */
  111201. soundTracks: Nullable<Array<SoundTrack>>;
  111202. /**
  111203. * Gets a sound using a given name
  111204. * @param name defines the name to search for
  111205. * @return the found sound or null if not found at all.
  111206. */
  111207. getSoundByName(name: string): Nullable<Sound>;
  111208. /**
  111209. * Gets or sets if audio support is enabled
  111210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111211. */
  111212. audioEnabled: boolean;
  111213. /**
  111214. * Gets or sets if audio will be output to headphones
  111215. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111216. */
  111217. headphone: boolean;
  111218. /**
  111219. * Gets or sets custom audio listener position provider
  111220. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111221. */
  111222. audioListenerPositionProvider: Nullable<() => Vector3>;
  111223. /**
  111224. * Gets or sets a refresh rate when using 3D audio positioning
  111225. */
  111226. audioPositioningRefreshRate: number;
  111227. }
  111228. /**
  111229. * Defines the sound scene component responsible to manage any sounds
  111230. * in a given scene.
  111231. */
  111232. export class AudioSceneComponent implements ISceneSerializableComponent {
  111233. /**
  111234. * The component name helpfull to identify the component in the list of scene components.
  111235. */
  111236. readonly name: string;
  111237. /**
  111238. * The scene the component belongs to.
  111239. */
  111240. scene: Scene;
  111241. private _audioEnabled;
  111242. /**
  111243. * Gets whether audio is enabled or not.
  111244. * Please use related enable/disable method to switch state.
  111245. */
  111246. get audioEnabled(): boolean;
  111247. private _headphone;
  111248. /**
  111249. * Gets whether audio is outputing to headphone or not.
  111250. * Please use the according Switch methods to change output.
  111251. */
  111252. get headphone(): boolean;
  111253. /**
  111254. * Gets or sets a refresh rate when using 3D audio positioning
  111255. */
  111256. audioPositioningRefreshRate: number;
  111257. private _audioListenerPositionProvider;
  111258. /**
  111259. * Gets the current audio listener position provider
  111260. */
  111261. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  111262. /**
  111263. * Sets a custom listener position for all sounds in the scene
  111264. * By default, this is the position of the first active camera
  111265. */
  111266. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  111267. /**
  111268. * Creates a new instance of the component for the given scene
  111269. * @param scene Defines the scene to register the component in
  111270. */
  111271. constructor(scene: Scene);
  111272. /**
  111273. * Registers the component in a given scene
  111274. */
  111275. register(): void;
  111276. /**
  111277. * Rebuilds the elements related to this component in case of
  111278. * context lost for instance.
  111279. */
  111280. rebuild(): void;
  111281. /**
  111282. * Serializes the component data to the specified json object
  111283. * @param serializationObject The object to serialize to
  111284. */
  111285. serialize(serializationObject: any): void;
  111286. /**
  111287. * Adds all the elements from the container to the scene
  111288. * @param container the container holding the elements
  111289. */
  111290. addFromContainer(container: AbstractScene): void;
  111291. /**
  111292. * Removes all the elements in the container from the scene
  111293. * @param container contains the elements to remove
  111294. * @param dispose if the removed element should be disposed (default: false)
  111295. */
  111296. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111297. /**
  111298. * Disposes the component and the associated ressources.
  111299. */
  111300. dispose(): void;
  111301. /**
  111302. * Disables audio in the associated scene.
  111303. */
  111304. disableAudio(): void;
  111305. /**
  111306. * Enables audio in the associated scene.
  111307. */
  111308. enableAudio(): void;
  111309. /**
  111310. * Switch audio to headphone output.
  111311. */
  111312. switchAudioModeForHeadphones(): void;
  111313. /**
  111314. * Switch audio to normal speakers.
  111315. */
  111316. switchAudioModeForNormalSpeakers(): void;
  111317. private _cachedCameraDirection;
  111318. private _cachedCameraPosition;
  111319. private _lastCheck;
  111320. private _afterRender;
  111321. }
  111322. }
  111323. declare module BABYLON {
  111324. /**
  111325. * Wraps one or more Sound objects and selects one with random weight for playback.
  111326. */
  111327. export class WeightedSound {
  111328. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111329. loop: boolean;
  111330. private _coneInnerAngle;
  111331. private _coneOuterAngle;
  111332. private _volume;
  111333. /** A Sound is currently playing. */
  111334. isPlaying: boolean;
  111335. /** A Sound is currently paused. */
  111336. isPaused: boolean;
  111337. private _sounds;
  111338. private _weights;
  111339. private _currentIndex?;
  111340. /**
  111341. * Creates a new WeightedSound from the list of sounds given.
  111342. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111343. * @param sounds Array of Sounds that will be selected from.
  111344. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111345. */
  111346. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111347. /**
  111348. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111349. */
  111350. get directionalConeInnerAngle(): number;
  111351. /**
  111352. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111353. */
  111354. set directionalConeInnerAngle(value: number);
  111355. /**
  111356. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111357. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111358. */
  111359. get directionalConeOuterAngle(): number;
  111360. /**
  111361. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111362. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111363. */
  111364. set directionalConeOuterAngle(value: number);
  111365. /**
  111366. * Playback volume.
  111367. */
  111368. get volume(): number;
  111369. /**
  111370. * Playback volume.
  111371. */
  111372. set volume(value: number);
  111373. private _onended;
  111374. /**
  111375. * Suspend playback
  111376. */
  111377. pause(): void;
  111378. /**
  111379. * Stop playback
  111380. */
  111381. stop(): void;
  111382. /**
  111383. * Start playback.
  111384. * @param startOffset Position the clip head at a specific time in seconds.
  111385. */
  111386. play(startOffset?: number): void;
  111387. }
  111388. }
  111389. declare module BABYLON {
  111390. /**
  111391. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111392. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111393. */
  111394. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111395. /**
  111396. * Gets the name of the behavior.
  111397. */
  111398. get name(): string;
  111399. /**
  111400. * The easing function used by animations
  111401. */
  111402. static EasingFunction: BackEase;
  111403. /**
  111404. * The easing mode used by animations
  111405. */
  111406. static EasingMode: number;
  111407. /**
  111408. * The duration of the animation, in milliseconds
  111409. */
  111410. transitionDuration: number;
  111411. /**
  111412. * Length of the distance animated by the transition when lower radius is reached
  111413. */
  111414. lowerRadiusTransitionRange: number;
  111415. /**
  111416. * Length of the distance animated by the transition when upper radius is reached
  111417. */
  111418. upperRadiusTransitionRange: number;
  111419. private _autoTransitionRange;
  111420. /**
  111421. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111422. */
  111423. get autoTransitionRange(): boolean;
  111424. /**
  111425. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111426. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111427. */
  111428. set autoTransitionRange(value: boolean);
  111429. private _attachedCamera;
  111430. private _onAfterCheckInputsObserver;
  111431. private _onMeshTargetChangedObserver;
  111432. /**
  111433. * Initializes the behavior.
  111434. */
  111435. init(): void;
  111436. /**
  111437. * Attaches the behavior to its arc rotate camera.
  111438. * @param camera Defines the camera to attach the behavior to
  111439. */
  111440. attach(camera: ArcRotateCamera): void;
  111441. /**
  111442. * Detaches the behavior from its current arc rotate camera.
  111443. */
  111444. detach(): void;
  111445. private _radiusIsAnimating;
  111446. private _radiusBounceTransition;
  111447. private _animatables;
  111448. private _cachedWheelPrecision;
  111449. /**
  111450. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111451. * @param radiusLimit The limit to check against.
  111452. * @return Bool to indicate if at limit.
  111453. */
  111454. private _isRadiusAtLimit;
  111455. /**
  111456. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111457. * @param radiusDelta The delta by which to animate to. Can be negative.
  111458. */
  111459. private _applyBoundRadiusAnimation;
  111460. /**
  111461. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111462. */
  111463. protected _clearAnimationLocks(): void;
  111464. /**
  111465. * Stops and removes all animations that have been applied to the camera
  111466. */
  111467. stopAllAnimations(): void;
  111468. }
  111469. }
  111470. declare module BABYLON {
  111471. /**
  111472. * 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.
  111473. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111474. */
  111475. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111476. /**
  111477. * Gets the name of the behavior.
  111478. */
  111479. get name(): string;
  111480. private _mode;
  111481. private _radiusScale;
  111482. private _positionScale;
  111483. private _defaultElevation;
  111484. private _elevationReturnTime;
  111485. private _elevationReturnWaitTime;
  111486. private _zoomStopsAnimation;
  111487. private _framingTime;
  111488. /**
  111489. * The easing function used by animations
  111490. */
  111491. static EasingFunction: ExponentialEase;
  111492. /**
  111493. * The easing mode used by animations
  111494. */
  111495. static EasingMode: number;
  111496. /**
  111497. * Sets the current mode used by the behavior
  111498. */
  111499. set mode(mode: number);
  111500. /**
  111501. * Gets current mode used by the behavior.
  111502. */
  111503. get mode(): number;
  111504. /**
  111505. * Sets the scale applied to the radius (1 by default)
  111506. */
  111507. set radiusScale(radius: number);
  111508. /**
  111509. * Gets the scale applied to the radius
  111510. */
  111511. get radiusScale(): number;
  111512. /**
  111513. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111514. */
  111515. set positionScale(scale: number);
  111516. /**
  111517. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111518. */
  111519. get positionScale(): number;
  111520. /**
  111521. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111522. * behaviour is triggered, in radians.
  111523. */
  111524. set defaultElevation(elevation: number);
  111525. /**
  111526. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111527. * behaviour is triggered, in radians.
  111528. */
  111529. get defaultElevation(): number;
  111530. /**
  111531. * Sets the time (in milliseconds) taken to return to the default beta position.
  111532. * Negative value indicates camera should not return to default.
  111533. */
  111534. set elevationReturnTime(speed: number);
  111535. /**
  111536. * Gets the time (in milliseconds) taken to return to the default beta position.
  111537. * Negative value indicates camera should not return to default.
  111538. */
  111539. get elevationReturnTime(): number;
  111540. /**
  111541. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111542. */
  111543. set elevationReturnWaitTime(time: number);
  111544. /**
  111545. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111546. */
  111547. get elevationReturnWaitTime(): number;
  111548. /**
  111549. * Sets the flag that indicates if user zooming should stop animation.
  111550. */
  111551. set zoomStopsAnimation(flag: boolean);
  111552. /**
  111553. * Gets the flag that indicates if user zooming should stop animation.
  111554. */
  111555. get zoomStopsAnimation(): boolean;
  111556. /**
  111557. * Sets the transition time when framing the mesh, in milliseconds
  111558. */
  111559. set framingTime(time: number);
  111560. /**
  111561. * Gets the transition time when framing the mesh, in milliseconds
  111562. */
  111563. get framingTime(): number;
  111564. /**
  111565. * Define if the behavior should automatically change the configured
  111566. * camera limits and sensibilities.
  111567. */
  111568. autoCorrectCameraLimitsAndSensibility: boolean;
  111569. private _onPrePointerObservableObserver;
  111570. private _onAfterCheckInputsObserver;
  111571. private _onMeshTargetChangedObserver;
  111572. private _attachedCamera;
  111573. private _isPointerDown;
  111574. private _lastInteractionTime;
  111575. /**
  111576. * Initializes the behavior.
  111577. */
  111578. init(): void;
  111579. /**
  111580. * Attaches the behavior to its arc rotate camera.
  111581. * @param camera Defines the camera to attach the behavior to
  111582. */
  111583. attach(camera: ArcRotateCamera): void;
  111584. /**
  111585. * Detaches the behavior from its current arc rotate camera.
  111586. */
  111587. detach(): void;
  111588. private _animatables;
  111589. private _betaIsAnimating;
  111590. private _betaTransition;
  111591. private _radiusTransition;
  111592. private _vectorTransition;
  111593. /**
  111594. * Targets the given mesh and updates zoom level accordingly.
  111595. * @param mesh The mesh to target.
  111596. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111597. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111598. */
  111599. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111600. /**
  111601. * Targets the given mesh with its children and updates zoom level accordingly.
  111602. * @param mesh The mesh to target.
  111603. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111604. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111605. */
  111606. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111607. /**
  111608. * Targets the given meshes with their children and updates zoom level accordingly.
  111609. * @param meshes The mesh to target.
  111610. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111611. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111612. */
  111613. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111614. /**
  111615. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111616. * @param minimumWorld Determines the smaller position of the bounding box extend
  111617. * @param maximumWorld Determines the bigger position of the bounding box extend
  111618. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111619. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111620. */
  111621. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111622. /**
  111623. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111624. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111625. * frustum width.
  111626. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111627. * to fully enclose the mesh in the viewing frustum.
  111628. */
  111629. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111630. /**
  111631. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111632. * is automatically returned to its default position (expected to be above ground plane).
  111633. */
  111634. private _maintainCameraAboveGround;
  111635. /**
  111636. * Returns the frustum slope based on the canvas ratio and camera FOV
  111637. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111638. */
  111639. private _getFrustumSlope;
  111640. /**
  111641. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111642. */
  111643. private _clearAnimationLocks;
  111644. /**
  111645. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111646. */
  111647. private _applyUserInteraction;
  111648. /**
  111649. * Stops and removes all animations that have been applied to the camera
  111650. */
  111651. stopAllAnimations(): void;
  111652. /**
  111653. * Gets a value indicating if the user is moving the camera
  111654. */
  111655. get isUserIsMoving(): boolean;
  111656. /**
  111657. * The camera can move all the way towards the mesh.
  111658. */
  111659. static IgnoreBoundsSizeMode: number;
  111660. /**
  111661. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111662. */
  111663. static FitFrustumSidesMode: number;
  111664. }
  111665. }
  111666. declare module BABYLON {
  111667. /**
  111668. * Base class for Camera Pointer Inputs.
  111669. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111670. * for example usage.
  111671. */
  111672. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111673. /**
  111674. * Defines the camera the input is attached to.
  111675. */
  111676. abstract camera: Camera;
  111677. /**
  111678. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111679. */
  111680. protected _altKey: boolean;
  111681. protected _ctrlKey: boolean;
  111682. protected _metaKey: boolean;
  111683. protected _shiftKey: boolean;
  111684. /**
  111685. * Which mouse buttons were pressed at time of last mouse event.
  111686. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111687. */
  111688. protected _buttonsPressed: number;
  111689. /**
  111690. * Defines the buttons associated with the input to handle camera move.
  111691. */
  111692. buttons: number[];
  111693. /**
  111694. * Attach the input controls to a specific dom element to get the input from.
  111695. * @param element Defines the element the controls should be listened from
  111696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111697. */
  111698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111699. /**
  111700. * Detach the current controls from the specified dom element.
  111701. * @param element Defines the element to stop listening the inputs from
  111702. */
  111703. detachControl(element: Nullable<HTMLElement>): void;
  111704. /**
  111705. * Gets the class name of the current input.
  111706. * @returns the class name
  111707. */
  111708. getClassName(): string;
  111709. /**
  111710. * Get the friendly name associated with the input class.
  111711. * @returns the input friendly name
  111712. */
  111713. getSimpleName(): string;
  111714. /**
  111715. * Called on pointer POINTERDOUBLETAP event.
  111716. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111717. */
  111718. protected onDoubleTap(type: string): void;
  111719. /**
  111720. * Called on pointer POINTERMOVE event if only a single touch is active.
  111721. * Override this method to provide functionality.
  111722. */
  111723. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111724. /**
  111725. * Called on pointer POINTERMOVE event if multiple touches are active.
  111726. * Override this method to provide functionality.
  111727. */
  111728. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111729. /**
  111730. * Called on JS contextmenu event.
  111731. * Override this method to provide functionality.
  111732. */
  111733. protected onContextMenu(evt: PointerEvent): void;
  111734. /**
  111735. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111736. * press.
  111737. * Override this method to provide functionality.
  111738. */
  111739. protected onButtonDown(evt: PointerEvent): void;
  111740. /**
  111741. * Called each time a new POINTERUP event occurs. Ie, for each button
  111742. * release.
  111743. * Override this method to provide functionality.
  111744. */
  111745. protected onButtonUp(evt: PointerEvent): void;
  111746. /**
  111747. * Called when window becomes inactive.
  111748. * Override this method to provide functionality.
  111749. */
  111750. protected onLostFocus(): void;
  111751. private _pointerInput;
  111752. private _observer;
  111753. private _onLostFocus;
  111754. private pointA;
  111755. private pointB;
  111756. }
  111757. }
  111758. declare module BABYLON {
  111759. /**
  111760. * Manage the pointers inputs to control an arc rotate camera.
  111761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111762. */
  111763. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111764. /**
  111765. * Defines the camera the input is attached to.
  111766. */
  111767. camera: ArcRotateCamera;
  111768. /**
  111769. * Gets the class name of the current input.
  111770. * @returns the class name
  111771. */
  111772. getClassName(): string;
  111773. /**
  111774. * Defines the buttons associated with the input to handle camera move.
  111775. */
  111776. buttons: number[];
  111777. /**
  111778. * Defines the pointer angular sensibility along the X axis or how fast is
  111779. * the camera rotating.
  111780. */
  111781. angularSensibilityX: number;
  111782. /**
  111783. * Defines the pointer angular sensibility along the Y axis or how fast is
  111784. * the camera rotating.
  111785. */
  111786. angularSensibilityY: number;
  111787. /**
  111788. * Defines the pointer pinch precision or how fast is the camera zooming.
  111789. */
  111790. pinchPrecision: number;
  111791. /**
  111792. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111793. * from 0.
  111794. * It defines the percentage of current camera.radius to use as delta when
  111795. * pinch zoom is used.
  111796. */
  111797. pinchDeltaPercentage: number;
  111798. /**
  111799. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111800. * that any object in the plane at the camera's target point will scale
  111801. * perfectly with finger motion.
  111802. * Overrides pinchDeltaPercentage and pinchPrecision.
  111803. */
  111804. useNaturalPinchZoom: boolean;
  111805. /**
  111806. * Defines the pointer panning sensibility or how fast is the camera moving.
  111807. */
  111808. panningSensibility: number;
  111809. /**
  111810. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111811. */
  111812. multiTouchPanning: boolean;
  111813. /**
  111814. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111815. * zoom (pinch) through multitouch.
  111816. */
  111817. multiTouchPanAndZoom: boolean;
  111818. /**
  111819. * Revers pinch action direction.
  111820. */
  111821. pinchInwards: boolean;
  111822. private _isPanClick;
  111823. private _twoFingerActivityCount;
  111824. private _isPinching;
  111825. /**
  111826. * Called on pointer POINTERMOVE event if only a single touch is active.
  111827. */
  111828. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111829. /**
  111830. * Called on pointer POINTERDOUBLETAP event.
  111831. */
  111832. protected onDoubleTap(type: string): void;
  111833. /**
  111834. * Called on pointer POINTERMOVE event if multiple touches are active.
  111835. */
  111836. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111837. /**
  111838. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111839. * press.
  111840. */
  111841. protected onButtonDown(evt: PointerEvent): void;
  111842. /**
  111843. * Called each time a new POINTERUP event occurs. Ie, for each button
  111844. * release.
  111845. */
  111846. protected onButtonUp(evt: PointerEvent): void;
  111847. /**
  111848. * Called when window becomes inactive.
  111849. */
  111850. protected onLostFocus(): void;
  111851. }
  111852. }
  111853. declare module BABYLON {
  111854. /**
  111855. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111857. */
  111858. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111859. /**
  111860. * Defines the camera the input is attached to.
  111861. */
  111862. camera: ArcRotateCamera;
  111863. /**
  111864. * Defines the list of key codes associated with the up action (increase alpha)
  111865. */
  111866. keysUp: number[];
  111867. /**
  111868. * Defines the list of key codes associated with the down action (decrease alpha)
  111869. */
  111870. keysDown: number[];
  111871. /**
  111872. * Defines the list of key codes associated with the left action (increase beta)
  111873. */
  111874. keysLeft: number[];
  111875. /**
  111876. * Defines the list of key codes associated with the right action (decrease beta)
  111877. */
  111878. keysRight: number[];
  111879. /**
  111880. * Defines the list of key codes associated with the reset action.
  111881. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111882. */
  111883. keysReset: number[];
  111884. /**
  111885. * Defines the panning sensibility of the inputs.
  111886. * (How fast is the camera panning)
  111887. */
  111888. panningSensibility: number;
  111889. /**
  111890. * Defines the zooming sensibility of the inputs.
  111891. * (How fast is the camera zooming)
  111892. */
  111893. zoomingSensibility: number;
  111894. /**
  111895. * Defines whether maintaining the alt key down switch the movement mode from
  111896. * orientation to zoom.
  111897. */
  111898. useAltToZoom: boolean;
  111899. /**
  111900. * Rotation speed of the camera
  111901. */
  111902. angularSpeed: number;
  111903. private _keys;
  111904. private _ctrlPressed;
  111905. private _altPressed;
  111906. private _onCanvasBlurObserver;
  111907. private _onKeyboardObserver;
  111908. private _engine;
  111909. private _scene;
  111910. /**
  111911. * Attach the input controls to a specific dom element to get the input from.
  111912. * @param element Defines the element the controls should be listened from
  111913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111914. */
  111915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111916. /**
  111917. * Detach the current controls from the specified dom element.
  111918. * @param element Defines the element to stop listening the inputs from
  111919. */
  111920. detachControl(element: Nullable<HTMLElement>): void;
  111921. /**
  111922. * Update the current camera state depending on the inputs that have been used this frame.
  111923. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111924. */
  111925. checkInputs(): void;
  111926. /**
  111927. * Gets the class name of the current intput.
  111928. * @returns the class name
  111929. */
  111930. getClassName(): string;
  111931. /**
  111932. * Get the friendly name associated with the input class.
  111933. * @returns the input friendly name
  111934. */
  111935. getSimpleName(): string;
  111936. }
  111937. }
  111938. declare module BABYLON {
  111939. /**
  111940. * Manage the mouse wheel inputs to control an arc rotate camera.
  111941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111942. */
  111943. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111944. /**
  111945. * Defines the camera the input is attached to.
  111946. */
  111947. camera: ArcRotateCamera;
  111948. /**
  111949. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111950. */
  111951. wheelPrecision: number;
  111952. /**
  111953. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111954. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111955. */
  111956. wheelDeltaPercentage: number;
  111957. private _wheel;
  111958. private _observer;
  111959. private computeDeltaFromMouseWheelLegacyEvent;
  111960. /**
  111961. * Attach the input controls to a specific dom element to get the input from.
  111962. * @param element Defines the element the controls should be listened from
  111963. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111964. */
  111965. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111966. /**
  111967. * Detach the current controls from the specified dom element.
  111968. * @param element Defines the element to stop listening the inputs from
  111969. */
  111970. detachControl(element: Nullable<HTMLElement>): void;
  111971. /**
  111972. * Gets the class name of the current intput.
  111973. * @returns the class name
  111974. */
  111975. getClassName(): string;
  111976. /**
  111977. * Get the friendly name associated with the input class.
  111978. * @returns the input friendly name
  111979. */
  111980. getSimpleName(): string;
  111981. }
  111982. }
  111983. declare module BABYLON {
  111984. /**
  111985. * Default Inputs manager for the ArcRotateCamera.
  111986. * It groups all the default supported inputs for ease of use.
  111987. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111988. */
  111989. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111990. /**
  111991. * Instantiates a new ArcRotateCameraInputsManager.
  111992. * @param camera Defines the camera the inputs belong to
  111993. */
  111994. constructor(camera: ArcRotateCamera);
  111995. /**
  111996. * Add mouse wheel input support to the input manager.
  111997. * @returns the current input manager
  111998. */
  111999. addMouseWheel(): ArcRotateCameraInputsManager;
  112000. /**
  112001. * Add pointers input support to the input manager.
  112002. * @returns the current input manager
  112003. */
  112004. addPointers(): ArcRotateCameraInputsManager;
  112005. /**
  112006. * Add keyboard input support to the input manager.
  112007. * @returns the current input manager
  112008. */
  112009. addKeyboard(): ArcRotateCameraInputsManager;
  112010. }
  112011. }
  112012. declare module BABYLON {
  112013. /**
  112014. * This represents an orbital type of camera.
  112015. *
  112016. * 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.
  112017. * 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.
  112018. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  112019. */
  112020. export class ArcRotateCamera extends TargetCamera {
  112021. /**
  112022. * Defines the rotation angle of the camera along the longitudinal axis.
  112023. */
  112024. alpha: number;
  112025. /**
  112026. * Defines the rotation angle of the camera along the latitudinal axis.
  112027. */
  112028. beta: number;
  112029. /**
  112030. * Defines the radius of the camera from it s target point.
  112031. */
  112032. radius: number;
  112033. protected _target: Vector3;
  112034. protected _targetHost: Nullable<AbstractMesh>;
  112035. /**
  112036. * Defines the target point of the camera.
  112037. * The camera looks towards it form the radius distance.
  112038. */
  112039. get target(): Vector3;
  112040. set target(value: Vector3);
  112041. /**
  112042. * Define the current local position of the camera in the scene
  112043. */
  112044. get position(): Vector3;
  112045. set position(newPosition: Vector3);
  112046. protected _upVector: Vector3;
  112047. protected _upToYMatrix: Matrix;
  112048. protected _YToUpMatrix: Matrix;
  112049. /**
  112050. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  112051. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  112052. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  112053. */
  112054. set upVector(vec: Vector3);
  112055. get upVector(): Vector3;
  112056. /**
  112057. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  112058. */
  112059. setMatUp(): void;
  112060. /**
  112061. * Current inertia value on the longitudinal axis.
  112062. * The bigger this number the longer it will take for the camera to stop.
  112063. */
  112064. inertialAlphaOffset: number;
  112065. /**
  112066. * Current inertia value on the latitudinal axis.
  112067. * The bigger this number the longer it will take for the camera to stop.
  112068. */
  112069. inertialBetaOffset: number;
  112070. /**
  112071. * Current inertia value on the radius axis.
  112072. * The bigger this number the longer it will take for the camera to stop.
  112073. */
  112074. inertialRadiusOffset: number;
  112075. /**
  112076. * Minimum allowed angle on the longitudinal axis.
  112077. * This can help limiting how the Camera is able to move in the scene.
  112078. */
  112079. lowerAlphaLimit: Nullable<number>;
  112080. /**
  112081. * Maximum allowed angle on the longitudinal axis.
  112082. * This can help limiting how the Camera is able to move in the scene.
  112083. */
  112084. upperAlphaLimit: Nullable<number>;
  112085. /**
  112086. * Minimum allowed angle on the latitudinal axis.
  112087. * This can help limiting how the Camera is able to move in the scene.
  112088. */
  112089. lowerBetaLimit: number;
  112090. /**
  112091. * Maximum allowed angle on the latitudinal axis.
  112092. * This can help limiting how the Camera is able to move in the scene.
  112093. */
  112094. upperBetaLimit: number;
  112095. /**
  112096. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  112097. * This can help limiting how the Camera is able to move in the scene.
  112098. */
  112099. lowerRadiusLimit: Nullable<number>;
  112100. /**
  112101. * Maximum allowed distance of the camera to the target (The camera can not get further).
  112102. * This can help limiting how the Camera is able to move in the scene.
  112103. */
  112104. upperRadiusLimit: Nullable<number>;
  112105. /**
  112106. * Defines the current inertia value used during panning of the camera along the X axis.
  112107. */
  112108. inertialPanningX: number;
  112109. /**
  112110. * Defines the current inertia value used during panning of the camera along the Y axis.
  112111. */
  112112. inertialPanningY: number;
  112113. /**
  112114. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  112115. * Basically if your fingers moves away from more than this distance you will be considered
  112116. * in pinch mode.
  112117. */
  112118. pinchToPanMaxDistance: number;
  112119. /**
  112120. * Defines the maximum distance the camera can pan.
  112121. * This could help keeping the cammera always in your scene.
  112122. */
  112123. panningDistanceLimit: Nullable<number>;
  112124. /**
  112125. * Defines the target of the camera before paning.
  112126. */
  112127. panningOriginTarget: Vector3;
  112128. /**
  112129. * Defines the value of the inertia used during panning.
  112130. * 0 would mean stop inertia and one would mean no decelleration at all.
  112131. */
  112132. panningInertia: number;
  112133. /**
  112134. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  112135. */
  112136. get angularSensibilityX(): number;
  112137. set angularSensibilityX(value: number);
  112138. /**
  112139. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  112140. */
  112141. get angularSensibilityY(): number;
  112142. set angularSensibilityY(value: number);
  112143. /**
  112144. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  112145. */
  112146. get pinchPrecision(): number;
  112147. set pinchPrecision(value: number);
  112148. /**
  112149. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  112150. * It will be used instead of pinchDeltaPrecision if different from 0.
  112151. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112152. */
  112153. get pinchDeltaPercentage(): number;
  112154. set pinchDeltaPercentage(value: number);
  112155. /**
  112156. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  112157. * and pinch delta percentage.
  112158. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  112159. * that any object in the plane at the camera's target point will scale
  112160. * perfectly with finger motion.
  112161. */
  112162. get useNaturalPinchZoom(): boolean;
  112163. set useNaturalPinchZoom(value: boolean);
  112164. /**
  112165. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  112166. */
  112167. get panningSensibility(): number;
  112168. set panningSensibility(value: number);
  112169. /**
  112170. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  112171. */
  112172. get keysUp(): number[];
  112173. set keysUp(value: number[]);
  112174. /**
  112175. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  112176. */
  112177. get keysDown(): number[];
  112178. set keysDown(value: number[]);
  112179. /**
  112180. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  112181. */
  112182. get keysLeft(): number[];
  112183. set keysLeft(value: number[]);
  112184. /**
  112185. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  112186. */
  112187. get keysRight(): number[];
  112188. set keysRight(value: number[]);
  112189. /**
  112190. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  112191. */
  112192. get wheelPrecision(): number;
  112193. set wheelPrecision(value: number);
  112194. /**
  112195. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  112196. * It will be used instead of pinchDeltaPrecision if different from 0.
  112197. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112198. */
  112199. get wheelDeltaPercentage(): number;
  112200. set wheelDeltaPercentage(value: number);
  112201. /**
  112202. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  112203. */
  112204. zoomOnFactor: number;
  112205. /**
  112206. * Defines a screen offset for the camera position.
  112207. */
  112208. targetScreenOffset: Vector2;
  112209. /**
  112210. * Allows the camera to be completely reversed.
  112211. * If false the camera can not arrive upside down.
  112212. */
  112213. allowUpsideDown: boolean;
  112214. /**
  112215. * Define if double tap/click is used to restore the previously saved state of the camera.
  112216. */
  112217. useInputToRestoreState: boolean;
  112218. /** @hidden */
  112219. _viewMatrix: Matrix;
  112220. /** @hidden */
  112221. _useCtrlForPanning: boolean;
  112222. /** @hidden */
  112223. _panningMouseButton: number;
  112224. /**
  112225. * Defines the input associated to the camera.
  112226. */
  112227. inputs: ArcRotateCameraInputsManager;
  112228. /** @hidden */
  112229. _reset: () => void;
  112230. /**
  112231. * Defines the allowed panning axis.
  112232. */
  112233. panningAxis: Vector3;
  112234. protected _localDirection: Vector3;
  112235. protected _transformedDirection: Vector3;
  112236. private _bouncingBehavior;
  112237. /**
  112238. * Gets the bouncing behavior of the camera if it has been enabled.
  112239. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112240. */
  112241. get bouncingBehavior(): Nullable<BouncingBehavior>;
  112242. /**
  112243. * Defines if the bouncing behavior of the camera is enabled on the camera.
  112244. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112245. */
  112246. get useBouncingBehavior(): boolean;
  112247. set useBouncingBehavior(value: boolean);
  112248. private _framingBehavior;
  112249. /**
  112250. * Gets the framing behavior of the camera if it has been enabled.
  112251. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112252. */
  112253. get framingBehavior(): Nullable<FramingBehavior>;
  112254. /**
  112255. * Defines if the framing behavior of the camera is enabled on the camera.
  112256. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112257. */
  112258. get useFramingBehavior(): boolean;
  112259. set useFramingBehavior(value: boolean);
  112260. private _autoRotationBehavior;
  112261. /**
  112262. * Gets the auto rotation behavior of the camera if it has been enabled.
  112263. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112264. */
  112265. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  112266. /**
  112267. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  112268. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112269. */
  112270. get useAutoRotationBehavior(): boolean;
  112271. set useAutoRotationBehavior(value: boolean);
  112272. /**
  112273. * Observable triggered when the mesh target has been changed on the camera.
  112274. */
  112275. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112276. /**
  112277. * Event raised when the camera is colliding with a mesh.
  112278. */
  112279. onCollide: (collidedMesh: AbstractMesh) => void;
  112280. /**
  112281. * Defines whether the camera should check collision with the objects oh the scene.
  112282. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112283. */
  112284. checkCollisions: boolean;
  112285. /**
  112286. * Defines the collision radius of the camera.
  112287. * This simulates a sphere around the camera.
  112288. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112289. */
  112290. collisionRadius: Vector3;
  112291. protected _collider: Collider;
  112292. protected _previousPosition: Vector3;
  112293. protected _collisionVelocity: Vector3;
  112294. protected _newPosition: Vector3;
  112295. protected _previousAlpha: number;
  112296. protected _previousBeta: number;
  112297. protected _previousRadius: number;
  112298. protected _collisionTriggered: boolean;
  112299. protected _targetBoundingCenter: Nullable<Vector3>;
  112300. private _computationVector;
  112301. /**
  112302. * Instantiates a new ArcRotateCamera in a given scene
  112303. * @param name Defines the name of the camera
  112304. * @param alpha Defines the camera rotation along the logitudinal axis
  112305. * @param beta Defines the camera rotation along the latitudinal axis
  112306. * @param radius Defines the camera distance from its target
  112307. * @param target Defines the camera target
  112308. * @param scene Defines the scene the camera belongs to
  112309. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112310. */
  112311. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112312. /** @hidden */
  112313. _initCache(): void;
  112314. /** @hidden */
  112315. _updateCache(ignoreParentClass?: boolean): void;
  112316. protected _getTargetPosition(): Vector3;
  112317. private _storedAlpha;
  112318. private _storedBeta;
  112319. private _storedRadius;
  112320. private _storedTarget;
  112321. private _storedTargetScreenOffset;
  112322. /**
  112323. * Stores the current state of the camera (alpha, beta, radius and target)
  112324. * @returns the camera itself
  112325. */
  112326. storeState(): Camera;
  112327. /**
  112328. * @hidden
  112329. * Restored camera state. You must call storeState() first
  112330. */
  112331. _restoreStateValues(): boolean;
  112332. /** @hidden */
  112333. _isSynchronizedViewMatrix(): boolean;
  112334. /**
  112335. * Attached controls to the current camera.
  112336. * @param element Defines the element the controls should be listened from
  112337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112338. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112339. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112340. */
  112341. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112342. /**
  112343. * Detach the current controls from the camera.
  112344. * The camera will stop reacting to inputs.
  112345. * @param element Defines the element to stop listening the inputs from
  112346. */
  112347. detachControl(element: HTMLElement): void;
  112348. /** @hidden */
  112349. _checkInputs(): void;
  112350. protected _checkLimits(): void;
  112351. /**
  112352. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112353. */
  112354. rebuildAnglesAndRadius(): void;
  112355. /**
  112356. * Use a position to define the current camera related information like alpha, beta and radius
  112357. * @param position Defines the position to set the camera at
  112358. */
  112359. setPosition(position: Vector3): void;
  112360. /**
  112361. * Defines the target the camera should look at.
  112362. * This will automatically adapt alpha beta and radius to fit within the new target.
  112363. * @param target Defines the new target as a Vector or a mesh
  112364. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112365. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112366. */
  112367. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112368. /** @hidden */
  112369. _getViewMatrix(): Matrix;
  112370. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112371. /**
  112372. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112373. * @param meshes Defines the mesh to zoom on
  112374. * @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)
  112375. */
  112376. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112377. /**
  112378. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112379. * The target will be changed but the radius
  112380. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112381. * @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)
  112382. */
  112383. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112384. min: Vector3;
  112385. max: Vector3;
  112386. distance: number;
  112387. }, doNotUpdateMaxZ?: boolean): void;
  112388. /**
  112389. * @override
  112390. * Override Camera.createRigCamera
  112391. */
  112392. createRigCamera(name: string, cameraIndex: number): Camera;
  112393. /**
  112394. * @hidden
  112395. * @override
  112396. * Override Camera._updateRigCameras
  112397. */
  112398. _updateRigCameras(): void;
  112399. /**
  112400. * Destroy the camera and release the current resources hold by it.
  112401. */
  112402. dispose(): void;
  112403. /**
  112404. * Gets the current object class name.
  112405. * @return the class name
  112406. */
  112407. getClassName(): string;
  112408. }
  112409. }
  112410. declare module BABYLON {
  112411. /**
  112412. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112414. */
  112415. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112416. /**
  112417. * Gets the name of the behavior.
  112418. */
  112419. get name(): string;
  112420. private _zoomStopsAnimation;
  112421. private _idleRotationSpeed;
  112422. private _idleRotationWaitTime;
  112423. private _idleRotationSpinupTime;
  112424. /**
  112425. * Sets the flag that indicates if user zooming should stop animation.
  112426. */
  112427. set zoomStopsAnimation(flag: boolean);
  112428. /**
  112429. * Gets the flag that indicates if user zooming should stop animation.
  112430. */
  112431. get zoomStopsAnimation(): boolean;
  112432. /**
  112433. * Sets the default speed at which the camera rotates around the model.
  112434. */
  112435. set idleRotationSpeed(speed: number);
  112436. /**
  112437. * Gets the default speed at which the camera rotates around the model.
  112438. */
  112439. get idleRotationSpeed(): number;
  112440. /**
  112441. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112442. */
  112443. set idleRotationWaitTime(time: number);
  112444. /**
  112445. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112446. */
  112447. get idleRotationWaitTime(): number;
  112448. /**
  112449. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112450. */
  112451. set idleRotationSpinupTime(time: number);
  112452. /**
  112453. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112454. */
  112455. get idleRotationSpinupTime(): number;
  112456. /**
  112457. * Gets a value indicating if the camera is currently rotating because of this behavior
  112458. */
  112459. get rotationInProgress(): boolean;
  112460. private _onPrePointerObservableObserver;
  112461. private _onAfterCheckInputsObserver;
  112462. private _attachedCamera;
  112463. private _isPointerDown;
  112464. private _lastFrameTime;
  112465. private _lastInteractionTime;
  112466. private _cameraRotationSpeed;
  112467. /**
  112468. * Initializes the behavior.
  112469. */
  112470. init(): void;
  112471. /**
  112472. * Attaches the behavior to its arc rotate camera.
  112473. * @param camera Defines the camera to attach the behavior to
  112474. */
  112475. attach(camera: ArcRotateCamera): void;
  112476. /**
  112477. * Detaches the behavior from its current arc rotate camera.
  112478. */
  112479. detach(): void;
  112480. /**
  112481. * Returns true if user is scrolling.
  112482. * @return true if user is scrolling.
  112483. */
  112484. private _userIsZooming;
  112485. private _lastFrameRadius;
  112486. private _shouldAnimationStopForInteraction;
  112487. /**
  112488. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112489. */
  112490. private _applyUserInteraction;
  112491. private _userIsMoving;
  112492. }
  112493. }
  112494. declare module BABYLON {
  112495. /**
  112496. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112497. */
  112498. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112499. private ui;
  112500. /**
  112501. * The name of the behavior
  112502. */
  112503. name: string;
  112504. /**
  112505. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112506. */
  112507. distanceAwayFromFace: number;
  112508. /**
  112509. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112510. */
  112511. distanceAwayFromBottomOfFace: number;
  112512. private _faceVectors;
  112513. private _target;
  112514. private _scene;
  112515. private _onRenderObserver;
  112516. private _tmpMatrix;
  112517. private _tmpVector;
  112518. /**
  112519. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112520. * @param ui The transform node that should be attched to the mesh
  112521. */
  112522. constructor(ui: TransformNode);
  112523. /**
  112524. * Initializes the behavior
  112525. */
  112526. init(): void;
  112527. private _closestFace;
  112528. private _zeroVector;
  112529. private _lookAtTmpMatrix;
  112530. private _lookAtToRef;
  112531. /**
  112532. * Attaches the AttachToBoxBehavior to the passed in mesh
  112533. * @param target The mesh that the specified node will be attached to
  112534. */
  112535. attach(target: Mesh): void;
  112536. /**
  112537. * Detaches the behavior from the mesh
  112538. */
  112539. detach(): void;
  112540. }
  112541. }
  112542. declare module BABYLON {
  112543. /**
  112544. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112545. */
  112546. export class FadeInOutBehavior implements Behavior<Mesh> {
  112547. /**
  112548. * Time in milliseconds to delay before fading in (Default: 0)
  112549. */
  112550. delay: number;
  112551. /**
  112552. * Time in milliseconds for the mesh to fade in (Default: 300)
  112553. */
  112554. fadeInTime: number;
  112555. private _millisecondsPerFrame;
  112556. private _hovered;
  112557. private _hoverValue;
  112558. private _ownerNode;
  112559. /**
  112560. * Instatiates the FadeInOutBehavior
  112561. */
  112562. constructor();
  112563. /**
  112564. * The name of the behavior
  112565. */
  112566. get name(): string;
  112567. /**
  112568. * Initializes the behavior
  112569. */
  112570. init(): void;
  112571. /**
  112572. * Attaches the fade behavior on the passed in mesh
  112573. * @param ownerNode The mesh that will be faded in/out once attached
  112574. */
  112575. attach(ownerNode: Mesh): void;
  112576. /**
  112577. * Detaches the behavior from the mesh
  112578. */
  112579. detach(): void;
  112580. /**
  112581. * Triggers the mesh to begin fading in or out
  112582. * @param value if the object should fade in or out (true to fade in)
  112583. */
  112584. fadeIn(value: boolean): void;
  112585. private _update;
  112586. private _setAllVisibility;
  112587. }
  112588. }
  112589. declare module BABYLON {
  112590. /**
  112591. * Class containing a set of static utilities functions for managing Pivots
  112592. * @hidden
  112593. */
  112594. export class PivotTools {
  112595. private static _PivotCached;
  112596. private static _OldPivotPoint;
  112597. private static _PivotTranslation;
  112598. private static _PivotTmpVector;
  112599. /** @hidden */
  112600. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112601. /** @hidden */
  112602. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112603. }
  112604. }
  112605. declare module BABYLON {
  112606. /**
  112607. * Class containing static functions to help procedurally build meshes
  112608. */
  112609. export class PlaneBuilder {
  112610. /**
  112611. * Creates a plane mesh
  112612. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112613. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112614. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112618. * @param name defines the name of the mesh
  112619. * @param options defines the options used to create the mesh
  112620. * @param scene defines the hosting scene
  112621. * @returns the plane mesh
  112622. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112623. */
  112624. static CreatePlane(name: string, options: {
  112625. size?: number;
  112626. width?: number;
  112627. height?: number;
  112628. sideOrientation?: number;
  112629. frontUVs?: Vector4;
  112630. backUVs?: Vector4;
  112631. updatable?: boolean;
  112632. sourcePlane?: Plane;
  112633. }, scene?: Nullable<Scene>): Mesh;
  112634. }
  112635. }
  112636. declare module BABYLON {
  112637. /**
  112638. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112639. */
  112640. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112641. private static _AnyMouseID;
  112642. /**
  112643. * Abstract mesh the behavior is set on
  112644. */
  112645. attachedNode: AbstractMesh;
  112646. private _dragPlane;
  112647. private _scene;
  112648. private _pointerObserver;
  112649. private _beforeRenderObserver;
  112650. private static _planeScene;
  112651. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112652. /**
  112653. * 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)
  112654. */
  112655. maxDragAngle: number;
  112656. /**
  112657. * @hidden
  112658. */
  112659. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112660. /**
  112661. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112662. */
  112663. currentDraggingPointerID: number;
  112664. /**
  112665. * The last position where the pointer hit the drag plane in world space
  112666. */
  112667. lastDragPosition: Vector3;
  112668. /**
  112669. * If the behavior is currently in a dragging state
  112670. */
  112671. dragging: boolean;
  112672. /**
  112673. * 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)
  112674. */
  112675. dragDeltaRatio: number;
  112676. /**
  112677. * If the drag plane orientation should be updated during the dragging (Default: true)
  112678. */
  112679. updateDragPlane: boolean;
  112680. private _debugMode;
  112681. private _moving;
  112682. /**
  112683. * Fires each time the attached mesh is dragged with the pointer
  112684. * * delta between last drag position and current drag position in world space
  112685. * * dragDistance along the drag axis
  112686. * * dragPlaneNormal normal of the current drag plane used during the drag
  112687. * * dragPlanePoint in world space where the drag intersects the drag plane
  112688. */
  112689. onDragObservable: Observable<{
  112690. delta: Vector3;
  112691. dragPlanePoint: Vector3;
  112692. dragPlaneNormal: Vector3;
  112693. dragDistance: number;
  112694. pointerId: number;
  112695. }>;
  112696. /**
  112697. * Fires each time a drag begins (eg. mouse down on mesh)
  112698. */
  112699. onDragStartObservable: Observable<{
  112700. dragPlanePoint: Vector3;
  112701. pointerId: number;
  112702. }>;
  112703. /**
  112704. * Fires each time a drag ends (eg. mouse release after drag)
  112705. */
  112706. onDragEndObservable: Observable<{
  112707. dragPlanePoint: Vector3;
  112708. pointerId: number;
  112709. }>;
  112710. /**
  112711. * If the attached mesh should be moved when dragged
  112712. */
  112713. moveAttached: boolean;
  112714. /**
  112715. * If the drag behavior will react to drag events (Default: true)
  112716. */
  112717. enabled: boolean;
  112718. /**
  112719. * If pointer events should start and release the drag (Default: true)
  112720. */
  112721. startAndReleaseDragOnPointerEvents: boolean;
  112722. /**
  112723. * If camera controls should be detached during the drag
  112724. */
  112725. detachCameraControls: boolean;
  112726. /**
  112727. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112728. */
  112729. useObjectOrientationForDragging: boolean;
  112730. private _options;
  112731. /**
  112732. * Gets the options used by the behavior
  112733. */
  112734. get options(): {
  112735. dragAxis?: Vector3;
  112736. dragPlaneNormal?: Vector3;
  112737. };
  112738. /**
  112739. * Sets the options used by the behavior
  112740. */
  112741. set options(options: {
  112742. dragAxis?: Vector3;
  112743. dragPlaneNormal?: Vector3;
  112744. });
  112745. /**
  112746. * Creates a pointer drag behavior that can be attached to a mesh
  112747. * @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)
  112748. */
  112749. constructor(options?: {
  112750. dragAxis?: Vector3;
  112751. dragPlaneNormal?: Vector3;
  112752. });
  112753. /**
  112754. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112755. */
  112756. validateDrag: (targetPosition: Vector3) => boolean;
  112757. /**
  112758. * The name of the behavior
  112759. */
  112760. get name(): string;
  112761. /**
  112762. * Initializes the behavior
  112763. */
  112764. init(): void;
  112765. private _tmpVector;
  112766. private _alternatePickedPoint;
  112767. private _worldDragAxis;
  112768. private _targetPosition;
  112769. private _attachedElement;
  112770. /**
  112771. * Attaches the drag behavior the passed in mesh
  112772. * @param ownerNode The mesh that will be dragged around once attached
  112773. * @param predicate Predicate to use for pick filtering
  112774. */
  112775. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112776. /**
  112777. * Force relase the drag action by code.
  112778. */
  112779. releaseDrag(): void;
  112780. private _startDragRay;
  112781. private _lastPointerRay;
  112782. /**
  112783. * Simulates the start of a pointer drag event on the behavior
  112784. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112785. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112786. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112787. */
  112788. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112789. private _startDrag;
  112790. private _dragDelta;
  112791. private _moveDrag;
  112792. private _pickWithRayOnDragPlane;
  112793. private _pointA;
  112794. private _pointB;
  112795. private _pointC;
  112796. private _lineA;
  112797. private _lineB;
  112798. private _localAxis;
  112799. private _lookAt;
  112800. private _updateDragPlanePosition;
  112801. /**
  112802. * Detaches the behavior from the mesh
  112803. */
  112804. detach(): void;
  112805. }
  112806. }
  112807. declare module BABYLON {
  112808. /**
  112809. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112810. */
  112811. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112812. private _dragBehaviorA;
  112813. private _dragBehaviorB;
  112814. private _startDistance;
  112815. private _initialScale;
  112816. private _targetScale;
  112817. private _ownerNode;
  112818. private _sceneRenderObserver;
  112819. /**
  112820. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112821. */
  112822. constructor();
  112823. /**
  112824. * The name of the behavior
  112825. */
  112826. get name(): string;
  112827. /**
  112828. * Initializes the behavior
  112829. */
  112830. init(): void;
  112831. private _getCurrentDistance;
  112832. /**
  112833. * Attaches the scale behavior the passed in mesh
  112834. * @param ownerNode The mesh that will be scaled around once attached
  112835. */
  112836. attach(ownerNode: Mesh): void;
  112837. /**
  112838. * Detaches the behavior from the mesh
  112839. */
  112840. detach(): void;
  112841. }
  112842. }
  112843. declare module BABYLON {
  112844. /**
  112845. * 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
  112846. */
  112847. export class SixDofDragBehavior implements Behavior<Mesh> {
  112848. private static _virtualScene;
  112849. private _ownerNode;
  112850. private _sceneRenderObserver;
  112851. private _scene;
  112852. private _targetPosition;
  112853. private _virtualOriginMesh;
  112854. private _virtualDragMesh;
  112855. private _pointerObserver;
  112856. private _moving;
  112857. private _startingOrientation;
  112858. /**
  112859. * 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)
  112860. */
  112861. private zDragFactor;
  112862. /**
  112863. * If the object should rotate to face the drag origin
  112864. */
  112865. rotateDraggedObject: boolean;
  112866. /**
  112867. * If the behavior is currently in a dragging state
  112868. */
  112869. dragging: boolean;
  112870. /**
  112871. * 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)
  112872. */
  112873. dragDeltaRatio: number;
  112874. /**
  112875. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112876. */
  112877. currentDraggingPointerID: number;
  112878. /**
  112879. * If camera controls should be detached during the drag
  112880. */
  112881. detachCameraControls: boolean;
  112882. /**
  112883. * Fires each time a drag starts
  112884. */
  112885. onDragStartObservable: Observable<{}>;
  112886. /**
  112887. * Fires each time a drag ends (eg. mouse release after drag)
  112888. */
  112889. onDragEndObservable: Observable<{}>;
  112890. /**
  112891. * 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
  112892. */
  112893. constructor();
  112894. /**
  112895. * The name of the behavior
  112896. */
  112897. get name(): string;
  112898. /**
  112899. * Initializes the behavior
  112900. */
  112901. init(): void;
  112902. /**
  112903. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112904. */
  112905. private get _pointerCamera();
  112906. /**
  112907. * Attaches the scale behavior the passed in mesh
  112908. * @param ownerNode The mesh that will be scaled around once attached
  112909. */
  112910. attach(ownerNode: Mesh): void;
  112911. /**
  112912. * Detaches the behavior from the mesh
  112913. */
  112914. detach(): void;
  112915. }
  112916. }
  112917. declare module BABYLON {
  112918. /**
  112919. * Class used to apply inverse kinematics to bones
  112920. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112921. */
  112922. export class BoneIKController {
  112923. private static _tmpVecs;
  112924. private static _tmpQuat;
  112925. private static _tmpMats;
  112926. /**
  112927. * Gets or sets the target mesh
  112928. */
  112929. targetMesh: AbstractMesh;
  112930. /** Gets or sets the mesh used as pole */
  112931. poleTargetMesh: AbstractMesh;
  112932. /**
  112933. * Gets or sets the bone used as pole
  112934. */
  112935. poleTargetBone: Nullable<Bone>;
  112936. /**
  112937. * Gets or sets the target position
  112938. */
  112939. targetPosition: Vector3;
  112940. /**
  112941. * Gets or sets the pole target position
  112942. */
  112943. poleTargetPosition: Vector3;
  112944. /**
  112945. * Gets or sets the pole target local offset
  112946. */
  112947. poleTargetLocalOffset: Vector3;
  112948. /**
  112949. * Gets or sets the pole angle
  112950. */
  112951. poleAngle: number;
  112952. /**
  112953. * Gets or sets the mesh associated with the controller
  112954. */
  112955. mesh: AbstractMesh;
  112956. /**
  112957. * 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)
  112958. */
  112959. slerpAmount: number;
  112960. private _bone1Quat;
  112961. private _bone1Mat;
  112962. private _bone2Ang;
  112963. private _bone1;
  112964. private _bone2;
  112965. private _bone1Length;
  112966. private _bone2Length;
  112967. private _maxAngle;
  112968. private _maxReach;
  112969. private _rightHandedSystem;
  112970. private _bendAxis;
  112971. private _slerping;
  112972. private _adjustRoll;
  112973. /**
  112974. * Gets or sets maximum allowed angle
  112975. */
  112976. get maxAngle(): number;
  112977. set maxAngle(value: number);
  112978. /**
  112979. * Creates a new BoneIKController
  112980. * @param mesh defines the mesh to control
  112981. * @param bone defines the bone to control
  112982. * @param options defines options to set up the controller
  112983. */
  112984. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112985. targetMesh?: AbstractMesh;
  112986. poleTargetMesh?: AbstractMesh;
  112987. poleTargetBone?: Bone;
  112988. poleTargetLocalOffset?: Vector3;
  112989. poleAngle?: number;
  112990. bendAxis?: Vector3;
  112991. maxAngle?: number;
  112992. slerpAmount?: number;
  112993. });
  112994. private _setMaxAngle;
  112995. /**
  112996. * Force the controller to update the bones
  112997. */
  112998. update(): void;
  112999. }
  113000. }
  113001. declare module BABYLON {
  113002. /**
  113003. * Class used to make a bone look toward a point in space
  113004. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  113005. */
  113006. export class BoneLookController {
  113007. private static _tmpVecs;
  113008. private static _tmpQuat;
  113009. private static _tmpMats;
  113010. /**
  113011. * The target Vector3 that the bone will look at
  113012. */
  113013. target: Vector3;
  113014. /**
  113015. * The mesh that the bone is attached to
  113016. */
  113017. mesh: AbstractMesh;
  113018. /**
  113019. * The bone that will be looking to the target
  113020. */
  113021. bone: Bone;
  113022. /**
  113023. * The up axis of the coordinate system that is used when the bone is rotated
  113024. */
  113025. upAxis: Vector3;
  113026. /**
  113027. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  113028. */
  113029. upAxisSpace: Space;
  113030. /**
  113031. * Used to make an adjustment to the yaw of the bone
  113032. */
  113033. adjustYaw: number;
  113034. /**
  113035. * Used to make an adjustment to the pitch of the bone
  113036. */
  113037. adjustPitch: number;
  113038. /**
  113039. * Used to make an adjustment to the roll of the bone
  113040. */
  113041. adjustRoll: number;
  113042. /**
  113043. * 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)
  113044. */
  113045. slerpAmount: number;
  113046. private _minYaw;
  113047. private _maxYaw;
  113048. private _minPitch;
  113049. private _maxPitch;
  113050. private _minYawSin;
  113051. private _minYawCos;
  113052. private _maxYawSin;
  113053. private _maxYawCos;
  113054. private _midYawConstraint;
  113055. private _minPitchTan;
  113056. private _maxPitchTan;
  113057. private _boneQuat;
  113058. private _slerping;
  113059. private _transformYawPitch;
  113060. private _transformYawPitchInv;
  113061. private _firstFrameSkipped;
  113062. private _yawRange;
  113063. private _fowardAxis;
  113064. /**
  113065. * Gets or sets the minimum yaw angle that the bone can look to
  113066. */
  113067. get minYaw(): number;
  113068. set minYaw(value: number);
  113069. /**
  113070. * Gets or sets the maximum yaw angle that the bone can look to
  113071. */
  113072. get maxYaw(): number;
  113073. set maxYaw(value: number);
  113074. /**
  113075. * Gets or sets the minimum pitch angle that the bone can look to
  113076. */
  113077. get minPitch(): number;
  113078. set minPitch(value: number);
  113079. /**
  113080. * Gets or sets the maximum pitch angle that the bone can look to
  113081. */
  113082. get maxPitch(): number;
  113083. set maxPitch(value: number);
  113084. /**
  113085. * Create a BoneLookController
  113086. * @param mesh the mesh that the bone belongs to
  113087. * @param bone the bone that will be looking to the target
  113088. * @param target the target Vector3 to look at
  113089. * @param options optional settings:
  113090. * * maxYaw: the maximum angle the bone will yaw to
  113091. * * minYaw: the minimum angle the bone will yaw to
  113092. * * maxPitch: the maximum angle the bone will pitch to
  113093. * * minPitch: the minimum angle the bone will yaw to
  113094. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  113095. * * upAxis: the up axis of the coordinate system
  113096. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  113097. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  113098. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  113099. * * adjustYaw: used to make an adjustment to the yaw of the bone
  113100. * * adjustPitch: used to make an adjustment to the pitch of the bone
  113101. * * adjustRoll: used to make an adjustment to the roll of the bone
  113102. **/
  113103. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  113104. maxYaw?: number;
  113105. minYaw?: number;
  113106. maxPitch?: number;
  113107. minPitch?: number;
  113108. slerpAmount?: number;
  113109. upAxis?: Vector3;
  113110. upAxisSpace?: Space;
  113111. yawAxis?: Vector3;
  113112. pitchAxis?: Vector3;
  113113. adjustYaw?: number;
  113114. adjustPitch?: number;
  113115. adjustRoll?: number;
  113116. });
  113117. /**
  113118. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  113119. */
  113120. update(): void;
  113121. private _getAngleDiff;
  113122. private _getAngleBetween;
  113123. private _isAngleBetween;
  113124. }
  113125. }
  113126. declare module BABYLON {
  113127. /**
  113128. * Manage the gamepad inputs to control an arc rotate camera.
  113129. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113130. */
  113131. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  113132. /**
  113133. * Defines the camera the input is attached to.
  113134. */
  113135. camera: ArcRotateCamera;
  113136. /**
  113137. * Defines the gamepad the input is gathering event from.
  113138. */
  113139. gamepad: Nullable<Gamepad>;
  113140. /**
  113141. * Defines the gamepad rotation sensiblity.
  113142. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113143. */
  113144. gamepadRotationSensibility: number;
  113145. /**
  113146. * Defines the gamepad move sensiblity.
  113147. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113148. */
  113149. gamepadMoveSensibility: number;
  113150. private _yAxisScale;
  113151. /**
  113152. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113153. */
  113154. get invertYAxis(): boolean;
  113155. set invertYAxis(value: boolean);
  113156. private _onGamepadConnectedObserver;
  113157. private _onGamepadDisconnectedObserver;
  113158. /**
  113159. * Attach the input controls to a specific dom element to get the input from.
  113160. * @param element Defines the element the controls should be listened from
  113161. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113162. */
  113163. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113164. /**
  113165. * Detach the current controls from the specified dom element.
  113166. * @param element Defines the element to stop listening the inputs from
  113167. */
  113168. detachControl(element: Nullable<HTMLElement>): void;
  113169. /**
  113170. * Update the current camera state depending on the inputs that have been used this frame.
  113171. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113172. */
  113173. checkInputs(): void;
  113174. /**
  113175. * Gets the class name of the current intput.
  113176. * @returns the class name
  113177. */
  113178. getClassName(): string;
  113179. /**
  113180. * Get the friendly name associated with the input class.
  113181. * @returns the input friendly name
  113182. */
  113183. getSimpleName(): string;
  113184. }
  113185. }
  113186. declare module BABYLON {
  113187. interface ArcRotateCameraInputsManager {
  113188. /**
  113189. * Add orientation input support to the input manager.
  113190. * @returns the current input manager
  113191. */
  113192. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  113193. }
  113194. /**
  113195. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  113196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113197. */
  113198. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  113199. /**
  113200. * Defines the camera the input is attached to.
  113201. */
  113202. camera: ArcRotateCamera;
  113203. /**
  113204. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  113205. */
  113206. alphaCorrection: number;
  113207. /**
  113208. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  113209. */
  113210. gammaCorrection: number;
  113211. private _alpha;
  113212. private _gamma;
  113213. private _dirty;
  113214. private _deviceOrientationHandler;
  113215. /**
  113216. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  113217. */
  113218. constructor();
  113219. /**
  113220. * Attach the input controls to a specific dom element to get the input from.
  113221. * @param element Defines the element the controls should be listened from
  113222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113223. */
  113224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113225. /** @hidden */
  113226. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  113227. /**
  113228. * Update the current camera state depending on the inputs that have been used this frame.
  113229. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113230. */
  113231. checkInputs(): void;
  113232. /**
  113233. * Detach the current controls from the specified dom element.
  113234. * @param element Defines the element to stop listening the inputs from
  113235. */
  113236. detachControl(element: Nullable<HTMLElement>): void;
  113237. /**
  113238. * Gets the class name of the current intput.
  113239. * @returns the class name
  113240. */
  113241. getClassName(): string;
  113242. /**
  113243. * Get the friendly name associated with the input class.
  113244. * @returns the input friendly name
  113245. */
  113246. getSimpleName(): string;
  113247. }
  113248. }
  113249. declare module BABYLON {
  113250. /**
  113251. * Listen to mouse events to control the camera.
  113252. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113253. */
  113254. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  113255. /**
  113256. * Defines the camera the input is attached to.
  113257. */
  113258. camera: FlyCamera;
  113259. /**
  113260. * Defines if touch is enabled. (Default is true.)
  113261. */
  113262. touchEnabled: boolean;
  113263. /**
  113264. * Defines the buttons associated with the input to handle camera rotation.
  113265. */
  113266. buttons: number[];
  113267. /**
  113268. * Assign buttons for Yaw control.
  113269. */
  113270. buttonsYaw: number[];
  113271. /**
  113272. * Assign buttons for Pitch control.
  113273. */
  113274. buttonsPitch: number[];
  113275. /**
  113276. * Assign buttons for Roll control.
  113277. */
  113278. buttonsRoll: number[];
  113279. /**
  113280. * Detect if any button is being pressed while mouse is moved.
  113281. * -1 = Mouse locked.
  113282. * 0 = Left button.
  113283. * 1 = Middle Button.
  113284. * 2 = Right Button.
  113285. */
  113286. activeButton: number;
  113287. /**
  113288. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113289. * Higher values reduce its sensitivity.
  113290. */
  113291. angularSensibility: number;
  113292. private _mousemoveCallback;
  113293. private _observer;
  113294. private _rollObserver;
  113295. private previousPosition;
  113296. private noPreventDefault;
  113297. private element;
  113298. /**
  113299. * Listen to mouse events to control the camera.
  113300. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113301. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113302. */
  113303. constructor(touchEnabled?: boolean);
  113304. /**
  113305. * Attach the mouse control to the HTML DOM element.
  113306. * @param element Defines the element that listens to the input events.
  113307. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113308. */
  113309. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113310. /**
  113311. * Detach the current controls from the specified dom element.
  113312. * @param element Defines the element to stop listening the inputs from
  113313. */
  113314. detachControl(element: Nullable<HTMLElement>): void;
  113315. /**
  113316. * Gets the class name of the current input.
  113317. * @returns the class name.
  113318. */
  113319. getClassName(): string;
  113320. /**
  113321. * Get the friendly name associated with the input class.
  113322. * @returns the input's friendly name.
  113323. */
  113324. getSimpleName(): string;
  113325. private _pointerInput;
  113326. private _onMouseMove;
  113327. /**
  113328. * Rotate camera by mouse offset.
  113329. */
  113330. private rotateCamera;
  113331. }
  113332. }
  113333. declare module BABYLON {
  113334. /**
  113335. * Default Inputs manager for the FlyCamera.
  113336. * It groups all the default supported inputs for ease of use.
  113337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113338. */
  113339. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113340. /**
  113341. * Instantiates a new FlyCameraInputsManager.
  113342. * @param camera Defines the camera the inputs belong to.
  113343. */
  113344. constructor(camera: FlyCamera);
  113345. /**
  113346. * Add keyboard input support to the input manager.
  113347. * @returns the new FlyCameraKeyboardMoveInput().
  113348. */
  113349. addKeyboard(): FlyCameraInputsManager;
  113350. /**
  113351. * Add mouse input support to the input manager.
  113352. * @param touchEnabled Enable touch screen support.
  113353. * @returns the new FlyCameraMouseInput().
  113354. */
  113355. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113356. }
  113357. }
  113358. declare module BABYLON {
  113359. /**
  113360. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113361. * such as in a 3D Space Shooter or a Flight Simulator.
  113362. */
  113363. export class FlyCamera extends TargetCamera {
  113364. /**
  113365. * Define the collision ellipsoid of the camera.
  113366. * This is helpful for simulating a camera body, like a player's body.
  113367. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113368. */
  113369. ellipsoid: Vector3;
  113370. /**
  113371. * Define an offset for the position of the ellipsoid around the camera.
  113372. * This can be helpful if the camera is attached away from the player's body center,
  113373. * such as at its head.
  113374. */
  113375. ellipsoidOffset: Vector3;
  113376. /**
  113377. * Enable or disable collisions of the camera with the rest of the scene objects.
  113378. */
  113379. checkCollisions: boolean;
  113380. /**
  113381. * Enable or disable gravity on the camera.
  113382. */
  113383. applyGravity: boolean;
  113384. /**
  113385. * Define the current direction the camera is moving to.
  113386. */
  113387. cameraDirection: Vector3;
  113388. /**
  113389. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113390. * This overrides and empties cameraRotation.
  113391. */
  113392. rotationQuaternion: Quaternion;
  113393. /**
  113394. * Track Roll to maintain the wanted Rolling when looking around.
  113395. */
  113396. _trackRoll: number;
  113397. /**
  113398. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113399. */
  113400. rollCorrect: number;
  113401. /**
  113402. * Mimic a banked turn, Rolling the camera when Yawing.
  113403. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113404. */
  113405. bankedTurn: boolean;
  113406. /**
  113407. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113408. */
  113409. bankedTurnLimit: number;
  113410. /**
  113411. * Value of 0 disables the banked Roll.
  113412. * Value of 1 is equal to the Yaw angle in radians.
  113413. */
  113414. bankedTurnMultiplier: number;
  113415. /**
  113416. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113417. */
  113418. inputs: FlyCameraInputsManager;
  113419. /**
  113420. * Gets the input sensibility for mouse input.
  113421. * Higher values reduce sensitivity.
  113422. */
  113423. get angularSensibility(): number;
  113424. /**
  113425. * Sets the input sensibility for a mouse input.
  113426. * Higher values reduce sensitivity.
  113427. */
  113428. set angularSensibility(value: number);
  113429. /**
  113430. * Get the keys for camera movement forward.
  113431. */
  113432. get keysForward(): number[];
  113433. /**
  113434. * Set the keys for camera movement forward.
  113435. */
  113436. set keysForward(value: number[]);
  113437. /**
  113438. * Get the keys for camera movement backward.
  113439. */
  113440. get keysBackward(): number[];
  113441. set keysBackward(value: number[]);
  113442. /**
  113443. * Get the keys for camera movement up.
  113444. */
  113445. get keysUp(): number[];
  113446. /**
  113447. * Set the keys for camera movement up.
  113448. */
  113449. set keysUp(value: number[]);
  113450. /**
  113451. * Get the keys for camera movement down.
  113452. */
  113453. get keysDown(): number[];
  113454. /**
  113455. * Set the keys for camera movement down.
  113456. */
  113457. set keysDown(value: number[]);
  113458. /**
  113459. * Get the keys for camera movement left.
  113460. */
  113461. get keysLeft(): number[];
  113462. /**
  113463. * Set the keys for camera movement left.
  113464. */
  113465. set keysLeft(value: number[]);
  113466. /**
  113467. * Set the keys for camera movement right.
  113468. */
  113469. get keysRight(): number[];
  113470. /**
  113471. * Set the keys for camera movement right.
  113472. */
  113473. set keysRight(value: number[]);
  113474. /**
  113475. * Event raised when the camera collides with a mesh in the scene.
  113476. */
  113477. onCollide: (collidedMesh: AbstractMesh) => void;
  113478. private _collider;
  113479. private _needMoveForGravity;
  113480. private _oldPosition;
  113481. private _diffPosition;
  113482. private _newPosition;
  113483. /** @hidden */
  113484. _localDirection: Vector3;
  113485. /** @hidden */
  113486. _transformedDirection: Vector3;
  113487. /**
  113488. * Instantiates a FlyCamera.
  113489. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113490. * such as in a 3D Space Shooter or a Flight Simulator.
  113491. * @param name Define the name of the camera in the scene.
  113492. * @param position Define the starting position of the camera in the scene.
  113493. * @param scene Define the scene the camera belongs to.
  113494. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113495. */
  113496. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113497. /**
  113498. * Attach a control to the HTML DOM element.
  113499. * @param element Defines the element that listens to the input events.
  113500. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113501. */
  113502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113503. /**
  113504. * Detach a control from the HTML DOM element.
  113505. * The camera will stop reacting to that input.
  113506. * @param element Defines the element that listens to the input events.
  113507. */
  113508. detachControl(element: HTMLElement): void;
  113509. private _collisionMask;
  113510. /**
  113511. * Get the mask that the camera ignores in collision events.
  113512. */
  113513. get collisionMask(): number;
  113514. /**
  113515. * Set the mask that the camera ignores in collision events.
  113516. */
  113517. set collisionMask(mask: number);
  113518. /** @hidden */
  113519. _collideWithWorld(displacement: Vector3): void;
  113520. /** @hidden */
  113521. private _onCollisionPositionChange;
  113522. /** @hidden */
  113523. _checkInputs(): void;
  113524. /** @hidden */
  113525. _decideIfNeedsToMove(): boolean;
  113526. /** @hidden */
  113527. _updatePosition(): void;
  113528. /**
  113529. * Restore the Roll to its target value at the rate specified.
  113530. * @param rate - Higher means slower restoring.
  113531. * @hidden
  113532. */
  113533. restoreRoll(rate: number): void;
  113534. /**
  113535. * Destroy the camera and release the current resources held by it.
  113536. */
  113537. dispose(): void;
  113538. /**
  113539. * Get the current object class name.
  113540. * @returns the class name.
  113541. */
  113542. getClassName(): string;
  113543. }
  113544. }
  113545. declare module BABYLON {
  113546. /**
  113547. * Listen to keyboard events to control the camera.
  113548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113549. */
  113550. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113551. /**
  113552. * Defines the camera the input is attached to.
  113553. */
  113554. camera: FlyCamera;
  113555. /**
  113556. * The list of keyboard keys used to control the forward move of the camera.
  113557. */
  113558. keysForward: number[];
  113559. /**
  113560. * The list of keyboard keys used to control the backward move of the camera.
  113561. */
  113562. keysBackward: number[];
  113563. /**
  113564. * The list of keyboard keys used to control the forward move of the camera.
  113565. */
  113566. keysUp: number[];
  113567. /**
  113568. * The list of keyboard keys used to control the backward move of the camera.
  113569. */
  113570. keysDown: number[];
  113571. /**
  113572. * The list of keyboard keys used to control the right strafe move of the camera.
  113573. */
  113574. keysRight: number[];
  113575. /**
  113576. * The list of keyboard keys used to control the left strafe move of the camera.
  113577. */
  113578. keysLeft: number[];
  113579. private _keys;
  113580. private _onCanvasBlurObserver;
  113581. private _onKeyboardObserver;
  113582. private _engine;
  113583. private _scene;
  113584. /**
  113585. * Attach the input controls to a specific dom element to get the input from.
  113586. * @param element Defines the element the controls should be listened from
  113587. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113588. */
  113589. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113590. /**
  113591. * Detach the current controls from the specified dom element.
  113592. * @param element Defines the element to stop listening the inputs from
  113593. */
  113594. detachControl(element: Nullable<HTMLElement>): void;
  113595. /**
  113596. * Gets the class name of the current intput.
  113597. * @returns the class name
  113598. */
  113599. getClassName(): string;
  113600. /** @hidden */
  113601. _onLostFocus(e: FocusEvent): void;
  113602. /**
  113603. * Get the friendly name associated with the input class.
  113604. * @returns the input friendly name
  113605. */
  113606. getSimpleName(): string;
  113607. /**
  113608. * Update the current camera state depending on the inputs that have been used this frame.
  113609. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113610. */
  113611. checkInputs(): void;
  113612. }
  113613. }
  113614. declare module BABYLON {
  113615. /**
  113616. * Manage the mouse wheel inputs to control a follow camera.
  113617. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113618. */
  113619. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113620. /**
  113621. * Defines the camera the input is attached to.
  113622. */
  113623. camera: FollowCamera;
  113624. /**
  113625. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113626. */
  113627. axisControlRadius: boolean;
  113628. /**
  113629. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113630. */
  113631. axisControlHeight: boolean;
  113632. /**
  113633. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113634. */
  113635. axisControlRotation: boolean;
  113636. /**
  113637. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113638. * relation to mouseWheel events.
  113639. */
  113640. wheelPrecision: number;
  113641. /**
  113642. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113643. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113644. */
  113645. wheelDeltaPercentage: number;
  113646. private _wheel;
  113647. private _observer;
  113648. /**
  113649. * Attach the input controls to a specific dom element to get the input from.
  113650. * @param element Defines the element the controls should be listened from
  113651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113652. */
  113653. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113654. /**
  113655. * Detach the current controls from the specified dom element.
  113656. * @param element Defines the element to stop listening the inputs from
  113657. */
  113658. detachControl(element: Nullable<HTMLElement>): void;
  113659. /**
  113660. * Gets the class name of the current intput.
  113661. * @returns the class name
  113662. */
  113663. getClassName(): string;
  113664. /**
  113665. * Get the friendly name associated with the input class.
  113666. * @returns the input friendly name
  113667. */
  113668. getSimpleName(): string;
  113669. }
  113670. }
  113671. declare module BABYLON {
  113672. /**
  113673. * Manage the pointers inputs to control an follow camera.
  113674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113675. */
  113676. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113677. /**
  113678. * Defines the camera the input is attached to.
  113679. */
  113680. camera: FollowCamera;
  113681. /**
  113682. * Gets the class name of the current input.
  113683. * @returns the class name
  113684. */
  113685. getClassName(): string;
  113686. /**
  113687. * Defines the pointer angular sensibility along the X axis or how fast is
  113688. * the camera rotating.
  113689. * A negative number will reverse the axis direction.
  113690. */
  113691. angularSensibilityX: number;
  113692. /**
  113693. * Defines the pointer angular sensibility along the Y axis or how fast is
  113694. * the camera rotating.
  113695. * A negative number will reverse the axis direction.
  113696. */
  113697. angularSensibilityY: number;
  113698. /**
  113699. * Defines the pointer pinch precision or how fast is the camera zooming.
  113700. * A negative number will reverse the axis direction.
  113701. */
  113702. pinchPrecision: number;
  113703. /**
  113704. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113705. * from 0.
  113706. * It defines the percentage of current camera.radius to use as delta when
  113707. * pinch zoom is used.
  113708. */
  113709. pinchDeltaPercentage: number;
  113710. /**
  113711. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113712. */
  113713. axisXControlRadius: boolean;
  113714. /**
  113715. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113716. */
  113717. axisXControlHeight: boolean;
  113718. /**
  113719. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113720. */
  113721. axisXControlRotation: boolean;
  113722. /**
  113723. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113724. */
  113725. axisYControlRadius: boolean;
  113726. /**
  113727. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113728. */
  113729. axisYControlHeight: boolean;
  113730. /**
  113731. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113732. */
  113733. axisYControlRotation: boolean;
  113734. /**
  113735. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113736. */
  113737. axisPinchControlRadius: boolean;
  113738. /**
  113739. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113740. */
  113741. axisPinchControlHeight: boolean;
  113742. /**
  113743. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113744. */
  113745. axisPinchControlRotation: boolean;
  113746. /**
  113747. * Log error messages if basic misconfiguration has occurred.
  113748. */
  113749. warningEnable: boolean;
  113750. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113751. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113752. private _warningCounter;
  113753. private _warning;
  113754. }
  113755. }
  113756. declare module BABYLON {
  113757. /**
  113758. * Default Inputs manager for the FollowCamera.
  113759. * It groups all the default supported inputs for ease of use.
  113760. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113761. */
  113762. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113763. /**
  113764. * Instantiates a new FollowCameraInputsManager.
  113765. * @param camera Defines the camera the inputs belong to
  113766. */
  113767. constructor(camera: FollowCamera);
  113768. /**
  113769. * Add keyboard input support to the input manager.
  113770. * @returns the current input manager
  113771. */
  113772. addKeyboard(): FollowCameraInputsManager;
  113773. /**
  113774. * Add mouse wheel input support to the input manager.
  113775. * @returns the current input manager
  113776. */
  113777. addMouseWheel(): FollowCameraInputsManager;
  113778. /**
  113779. * Add pointers input support to the input manager.
  113780. * @returns the current input manager
  113781. */
  113782. addPointers(): FollowCameraInputsManager;
  113783. /**
  113784. * Add orientation input support to the input manager.
  113785. * @returns the current input manager
  113786. */
  113787. addVRDeviceOrientation(): FollowCameraInputsManager;
  113788. }
  113789. }
  113790. declare module BABYLON {
  113791. /**
  113792. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113793. * an arc rotate version arcFollowCamera are available.
  113794. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113795. */
  113796. export class FollowCamera extends TargetCamera {
  113797. /**
  113798. * Distance the follow camera should follow an object at
  113799. */
  113800. radius: number;
  113801. /**
  113802. * Minimum allowed distance of the camera to the axis of rotation
  113803. * (The camera can not get closer).
  113804. * This can help limiting how the Camera is able to move in the scene.
  113805. */
  113806. lowerRadiusLimit: Nullable<number>;
  113807. /**
  113808. * Maximum allowed distance of the camera to the axis of rotation
  113809. * (The camera can not get further).
  113810. * This can help limiting how the Camera is able to move in the scene.
  113811. */
  113812. upperRadiusLimit: Nullable<number>;
  113813. /**
  113814. * Define a rotation offset between the camera and the object it follows
  113815. */
  113816. rotationOffset: number;
  113817. /**
  113818. * Minimum allowed angle to camera position relative to target object.
  113819. * This can help limiting how the Camera is able to move in the scene.
  113820. */
  113821. lowerRotationOffsetLimit: Nullable<number>;
  113822. /**
  113823. * Maximum allowed angle to camera position relative to target object.
  113824. * This can help limiting how the Camera is able to move in the scene.
  113825. */
  113826. upperRotationOffsetLimit: Nullable<number>;
  113827. /**
  113828. * Define a height offset between the camera and the object it follows.
  113829. * It can help following an object from the top (like a car chaing a plane)
  113830. */
  113831. heightOffset: number;
  113832. /**
  113833. * Minimum allowed height of camera position relative to target object.
  113834. * This can help limiting how the Camera is able to move in the scene.
  113835. */
  113836. lowerHeightOffsetLimit: Nullable<number>;
  113837. /**
  113838. * Maximum allowed height of camera position relative to target object.
  113839. * This can help limiting how the Camera is able to move in the scene.
  113840. */
  113841. upperHeightOffsetLimit: Nullable<number>;
  113842. /**
  113843. * Define how fast the camera can accelerate to follow it s target.
  113844. */
  113845. cameraAcceleration: number;
  113846. /**
  113847. * Define the speed limit of the camera following an object.
  113848. */
  113849. maxCameraSpeed: number;
  113850. /**
  113851. * Define the target of the camera.
  113852. */
  113853. lockedTarget: Nullable<AbstractMesh>;
  113854. /**
  113855. * Defines the input associated with the camera.
  113856. */
  113857. inputs: FollowCameraInputsManager;
  113858. /**
  113859. * Instantiates the follow camera.
  113860. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113861. * @param name Define the name of the camera in the scene
  113862. * @param position Define the position of the camera
  113863. * @param scene Define the scene the camera belong to
  113864. * @param lockedTarget Define the target of the camera
  113865. */
  113866. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113867. private _follow;
  113868. /**
  113869. * Attached controls to the current camera.
  113870. * @param element Defines the element the controls should be listened from
  113871. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113872. */
  113873. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113874. /**
  113875. * Detach the current controls from the camera.
  113876. * The camera will stop reacting to inputs.
  113877. * @param element Defines the element to stop listening the inputs from
  113878. */
  113879. detachControl(element: HTMLElement): void;
  113880. /** @hidden */
  113881. _checkInputs(): void;
  113882. private _checkLimits;
  113883. /**
  113884. * Gets the camera class name.
  113885. * @returns the class name
  113886. */
  113887. getClassName(): string;
  113888. }
  113889. /**
  113890. * Arc Rotate version of the follow camera.
  113891. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113892. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113893. */
  113894. export class ArcFollowCamera extends TargetCamera {
  113895. /** The longitudinal angle of the camera */
  113896. alpha: number;
  113897. /** The latitudinal angle of the camera */
  113898. beta: number;
  113899. /** The radius of the camera from its target */
  113900. radius: number;
  113901. /** Define the camera target (the messh it should follow) */
  113902. target: Nullable<AbstractMesh>;
  113903. private _cartesianCoordinates;
  113904. /**
  113905. * Instantiates a new ArcFollowCamera
  113906. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113907. * @param name Define the name of the camera
  113908. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113909. * @param beta Define the rotation angle of the camera around the elevation axis
  113910. * @param radius Define the radius of the camera from its target point
  113911. * @param target Define the target of the camera
  113912. * @param scene Define the scene the camera belongs to
  113913. */
  113914. constructor(name: string,
  113915. /** The longitudinal angle of the camera */
  113916. alpha: number,
  113917. /** The latitudinal angle of the camera */
  113918. beta: number,
  113919. /** The radius of the camera from its target */
  113920. radius: number,
  113921. /** Define the camera target (the messh it should follow) */
  113922. target: Nullable<AbstractMesh>, scene: Scene);
  113923. private _follow;
  113924. /** @hidden */
  113925. _checkInputs(): void;
  113926. /**
  113927. * Returns the class name of the object.
  113928. * It is mostly used internally for serialization purposes.
  113929. */
  113930. getClassName(): string;
  113931. }
  113932. }
  113933. declare module BABYLON {
  113934. /**
  113935. * Manage the keyboard inputs to control the movement of a follow camera.
  113936. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113937. */
  113938. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113939. /**
  113940. * Defines the camera the input is attached to.
  113941. */
  113942. camera: FollowCamera;
  113943. /**
  113944. * Defines the list of key codes associated with the up action (increase heightOffset)
  113945. */
  113946. keysHeightOffsetIncr: number[];
  113947. /**
  113948. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113949. */
  113950. keysHeightOffsetDecr: number[];
  113951. /**
  113952. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113953. */
  113954. keysHeightOffsetModifierAlt: boolean;
  113955. /**
  113956. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113957. */
  113958. keysHeightOffsetModifierCtrl: boolean;
  113959. /**
  113960. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113961. */
  113962. keysHeightOffsetModifierShift: boolean;
  113963. /**
  113964. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113965. */
  113966. keysRotationOffsetIncr: number[];
  113967. /**
  113968. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113969. */
  113970. keysRotationOffsetDecr: number[];
  113971. /**
  113972. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113973. */
  113974. keysRotationOffsetModifierAlt: boolean;
  113975. /**
  113976. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113977. */
  113978. keysRotationOffsetModifierCtrl: boolean;
  113979. /**
  113980. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113981. */
  113982. keysRotationOffsetModifierShift: boolean;
  113983. /**
  113984. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113985. */
  113986. keysRadiusIncr: number[];
  113987. /**
  113988. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113989. */
  113990. keysRadiusDecr: number[];
  113991. /**
  113992. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113993. */
  113994. keysRadiusModifierAlt: boolean;
  113995. /**
  113996. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113997. */
  113998. keysRadiusModifierCtrl: boolean;
  113999. /**
  114000. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  114001. */
  114002. keysRadiusModifierShift: boolean;
  114003. /**
  114004. * Defines the rate of change of heightOffset.
  114005. */
  114006. heightSensibility: number;
  114007. /**
  114008. * Defines the rate of change of rotationOffset.
  114009. */
  114010. rotationSensibility: number;
  114011. /**
  114012. * Defines the rate of change of radius.
  114013. */
  114014. radiusSensibility: number;
  114015. private _keys;
  114016. private _ctrlPressed;
  114017. private _altPressed;
  114018. private _shiftPressed;
  114019. private _onCanvasBlurObserver;
  114020. private _onKeyboardObserver;
  114021. private _engine;
  114022. private _scene;
  114023. /**
  114024. * Attach the input controls to a specific dom element to get the input from.
  114025. * @param element Defines the element the controls should be listened from
  114026. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114027. */
  114028. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114029. /**
  114030. * Detach the current controls from the specified dom element.
  114031. * @param element Defines the element to stop listening the inputs from
  114032. */
  114033. detachControl(element: Nullable<HTMLElement>): void;
  114034. /**
  114035. * Update the current camera state depending on the inputs that have been used this frame.
  114036. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114037. */
  114038. checkInputs(): void;
  114039. /**
  114040. * Gets the class name of the current input.
  114041. * @returns the class name
  114042. */
  114043. getClassName(): string;
  114044. /**
  114045. * Get the friendly name associated with the input class.
  114046. * @returns the input friendly name
  114047. */
  114048. getSimpleName(): string;
  114049. /**
  114050. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114051. * allow modification of the heightOffset value.
  114052. */
  114053. private _modifierHeightOffset;
  114054. /**
  114055. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114056. * allow modification of the rotationOffset value.
  114057. */
  114058. private _modifierRotationOffset;
  114059. /**
  114060. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114061. * allow modification of the radius value.
  114062. */
  114063. private _modifierRadius;
  114064. }
  114065. }
  114066. declare module BABYLON {
  114067. interface FreeCameraInputsManager {
  114068. /**
  114069. * @hidden
  114070. */
  114071. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  114072. /**
  114073. * Add orientation input support to the input manager.
  114074. * @returns the current input manager
  114075. */
  114076. addDeviceOrientation(): FreeCameraInputsManager;
  114077. }
  114078. /**
  114079. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  114080. * Screen rotation is taken into account.
  114081. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114082. */
  114083. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  114084. private _camera;
  114085. private _screenOrientationAngle;
  114086. private _constantTranform;
  114087. private _screenQuaternion;
  114088. private _alpha;
  114089. private _beta;
  114090. private _gamma;
  114091. /**
  114092. * Can be used to detect if a device orientation sensor is available on a device
  114093. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  114094. * @returns a promise that will resolve on orientation change
  114095. */
  114096. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  114097. /**
  114098. * @hidden
  114099. */
  114100. _onDeviceOrientationChangedObservable: Observable<void>;
  114101. /**
  114102. * Instantiates a new input
  114103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114104. */
  114105. constructor();
  114106. /**
  114107. * Define the camera controlled by the input.
  114108. */
  114109. get camera(): FreeCamera;
  114110. set camera(camera: FreeCamera);
  114111. /**
  114112. * Attach the input controls to a specific dom element to get the input from.
  114113. * @param element Defines the element the controls should be listened from
  114114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114115. */
  114116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114117. private _orientationChanged;
  114118. private _deviceOrientation;
  114119. /**
  114120. * Detach the current controls from the specified dom element.
  114121. * @param element Defines the element to stop listening the inputs from
  114122. */
  114123. detachControl(element: Nullable<HTMLElement>): void;
  114124. /**
  114125. * Update the current camera state depending on the inputs that have been used this frame.
  114126. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114127. */
  114128. checkInputs(): void;
  114129. /**
  114130. * Gets the class name of the current intput.
  114131. * @returns the class name
  114132. */
  114133. getClassName(): string;
  114134. /**
  114135. * Get the friendly name associated with the input class.
  114136. * @returns the input friendly name
  114137. */
  114138. getSimpleName(): string;
  114139. }
  114140. }
  114141. declare module BABYLON {
  114142. /**
  114143. * Manage the gamepad inputs to control a free camera.
  114144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114145. */
  114146. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  114147. /**
  114148. * Define the camera the input is attached to.
  114149. */
  114150. camera: FreeCamera;
  114151. /**
  114152. * Define the Gamepad controlling the input
  114153. */
  114154. gamepad: Nullable<Gamepad>;
  114155. /**
  114156. * Defines the gamepad rotation sensiblity.
  114157. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114158. */
  114159. gamepadAngularSensibility: number;
  114160. /**
  114161. * Defines the gamepad move sensiblity.
  114162. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114163. */
  114164. gamepadMoveSensibility: number;
  114165. private _yAxisScale;
  114166. /**
  114167. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  114168. */
  114169. get invertYAxis(): boolean;
  114170. set invertYAxis(value: boolean);
  114171. private _onGamepadConnectedObserver;
  114172. private _onGamepadDisconnectedObserver;
  114173. private _cameraTransform;
  114174. private _deltaTransform;
  114175. private _vector3;
  114176. private _vector2;
  114177. /**
  114178. * Attach the input controls to a specific dom element to get the input from.
  114179. * @param element Defines the element the controls should be listened from
  114180. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114181. */
  114182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114183. /**
  114184. * Detach the current controls from the specified dom element.
  114185. * @param element Defines the element to stop listening the inputs from
  114186. */
  114187. detachControl(element: Nullable<HTMLElement>): void;
  114188. /**
  114189. * Update the current camera state depending on the inputs that have been used this frame.
  114190. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114191. */
  114192. checkInputs(): void;
  114193. /**
  114194. * Gets the class name of the current intput.
  114195. * @returns the class name
  114196. */
  114197. getClassName(): string;
  114198. /**
  114199. * Get the friendly name associated with the input class.
  114200. * @returns the input friendly name
  114201. */
  114202. getSimpleName(): string;
  114203. }
  114204. }
  114205. declare module BABYLON {
  114206. /**
  114207. * Defines the potential axis of a Joystick
  114208. */
  114209. export enum JoystickAxis {
  114210. /** X axis */
  114211. X = 0,
  114212. /** Y axis */
  114213. Y = 1,
  114214. /** Z axis */
  114215. Z = 2
  114216. }
  114217. /**
  114218. * Class used to define virtual joystick (used in touch mode)
  114219. */
  114220. export class VirtualJoystick {
  114221. /**
  114222. * Gets or sets a boolean indicating that left and right values must be inverted
  114223. */
  114224. reverseLeftRight: boolean;
  114225. /**
  114226. * Gets or sets a boolean indicating that up and down values must be inverted
  114227. */
  114228. reverseUpDown: boolean;
  114229. /**
  114230. * Gets the offset value for the position (ie. the change of the position value)
  114231. */
  114232. deltaPosition: Vector3;
  114233. /**
  114234. * Gets a boolean indicating if the virtual joystick was pressed
  114235. */
  114236. pressed: boolean;
  114237. /**
  114238. * Canvas the virtual joystick will render onto, default z-index of this is 5
  114239. */
  114240. static Canvas: Nullable<HTMLCanvasElement>;
  114241. private static _globalJoystickIndex;
  114242. private static vjCanvasContext;
  114243. private static vjCanvasWidth;
  114244. private static vjCanvasHeight;
  114245. private static halfWidth;
  114246. private _action;
  114247. private _axisTargetedByLeftAndRight;
  114248. private _axisTargetedByUpAndDown;
  114249. private _joystickSensibility;
  114250. private _inversedSensibility;
  114251. private _joystickPointerID;
  114252. private _joystickColor;
  114253. private _joystickPointerPos;
  114254. private _joystickPreviousPointerPos;
  114255. private _joystickPointerStartPos;
  114256. private _deltaJoystickVector;
  114257. private _leftJoystick;
  114258. private _touches;
  114259. private _onPointerDownHandlerRef;
  114260. private _onPointerMoveHandlerRef;
  114261. private _onPointerUpHandlerRef;
  114262. private _onResize;
  114263. /**
  114264. * Creates a new virtual joystick
  114265. * @param leftJoystick defines that the joystick is for left hand (false by default)
  114266. */
  114267. constructor(leftJoystick?: boolean);
  114268. /**
  114269. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  114270. * @param newJoystickSensibility defines the new sensibility
  114271. */
  114272. setJoystickSensibility(newJoystickSensibility: number): void;
  114273. private _onPointerDown;
  114274. private _onPointerMove;
  114275. private _onPointerUp;
  114276. /**
  114277. * Change the color of the virtual joystick
  114278. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114279. */
  114280. setJoystickColor(newColor: string): void;
  114281. /**
  114282. * Defines a callback to call when the joystick is touched
  114283. * @param action defines the callback
  114284. */
  114285. setActionOnTouch(action: () => any): void;
  114286. /**
  114287. * Defines which axis you'd like to control for left & right
  114288. * @param axis defines the axis to use
  114289. */
  114290. setAxisForLeftRight(axis: JoystickAxis): void;
  114291. /**
  114292. * Defines which axis you'd like to control for up & down
  114293. * @param axis defines the axis to use
  114294. */
  114295. setAxisForUpDown(axis: JoystickAxis): void;
  114296. private _drawVirtualJoystick;
  114297. /**
  114298. * Release internal HTML canvas
  114299. */
  114300. releaseCanvas(): void;
  114301. }
  114302. }
  114303. declare module BABYLON {
  114304. interface FreeCameraInputsManager {
  114305. /**
  114306. * Add virtual joystick input support to the input manager.
  114307. * @returns the current input manager
  114308. */
  114309. addVirtualJoystick(): FreeCameraInputsManager;
  114310. }
  114311. /**
  114312. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114313. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114314. */
  114315. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114316. /**
  114317. * Defines the camera the input is attached to.
  114318. */
  114319. camera: FreeCamera;
  114320. private _leftjoystick;
  114321. private _rightjoystick;
  114322. /**
  114323. * Gets the left stick of the virtual joystick.
  114324. * @returns The virtual Joystick
  114325. */
  114326. getLeftJoystick(): VirtualJoystick;
  114327. /**
  114328. * Gets the right stick of the virtual joystick.
  114329. * @returns The virtual Joystick
  114330. */
  114331. getRightJoystick(): VirtualJoystick;
  114332. /**
  114333. * Update the current camera state depending on the inputs that have been used this frame.
  114334. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114335. */
  114336. checkInputs(): void;
  114337. /**
  114338. * Attach the input controls to a specific dom element to get the input from.
  114339. * @param element Defines the element the controls should be listened from
  114340. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114341. */
  114342. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114343. /**
  114344. * Detach the current controls from the specified dom element.
  114345. * @param element Defines the element to stop listening the inputs from
  114346. */
  114347. detachControl(element: Nullable<HTMLElement>): void;
  114348. /**
  114349. * Gets the class name of the current intput.
  114350. * @returns the class name
  114351. */
  114352. getClassName(): string;
  114353. /**
  114354. * Get the friendly name associated with the input class.
  114355. * @returns the input friendly name
  114356. */
  114357. getSimpleName(): string;
  114358. }
  114359. }
  114360. declare module BABYLON {
  114361. /**
  114362. * This represents a FPS type of camera controlled by touch.
  114363. * This is like a universal camera minus the Gamepad controls.
  114364. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114365. */
  114366. export class TouchCamera extends FreeCamera {
  114367. /**
  114368. * Defines the touch sensibility for rotation.
  114369. * The higher the faster.
  114370. */
  114371. get touchAngularSensibility(): number;
  114372. set touchAngularSensibility(value: number);
  114373. /**
  114374. * Defines the touch sensibility for move.
  114375. * The higher the faster.
  114376. */
  114377. get touchMoveSensibility(): number;
  114378. set touchMoveSensibility(value: number);
  114379. /**
  114380. * Instantiates a new touch camera.
  114381. * This represents a FPS type of camera controlled by touch.
  114382. * This is like a universal camera minus the Gamepad controls.
  114383. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114384. * @param name Define the name of the camera in the scene
  114385. * @param position Define the start position of the camera in the scene
  114386. * @param scene Define the scene the camera belongs to
  114387. */
  114388. constructor(name: string, position: Vector3, scene: Scene);
  114389. /**
  114390. * Gets the current object class name.
  114391. * @return the class name
  114392. */
  114393. getClassName(): string;
  114394. /** @hidden */
  114395. _setupInputs(): void;
  114396. }
  114397. }
  114398. declare module BABYLON {
  114399. /**
  114400. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114401. * being tilted forward or back and left or right.
  114402. */
  114403. export class DeviceOrientationCamera extends FreeCamera {
  114404. private _initialQuaternion;
  114405. private _quaternionCache;
  114406. private _tmpDragQuaternion;
  114407. private _disablePointerInputWhenUsingDeviceOrientation;
  114408. /**
  114409. * Creates a new device orientation camera
  114410. * @param name The name of the camera
  114411. * @param position The start position camera
  114412. * @param scene The scene the camera belongs to
  114413. */
  114414. constructor(name: string, position: Vector3, scene: Scene);
  114415. /**
  114416. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114417. */
  114418. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114419. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114420. private _dragFactor;
  114421. /**
  114422. * Enabled turning on the y axis when the orientation sensor is active
  114423. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114424. */
  114425. enableHorizontalDragging(dragFactor?: number): void;
  114426. /**
  114427. * Gets the current instance class name ("DeviceOrientationCamera").
  114428. * This helps avoiding instanceof at run time.
  114429. * @returns the class name
  114430. */
  114431. getClassName(): string;
  114432. /**
  114433. * @hidden
  114434. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114435. */
  114436. _checkInputs(): void;
  114437. /**
  114438. * Reset the camera to its default orientation on the specified axis only.
  114439. * @param axis The axis to reset
  114440. */
  114441. resetToCurrentRotation(axis?: Axis): void;
  114442. }
  114443. }
  114444. declare module BABYLON {
  114445. /**
  114446. * Defines supported buttons for XBox360 compatible gamepads
  114447. */
  114448. export enum Xbox360Button {
  114449. /** A */
  114450. A = 0,
  114451. /** B */
  114452. B = 1,
  114453. /** X */
  114454. X = 2,
  114455. /** Y */
  114456. Y = 3,
  114457. /** Left button */
  114458. LB = 4,
  114459. /** Right button */
  114460. RB = 5,
  114461. /** Back */
  114462. Back = 8,
  114463. /** Start */
  114464. Start = 9,
  114465. /** Left stick */
  114466. LeftStick = 10,
  114467. /** Right stick */
  114468. RightStick = 11
  114469. }
  114470. /** Defines values for XBox360 DPad */
  114471. export enum Xbox360Dpad {
  114472. /** Up */
  114473. Up = 12,
  114474. /** Down */
  114475. Down = 13,
  114476. /** Left */
  114477. Left = 14,
  114478. /** Right */
  114479. Right = 15
  114480. }
  114481. /**
  114482. * Defines a XBox360 gamepad
  114483. */
  114484. export class Xbox360Pad extends Gamepad {
  114485. private _leftTrigger;
  114486. private _rightTrigger;
  114487. private _onlefttriggerchanged;
  114488. private _onrighttriggerchanged;
  114489. private _onbuttondown;
  114490. private _onbuttonup;
  114491. private _ondpaddown;
  114492. private _ondpadup;
  114493. /** Observable raised when a button is pressed */
  114494. onButtonDownObservable: Observable<Xbox360Button>;
  114495. /** Observable raised when a button is released */
  114496. onButtonUpObservable: Observable<Xbox360Button>;
  114497. /** Observable raised when a pad is pressed */
  114498. onPadDownObservable: Observable<Xbox360Dpad>;
  114499. /** Observable raised when a pad is released */
  114500. onPadUpObservable: Observable<Xbox360Dpad>;
  114501. private _buttonA;
  114502. private _buttonB;
  114503. private _buttonX;
  114504. private _buttonY;
  114505. private _buttonBack;
  114506. private _buttonStart;
  114507. private _buttonLB;
  114508. private _buttonRB;
  114509. private _buttonLeftStick;
  114510. private _buttonRightStick;
  114511. private _dPadUp;
  114512. private _dPadDown;
  114513. private _dPadLeft;
  114514. private _dPadRight;
  114515. private _isXboxOnePad;
  114516. /**
  114517. * Creates a new XBox360 gamepad object
  114518. * @param id defines the id of this gamepad
  114519. * @param index defines its index
  114520. * @param gamepad defines the internal HTML gamepad object
  114521. * @param xboxOne defines if it is a XBox One gamepad
  114522. */
  114523. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114524. /**
  114525. * Defines the callback to call when left trigger is pressed
  114526. * @param callback defines the callback to use
  114527. */
  114528. onlefttriggerchanged(callback: (value: number) => void): void;
  114529. /**
  114530. * Defines the callback to call when right trigger is pressed
  114531. * @param callback defines the callback to use
  114532. */
  114533. onrighttriggerchanged(callback: (value: number) => void): void;
  114534. /**
  114535. * Gets the left trigger value
  114536. */
  114537. get leftTrigger(): number;
  114538. /**
  114539. * Sets the left trigger value
  114540. */
  114541. set leftTrigger(newValue: number);
  114542. /**
  114543. * Gets the right trigger value
  114544. */
  114545. get rightTrigger(): number;
  114546. /**
  114547. * Sets the right trigger value
  114548. */
  114549. set rightTrigger(newValue: number);
  114550. /**
  114551. * Defines the callback to call when a button is pressed
  114552. * @param callback defines the callback to use
  114553. */
  114554. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114555. /**
  114556. * Defines the callback to call when a button is released
  114557. * @param callback defines the callback to use
  114558. */
  114559. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114560. /**
  114561. * Defines the callback to call when a pad is pressed
  114562. * @param callback defines the callback to use
  114563. */
  114564. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114565. /**
  114566. * Defines the callback to call when a pad is released
  114567. * @param callback defines the callback to use
  114568. */
  114569. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114570. private _setButtonValue;
  114571. private _setDPadValue;
  114572. /**
  114573. * Gets the value of the `A` button
  114574. */
  114575. get buttonA(): number;
  114576. /**
  114577. * Sets the value of the `A` button
  114578. */
  114579. set buttonA(value: number);
  114580. /**
  114581. * Gets the value of the `B` button
  114582. */
  114583. get buttonB(): number;
  114584. /**
  114585. * Sets the value of the `B` button
  114586. */
  114587. set buttonB(value: number);
  114588. /**
  114589. * Gets the value of the `X` button
  114590. */
  114591. get buttonX(): number;
  114592. /**
  114593. * Sets the value of the `X` button
  114594. */
  114595. set buttonX(value: number);
  114596. /**
  114597. * Gets the value of the `Y` button
  114598. */
  114599. get buttonY(): number;
  114600. /**
  114601. * Sets the value of the `Y` button
  114602. */
  114603. set buttonY(value: number);
  114604. /**
  114605. * Gets the value of the `Start` button
  114606. */
  114607. get buttonStart(): number;
  114608. /**
  114609. * Sets the value of the `Start` button
  114610. */
  114611. set buttonStart(value: number);
  114612. /**
  114613. * Gets the value of the `Back` button
  114614. */
  114615. get buttonBack(): number;
  114616. /**
  114617. * Sets the value of the `Back` button
  114618. */
  114619. set buttonBack(value: number);
  114620. /**
  114621. * Gets the value of the `Left` button
  114622. */
  114623. get buttonLB(): number;
  114624. /**
  114625. * Sets the value of the `Left` button
  114626. */
  114627. set buttonLB(value: number);
  114628. /**
  114629. * Gets the value of the `Right` button
  114630. */
  114631. get buttonRB(): number;
  114632. /**
  114633. * Sets the value of the `Right` button
  114634. */
  114635. set buttonRB(value: number);
  114636. /**
  114637. * Gets the value of the Left joystick
  114638. */
  114639. get buttonLeftStick(): number;
  114640. /**
  114641. * Sets the value of the Left joystick
  114642. */
  114643. set buttonLeftStick(value: number);
  114644. /**
  114645. * Gets the value of the Right joystick
  114646. */
  114647. get buttonRightStick(): number;
  114648. /**
  114649. * Sets the value of the Right joystick
  114650. */
  114651. set buttonRightStick(value: number);
  114652. /**
  114653. * Gets the value of D-pad up
  114654. */
  114655. get dPadUp(): number;
  114656. /**
  114657. * Sets the value of D-pad up
  114658. */
  114659. set dPadUp(value: number);
  114660. /**
  114661. * Gets the value of D-pad down
  114662. */
  114663. get dPadDown(): number;
  114664. /**
  114665. * Sets the value of D-pad down
  114666. */
  114667. set dPadDown(value: number);
  114668. /**
  114669. * Gets the value of D-pad left
  114670. */
  114671. get dPadLeft(): number;
  114672. /**
  114673. * Sets the value of D-pad left
  114674. */
  114675. set dPadLeft(value: number);
  114676. /**
  114677. * Gets the value of D-pad right
  114678. */
  114679. get dPadRight(): number;
  114680. /**
  114681. * Sets the value of D-pad right
  114682. */
  114683. set dPadRight(value: number);
  114684. /**
  114685. * Force the gamepad to synchronize with device values
  114686. */
  114687. update(): void;
  114688. /**
  114689. * Disposes the gamepad
  114690. */
  114691. dispose(): void;
  114692. }
  114693. }
  114694. declare module BABYLON {
  114695. /**
  114696. * Defines supported buttons for DualShock compatible gamepads
  114697. */
  114698. export enum DualShockButton {
  114699. /** Cross */
  114700. Cross = 0,
  114701. /** Circle */
  114702. Circle = 1,
  114703. /** Square */
  114704. Square = 2,
  114705. /** Triangle */
  114706. Triangle = 3,
  114707. /** L1 */
  114708. L1 = 4,
  114709. /** R1 */
  114710. R1 = 5,
  114711. /** Share */
  114712. Share = 8,
  114713. /** Options */
  114714. Options = 9,
  114715. /** Left stick */
  114716. LeftStick = 10,
  114717. /** Right stick */
  114718. RightStick = 11
  114719. }
  114720. /** Defines values for DualShock DPad */
  114721. export enum DualShockDpad {
  114722. /** Up */
  114723. Up = 12,
  114724. /** Down */
  114725. Down = 13,
  114726. /** Left */
  114727. Left = 14,
  114728. /** Right */
  114729. Right = 15
  114730. }
  114731. /**
  114732. * Defines a DualShock gamepad
  114733. */
  114734. export class DualShockPad extends Gamepad {
  114735. private _leftTrigger;
  114736. private _rightTrigger;
  114737. private _onlefttriggerchanged;
  114738. private _onrighttriggerchanged;
  114739. private _onbuttondown;
  114740. private _onbuttonup;
  114741. private _ondpaddown;
  114742. private _ondpadup;
  114743. /** Observable raised when a button is pressed */
  114744. onButtonDownObservable: Observable<DualShockButton>;
  114745. /** Observable raised when a button is released */
  114746. onButtonUpObservable: Observable<DualShockButton>;
  114747. /** Observable raised when a pad is pressed */
  114748. onPadDownObservable: Observable<DualShockDpad>;
  114749. /** Observable raised when a pad is released */
  114750. onPadUpObservable: Observable<DualShockDpad>;
  114751. private _buttonCross;
  114752. private _buttonCircle;
  114753. private _buttonSquare;
  114754. private _buttonTriangle;
  114755. private _buttonShare;
  114756. private _buttonOptions;
  114757. private _buttonL1;
  114758. private _buttonR1;
  114759. private _buttonLeftStick;
  114760. private _buttonRightStick;
  114761. private _dPadUp;
  114762. private _dPadDown;
  114763. private _dPadLeft;
  114764. private _dPadRight;
  114765. /**
  114766. * Creates a new DualShock gamepad object
  114767. * @param id defines the id of this gamepad
  114768. * @param index defines its index
  114769. * @param gamepad defines the internal HTML gamepad object
  114770. */
  114771. constructor(id: string, index: number, gamepad: any);
  114772. /**
  114773. * Defines the callback to call when left trigger is pressed
  114774. * @param callback defines the callback to use
  114775. */
  114776. onlefttriggerchanged(callback: (value: number) => void): void;
  114777. /**
  114778. * Defines the callback to call when right trigger is pressed
  114779. * @param callback defines the callback to use
  114780. */
  114781. onrighttriggerchanged(callback: (value: number) => void): void;
  114782. /**
  114783. * Gets the left trigger value
  114784. */
  114785. get leftTrigger(): number;
  114786. /**
  114787. * Sets the left trigger value
  114788. */
  114789. set leftTrigger(newValue: number);
  114790. /**
  114791. * Gets the right trigger value
  114792. */
  114793. get rightTrigger(): number;
  114794. /**
  114795. * Sets the right trigger value
  114796. */
  114797. set rightTrigger(newValue: number);
  114798. /**
  114799. * Defines the callback to call when a button is pressed
  114800. * @param callback defines the callback to use
  114801. */
  114802. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114803. /**
  114804. * Defines the callback to call when a button is released
  114805. * @param callback defines the callback to use
  114806. */
  114807. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114808. /**
  114809. * Defines the callback to call when a pad is pressed
  114810. * @param callback defines the callback to use
  114811. */
  114812. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114813. /**
  114814. * Defines the callback to call when a pad is released
  114815. * @param callback defines the callback to use
  114816. */
  114817. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114818. private _setButtonValue;
  114819. private _setDPadValue;
  114820. /**
  114821. * Gets the value of the `Cross` button
  114822. */
  114823. get buttonCross(): number;
  114824. /**
  114825. * Sets the value of the `Cross` button
  114826. */
  114827. set buttonCross(value: number);
  114828. /**
  114829. * Gets the value of the `Circle` button
  114830. */
  114831. get buttonCircle(): number;
  114832. /**
  114833. * Sets the value of the `Circle` button
  114834. */
  114835. set buttonCircle(value: number);
  114836. /**
  114837. * Gets the value of the `Square` button
  114838. */
  114839. get buttonSquare(): number;
  114840. /**
  114841. * Sets the value of the `Square` button
  114842. */
  114843. set buttonSquare(value: number);
  114844. /**
  114845. * Gets the value of the `Triangle` button
  114846. */
  114847. get buttonTriangle(): number;
  114848. /**
  114849. * Sets the value of the `Triangle` button
  114850. */
  114851. set buttonTriangle(value: number);
  114852. /**
  114853. * Gets the value of the `Options` button
  114854. */
  114855. get buttonOptions(): number;
  114856. /**
  114857. * Sets the value of the `Options` button
  114858. */
  114859. set buttonOptions(value: number);
  114860. /**
  114861. * Gets the value of the `Share` button
  114862. */
  114863. get buttonShare(): number;
  114864. /**
  114865. * Sets the value of the `Share` button
  114866. */
  114867. set buttonShare(value: number);
  114868. /**
  114869. * Gets the value of the `L1` button
  114870. */
  114871. get buttonL1(): number;
  114872. /**
  114873. * Sets the value of the `L1` button
  114874. */
  114875. set buttonL1(value: number);
  114876. /**
  114877. * Gets the value of the `R1` button
  114878. */
  114879. get buttonR1(): number;
  114880. /**
  114881. * Sets the value of the `R1` button
  114882. */
  114883. set buttonR1(value: number);
  114884. /**
  114885. * Gets the value of the Left joystick
  114886. */
  114887. get buttonLeftStick(): number;
  114888. /**
  114889. * Sets the value of the Left joystick
  114890. */
  114891. set buttonLeftStick(value: number);
  114892. /**
  114893. * Gets the value of the Right joystick
  114894. */
  114895. get buttonRightStick(): number;
  114896. /**
  114897. * Sets the value of the Right joystick
  114898. */
  114899. set buttonRightStick(value: number);
  114900. /**
  114901. * Gets the value of D-pad up
  114902. */
  114903. get dPadUp(): number;
  114904. /**
  114905. * Sets the value of D-pad up
  114906. */
  114907. set dPadUp(value: number);
  114908. /**
  114909. * Gets the value of D-pad down
  114910. */
  114911. get dPadDown(): number;
  114912. /**
  114913. * Sets the value of D-pad down
  114914. */
  114915. set dPadDown(value: number);
  114916. /**
  114917. * Gets the value of D-pad left
  114918. */
  114919. get dPadLeft(): number;
  114920. /**
  114921. * Sets the value of D-pad left
  114922. */
  114923. set dPadLeft(value: number);
  114924. /**
  114925. * Gets the value of D-pad right
  114926. */
  114927. get dPadRight(): number;
  114928. /**
  114929. * Sets the value of D-pad right
  114930. */
  114931. set dPadRight(value: number);
  114932. /**
  114933. * Force the gamepad to synchronize with device values
  114934. */
  114935. update(): void;
  114936. /**
  114937. * Disposes the gamepad
  114938. */
  114939. dispose(): void;
  114940. }
  114941. }
  114942. declare module BABYLON {
  114943. /**
  114944. * Manager for handling gamepads
  114945. */
  114946. export class GamepadManager {
  114947. private _scene?;
  114948. private _babylonGamepads;
  114949. private _oneGamepadConnected;
  114950. /** @hidden */
  114951. _isMonitoring: boolean;
  114952. private _gamepadEventSupported;
  114953. private _gamepadSupport?;
  114954. /**
  114955. * observable to be triggered when the gamepad controller has been connected
  114956. */
  114957. onGamepadConnectedObservable: Observable<Gamepad>;
  114958. /**
  114959. * observable to be triggered when the gamepad controller has been disconnected
  114960. */
  114961. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114962. private _onGamepadConnectedEvent;
  114963. private _onGamepadDisconnectedEvent;
  114964. /**
  114965. * Initializes the gamepad manager
  114966. * @param _scene BabylonJS scene
  114967. */
  114968. constructor(_scene?: Scene | undefined);
  114969. /**
  114970. * The gamepads in the game pad manager
  114971. */
  114972. get gamepads(): Gamepad[];
  114973. /**
  114974. * Get the gamepad controllers based on type
  114975. * @param type The type of gamepad controller
  114976. * @returns Nullable gamepad
  114977. */
  114978. getGamepadByType(type?: number): Nullable<Gamepad>;
  114979. /**
  114980. * Disposes the gamepad manager
  114981. */
  114982. dispose(): void;
  114983. private _addNewGamepad;
  114984. private _startMonitoringGamepads;
  114985. private _stopMonitoringGamepads;
  114986. /** @hidden */
  114987. _checkGamepadsStatus(): void;
  114988. private _updateGamepadObjects;
  114989. }
  114990. }
  114991. declare module BABYLON {
  114992. interface Scene {
  114993. /** @hidden */
  114994. _gamepadManager: Nullable<GamepadManager>;
  114995. /**
  114996. * Gets the gamepad manager associated with the scene
  114997. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114998. */
  114999. gamepadManager: GamepadManager;
  115000. }
  115001. /**
  115002. * Interface representing a free camera inputs manager
  115003. */
  115004. interface FreeCameraInputsManager {
  115005. /**
  115006. * Adds gamepad input support to the FreeCameraInputsManager.
  115007. * @returns the FreeCameraInputsManager
  115008. */
  115009. addGamepad(): FreeCameraInputsManager;
  115010. }
  115011. /**
  115012. * Interface representing an arc rotate camera inputs manager
  115013. */
  115014. interface ArcRotateCameraInputsManager {
  115015. /**
  115016. * Adds gamepad input support to the ArcRotateCamera InputManager.
  115017. * @returns the camera inputs manager
  115018. */
  115019. addGamepad(): ArcRotateCameraInputsManager;
  115020. }
  115021. /**
  115022. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  115023. */
  115024. export class GamepadSystemSceneComponent implements ISceneComponent {
  115025. /**
  115026. * The component name helpfull to identify the component in the list of scene components.
  115027. */
  115028. readonly name: string;
  115029. /**
  115030. * The scene the component belongs to.
  115031. */
  115032. scene: Scene;
  115033. /**
  115034. * Creates a new instance of the component for the given scene
  115035. * @param scene Defines the scene to register the component in
  115036. */
  115037. constructor(scene: Scene);
  115038. /**
  115039. * Registers the component in a given scene
  115040. */
  115041. register(): void;
  115042. /**
  115043. * Rebuilds the elements related to this component in case of
  115044. * context lost for instance.
  115045. */
  115046. rebuild(): void;
  115047. /**
  115048. * Disposes the component and the associated ressources
  115049. */
  115050. dispose(): void;
  115051. private _beforeCameraUpdate;
  115052. }
  115053. }
  115054. declare module BABYLON {
  115055. /**
  115056. * 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,
  115057. * which still works and will still be found in many Playgrounds.
  115058. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115059. */
  115060. export class UniversalCamera extends TouchCamera {
  115061. /**
  115062. * Defines the gamepad rotation sensiblity.
  115063. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  115064. */
  115065. get gamepadAngularSensibility(): number;
  115066. set gamepadAngularSensibility(value: number);
  115067. /**
  115068. * Defines the gamepad move sensiblity.
  115069. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  115070. */
  115071. get gamepadMoveSensibility(): number;
  115072. set gamepadMoveSensibility(value: number);
  115073. /**
  115074. * 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,
  115075. * which still works and will still be found in many Playgrounds.
  115076. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115077. * @param name Define the name of the camera in the scene
  115078. * @param position Define the start position of the camera in the scene
  115079. * @param scene Define the scene the camera belongs to
  115080. */
  115081. constructor(name: string, position: Vector3, scene: Scene);
  115082. /**
  115083. * Gets the current object class name.
  115084. * @return the class name
  115085. */
  115086. getClassName(): string;
  115087. }
  115088. }
  115089. declare module BABYLON {
  115090. /**
  115091. * This represents a FPS type of camera. This is only here for back compat purpose.
  115092. * Please use the UniversalCamera instead as both are identical.
  115093. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115094. */
  115095. export class GamepadCamera extends UniversalCamera {
  115096. /**
  115097. * Instantiates a new Gamepad Camera
  115098. * This represents a FPS type of camera. This is only here for back compat purpose.
  115099. * Please use the UniversalCamera instead as both are identical.
  115100. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115101. * @param name Define the name of the camera in the scene
  115102. * @param position Define the start position of the camera in the scene
  115103. * @param scene Define the scene the camera belongs to
  115104. */
  115105. constructor(name: string, position: Vector3, scene: Scene);
  115106. /**
  115107. * Gets the current object class name.
  115108. * @return the class name
  115109. */
  115110. getClassName(): string;
  115111. }
  115112. }
  115113. declare module BABYLON {
  115114. /** @hidden */
  115115. export var passPixelShader: {
  115116. name: string;
  115117. shader: string;
  115118. };
  115119. }
  115120. declare module BABYLON {
  115121. /** @hidden */
  115122. export var passCubePixelShader: {
  115123. name: string;
  115124. shader: string;
  115125. };
  115126. }
  115127. declare module BABYLON {
  115128. /**
  115129. * PassPostProcess which produces an output the same as it's input
  115130. */
  115131. export class PassPostProcess extends PostProcess {
  115132. /**
  115133. * Creates the PassPostProcess
  115134. * @param name The name of the effect.
  115135. * @param options The required width/height ratio to downsize to before computing the render pass.
  115136. * @param camera The camera to apply the render pass to.
  115137. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115138. * @param engine The engine which the post process will be applied. (default: current engine)
  115139. * @param reusable If the post process can be reused on the same frame. (default: false)
  115140. * @param textureType The type of texture to be used when performing the post processing.
  115141. * @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)
  115142. */
  115143. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  115144. }
  115145. /**
  115146. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  115147. */
  115148. export class PassCubePostProcess extends PostProcess {
  115149. private _face;
  115150. /**
  115151. * Gets or sets the cube face to display.
  115152. * * 0 is +X
  115153. * * 1 is -X
  115154. * * 2 is +Y
  115155. * * 3 is -Y
  115156. * * 4 is +Z
  115157. * * 5 is -Z
  115158. */
  115159. get face(): number;
  115160. set face(value: number);
  115161. /**
  115162. * Creates the PassCubePostProcess
  115163. * @param name The name of the effect.
  115164. * @param options The required width/height ratio to downsize to before computing the render pass.
  115165. * @param camera The camera to apply the render pass to.
  115166. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115167. * @param engine The engine which the post process will be applied. (default: current engine)
  115168. * @param reusable If the post process can be reused on the same frame. (default: false)
  115169. * @param textureType The type of texture to be used when performing the post processing.
  115170. * @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)
  115171. */
  115172. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  115173. }
  115174. }
  115175. declare module BABYLON {
  115176. /** @hidden */
  115177. export var anaglyphPixelShader: {
  115178. name: string;
  115179. shader: string;
  115180. };
  115181. }
  115182. declare module BABYLON {
  115183. /**
  115184. * Postprocess used to generate anaglyphic rendering
  115185. */
  115186. export class AnaglyphPostProcess extends PostProcess {
  115187. private _passedProcess;
  115188. /**
  115189. * Creates a new AnaglyphPostProcess
  115190. * @param name defines postprocess name
  115191. * @param options defines creation options or target ratio scale
  115192. * @param rigCameras defines cameras using this postprocess
  115193. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  115194. * @param engine defines hosting engine
  115195. * @param reusable defines if the postprocess will be reused multiple times per frame
  115196. */
  115197. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  115198. }
  115199. }
  115200. declare module BABYLON {
  115201. /**
  115202. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  115203. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115204. */
  115205. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  115206. /**
  115207. * Creates a new AnaglyphArcRotateCamera
  115208. * @param name defines camera name
  115209. * @param alpha defines alpha angle (in radians)
  115210. * @param beta defines beta angle (in radians)
  115211. * @param radius defines radius
  115212. * @param target defines camera target
  115213. * @param interaxialDistance defines distance between each color axis
  115214. * @param scene defines the hosting scene
  115215. */
  115216. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  115217. /**
  115218. * Gets camera class name
  115219. * @returns AnaglyphArcRotateCamera
  115220. */
  115221. getClassName(): string;
  115222. }
  115223. }
  115224. declare module BABYLON {
  115225. /**
  115226. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  115227. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115228. */
  115229. export class AnaglyphFreeCamera extends FreeCamera {
  115230. /**
  115231. * Creates a new AnaglyphFreeCamera
  115232. * @param name defines camera name
  115233. * @param position defines initial position
  115234. * @param interaxialDistance defines distance between each color axis
  115235. * @param scene defines the hosting scene
  115236. */
  115237. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115238. /**
  115239. * Gets camera class name
  115240. * @returns AnaglyphFreeCamera
  115241. */
  115242. getClassName(): string;
  115243. }
  115244. }
  115245. declare module BABYLON {
  115246. /**
  115247. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  115248. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115249. */
  115250. export class AnaglyphGamepadCamera extends GamepadCamera {
  115251. /**
  115252. * Creates a new AnaglyphGamepadCamera
  115253. * @param name defines camera name
  115254. * @param position defines initial position
  115255. * @param interaxialDistance defines distance between each color axis
  115256. * @param scene defines the hosting scene
  115257. */
  115258. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115259. /**
  115260. * Gets camera class name
  115261. * @returns AnaglyphGamepadCamera
  115262. */
  115263. getClassName(): string;
  115264. }
  115265. }
  115266. declare module BABYLON {
  115267. /**
  115268. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  115269. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115270. */
  115271. export class AnaglyphUniversalCamera extends UniversalCamera {
  115272. /**
  115273. * Creates a new AnaglyphUniversalCamera
  115274. * @param name defines camera name
  115275. * @param position defines initial position
  115276. * @param interaxialDistance defines distance between each color axis
  115277. * @param scene defines the hosting scene
  115278. */
  115279. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115280. /**
  115281. * Gets camera class name
  115282. * @returns AnaglyphUniversalCamera
  115283. */
  115284. getClassName(): string;
  115285. }
  115286. }
  115287. declare module BABYLON {
  115288. /** @hidden */
  115289. export var stereoscopicInterlacePixelShader: {
  115290. name: string;
  115291. shader: string;
  115292. };
  115293. }
  115294. declare module BABYLON {
  115295. /**
  115296. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115297. */
  115298. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115299. private _stepSize;
  115300. private _passedProcess;
  115301. /**
  115302. * Initializes a StereoscopicInterlacePostProcessI
  115303. * @param name The name of the effect.
  115304. * @param rigCameras The rig cameras to be appled to the post process
  115305. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115306. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115308. * @param engine The engine which the post process will be applied. (default: current engine)
  115309. * @param reusable If the post process can be reused on the same frame. (default: false)
  115310. */
  115311. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115312. }
  115313. /**
  115314. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115315. */
  115316. export class StereoscopicInterlacePostProcess extends PostProcess {
  115317. private _stepSize;
  115318. private _passedProcess;
  115319. /**
  115320. * Initializes a StereoscopicInterlacePostProcess
  115321. * @param name The name of the effect.
  115322. * @param rigCameras The rig cameras to be appled to the post process
  115323. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115325. * @param engine The engine which the post process will be applied. (default: current engine)
  115326. * @param reusable If the post process can be reused on the same frame. (default: false)
  115327. */
  115328. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115329. }
  115330. }
  115331. declare module BABYLON {
  115332. /**
  115333. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115334. * @see http://doc.babylonjs.com/features/cameras
  115335. */
  115336. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115337. /**
  115338. * Creates a new StereoscopicArcRotateCamera
  115339. * @param name defines camera name
  115340. * @param alpha defines alpha angle (in radians)
  115341. * @param beta defines beta angle (in radians)
  115342. * @param radius defines radius
  115343. * @param target defines camera target
  115344. * @param interaxialDistance defines distance between each color axis
  115345. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115346. * @param scene defines the hosting scene
  115347. */
  115348. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115349. /**
  115350. * Gets camera class name
  115351. * @returns StereoscopicArcRotateCamera
  115352. */
  115353. getClassName(): string;
  115354. }
  115355. }
  115356. declare module BABYLON {
  115357. /**
  115358. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115359. * @see http://doc.babylonjs.com/features/cameras
  115360. */
  115361. export class StereoscopicFreeCamera extends FreeCamera {
  115362. /**
  115363. * Creates a new StereoscopicFreeCamera
  115364. * @param name defines camera name
  115365. * @param position defines initial position
  115366. * @param interaxialDistance defines distance between each color axis
  115367. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115368. * @param scene defines the hosting scene
  115369. */
  115370. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115371. /**
  115372. * Gets camera class name
  115373. * @returns StereoscopicFreeCamera
  115374. */
  115375. getClassName(): string;
  115376. }
  115377. }
  115378. declare module BABYLON {
  115379. /**
  115380. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115381. * @see http://doc.babylonjs.com/features/cameras
  115382. */
  115383. export class StereoscopicGamepadCamera extends GamepadCamera {
  115384. /**
  115385. * Creates a new StereoscopicGamepadCamera
  115386. * @param name defines camera name
  115387. * @param position defines initial position
  115388. * @param interaxialDistance defines distance between each color axis
  115389. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115390. * @param scene defines the hosting scene
  115391. */
  115392. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115393. /**
  115394. * Gets camera class name
  115395. * @returns StereoscopicGamepadCamera
  115396. */
  115397. getClassName(): string;
  115398. }
  115399. }
  115400. declare module BABYLON {
  115401. /**
  115402. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115403. * @see http://doc.babylonjs.com/features/cameras
  115404. */
  115405. export class StereoscopicUniversalCamera extends UniversalCamera {
  115406. /**
  115407. * Creates a new StereoscopicUniversalCamera
  115408. * @param name defines camera name
  115409. * @param position defines initial position
  115410. * @param interaxialDistance defines distance between each color axis
  115411. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115412. * @param scene defines the hosting scene
  115413. */
  115414. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115415. /**
  115416. * Gets camera class name
  115417. * @returns StereoscopicUniversalCamera
  115418. */
  115419. getClassName(): string;
  115420. }
  115421. }
  115422. declare module BABYLON {
  115423. /**
  115424. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115425. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115426. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115427. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115428. */
  115429. export class VirtualJoysticksCamera extends FreeCamera {
  115430. /**
  115431. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115432. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115433. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115434. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115435. * @param name Define the name of the camera in the scene
  115436. * @param position Define the start position of the camera in the scene
  115437. * @param scene Define the scene the camera belongs to
  115438. */
  115439. constructor(name: string, position: Vector3, scene: Scene);
  115440. /**
  115441. * Gets the current object class name.
  115442. * @return the class name
  115443. */
  115444. getClassName(): string;
  115445. }
  115446. }
  115447. declare module BABYLON {
  115448. /**
  115449. * This represents all the required metrics to create a VR camera.
  115450. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115451. */
  115452. export class VRCameraMetrics {
  115453. /**
  115454. * Define the horizontal resolution off the screen.
  115455. */
  115456. hResolution: number;
  115457. /**
  115458. * Define the vertical resolution off the screen.
  115459. */
  115460. vResolution: number;
  115461. /**
  115462. * Define the horizontal screen size.
  115463. */
  115464. hScreenSize: number;
  115465. /**
  115466. * Define the vertical screen size.
  115467. */
  115468. vScreenSize: number;
  115469. /**
  115470. * Define the vertical screen center position.
  115471. */
  115472. vScreenCenter: number;
  115473. /**
  115474. * Define the distance of the eyes to the screen.
  115475. */
  115476. eyeToScreenDistance: number;
  115477. /**
  115478. * Define the distance between both lenses
  115479. */
  115480. lensSeparationDistance: number;
  115481. /**
  115482. * Define the distance between both viewer's eyes.
  115483. */
  115484. interpupillaryDistance: number;
  115485. /**
  115486. * Define the distortion factor of the VR postprocess.
  115487. * Please, touch with care.
  115488. */
  115489. distortionK: number[];
  115490. /**
  115491. * Define the chromatic aberration correction factors for the VR post process.
  115492. */
  115493. chromaAbCorrection: number[];
  115494. /**
  115495. * Define the scale factor of the post process.
  115496. * The smaller the better but the slower.
  115497. */
  115498. postProcessScaleFactor: number;
  115499. /**
  115500. * Define an offset for the lens center.
  115501. */
  115502. lensCenterOffset: number;
  115503. /**
  115504. * Define if the current vr camera should compensate the distortion of the lense or not.
  115505. */
  115506. compensateDistortion: boolean;
  115507. /**
  115508. * Defines if multiview should be enabled when rendering (Default: false)
  115509. */
  115510. multiviewEnabled: boolean;
  115511. /**
  115512. * Gets the rendering aspect ratio based on the provided resolutions.
  115513. */
  115514. get aspectRatio(): number;
  115515. /**
  115516. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115517. */
  115518. get aspectRatioFov(): number;
  115519. /**
  115520. * @hidden
  115521. */
  115522. get leftHMatrix(): Matrix;
  115523. /**
  115524. * @hidden
  115525. */
  115526. get rightHMatrix(): Matrix;
  115527. /**
  115528. * @hidden
  115529. */
  115530. get leftPreViewMatrix(): Matrix;
  115531. /**
  115532. * @hidden
  115533. */
  115534. get rightPreViewMatrix(): Matrix;
  115535. /**
  115536. * Get the default VRMetrics based on the most generic setup.
  115537. * @returns the default vr metrics
  115538. */
  115539. static GetDefault(): VRCameraMetrics;
  115540. }
  115541. }
  115542. declare module BABYLON {
  115543. /** @hidden */
  115544. export var vrDistortionCorrectionPixelShader: {
  115545. name: string;
  115546. shader: string;
  115547. };
  115548. }
  115549. declare module BABYLON {
  115550. /**
  115551. * VRDistortionCorrectionPostProcess used for mobile VR
  115552. */
  115553. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115554. private _isRightEye;
  115555. private _distortionFactors;
  115556. private _postProcessScaleFactor;
  115557. private _lensCenterOffset;
  115558. private _scaleIn;
  115559. private _scaleFactor;
  115560. private _lensCenter;
  115561. /**
  115562. * Initializes the VRDistortionCorrectionPostProcess
  115563. * @param name The name of the effect.
  115564. * @param camera The camera to apply the render pass to.
  115565. * @param isRightEye If this is for the right eye distortion
  115566. * @param vrMetrics All the required metrics for the VR camera
  115567. */
  115568. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115569. }
  115570. }
  115571. declare module BABYLON {
  115572. /**
  115573. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115574. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115575. */
  115576. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115577. /**
  115578. * Creates a new VRDeviceOrientationArcRotateCamera
  115579. * @param name defines camera name
  115580. * @param alpha defines the camera rotation along the logitudinal axis
  115581. * @param beta defines the camera rotation along the latitudinal axis
  115582. * @param radius defines the camera distance from its target
  115583. * @param target defines the camera target
  115584. * @param scene defines the scene the camera belongs to
  115585. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115586. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115587. */
  115588. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115589. /**
  115590. * Gets camera class name
  115591. * @returns VRDeviceOrientationArcRotateCamera
  115592. */
  115593. getClassName(): string;
  115594. }
  115595. }
  115596. declare module BABYLON {
  115597. /**
  115598. * Camera used to simulate VR rendering (based on FreeCamera)
  115599. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115600. */
  115601. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115602. /**
  115603. * Creates a new VRDeviceOrientationFreeCamera
  115604. * @param name defines camera name
  115605. * @param position defines the start position of the camera
  115606. * @param scene defines the scene the camera belongs to
  115607. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115608. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115609. */
  115610. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115611. /**
  115612. * Gets camera class name
  115613. * @returns VRDeviceOrientationFreeCamera
  115614. */
  115615. getClassName(): string;
  115616. }
  115617. }
  115618. declare module BABYLON {
  115619. /**
  115620. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115621. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115622. */
  115623. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115624. /**
  115625. * Creates a new VRDeviceOrientationGamepadCamera
  115626. * @param name defines camera name
  115627. * @param position defines the start position of the camera
  115628. * @param scene defines the scene the camera belongs to
  115629. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115630. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115631. */
  115632. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115633. /**
  115634. * Gets camera class name
  115635. * @returns VRDeviceOrientationGamepadCamera
  115636. */
  115637. getClassName(): string;
  115638. }
  115639. }
  115640. declare module BABYLON {
  115641. /** @hidden */
  115642. export var imageProcessingPixelShader: {
  115643. name: string;
  115644. shader: string;
  115645. };
  115646. }
  115647. declare module BABYLON {
  115648. /**
  115649. * ImageProcessingPostProcess
  115650. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115651. */
  115652. export class ImageProcessingPostProcess extends PostProcess {
  115653. /**
  115654. * Default configuration related to image processing available in the PBR Material.
  115655. */
  115656. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115657. /**
  115658. * Gets the image processing configuration used either in this material.
  115659. */
  115660. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115661. /**
  115662. * Sets the Default image processing configuration used either in the this material.
  115663. *
  115664. * If sets to null, the scene one is in use.
  115665. */
  115666. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115667. /**
  115668. * Keep track of the image processing observer to allow dispose and replace.
  115669. */
  115670. private _imageProcessingObserver;
  115671. /**
  115672. * Attaches a new image processing configuration to the PBR Material.
  115673. * @param configuration
  115674. */
  115675. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115676. /**
  115677. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115678. */
  115679. get colorCurves(): Nullable<ColorCurves>;
  115680. /**
  115681. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115682. */
  115683. set colorCurves(value: Nullable<ColorCurves>);
  115684. /**
  115685. * Gets wether the color curves effect is enabled.
  115686. */
  115687. get colorCurvesEnabled(): boolean;
  115688. /**
  115689. * Sets wether the color curves effect is enabled.
  115690. */
  115691. set colorCurvesEnabled(value: boolean);
  115692. /**
  115693. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115694. */
  115695. get colorGradingTexture(): Nullable<BaseTexture>;
  115696. /**
  115697. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115698. */
  115699. set colorGradingTexture(value: Nullable<BaseTexture>);
  115700. /**
  115701. * Gets wether the color grading effect is enabled.
  115702. */
  115703. get colorGradingEnabled(): boolean;
  115704. /**
  115705. * Gets wether the color grading effect is enabled.
  115706. */
  115707. set colorGradingEnabled(value: boolean);
  115708. /**
  115709. * Gets exposure used in the effect.
  115710. */
  115711. get exposure(): number;
  115712. /**
  115713. * Sets exposure used in the effect.
  115714. */
  115715. set exposure(value: number);
  115716. /**
  115717. * Gets wether tonemapping is enabled or not.
  115718. */
  115719. get toneMappingEnabled(): boolean;
  115720. /**
  115721. * Sets wether tonemapping is enabled or not
  115722. */
  115723. set toneMappingEnabled(value: boolean);
  115724. /**
  115725. * Gets the type of tone mapping effect.
  115726. */
  115727. get toneMappingType(): number;
  115728. /**
  115729. * Sets the type of tone mapping effect.
  115730. */
  115731. set toneMappingType(value: number);
  115732. /**
  115733. * Gets contrast used in the effect.
  115734. */
  115735. get contrast(): number;
  115736. /**
  115737. * Sets contrast used in the effect.
  115738. */
  115739. set contrast(value: number);
  115740. /**
  115741. * Gets Vignette stretch size.
  115742. */
  115743. get vignetteStretch(): number;
  115744. /**
  115745. * Sets Vignette stretch size.
  115746. */
  115747. set vignetteStretch(value: number);
  115748. /**
  115749. * Gets Vignette centre X Offset.
  115750. */
  115751. get vignetteCentreX(): number;
  115752. /**
  115753. * Sets Vignette centre X Offset.
  115754. */
  115755. set vignetteCentreX(value: number);
  115756. /**
  115757. * Gets Vignette centre Y Offset.
  115758. */
  115759. get vignetteCentreY(): number;
  115760. /**
  115761. * Sets Vignette centre Y Offset.
  115762. */
  115763. set vignetteCentreY(value: number);
  115764. /**
  115765. * Gets Vignette weight or intensity of the vignette effect.
  115766. */
  115767. get vignetteWeight(): number;
  115768. /**
  115769. * Sets Vignette weight or intensity of the vignette effect.
  115770. */
  115771. set vignetteWeight(value: number);
  115772. /**
  115773. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115774. * if vignetteEnabled is set to true.
  115775. */
  115776. get vignetteColor(): Color4;
  115777. /**
  115778. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115779. * if vignetteEnabled is set to true.
  115780. */
  115781. set vignetteColor(value: Color4);
  115782. /**
  115783. * Gets Camera field of view used by the Vignette effect.
  115784. */
  115785. get vignetteCameraFov(): number;
  115786. /**
  115787. * Sets Camera field of view used by the Vignette effect.
  115788. */
  115789. set vignetteCameraFov(value: number);
  115790. /**
  115791. * Gets the vignette blend mode allowing different kind of effect.
  115792. */
  115793. get vignetteBlendMode(): number;
  115794. /**
  115795. * Sets the vignette blend mode allowing different kind of effect.
  115796. */
  115797. set vignetteBlendMode(value: number);
  115798. /**
  115799. * Gets wether the vignette effect is enabled.
  115800. */
  115801. get vignetteEnabled(): boolean;
  115802. /**
  115803. * Sets wether the vignette effect is enabled.
  115804. */
  115805. set vignetteEnabled(value: boolean);
  115806. private _fromLinearSpace;
  115807. /**
  115808. * Gets wether the input of the processing is in Gamma or Linear Space.
  115809. */
  115810. get fromLinearSpace(): boolean;
  115811. /**
  115812. * Sets wether the input of the processing is in Gamma or Linear Space.
  115813. */
  115814. set fromLinearSpace(value: boolean);
  115815. /**
  115816. * Defines cache preventing GC.
  115817. */
  115818. private _defines;
  115819. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115820. /**
  115821. * "ImageProcessingPostProcess"
  115822. * @returns "ImageProcessingPostProcess"
  115823. */
  115824. getClassName(): string;
  115825. protected _updateParameters(): void;
  115826. dispose(camera?: Camera): void;
  115827. }
  115828. }
  115829. declare module BABYLON {
  115830. /**
  115831. * Class containing static functions to help procedurally build meshes
  115832. */
  115833. export class GroundBuilder {
  115834. /**
  115835. * Creates a ground mesh
  115836. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115837. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115839. * @param name defines the name of the mesh
  115840. * @param options defines the options used to create the mesh
  115841. * @param scene defines the hosting scene
  115842. * @returns the ground mesh
  115843. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115844. */
  115845. static CreateGround(name: string, options: {
  115846. width?: number;
  115847. height?: number;
  115848. subdivisions?: number;
  115849. subdivisionsX?: number;
  115850. subdivisionsY?: number;
  115851. updatable?: boolean;
  115852. }, scene: any): Mesh;
  115853. /**
  115854. * Creates a tiled ground mesh
  115855. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115856. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115857. * * 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
  115858. * * 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
  115859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115860. * @param name defines the name of the mesh
  115861. * @param options defines the options used to create the mesh
  115862. * @param scene defines the hosting scene
  115863. * @returns the tiled ground mesh
  115864. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115865. */
  115866. static CreateTiledGround(name: string, options: {
  115867. xmin: number;
  115868. zmin: number;
  115869. xmax: number;
  115870. zmax: number;
  115871. subdivisions?: {
  115872. w: number;
  115873. h: number;
  115874. };
  115875. precision?: {
  115876. w: number;
  115877. h: number;
  115878. };
  115879. updatable?: boolean;
  115880. }, scene?: Nullable<Scene>): Mesh;
  115881. /**
  115882. * Creates a ground mesh from a height map
  115883. * * The parameter `url` sets the URL of the height map image resource.
  115884. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115885. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115886. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115887. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115888. * * 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.
  115889. * * 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).
  115890. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115892. * @param name defines the name of the mesh
  115893. * @param url defines the url to the height map
  115894. * @param options defines the options used to create the mesh
  115895. * @param scene defines the hosting scene
  115896. * @returns the ground mesh
  115897. * @see https://doc.babylonjs.com/babylon101/height_map
  115898. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115899. */
  115900. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115901. width?: number;
  115902. height?: number;
  115903. subdivisions?: number;
  115904. minHeight?: number;
  115905. maxHeight?: number;
  115906. colorFilter?: Color3;
  115907. alphaFilter?: number;
  115908. updatable?: boolean;
  115909. onReady?: (mesh: GroundMesh) => void;
  115910. }, scene?: Nullable<Scene>): GroundMesh;
  115911. }
  115912. }
  115913. declare module BABYLON {
  115914. /**
  115915. * Class containing static functions to help procedurally build meshes
  115916. */
  115917. export class TorusBuilder {
  115918. /**
  115919. * Creates a torus mesh
  115920. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115921. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115922. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115926. * @param name defines the name of the mesh
  115927. * @param options defines the options used to create the mesh
  115928. * @param scene defines the hosting scene
  115929. * @returns the torus mesh
  115930. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115931. */
  115932. static CreateTorus(name: string, options: {
  115933. diameter?: number;
  115934. thickness?: number;
  115935. tessellation?: number;
  115936. updatable?: boolean;
  115937. sideOrientation?: number;
  115938. frontUVs?: Vector4;
  115939. backUVs?: Vector4;
  115940. }, scene: any): Mesh;
  115941. }
  115942. }
  115943. declare module BABYLON {
  115944. /**
  115945. * Class containing static functions to help procedurally build meshes
  115946. */
  115947. export class CylinderBuilder {
  115948. /**
  115949. * Creates a cylinder or a cone mesh
  115950. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115951. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115952. * * 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.
  115953. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115954. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115955. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115956. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115957. * * 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).
  115958. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115959. * * 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).
  115960. * * 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
  115961. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115962. * * 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
  115963. * * 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.
  115964. * * If `enclose` is false, a ring surface is one element.
  115965. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115966. * * 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
  115967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115968. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115970. * @param name defines the name of the mesh
  115971. * @param options defines the options used to create the mesh
  115972. * @param scene defines the hosting scene
  115973. * @returns the cylinder mesh
  115974. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115975. */
  115976. static CreateCylinder(name: string, options: {
  115977. height?: number;
  115978. diameterTop?: number;
  115979. diameterBottom?: number;
  115980. diameter?: number;
  115981. tessellation?: number;
  115982. subdivisions?: number;
  115983. arc?: number;
  115984. faceColors?: Color4[];
  115985. faceUV?: Vector4[];
  115986. updatable?: boolean;
  115987. hasRings?: boolean;
  115988. enclose?: boolean;
  115989. cap?: number;
  115990. sideOrientation?: number;
  115991. frontUVs?: Vector4;
  115992. backUVs?: Vector4;
  115993. }, scene: any): Mesh;
  115994. }
  115995. }
  115996. declare module BABYLON {
  115997. /**
  115998. * States of the webXR experience
  115999. */
  116000. export enum WebXRState {
  116001. /**
  116002. * Transitioning to being in XR mode
  116003. */
  116004. ENTERING_XR = 0,
  116005. /**
  116006. * Transitioning to non XR mode
  116007. */
  116008. EXITING_XR = 1,
  116009. /**
  116010. * In XR mode and presenting
  116011. */
  116012. IN_XR = 2,
  116013. /**
  116014. * Not entered XR mode
  116015. */
  116016. NOT_IN_XR = 3
  116017. }
  116018. /**
  116019. * Abstraction of the XR render target
  116020. */
  116021. export interface WebXRRenderTarget extends IDisposable {
  116022. /**
  116023. * xrpresent context of the canvas which can be used to display/mirror xr content
  116024. */
  116025. canvasContext: WebGLRenderingContext;
  116026. /**
  116027. * xr layer for the canvas
  116028. */
  116029. xrLayer: Nullable<XRWebGLLayer>;
  116030. /**
  116031. * Initializes the xr layer for the session
  116032. * @param xrSession xr session
  116033. * @returns a promise that will resolve once the XR Layer has been created
  116034. */
  116035. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  116036. }
  116037. }
  116038. declare module BABYLON {
  116039. /**
  116040. * COnfiguration object for WebXR output canvas
  116041. */
  116042. export class WebXRManagedOutputCanvasOptions {
  116043. /**
  116044. * An optional canvas in case you wish to create it yourself and provide it here.
  116045. * If not provided, a new canvas will be created
  116046. */
  116047. canvasElement?: HTMLCanvasElement;
  116048. /**
  116049. * Options for this XR Layer output
  116050. */
  116051. canvasOptions?: XRWebGLLayerOptions;
  116052. /**
  116053. * CSS styling for a newly created canvas (if not provided)
  116054. */
  116055. newCanvasCssStyle?: string;
  116056. /**
  116057. * Get the default values of the configuration object
  116058. * @returns default values of this configuration object
  116059. */
  116060. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  116061. }
  116062. /**
  116063. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  116064. */
  116065. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  116066. private _options;
  116067. private _canvas;
  116068. private _engine;
  116069. /**
  116070. * Rendering context of the canvas which can be used to display/mirror xr content
  116071. */
  116072. canvasContext: WebGLRenderingContext;
  116073. /**
  116074. * xr layer for the canvas
  116075. */
  116076. xrLayer: Nullable<XRWebGLLayer>;
  116077. /**
  116078. * Initializes the canvas to be added/removed upon entering/exiting xr
  116079. * @param _xrSessionManager The XR Session manager
  116080. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  116081. */
  116082. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  116083. /**
  116084. * Disposes of the object
  116085. */
  116086. dispose(): void;
  116087. /**
  116088. * Initializes the xr layer for the session
  116089. * @param xrSession xr session
  116090. * @returns a promise that will resolve once the XR Layer has been created
  116091. */
  116092. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  116093. private _addCanvas;
  116094. private _removeCanvas;
  116095. private _setManagedOutputCanvas;
  116096. }
  116097. }
  116098. declare module BABYLON {
  116099. /**
  116100. * Manages an XRSession to work with Babylon's engine
  116101. * @see https://doc.babylonjs.com/how_to/webxr
  116102. */
  116103. export class WebXRSessionManager implements IDisposable {
  116104. /** The scene which the session should be created for */
  116105. scene: Scene;
  116106. private _referenceSpace;
  116107. private _rttProvider;
  116108. private _sessionEnded;
  116109. private _xrNavigator;
  116110. private baseLayer;
  116111. /**
  116112. * The base reference space from which the session started. good if you want to reset your
  116113. * reference space
  116114. */
  116115. baseReferenceSpace: XRReferenceSpace;
  116116. /**
  116117. * Current XR frame
  116118. */
  116119. currentFrame: Nullable<XRFrame>;
  116120. /** WebXR timestamp updated every frame */
  116121. currentTimestamp: number;
  116122. /**
  116123. * Used just in case of a failure to initialize an immersive session.
  116124. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  116125. */
  116126. defaultHeightCompensation: number;
  116127. /**
  116128. * Fires every time a new xrFrame arrives which can be used to update the camera
  116129. */
  116130. onXRFrameObservable: Observable<XRFrame>;
  116131. /**
  116132. * Fires when the reference space changed
  116133. */
  116134. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  116135. /**
  116136. * Fires when the xr session is ended either by the device or manually done
  116137. */
  116138. onXRSessionEnded: Observable<any>;
  116139. /**
  116140. * Fires when the xr session is ended either by the device or manually done
  116141. */
  116142. onXRSessionInit: Observable<XRSession>;
  116143. /**
  116144. * Underlying xr session
  116145. */
  116146. session: XRSession;
  116147. /**
  116148. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  116149. * or get the offset the player is currently at.
  116150. */
  116151. viewerReferenceSpace: XRReferenceSpace;
  116152. /**
  116153. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  116154. * @param scene The scene which the session should be created for
  116155. */
  116156. constructor(
  116157. /** The scene which the session should be created for */
  116158. scene: Scene);
  116159. /**
  116160. * The current reference space used in this session. This reference space can constantly change!
  116161. * It is mainly used to offset the camera's position.
  116162. */
  116163. get referenceSpace(): XRReferenceSpace;
  116164. /**
  116165. * Set a new reference space and triggers the observable
  116166. */
  116167. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  116168. /**
  116169. * Disposes of the session manager
  116170. */
  116171. dispose(): void;
  116172. /**
  116173. * Stops the xrSession and restores the render loop
  116174. * @returns Promise which resolves after it exits XR
  116175. */
  116176. exitXRAsync(): Promise<void>;
  116177. /**
  116178. * Gets the correct render target texture to be rendered this frame for this eye
  116179. * @param eye the eye for which to get the render target
  116180. * @returns the render target for the specified eye
  116181. */
  116182. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  116183. /**
  116184. * Creates a WebXRRenderTarget object for the XR session
  116185. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  116186. * @param options optional options to provide when creating a new render target
  116187. * @returns a WebXR render target to which the session can render
  116188. */
  116189. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  116190. /**
  116191. * Initializes the manager
  116192. * After initialization enterXR can be called to start an XR session
  116193. * @returns Promise which resolves after it is initialized
  116194. */
  116195. initializeAsync(): Promise<void>;
  116196. /**
  116197. * Initializes an xr session
  116198. * @param xrSessionMode mode to initialize
  116199. * @param xrSessionInit defines optional and required values to pass to the session builder
  116200. * @returns a promise which will resolve once the session has been initialized
  116201. */
  116202. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  116203. /**
  116204. * Checks if a session would be supported for the creation options specified
  116205. * @param sessionMode session mode to check if supported eg. immersive-vr
  116206. * @returns A Promise that resolves to true if supported and false if not
  116207. */
  116208. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116209. /**
  116210. * Resets the reference space to the one started the session
  116211. */
  116212. resetReferenceSpace(): void;
  116213. /**
  116214. * Starts rendering to the xr layer
  116215. */
  116216. runXRRenderLoop(): void;
  116217. /**
  116218. * Sets the reference space on the xr session
  116219. * @param referenceSpaceType space to set
  116220. * @returns a promise that will resolve once the reference space has been set
  116221. */
  116222. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  116223. /**
  116224. * Updates the render state of the session
  116225. * @param state state to set
  116226. * @returns a promise that resolves once the render state has been updated
  116227. */
  116228. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  116229. /**
  116230. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  116231. * @param sessionMode defines the session to test
  116232. * @returns a promise with boolean as final value
  116233. */
  116234. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116235. private _createRenderTargetTexture;
  116236. }
  116237. }
  116238. declare module BABYLON {
  116239. /**
  116240. * WebXR Camera which holds the views for the xrSession
  116241. * @see https://doc.babylonjs.com/how_to/webxr_camera
  116242. */
  116243. export class WebXRCamera extends FreeCamera {
  116244. private _xrSessionManager;
  116245. private _firstFrame;
  116246. private _referenceQuaternion;
  116247. private _referencedPosition;
  116248. private _xrInvPositionCache;
  116249. private _xrInvQuaternionCache;
  116250. /**
  116251. * Should position compensation execute on first frame.
  116252. * This is used when copying the position from a native (non XR) camera
  116253. */
  116254. compensateOnFirstFrame: boolean;
  116255. /**
  116256. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  116257. * @param name the name of the camera
  116258. * @param scene the scene to add the camera to
  116259. * @param _xrSessionManager a constructed xr session manager
  116260. */
  116261. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  116262. /**
  116263. * Return the user's height, unrelated to the current ground.
  116264. * This will be the y position of this camera, when ground level is 0.
  116265. */
  116266. get realWorldHeight(): number;
  116267. /** @hidden */
  116268. _updateForDualEyeDebugging(): void;
  116269. /**
  116270. * Sets this camera's transformation based on a non-vr camera
  116271. * @param otherCamera the non-vr camera to copy the transformation from
  116272. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116273. */
  116274. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116275. /**
  116276. * Gets the current instance class name ("WebXRCamera").
  116277. * @returns the class name
  116278. */
  116279. getClassName(): string;
  116280. private _updateFromXRSession;
  116281. private _updateNumberOfRigCameras;
  116282. private _updateReferenceSpace;
  116283. private _updateReferenceSpaceOffset;
  116284. }
  116285. }
  116286. declare module BABYLON {
  116287. /**
  116288. * Defining the interface required for a (webxr) feature
  116289. */
  116290. export interface IWebXRFeature extends IDisposable {
  116291. /**
  116292. * Is this feature attached
  116293. */
  116294. attached: boolean;
  116295. /**
  116296. * Should auto-attach be disabled?
  116297. */
  116298. disableAutoAttach: boolean;
  116299. /**
  116300. * Attach the feature to the session
  116301. * Will usually be called by the features manager
  116302. *
  116303. * @param force should attachment be forced (even when already attached)
  116304. * @returns true if successful.
  116305. */
  116306. attach(force?: boolean): boolean;
  116307. /**
  116308. * Detach the feature from the session
  116309. * Will usually be called by the features manager
  116310. *
  116311. * @returns true if successful.
  116312. */
  116313. detach(): boolean;
  116314. }
  116315. /**
  116316. * A list of the currently available features without referencing them
  116317. */
  116318. export class WebXRFeatureName {
  116319. /**
  116320. * The name of the anchor system feature
  116321. */
  116322. static ANCHOR_SYSTEM: string;
  116323. /**
  116324. * The name of the background remover feature
  116325. */
  116326. static BACKGROUND_REMOVER: string;
  116327. /**
  116328. * The name of the hit test feature
  116329. */
  116330. static HIT_TEST: string;
  116331. /**
  116332. * physics impostors for xr controllers feature
  116333. */
  116334. static PHYSICS_CONTROLLERS: string;
  116335. /**
  116336. * The name of the plane detection feature
  116337. */
  116338. static PLANE_DETECTION: string;
  116339. /**
  116340. * The name of the pointer selection feature
  116341. */
  116342. static POINTER_SELECTION: string;
  116343. /**
  116344. * The name of the teleportation feature
  116345. */
  116346. static TELEPORTATION: string;
  116347. }
  116348. /**
  116349. * Defining the constructor of a feature. Used to register the modules.
  116350. */
  116351. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116352. /**
  116353. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116354. * It is mainly used in AR sessions.
  116355. *
  116356. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116357. */
  116358. export class WebXRFeaturesManager implements IDisposable {
  116359. private _xrSessionManager;
  116360. private static readonly _AvailableFeatures;
  116361. private _features;
  116362. /**
  116363. * constructs a new features manages.
  116364. *
  116365. * @param _xrSessionManager an instance of WebXRSessionManager
  116366. */
  116367. constructor(_xrSessionManager: WebXRSessionManager);
  116368. /**
  116369. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116370. * Mainly used internally.
  116371. *
  116372. * @param featureName the name of the feature to register
  116373. * @param constructorFunction the function used to construct the module
  116374. * @param version the (babylon) version of the module
  116375. * @param stable is that a stable version of this module
  116376. */
  116377. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116378. /**
  116379. * Returns a constructor of a specific feature.
  116380. *
  116381. * @param featureName the name of the feature to construct
  116382. * @param version the version of the feature to load
  116383. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116384. * @param options optional options provided to the module.
  116385. * @returns a function that, when called, will return a new instance of this feature
  116386. */
  116387. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116388. /**
  116389. * Can be used to return the list of features currently registered
  116390. *
  116391. * @returns an Array of available features
  116392. */
  116393. static GetAvailableFeatures(): string[];
  116394. /**
  116395. * Gets the versions available for a specific feature
  116396. * @param featureName the name of the feature
  116397. * @returns an array with the available versions
  116398. */
  116399. static GetAvailableVersions(featureName: string): string[];
  116400. /**
  116401. * Return the latest unstable version of this feature
  116402. * @param featureName the name of the feature to search
  116403. * @returns the version number. if not found will return -1
  116404. */
  116405. static GetLatestVersionOfFeature(featureName: string): number;
  116406. /**
  116407. * Return the latest stable version of this feature
  116408. * @param featureName the name of the feature to search
  116409. * @returns the version number. if not found will return -1
  116410. */
  116411. static GetStableVersionOfFeature(featureName: string): number;
  116412. /**
  116413. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116414. * Can be used during a session to start a feature
  116415. * @param featureName the name of feature to attach
  116416. */
  116417. attachFeature(featureName: string): void;
  116418. /**
  116419. * Can be used inside a session or when the session ends to detach a specific feature
  116420. * @param featureName the name of the feature to detach
  116421. */
  116422. detachFeature(featureName: string): void;
  116423. /**
  116424. * Used to disable an already-enabled feature
  116425. * The feature will be disposed and will be recreated once enabled.
  116426. * @param featureName the feature to disable
  116427. * @returns true if disable was successful
  116428. */
  116429. disableFeature(featureName: string | {
  116430. Name: string;
  116431. }): boolean;
  116432. /**
  116433. * dispose this features manager
  116434. */
  116435. dispose(): void;
  116436. /**
  116437. * 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.
  116438. * 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.
  116439. *
  116440. * @param featureName the name of the feature to load or the class of the feature
  116441. * @param version optional version to load. if not provided the latest version will be enabled
  116442. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116443. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116444. * @returns a new constructed feature or throws an error if feature not found.
  116445. */
  116446. enableFeature(featureName: string | {
  116447. Name: string;
  116448. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116449. /**
  116450. * get the implementation of an enabled feature.
  116451. * @param featureName the name of the feature to load
  116452. * @returns the feature class, if found
  116453. */
  116454. getEnabledFeature(featureName: string): IWebXRFeature;
  116455. /**
  116456. * Get the list of enabled features
  116457. * @returns an array of enabled features
  116458. */
  116459. getEnabledFeatures(): string[];
  116460. }
  116461. }
  116462. declare module BABYLON {
  116463. /**
  116464. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  116465. * @see https://doc.babylonjs.com/how_to/webxr
  116466. */
  116467. export class WebXRExperienceHelper implements IDisposable {
  116468. private scene;
  116469. private _nonVRCamera;
  116470. private _originalSceneAutoClear;
  116471. private _supported;
  116472. /**
  116473. * Camera used to render xr content
  116474. */
  116475. camera: WebXRCamera;
  116476. /** A features manager for this xr session */
  116477. featuresManager: WebXRFeaturesManager;
  116478. /**
  116479. * Observers registered here will be triggered after the camera's initial transformation is set
  116480. * This can be used to set a different ground level or an extra rotation.
  116481. *
  116482. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116483. * to the position set after this observable is done executing.
  116484. */
  116485. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116486. /**
  116487. * Fires when the state of the experience helper has changed
  116488. */
  116489. onStateChangedObservable: Observable<WebXRState>;
  116490. /** Session manager used to keep track of xr session */
  116491. sessionManager: WebXRSessionManager;
  116492. /**
  116493. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116494. */
  116495. state: WebXRState;
  116496. /**
  116497. * Creates a WebXRExperienceHelper
  116498. * @param scene The scene the helper should be created in
  116499. */
  116500. private constructor();
  116501. /**
  116502. * Creates the experience helper
  116503. * @param scene the scene to attach the experience helper to
  116504. * @returns a promise for the experience helper
  116505. */
  116506. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116507. /**
  116508. * Disposes of the experience helper
  116509. */
  116510. dispose(): void;
  116511. /**
  116512. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116513. * @param sessionMode options for the XR session
  116514. * @param referenceSpaceType frame of reference of the XR session
  116515. * @param renderTarget the output canvas that will be used to enter XR mode
  116516. * @returns promise that resolves after xr mode has entered
  116517. */
  116518. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116519. /**
  116520. * Exits XR mode and returns the scene to its original state
  116521. * @returns promise that resolves after xr mode has exited
  116522. */
  116523. exitXRAsync(): Promise<void>;
  116524. private _nonXRToXRCamera;
  116525. private _setState;
  116526. }
  116527. }
  116528. declare module BABYLON {
  116529. /**
  116530. * X-Y values for axes in WebXR
  116531. */
  116532. export interface IWebXRMotionControllerAxesValue {
  116533. /**
  116534. * The value of the x axis
  116535. */
  116536. x: number;
  116537. /**
  116538. * The value of the y-axis
  116539. */
  116540. y: number;
  116541. }
  116542. /**
  116543. * changed / previous values for the values of this component
  116544. */
  116545. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116546. /**
  116547. * current (this frame) value
  116548. */
  116549. current: T;
  116550. /**
  116551. * previous (last change) value
  116552. */
  116553. previous: T;
  116554. }
  116555. /**
  116556. * Represents changes in the component between current frame and last values recorded
  116557. */
  116558. export interface IWebXRMotionControllerComponentChanges {
  116559. /**
  116560. * will be populated with previous and current values if axes changed
  116561. */
  116562. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116563. /**
  116564. * will be populated with previous and current values if pressed changed
  116565. */
  116566. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116567. /**
  116568. * will be populated with previous and current values if touched changed
  116569. */
  116570. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116571. /**
  116572. * will be populated with previous and current values if value changed
  116573. */
  116574. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116575. }
  116576. /**
  116577. * This class represents a single component (for example button or thumbstick) of a motion controller
  116578. */
  116579. export class WebXRControllerComponent implements IDisposable {
  116580. /**
  116581. * the id of this component
  116582. */
  116583. id: string;
  116584. /**
  116585. * the type of the component
  116586. */
  116587. type: MotionControllerComponentType;
  116588. private _buttonIndex;
  116589. private _axesIndices;
  116590. private _axes;
  116591. private _changes;
  116592. private _currentValue;
  116593. private _hasChanges;
  116594. private _pressed;
  116595. private _touched;
  116596. /**
  116597. * button component type
  116598. */
  116599. static BUTTON_TYPE: MotionControllerComponentType;
  116600. /**
  116601. * squeeze component type
  116602. */
  116603. static SQUEEZE_TYPE: MotionControllerComponentType;
  116604. /**
  116605. * Thumbstick component type
  116606. */
  116607. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116608. /**
  116609. * Touchpad component type
  116610. */
  116611. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116612. /**
  116613. * trigger component type
  116614. */
  116615. static TRIGGER_TYPE: MotionControllerComponentType;
  116616. /**
  116617. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116618. * the axes data changes
  116619. */
  116620. onAxisValueChangedObservable: Observable<{
  116621. x: number;
  116622. y: number;
  116623. }>;
  116624. /**
  116625. * Observers registered here will be triggered when the state of a button changes
  116626. * State change is either pressed / touched / value
  116627. */
  116628. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116629. /**
  116630. * Creates a new component for a motion controller.
  116631. * It is created by the motion controller itself
  116632. *
  116633. * @param id the id of this component
  116634. * @param type the type of the component
  116635. * @param _buttonIndex index in the buttons array of the gamepad
  116636. * @param _axesIndices indices of the values in the axes array of the gamepad
  116637. */
  116638. constructor(
  116639. /**
  116640. * the id of this component
  116641. */
  116642. id: string,
  116643. /**
  116644. * the type of the component
  116645. */
  116646. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116647. /**
  116648. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116649. */
  116650. get axes(): IWebXRMotionControllerAxesValue;
  116651. /**
  116652. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116653. */
  116654. get changes(): IWebXRMotionControllerComponentChanges;
  116655. /**
  116656. * Return whether or not the component changed the last frame
  116657. */
  116658. get hasChanges(): boolean;
  116659. /**
  116660. * is the button currently pressed
  116661. */
  116662. get pressed(): boolean;
  116663. /**
  116664. * is the button currently touched
  116665. */
  116666. get touched(): boolean;
  116667. /**
  116668. * Get the current value of this component
  116669. */
  116670. get value(): number;
  116671. /**
  116672. * Dispose this component
  116673. */
  116674. dispose(): void;
  116675. /**
  116676. * Are there axes correlating to this component
  116677. * @return true is axes data is available
  116678. */
  116679. isAxes(): boolean;
  116680. /**
  116681. * Is this component a button (hence - pressable)
  116682. * @returns true if can be pressed
  116683. */
  116684. isButton(): boolean;
  116685. /**
  116686. * update this component using the gamepad object it is in. Called on every frame
  116687. * @param nativeController the native gamepad controller object
  116688. */
  116689. update(nativeController: IMinimalMotionControllerObject): void;
  116690. }
  116691. }
  116692. declare module BABYLON {
  116693. /**
  116694. * Class used to represent data loading progression
  116695. */
  116696. export class SceneLoaderProgressEvent {
  116697. /** defines if data length to load can be evaluated */
  116698. readonly lengthComputable: boolean;
  116699. /** defines the loaded data length */
  116700. readonly loaded: number;
  116701. /** defines the data length to load */
  116702. readonly total: number;
  116703. /**
  116704. * Create a new progress event
  116705. * @param lengthComputable defines if data length to load can be evaluated
  116706. * @param loaded defines the loaded data length
  116707. * @param total defines the data length to load
  116708. */
  116709. constructor(
  116710. /** defines if data length to load can be evaluated */
  116711. lengthComputable: boolean,
  116712. /** defines the loaded data length */
  116713. loaded: number,
  116714. /** defines the data length to load */
  116715. total: number);
  116716. /**
  116717. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116718. * @param event defines the source event
  116719. * @returns a new SceneLoaderProgressEvent
  116720. */
  116721. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116722. }
  116723. /**
  116724. * Interface used by SceneLoader plugins to define supported file extensions
  116725. */
  116726. export interface ISceneLoaderPluginExtensions {
  116727. /**
  116728. * Defines the list of supported extensions
  116729. */
  116730. [extension: string]: {
  116731. isBinary: boolean;
  116732. };
  116733. }
  116734. /**
  116735. * Interface used by SceneLoader plugin factory
  116736. */
  116737. export interface ISceneLoaderPluginFactory {
  116738. /**
  116739. * Defines the name of the factory
  116740. */
  116741. name: string;
  116742. /**
  116743. * Function called to create a new plugin
  116744. * @return the new plugin
  116745. */
  116746. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116747. /**
  116748. * The callback that returns true if the data can be directly loaded.
  116749. * @param data string containing the file data
  116750. * @returns if the data can be loaded directly
  116751. */
  116752. canDirectLoad?(data: string): boolean;
  116753. }
  116754. /**
  116755. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116756. */
  116757. export interface ISceneLoaderPluginBase {
  116758. /**
  116759. * The friendly name of this plugin.
  116760. */
  116761. name: string;
  116762. /**
  116763. * The file extensions supported by this plugin.
  116764. */
  116765. extensions: string | ISceneLoaderPluginExtensions;
  116766. /**
  116767. * The callback called when loading from a url.
  116768. * @param scene scene loading this url
  116769. * @param url url to load
  116770. * @param onSuccess callback called when the file successfully loads
  116771. * @param onProgress callback called while file is loading (if the server supports this mode)
  116772. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116773. * @param onError callback called when the file fails to load
  116774. * @returns a file request object
  116775. */
  116776. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116777. /**
  116778. * The callback called when loading from a file object.
  116779. * @param scene scene loading this file
  116780. * @param file defines the file to load
  116781. * @param onSuccess defines the callback to call when data is loaded
  116782. * @param onProgress defines the callback to call during loading process
  116783. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116784. * @param onError defines the callback to call when an error occurs
  116785. * @returns a file request object
  116786. */
  116787. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116788. /**
  116789. * The callback that returns true if the data can be directly loaded.
  116790. * @param data string containing the file data
  116791. * @returns if the data can be loaded directly
  116792. */
  116793. canDirectLoad?(data: string): boolean;
  116794. /**
  116795. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116796. * @param scene scene loading this data
  116797. * @param data string containing the data
  116798. * @returns data to pass to the plugin
  116799. */
  116800. directLoad?(scene: Scene, data: string): any;
  116801. /**
  116802. * The callback that allows custom handling of the root url based on the response url.
  116803. * @param rootUrl the original root url
  116804. * @param responseURL the response url if available
  116805. * @returns the new root url
  116806. */
  116807. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116808. }
  116809. /**
  116810. * Interface used to define a SceneLoader plugin
  116811. */
  116812. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116813. /**
  116814. * Import meshes into a scene.
  116815. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116816. * @param scene The scene to import into
  116817. * @param data The data to import
  116818. * @param rootUrl The root url for scene and resources
  116819. * @param meshes The meshes array to import into
  116820. * @param particleSystems The particle systems array to import into
  116821. * @param skeletons The skeletons array to import into
  116822. * @param onError The callback when import fails
  116823. * @returns True if successful or false otherwise
  116824. */
  116825. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116826. /**
  116827. * Load into a scene.
  116828. * @param scene The scene to load into
  116829. * @param data The data to import
  116830. * @param rootUrl The root url for scene and resources
  116831. * @param onError The callback when import fails
  116832. * @returns True if successful or false otherwise
  116833. */
  116834. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116835. /**
  116836. * Load into an asset container.
  116837. * @param scene The scene to load into
  116838. * @param data The data to import
  116839. * @param rootUrl The root url for scene and resources
  116840. * @param onError The callback when import fails
  116841. * @returns The loaded asset container
  116842. */
  116843. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116844. }
  116845. /**
  116846. * Interface used to define an async SceneLoader plugin
  116847. */
  116848. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116849. /**
  116850. * Import meshes into a scene.
  116851. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116852. * @param scene The scene to import into
  116853. * @param data The data to import
  116854. * @param rootUrl The root url for scene and resources
  116855. * @param onProgress The callback when the load progresses
  116856. * @param fileName Defines the name of the file to load
  116857. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116858. */
  116859. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116860. meshes: AbstractMesh[];
  116861. particleSystems: IParticleSystem[];
  116862. skeletons: Skeleton[];
  116863. animationGroups: AnimationGroup[];
  116864. }>;
  116865. /**
  116866. * Load into a scene.
  116867. * @param scene The scene to load into
  116868. * @param data The data to import
  116869. * @param rootUrl The root url for scene and resources
  116870. * @param onProgress The callback when the load progresses
  116871. * @param fileName Defines the name of the file to load
  116872. * @returns Nothing
  116873. */
  116874. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116875. /**
  116876. * Load into an asset container.
  116877. * @param scene The scene to load into
  116878. * @param data The data to import
  116879. * @param rootUrl The root url for scene and resources
  116880. * @param onProgress The callback when the load progresses
  116881. * @param fileName Defines the name of the file to load
  116882. * @returns The loaded asset container
  116883. */
  116884. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116885. }
  116886. /**
  116887. * Mode that determines how to handle old animation groups before loading new ones.
  116888. */
  116889. export enum SceneLoaderAnimationGroupLoadingMode {
  116890. /**
  116891. * Reset all old animations to initial state then dispose them.
  116892. */
  116893. Clean = 0,
  116894. /**
  116895. * Stop all old animations.
  116896. */
  116897. Stop = 1,
  116898. /**
  116899. * Restart old animations from first frame.
  116900. */
  116901. Sync = 2,
  116902. /**
  116903. * Old animations remains untouched.
  116904. */
  116905. NoSync = 3
  116906. }
  116907. /**
  116908. * Class used to load scene from various file formats using registered plugins
  116909. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116910. */
  116911. export class SceneLoader {
  116912. /**
  116913. * No logging while loading
  116914. */
  116915. static readonly NO_LOGGING: number;
  116916. /**
  116917. * Minimal logging while loading
  116918. */
  116919. static readonly MINIMAL_LOGGING: number;
  116920. /**
  116921. * Summary logging while loading
  116922. */
  116923. static readonly SUMMARY_LOGGING: number;
  116924. /**
  116925. * Detailled logging while loading
  116926. */
  116927. static readonly DETAILED_LOGGING: number;
  116928. /**
  116929. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116930. */
  116931. static get ForceFullSceneLoadingForIncremental(): boolean;
  116932. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116933. /**
  116934. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116935. */
  116936. static get ShowLoadingScreen(): boolean;
  116937. static set ShowLoadingScreen(value: boolean);
  116938. /**
  116939. * Defines the current logging level (while loading the scene)
  116940. * @ignorenaming
  116941. */
  116942. static get loggingLevel(): number;
  116943. static set loggingLevel(value: number);
  116944. /**
  116945. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116946. */
  116947. static get CleanBoneMatrixWeights(): boolean;
  116948. static set CleanBoneMatrixWeights(value: boolean);
  116949. /**
  116950. * Event raised when a plugin is used to load a scene
  116951. */
  116952. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116953. private static _registeredPlugins;
  116954. private static _getDefaultPlugin;
  116955. private static _getPluginForExtension;
  116956. private static _getPluginForDirectLoad;
  116957. private static _getPluginForFilename;
  116958. private static _getDirectLoad;
  116959. private static _loadData;
  116960. private static _getFileInfo;
  116961. /**
  116962. * Gets a plugin that can load the given extension
  116963. * @param extension defines the extension to load
  116964. * @returns a plugin or null if none works
  116965. */
  116966. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116967. /**
  116968. * Gets a boolean indicating that the given extension can be loaded
  116969. * @param extension defines the extension to load
  116970. * @returns true if the extension is supported
  116971. */
  116972. static IsPluginForExtensionAvailable(extension: string): boolean;
  116973. /**
  116974. * Adds a new plugin to the list of registered plugins
  116975. * @param plugin defines the plugin to add
  116976. */
  116977. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116978. /**
  116979. * Import meshes into a scene
  116980. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116981. * @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)
  116982. * @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)
  116983. * @param scene the instance of BABYLON.Scene to append to
  116984. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116985. * @param onProgress a callback with a progress event for each file being loaded
  116986. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116987. * @param pluginExtension the extension used to determine the plugin
  116988. * @returns The loaded plugin
  116989. */
  116990. 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>;
  116991. /**
  116992. * Import meshes into a scene
  116993. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116994. * @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)
  116995. * @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)
  116996. * @param scene the instance of BABYLON.Scene to append to
  116997. * @param onProgress a callback with a progress event for each file being loaded
  116998. * @param pluginExtension the extension used to determine the plugin
  116999. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  117000. */
  117001. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  117002. meshes: AbstractMesh[];
  117003. particleSystems: IParticleSystem[];
  117004. skeletons: Skeleton[];
  117005. animationGroups: AnimationGroup[];
  117006. }>;
  117007. /**
  117008. * Load a scene
  117009. * @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)
  117010. * @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)
  117011. * @param engine is the instance of BABYLON.Engine to use to create the scene
  117012. * @param onSuccess a callback with the scene when import succeeds
  117013. * @param onProgress a callback with a progress event for each file being loaded
  117014. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117015. * @param pluginExtension the extension used to determine the plugin
  117016. * @returns The loaded plugin
  117017. */
  117018. 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>;
  117019. /**
  117020. * Load a scene
  117021. * @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)
  117022. * @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)
  117023. * @param engine is the instance of BABYLON.Engine to use to create the scene
  117024. * @param onProgress a callback with a progress event for each file being loaded
  117025. * @param pluginExtension the extension used to determine the plugin
  117026. * @returns The loaded scene
  117027. */
  117028. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  117029. /**
  117030. * Append a scene
  117031. * @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)
  117032. * @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)
  117033. * @param scene is the instance of BABYLON.Scene to append to
  117034. * @param onSuccess a callback with the scene when import succeeds
  117035. * @param onProgress a callback with a progress event for each file being loaded
  117036. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117037. * @param pluginExtension the extension used to determine the plugin
  117038. * @returns The loaded plugin
  117039. */
  117040. 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>;
  117041. /**
  117042. * Append a scene
  117043. * @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)
  117044. * @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)
  117045. * @param scene is the instance of BABYLON.Scene to append to
  117046. * @param onProgress a callback with a progress event for each file being loaded
  117047. * @param pluginExtension the extension used to determine the plugin
  117048. * @returns The given scene
  117049. */
  117050. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  117051. /**
  117052. * Load a scene into an asset container
  117053. * @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)
  117054. * @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)
  117055. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117056. * @param onSuccess a callback with the scene when import succeeds
  117057. * @param onProgress a callback with a progress event for each file being loaded
  117058. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117059. * @param pluginExtension the extension used to determine the plugin
  117060. * @returns The loaded plugin
  117061. */
  117062. 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>;
  117063. /**
  117064. * Load a scene into an asset container
  117065. * @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)
  117066. * @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)
  117067. * @param scene is the instance of Scene to append to
  117068. * @param onProgress a callback with a progress event for each file being loaded
  117069. * @param pluginExtension the extension used to determine the plugin
  117070. * @returns The loaded asset container
  117071. */
  117072. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  117073. /**
  117074. * Import animations from a file into a scene
  117075. * @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)
  117076. * @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)
  117077. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117078. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  117079. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  117080. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  117081. * @param onSuccess a callback with the scene when import succeeds
  117082. * @param onProgress a callback with a progress event for each file being loaded
  117083. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117084. */
  117085. 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;
  117086. /**
  117087. * Import animations from a file into a scene
  117088. * @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)
  117089. * @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)
  117090. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117091. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  117092. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  117093. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  117094. * @param onSuccess a callback with the scene when import succeeds
  117095. * @param onProgress a callback with a progress event for each file being loaded
  117096. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117097. * @returns the updated scene with imported animations
  117098. */
  117099. 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>;
  117100. }
  117101. }
  117102. declare module BABYLON {
  117103. /**
  117104. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  117105. */
  117106. export type MotionControllerHandness = "none" | "left" | "right";
  117107. /**
  117108. * The type of components available in motion controllers.
  117109. * This is not the name of the component.
  117110. */
  117111. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  117112. /**
  117113. * The state of a controller component
  117114. */
  117115. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  117116. /**
  117117. * The schema of motion controller layout.
  117118. * No object will be initialized using this interface
  117119. * This is used just to define the profile.
  117120. */
  117121. export interface IMotionControllerLayout {
  117122. /**
  117123. * Path to load the assets. Usually relative to the base path
  117124. */
  117125. assetPath: string;
  117126. /**
  117127. * Available components (unsorted)
  117128. */
  117129. components: {
  117130. /**
  117131. * A map of component Ids
  117132. */
  117133. [componentId: string]: {
  117134. /**
  117135. * The type of input the component outputs
  117136. */
  117137. type: MotionControllerComponentType;
  117138. /**
  117139. * The indices of this component in the gamepad object
  117140. */
  117141. gamepadIndices: {
  117142. /**
  117143. * Index of button
  117144. */
  117145. button?: number;
  117146. /**
  117147. * If available, index of x-axis
  117148. */
  117149. xAxis?: number;
  117150. /**
  117151. * If available, index of y-axis
  117152. */
  117153. yAxis?: number;
  117154. };
  117155. /**
  117156. * The mesh's root node name
  117157. */
  117158. rootNodeName: string;
  117159. /**
  117160. * Animation definitions for this model
  117161. */
  117162. visualResponses: {
  117163. [stateKey: string]: {
  117164. /**
  117165. * What property will be animated
  117166. */
  117167. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  117168. /**
  117169. * What states influence this visual response
  117170. */
  117171. states: MotionControllerComponentStateType[];
  117172. /**
  117173. * Type of animation - movement or visibility
  117174. */
  117175. valueNodeProperty: "transform" | "visibility";
  117176. /**
  117177. * Base node name to move. Its position will be calculated according to the min and max nodes
  117178. */
  117179. valueNodeName?: string;
  117180. /**
  117181. * Minimum movement node
  117182. */
  117183. minNodeName?: string;
  117184. /**
  117185. * Max movement node
  117186. */
  117187. maxNodeName?: string;
  117188. };
  117189. };
  117190. /**
  117191. * If touch enabled, what is the name of node to display user feedback
  117192. */
  117193. touchPointNodeName?: string;
  117194. };
  117195. };
  117196. /**
  117197. * Is it xr standard mapping or not
  117198. */
  117199. gamepadMapping: "" | "xr-standard";
  117200. /**
  117201. * Base root node of this entire model
  117202. */
  117203. rootNodeName: string;
  117204. /**
  117205. * Defines the main button component id
  117206. */
  117207. selectComponentId: string;
  117208. }
  117209. /**
  117210. * A definition for the layout map in the input profile
  117211. */
  117212. export interface IMotionControllerLayoutMap {
  117213. /**
  117214. * Layouts with handness type as a key
  117215. */
  117216. [handness: string]: IMotionControllerLayout;
  117217. }
  117218. /**
  117219. * The XR Input profile schema
  117220. * Profiles can be found here:
  117221. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  117222. */
  117223. export interface IMotionControllerProfile {
  117224. /**
  117225. * fallback profiles for this profileId
  117226. */
  117227. fallbackProfileIds: string[];
  117228. /**
  117229. * The layout map, with handness as key
  117230. */
  117231. layouts: IMotionControllerLayoutMap;
  117232. /**
  117233. * The id of this profile
  117234. * correlates to the profile(s) in the xrInput.profiles array
  117235. */
  117236. profileId: string;
  117237. }
  117238. /**
  117239. * A helper-interface for the 3 meshes needed for controller button animation
  117240. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  117241. */
  117242. export interface IMotionControllerButtonMeshMap {
  117243. /**
  117244. * the mesh that defines the pressed value mesh position.
  117245. * This is used to find the max-position of this button
  117246. */
  117247. pressedMesh: AbstractMesh;
  117248. /**
  117249. * the mesh that defines the unpressed value mesh position.
  117250. * This is used to find the min (or initial) position of this button
  117251. */
  117252. unpressedMesh: AbstractMesh;
  117253. /**
  117254. * The mesh that will be changed when value changes
  117255. */
  117256. valueMesh: AbstractMesh;
  117257. }
  117258. /**
  117259. * A helper-interface for the 3 meshes needed for controller axis animation.
  117260. * This will be expanded when touchpad animations are fully supported
  117261. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  117262. */
  117263. export interface IMotionControllerMeshMap {
  117264. /**
  117265. * the mesh that defines the maximum value mesh position.
  117266. */
  117267. maxMesh?: AbstractMesh;
  117268. /**
  117269. * the mesh that defines the minimum value mesh position.
  117270. */
  117271. minMesh?: AbstractMesh;
  117272. /**
  117273. * The mesh that will be changed when axis value changes
  117274. */
  117275. valueMesh: AbstractMesh;
  117276. }
  117277. /**
  117278. * The elements needed for change-detection of the gamepad objects in motion controllers
  117279. */
  117280. export interface IMinimalMotionControllerObject {
  117281. /**
  117282. * Available axes of this controller
  117283. */
  117284. axes: number[];
  117285. /**
  117286. * An array of available buttons
  117287. */
  117288. buttons: Array<{
  117289. /**
  117290. * Value of the button/trigger
  117291. */
  117292. value: number;
  117293. /**
  117294. * If the button/trigger is currently touched
  117295. */
  117296. touched: boolean;
  117297. /**
  117298. * If the button/trigger is currently pressed
  117299. */
  117300. pressed: boolean;
  117301. }>;
  117302. }
  117303. /**
  117304. * An Abstract Motion controller
  117305. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117306. * Each component has an observable to check for changes in value and state
  117307. */
  117308. export abstract class WebXRAbstractMotionController implements IDisposable {
  117309. protected scene: Scene;
  117310. protected layout: IMotionControllerLayout;
  117311. /**
  117312. * The gamepad object correlating to this controller
  117313. */
  117314. gamepadObject: IMinimalMotionControllerObject;
  117315. /**
  117316. * handness (left/right/none) of this controller
  117317. */
  117318. handness: MotionControllerHandness;
  117319. private _initComponent;
  117320. private _modelReady;
  117321. /**
  117322. * A map of components (WebXRControllerComponent) in this motion controller
  117323. * Components have a ComponentType and can also have both button and axis definitions
  117324. */
  117325. readonly components: {
  117326. [id: string]: WebXRControllerComponent;
  117327. };
  117328. /**
  117329. * Disable the model's animation. Can be set at any time.
  117330. */
  117331. disableAnimation: boolean;
  117332. /**
  117333. * Observers registered here will be triggered when the model of this controller is done loading
  117334. */
  117335. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117336. /**
  117337. * The profile id of this motion controller
  117338. */
  117339. abstract profileId: string;
  117340. /**
  117341. * The root mesh of the model. It is null if the model was not yet initialized
  117342. */
  117343. rootMesh: Nullable<AbstractMesh>;
  117344. /**
  117345. * constructs a new abstract motion controller
  117346. * @param scene the scene to which the model of the controller will be added
  117347. * @param layout The profile layout to load
  117348. * @param gamepadObject The gamepad object correlating to this controller
  117349. * @param handness handness (left/right/none) of this controller
  117350. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117351. */
  117352. constructor(scene: Scene, layout: IMotionControllerLayout,
  117353. /**
  117354. * The gamepad object correlating to this controller
  117355. */
  117356. gamepadObject: IMinimalMotionControllerObject,
  117357. /**
  117358. * handness (left/right/none) of this controller
  117359. */
  117360. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117361. /**
  117362. * Dispose this controller, the model mesh and all its components
  117363. */
  117364. dispose(): void;
  117365. /**
  117366. * Returns all components of specific type
  117367. * @param type the type to search for
  117368. * @return an array of components with this type
  117369. */
  117370. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117371. /**
  117372. * get a component based an its component id as defined in layout.components
  117373. * @param id the id of the component
  117374. * @returns the component correlates to the id or undefined if not found
  117375. */
  117376. getComponent(id: string): WebXRControllerComponent;
  117377. /**
  117378. * Get the list of components available in this motion controller
  117379. * @returns an array of strings correlating to available components
  117380. */
  117381. getComponentIds(): string[];
  117382. /**
  117383. * Get the first component of specific type
  117384. * @param type type of component to find
  117385. * @return a controller component or null if not found
  117386. */
  117387. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117388. /**
  117389. * Get the main (Select) component of this controller as defined in the layout
  117390. * @returns the main component of this controller
  117391. */
  117392. getMainComponent(): WebXRControllerComponent;
  117393. /**
  117394. * Loads the model correlating to this controller
  117395. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117396. * @returns A promise fulfilled with the result of the model loading
  117397. */
  117398. loadModel(): Promise<boolean>;
  117399. /**
  117400. * Update this model using the current XRFrame
  117401. * @param xrFrame the current xr frame to use and update the model
  117402. */
  117403. updateFromXRFrame(xrFrame: XRFrame): void;
  117404. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117405. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117406. /**
  117407. * Moves the axis on the controller mesh based on its current state
  117408. * @param axis the index of the axis
  117409. * @param axisValue the value of the axis which determines the meshes new position
  117410. * @hidden
  117411. */
  117412. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117413. /**
  117414. * Update the model itself with the current frame data
  117415. * @param xrFrame the frame to use for updating the model mesh
  117416. */
  117417. protected updateModel(xrFrame: XRFrame): void;
  117418. /**
  117419. * Get the filename and path for this controller's model
  117420. * @returns a map of filename and path
  117421. */
  117422. protected abstract _getFilenameAndPath(): {
  117423. filename: string;
  117424. path: string;
  117425. };
  117426. /**
  117427. * This function is called before the mesh is loaded. It checks for loading constraints.
  117428. * For example, this function can check if the GLB loader is available
  117429. * If this function returns false, the generic controller will be loaded instead
  117430. * @returns Is the client ready to load the mesh
  117431. */
  117432. protected abstract _getModelLoadingConstraints(): boolean;
  117433. /**
  117434. * This function will be called after the model was successfully loaded and can be used
  117435. * for mesh transformations before it is available for the user
  117436. * @param meshes the loaded meshes
  117437. */
  117438. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117439. /**
  117440. * Set the root mesh for this controller. Important for the WebXR controller class
  117441. * @param meshes the loaded meshes
  117442. */
  117443. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117444. /**
  117445. * A function executed each frame that updates the mesh (if needed)
  117446. * @param xrFrame the current xrFrame
  117447. */
  117448. protected abstract _updateModel(xrFrame: XRFrame): void;
  117449. private _getGenericFilenameAndPath;
  117450. private _getGenericParentMesh;
  117451. }
  117452. }
  117453. declare module BABYLON {
  117454. /**
  117455. * A generic trigger-only motion controller for WebXR
  117456. */
  117457. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117458. /**
  117459. * Static version of the profile id of this controller
  117460. */
  117461. static ProfileId: string;
  117462. profileId: string;
  117463. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117464. protected _getFilenameAndPath(): {
  117465. filename: string;
  117466. path: string;
  117467. };
  117468. protected _getModelLoadingConstraints(): boolean;
  117469. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117470. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117471. protected _updateModel(): void;
  117472. }
  117473. }
  117474. declare module BABYLON {
  117475. /**
  117476. * Class containing static functions to help procedurally build meshes
  117477. */
  117478. export class SphereBuilder {
  117479. /**
  117480. * Creates a sphere mesh
  117481. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117482. * * 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`)
  117483. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117484. * * 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
  117485. * * 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)
  117486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117489. * @param name defines the name of the mesh
  117490. * @param options defines the options used to create the mesh
  117491. * @param scene defines the hosting scene
  117492. * @returns the sphere mesh
  117493. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117494. */
  117495. static CreateSphere(name: string, options: {
  117496. segments?: number;
  117497. diameter?: number;
  117498. diameterX?: number;
  117499. diameterY?: number;
  117500. diameterZ?: number;
  117501. arc?: number;
  117502. slice?: number;
  117503. sideOrientation?: number;
  117504. frontUVs?: Vector4;
  117505. backUVs?: Vector4;
  117506. updatable?: boolean;
  117507. }, scene?: Nullable<Scene>): Mesh;
  117508. }
  117509. }
  117510. declare module BABYLON {
  117511. /**
  117512. * A profiled motion controller has its profile loaded from an online repository.
  117513. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117514. */
  117515. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117516. private _repositoryUrl;
  117517. private _buttonMeshMapping;
  117518. private _touchDots;
  117519. /**
  117520. * The profile ID of this controller. Will be populated when the controller initializes.
  117521. */
  117522. profileId: string;
  117523. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117524. dispose(): void;
  117525. protected _getFilenameAndPath(): {
  117526. filename: string;
  117527. path: string;
  117528. };
  117529. protected _getModelLoadingConstraints(): boolean;
  117530. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117531. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117532. protected _updateModel(_xrFrame: XRFrame): void;
  117533. }
  117534. }
  117535. declare module BABYLON {
  117536. /**
  117537. * A construction function type to create a new controller based on an xrInput object
  117538. */
  117539. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117540. /**
  117541. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117542. *
  117543. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117544. * it should be replaced with auto-loaded controllers.
  117545. *
  117546. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117547. */
  117548. export class WebXRMotionControllerManager {
  117549. private static _AvailableControllers;
  117550. private static _Fallbacks;
  117551. private static _ProfileLoadingPromises;
  117552. private static _ProfilesList;
  117553. /**
  117554. * The base URL of the online controller repository. Can be changed at any time.
  117555. */
  117556. static BaseRepositoryUrl: string;
  117557. /**
  117558. * Which repository gets priority - local or online
  117559. */
  117560. static PrioritizeOnlineRepository: boolean;
  117561. /**
  117562. * Use the online repository, or use only locally-defined controllers
  117563. */
  117564. static UseOnlineRepository: boolean;
  117565. /**
  117566. * Clear the cache used for profile loading and reload when requested again
  117567. */
  117568. static ClearProfilesCache(): void;
  117569. /**
  117570. * Register the default fallbacks.
  117571. * This function is called automatically when this file is imported.
  117572. */
  117573. static DefaultFallbacks(): void;
  117574. /**
  117575. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117576. * @param profileId the profile to which a fallback needs to be found
  117577. * @return an array with corresponding fallback profiles
  117578. */
  117579. static FindFallbackWithProfileId(profileId: string): string[];
  117580. /**
  117581. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117582. * The order of search:
  117583. *
  117584. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117585. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117586. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117587. * 4) return the generic trigger controller if none were found
  117588. *
  117589. * @param xrInput the xrInput to which a new controller is initialized
  117590. * @param scene the scene to which the model will be added
  117591. * @param forceProfile force a certain profile for this controller
  117592. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117593. */
  117594. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117595. /**
  117596. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117597. *
  117598. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117599. *
  117600. * @param type the profile type to register
  117601. * @param constructFunction the function to be called when loading this profile
  117602. */
  117603. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117604. /**
  117605. * Register a fallback to a specific profile.
  117606. * @param profileId the profileId that will receive the fallbacks
  117607. * @param fallbacks A list of fallback profiles
  117608. */
  117609. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117610. /**
  117611. * Will update the list of profiles available in the repository
  117612. * @return a promise that resolves to a map of profiles available online
  117613. */
  117614. static UpdateProfilesList(): Promise<{
  117615. [profile: string]: string;
  117616. }>;
  117617. private static _LoadProfileFromRepository;
  117618. private static _LoadProfilesFromAvailableControllers;
  117619. }
  117620. }
  117621. declare module BABYLON {
  117622. /**
  117623. * Configuration options for the WebXR controller creation
  117624. */
  117625. export interface IWebXRControllerOptions {
  117626. /**
  117627. * Should the controller mesh be animated when a user interacts with it
  117628. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117629. */
  117630. disableMotionControllerAnimation?: boolean;
  117631. /**
  117632. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117633. */
  117634. doNotLoadControllerMesh?: boolean;
  117635. /**
  117636. * Force a specific controller type for this controller.
  117637. * This can be used when creating your own profile or when testing different controllers
  117638. */
  117639. forceControllerProfile?: string;
  117640. }
  117641. /**
  117642. * Represents an XR controller
  117643. */
  117644. export class WebXRInputSource {
  117645. private _scene;
  117646. /** The underlying input source for the controller */
  117647. inputSource: XRInputSource;
  117648. private _options;
  117649. private _tmpQuaternion;
  117650. private _tmpVector;
  117651. private _uniqueId;
  117652. /**
  117653. * 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
  117654. */
  117655. grip?: AbstractMesh;
  117656. /**
  117657. * If available, this is the gamepad object related to this controller.
  117658. * Using this object it is possible to get click events and trackpad changes of the
  117659. * webxr controller that is currently being used.
  117660. */
  117661. motionController?: WebXRAbstractMotionController;
  117662. /**
  117663. * Event that fires when the controller is removed/disposed.
  117664. * The object provided as event data is this controller, after associated assets were disposed.
  117665. * uniqueId is still available.
  117666. */
  117667. onDisposeObservable: Observable<WebXRInputSource>;
  117668. /**
  117669. * Will be triggered when the mesh associated with the motion controller is done loading.
  117670. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117671. * A shortened version of controller -> motion controller -> on mesh loaded.
  117672. */
  117673. onMeshLoadedObservable: Observable<AbstractMesh>;
  117674. /**
  117675. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117676. */
  117677. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117678. /**
  117679. * Pointer which can be used to select objects or attach a visible laser to
  117680. */
  117681. pointer: AbstractMesh;
  117682. /**
  117683. * Creates the controller
  117684. * @see https://doc.babylonjs.com/how_to/webxr
  117685. * @param _scene the scene which the controller should be associated to
  117686. * @param inputSource the underlying input source for the controller
  117687. * @param _options options for this controller creation
  117688. */
  117689. constructor(_scene: Scene,
  117690. /** The underlying input source for the controller */
  117691. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117692. /**
  117693. * Get this controllers unique id
  117694. */
  117695. get uniqueId(): string;
  117696. /**
  117697. * Disposes of the object
  117698. */
  117699. dispose(): void;
  117700. /**
  117701. * Gets a world space ray coming from the pointer or grip
  117702. * @param result the resulting ray
  117703. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117704. */
  117705. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117706. /**
  117707. * Updates the controller pose based on the given XRFrame
  117708. * @param xrFrame xr frame to update the pose with
  117709. * @param referenceSpace reference space to use
  117710. */
  117711. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117712. }
  117713. }
  117714. declare module BABYLON {
  117715. /**
  117716. * The schema for initialization options of the XR Input class
  117717. */
  117718. export interface IWebXRInputOptions {
  117719. /**
  117720. * If set to true no model will be automatically loaded
  117721. */
  117722. doNotLoadControllerMeshes?: boolean;
  117723. /**
  117724. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117725. * If not found, the xr input profile data will be used.
  117726. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117727. */
  117728. forceInputProfile?: string;
  117729. /**
  117730. * Do not send a request to the controller repository to load the profile.
  117731. *
  117732. * Instead, use the controllers available in babylon itself.
  117733. */
  117734. disableOnlineControllerRepository?: boolean;
  117735. /**
  117736. * A custom URL for the controllers repository
  117737. */
  117738. customControllersRepositoryURL?: string;
  117739. /**
  117740. * Should the controller model's components not move according to the user input
  117741. */
  117742. disableControllerAnimation?: boolean;
  117743. }
  117744. /**
  117745. * XR input used to track XR inputs such as controllers/rays
  117746. */
  117747. export class WebXRInput implements IDisposable {
  117748. /**
  117749. * the xr session manager for this session
  117750. */
  117751. xrSessionManager: WebXRSessionManager;
  117752. /**
  117753. * the WebXR camera for this session. Mainly used for teleportation
  117754. */
  117755. xrCamera: WebXRCamera;
  117756. private readonly options;
  117757. /**
  117758. * XR controllers being tracked
  117759. */
  117760. controllers: Array<WebXRInputSource>;
  117761. private _frameObserver;
  117762. private _sessionEndedObserver;
  117763. private _sessionInitObserver;
  117764. /**
  117765. * Event when a controller has been connected/added
  117766. */
  117767. onControllerAddedObservable: Observable<WebXRInputSource>;
  117768. /**
  117769. * Event when a controller has been removed/disconnected
  117770. */
  117771. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117772. /**
  117773. * Initializes the WebXRInput
  117774. * @param xrSessionManager the xr session manager for this session
  117775. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117776. * @param options = initialization options for this xr input
  117777. */
  117778. constructor(
  117779. /**
  117780. * the xr session manager for this session
  117781. */
  117782. xrSessionManager: WebXRSessionManager,
  117783. /**
  117784. * the WebXR camera for this session. Mainly used for teleportation
  117785. */
  117786. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117787. private _onInputSourcesChange;
  117788. private _addAndRemoveControllers;
  117789. /**
  117790. * Disposes of the object
  117791. */
  117792. dispose(): void;
  117793. }
  117794. }
  117795. declare module BABYLON {
  117796. /**
  117797. * This is the base class for all WebXR features.
  117798. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117799. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117800. */
  117801. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117802. protected _xrSessionManager: WebXRSessionManager;
  117803. private _attached;
  117804. private _removeOnDetach;
  117805. /**
  117806. * Should auto-attach be disabled?
  117807. */
  117808. disableAutoAttach: boolean;
  117809. /**
  117810. * Construct a new (abstract) WebXR feature
  117811. * @param _xrSessionManager the xr session manager for this feature
  117812. */
  117813. constructor(_xrSessionManager: WebXRSessionManager);
  117814. /**
  117815. * Is this feature attached
  117816. */
  117817. get attached(): boolean;
  117818. /**
  117819. * attach this feature
  117820. *
  117821. * @param force should attachment be forced (even when already attached)
  117822. * @returns true if successful, false is failed or already attached
  117823. */
  117824. attach(force?: boolean): boolean;
  117825. /**
  117826. * detach this feature.
  117827. *
  117828. * @returns true if successful, false if failed or already detached
  117829. */
  117830. detach(): boolean;
  117831. /**
  117832. * Dispose this feature and all of the resources attached
  117833. */
  117834. dispose(): void;
  117835. /**
  117836. * This is used to register callbacks that will automatically be removed when detach is called.
  117837. * @param observable the observable to which the observer will be attached
  117838. * @param callback the callback to register
  117839. */
  117840. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117841. /**
  117842. * Code in this function will be executed on each xrFrame received from the browser.
  117843. * This function will not execute after the feature is detached.
  117844. * @param _xrFrame the current frame
  117845. */
  117846. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117847. }
  117848. }
  117849. declare module BABYLON {
  117850. /**
  117851. * Renders a layer on top of an existing scene
  117852. */
  117853. export class UtilityLayerRenderer implements IDisposable {
  117854. /** the original scene that will be rendered on top of */
  117855. originalScene: Scene;
  117856. private _pointerCaptures;
  117857. private _lastPointerEvents;
  117858. private static _DefaultUtilityLayer;
  117859. private static _DefaultKeepDepthUtilityLayer;
  117860. private _sharedGizmoLight;
  117861. private _renderCamera;
  117862. /**
  117863. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117864. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  117865. * @returns the camera that is used when rendering the utility layer
  117866. */
  117867. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  117868. /**
  117869. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117870. * @param cam the camera that should be used when rendering the utility layer
  117871. */
  117872. setRenderCamera(cam: Nullable<Camera>): void;
  117873. /**
  117874. * @hidden
  117875. * Light which used by gizmos to get light shading
  117876. */
  117877. _getSharedGizmoLight(): HemisphericLight;
  117878. /**
  117879. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117880. */
  117881. pickUtilitySceneFirst: boolean;
  117882. /**
  117883. * 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)
  117884. */
  117885. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117886. /**
  117887. * 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)
  117888. */
  117889. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117890. /**
  117891. * The scene that is rendered on top of the original scene
  117892. */
  117893. utilityLayerScene: Scene;
  117894. /**
  117895. * If the utility layer should automatically be rendered on top of existing scene
  117896. */
  117897. shouldRender: boolean;
  117898. /**
  117899. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117900. */
  117901. onlyCheckPointerDownEvents: boolean;
  117902. /**
  117903. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117904. */
  117905. processAllEvents: boolean;
  117906. /**
  117907. * Observable raised when the pointer move from the utility layer scene to the main scene
  117908. */
  117909. onPointerOutObservable: Observable<number>;
  117910. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117911. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117912. private _afterRenderObserver;
  117913. private _sceneDisposeObserver;
  117914. private _originalPointerObserver;
  117915. /**
  117916. * Instantiates a UtilityLayerRenderer
  117917. * @param originalScene the original scene that will be rendered on top of
  117918. * @param handleEvents boolean indicating if the utility layer should handle events
  117919. */
  117920. constructor(
  117921. /** the original scene that will be rendered on top of */
  117922. originalScene: Scene, handleEvents?: boolean);
  117923. private _notifyObservers;
  117924. /**
  117925. * Renders the utility layers scene on top of the original scene
  117926. */
  117927. render(): void;
  117928. /**
  117929. * Disposes of the renderer
  117930. */
  117931. dispose(): void;
  117932. private _updateCamera;
  117933. }
  117934. }
  117935. declare module BABYLON {
  117936. /**
  117937. * Options interface for the pointer selection module
  117938. */
  117939. export interface IWebXRControllerPointerSelectionOptions {
  117940. /**
  117941. * if provided, this scene will be used to render meshes.
  117942. */
  117943. customUtilityLayerScene?: Scene;
  117944. /**
  117945. * 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)
  117946. * If not disabled, the last picked point will be used to execute a pointer up event
  117947. * If disabled, pointer up event will be triggered right after the pointer down event.
  117948. * Used in screen and gaze target ray mode only
  117949. */
  117950. disablePointerUpOnTouchOut: boolean;
  117951. /**
  117952. * For gaze mode (time to select instead of press)
  117953. */
  117954. forceGazeMode: boolean;
  117955. /**
  117956. * 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
  117957. * to start a new countdown to the pointer down event.
  117958. * Defaults to 1.
  117959. */
  117960. gazeModePointerMovedFactor?: number;
  117961. /**
  117962. * Different button type to use instead of the main component
  117963. */
  117964. overrideButtonId?: string;
  117965. /**
  117966. * use this rendering group id for the meshes (optional)
  117967. */
  117968. renderingGroupId?: number;
  117969. /**
  117970. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  117971. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117972. * 3000 means 3 seconds between pointing at something and selecting it
  117973. */
  117974. timeToSelect?: number;
  117975. /**
  117976. * Should meshes created here be added to a utility layer or the main scene
  117977. */
  117978. useUtilityLayer?: boolean;
  117979. /**
  117980. * the xr input to use with this pointer selection
  117981. */
  117982. xrInput: WebXRInput;
  117983. }
  117984. /**
  117985. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117986. */
  117987. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117988. private readonly _options;
  117989. private static _idCounter;
  117990. private _attachController;
  117991. private _controllers;
  117992. private _scene;
  117993. private _tmpVectorForPickCompare;
  117994. /**
  117995. * The module's name
  117996. */
  117997. static readonly Name: string;
  117998. /**
  117999. * The (Babylon) version of this module.
  118000. * This is an integer representing the implementation version.
  118001. * This number does not correspond to the WebXR specs version
  118002. */
  118003. static readonly Version: number;
  118004. /**
  118005. * Disable lighting on the laser pointer (so it will always be visible)
  118006. */
  118007. disablePointerLighting: boolean;
  118008. /**
  118009. * Disable lighting on the selection mesh (so it will always be visible)
  118010. */
  118011. disableSelectionMeshLighting: boolean;
  118012. /**
  118013. * Should the laser pointer be displayed
  118014. */
  118015. displayLaserPointer: boolean;
  118016. /**
  118017. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  118018. */
  118019. displaySelectionMesh: boolean;
  118020. /**
  118021. * This color will be set to the laser pointer when selection is triggered
  118022. */
  118023. laserPointerPickedColor: Color3;
  118024. /**
  118025. * Default color of the laser pointer
  118026. */
  118027. lasterPointerDefaultColor: Color3;
  118028. /**
  118029. * default color of the selection ring
  118030. */
  118031. selectionMeshDefaultColor: Color3;
  118032. /**
  118033. * This color will be applied to the selection ring when selection is triggered
  118034. */
  118035. selectionMeshPickedColor: Color3;
  118036. /**
  118037. * constructs a new background remover module
  118038. * @param _xrSessionManager the session manager for this module
  118039. * @param _options read-only options to be used in this module
  118040. */
  118041. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  118042. /**
  118043. * attach this feature
  118044. * Will usually be called by the features manager
  118045. *
  118046. * @returns true if successful.
  118047. */
  118048. attach(): boolean;
  118049. /**
  118050. * detach this feature.
  118051. * Will usually be called by the features manager
  118052. *
  118053. * @returns true if successful.
  118054. */
  118055. detach(): boolean;
  118056. /**
  118057. * Will get the mesh under a specific pointer.
  118058. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  118059. * @param controllerId the controllerId to check
  118060. * @returns The mesh under pointer or null if no mesh is under the pointer
  118061. */
  118062. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  118063. /**
  118064. * Get the xr controller that correlates to the pointer id in the pointer event
  118065. *
  118066. * @param id the pointer id to search for
  118067. * @returns the controller that correlates to this id or null if not found
  118068. */
  118069. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  118070. protected _onXRFrame(_xrFrame: XRFrame): void;
  118071. private _attachGazeMode;
  118072. private _attachScreenRayMode;
  118073. private _attachTrackedPointerRayMode;
  118074. private _convertNormalToDirectionOfRay;
  118075. private _detachController;
  118076. private _generateNewMeshPair;
  118077. private _pickingMoved;
  118078. private _updatePointerDistance;
  118079. }
  118080. }
  118081. declare module BABYLON {
  118082. /**
  118083. * Button which can be used to enter a different mode of XR
  118084. */
  118085. export class WebXREnterExitUIButton {
  118086. /** button element */
  118087. element: HTMLElement;
  118088. /** XR initialization options for the button */
  118089. sessionMode: XRSessionMode;
  118090. /** Reference space type */
  118091. referenceSpaceType: XRReferenceSpaceType;
  118092. /**
  118093. * Creates a WebXREnterExitUIButton
  118094. * @param element button element
  118095. * @param sessionMode XR initialization session mode
  118096. * @param referenceSpaceType the type of reference space to be used
  118097. */
  118098. constructor(
  118099. /** button element */
  118100. element: HTMLElement,
  118101. /** XR initialization options for the button */
  118102. sessionMode: XRSessionMode,
  118103. /** Reference space type */
  118104. referenceSpaceType: XRReferenceSpaceType);
  118105. /**
  118106. * Extendable function which can be used to update the button's visuals when the state changes
  118107. * @param activeButton the current active button in the UI
  118108. */
  118109. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  118110. }
  118111. /**
  118112. * Options to create the webXR UI
  118113. */
  118114. export class WebXREnterExitUIOptions {
  118115. /**
  118116. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  118117. */
  118118. customButtons?: Array<WebXREnterExitUIButton>;
  118119. /**
  118120. * A reference space type to use when creating the default button.
  118121. * Default is local-floor
  118122. */
  118123. referenceSpaceType?: XRReferenceSpaceType;
  118124. /**
  118125. * Context to enter xr with
  118126. */
  118127. renderTarget?: Nullable<WebXRRenderTarget>;
  118128. /**
  118129. * A session mode to use when creating the default button.
  118130. * Default is immersive-vr
  118131. */
  118132. sessionMode?: XRSessionMode;
  118133. }
  118134. /**
  118135. * UI to allow the user to enter/exit XR mode
  118136. */
  118137. export class WebXREnterExitUI implements IDisposable {
  118138. private scene;
  118139. /** version of the options passed to this UI */
  118140. options: WebXREnterExitUIOptions;
  118141. private _activeButton;
  118142. private _buttons;
  118143. private _overlay;
  118144. /**
  118145. * Fired every time the active button is changed.
  118146. *
  118147. * When xr is entered via a button that launches xr that button will be the callback parameter
  118148. *
  118149. * When exiting xr the callback parameter will be null)
  118150. */
  118151. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  118152. /**
  118153. *
  118154. * @param scene babylon scene object to use
  118155. * @param options (read-only) version of the options passed to this UI
  118156. */
  118157. private constructor();
  118158. /**
  118159. * Creates UI to allow the user to enter/exit XR mode
  118160. * @param scene the scene to add the ui to
  118161. * @param helper the xr experience helper to enter/exit xr with
  118162. * @param options options to configure the UI
  118163. * @returns the created ui
  118164. */
  118165. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  118166. /**
  118167. * Disposes of the XR UI component
  118168. */
  118169. dispose(): void;
  118170. private _updateButtons;
  118171. }
  118172. }
  118173. declare module BABYLON {
  118174. /**
  118175. * Class containing static functions to help procedurally build meshes
  118176. */
  118177. export class LinesBuilder {
  118178. /**
  118179. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  118180. * * 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
  118181. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  118182. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  118183. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  118184. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  118185. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118186. * * 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
  118187. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  118188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118189. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  118190. * @param name defines the name of the new line system
  118191. * @param options defines the options used to create the line system
  118192. * @param scene defines the hosting scene
  118193. * @returns a new line system mesh
  118194. */
  118195. static CreateLineSystem(name: string, options: {
  118196. lines: Vector3[][];
  118197. updatable?: boolean;
  118198. instance?: Nullable<LinesMesh>;
  118199. colors?: Nullable<Color4[][]>;
  118200. useVertexAlpha?: boolean;
  118201. }, scene: Nullable<Scene>): LinesMesh;
  118202. /**
  118203. * Creates a line mesh
  118204. * 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
  118205. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118206. * * The parameter `points` is an array successive Vector3
  118207. * * 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
  118208. * * The optional parameter `colors` is an array of successive Color4, one per line point
  118209. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  118210. * * When updating an instance, remember that only point positions can change, not the number of points
  118211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118212. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  118213. * @param name defines the name of the new line system
  118214. * @param options defines the options used to create the line system
  118215. * @param scene defines the hosting scene
  118216. * @returns a new line mesh
  118217. */
  118218. static CreateLines(name: string, options: {
  118219. points: Vector3[];
  118220. updatable?: boolean;
  118221. instance?: Nullable<LinesMesh>;
  118222. colors?: Color4[];
  118223. useVertexAlpha?: boolean;
  118224. }, scene?: Nullable<Scene>): LinesMesh;
  118225. /**
  118226. * Creates a dashed line mesh
  118227. * * 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
  118228. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118229. * * The parameter `points` is an array successive Vector3
  118230. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118231. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118232. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118233. * * 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
  118234. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118235. * * When updating an instance, remember that only point positions can change, not the number of points
  118236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118237. * @param name defines the name of the mesh
  118238. * @param options defines the options used to create the mesh
  118239. * @param scene defines the hosting scene
  118240. * @returns the dashed line mesh
  118241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118242. */
  118243. static CreateDashedLines(name: string, options: {
  118244. points: Vector3[];
  118245. dashSize?: number;
  118246. gapSize?: number;
  118247. dashNb?: number;
  118248. updatable?: boolean;
  118249. instance?: LinesMesh;
  118250. useVertexAlpha?: boolean;
  118251. }, scene?: Nullable<Scene>): LinesMesh;
  118252. }
  118253. }
  118254. declare module BABYLON {
  118255. /**
  118256. * The options container for the teleportation module
  118257. */
  118258. export interface IWebXRTeleportationOptions {
  118259. /**
  118260. * if provided, this scene will be used to render meshes.
  118261. */
  118262. customUtilityLayerScene?: Scene;
  118263. /**
  118264. * Values to configure the default target mesh
  118265. */
  118266. defaultTargetMeshOptions?: {
  118267. /**
  118268. * Fill color of the teleportation area
  118269. */
  118270. teleportationFillColor?: string;
  118271. /**
  118272. * Border color for the teleportation area
  118273. */
  118274. teleportationBorderColor?: string;
  118275. /**
  118276. * Disable the mesh's animation sequence
  118277. */
  118278. disableAnimation?: boolean;
  118279. /**
  118280. * Disable lighting on the material or the ring and arrow
  118281. */
  118282. disableLighting?: boolean;
  118283. /**
  118284. * Override the default material of the torus and arrow
  118285. */
  118286. torusArrowMaterial?: Material;
  118287. };
  118288. /**
  118289. * A list of meshes to use as floor meshes.
  118290. * Meshes can be added and removed after initializing the feature using the
  118291. * addFloorMesh and removeFloorMesh functions
  118292. * If empty, rotation will still work
  118293. */
  118294. floorMeshes?: AbstractMesh[];
  118295. /**
  118296. * use this rendering group id for the meshes (optional)
  118297. */
  118298. renderingGroupId?: number;
  118299. /**
  118300. * Should teleportation move only to snap points
  118301. */
  118302. snapPointsOnly?: boolean;
  118303. /**
  118304. * An array of points to which the teleportation will snap to.
  118305. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  118306. */
  118307. snapPositions?: Vector3[];
  118308. /**
  118309. * How close should the teleportation ray be in order to snap to position.
  118310. * Default to 0.8 units (meters)
  118311. */
  118312. snapToPositionRadius?: number;
  118313. /**
  118314. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  118315. * If you want to support rotation, make sure your mesh has a direction indicator.
  118316. *
  118317. * When left untouched, the default mesh will be initialized.
  118318. */
  118319. teleportationTargetMesh?: AbstractMesh;
  118320. /**
  118321. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  118322. */
  118323. timeToTeleport?: number;
  118324. /**
  118325. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  118326. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  118327. */
  118328. useMainComponentOnly?: boolean;
  118329. /**
  118330. * Should meshes created here be added to a utility layer or the main scene
  118331. */
  118332. useUtilityLayer?: boolean;
  118333. /**
  118334. * Babylon XR Input class for controller
  118335. */
  118336. xrInput: WebXRInput;
  118337. }
  118338. /**
  118339. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  118340. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118341. * the input of the attached controllers.
  118342. */
  118343. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118344. private _options;
  118345. private _controllers;
  118346. private _currentTeleportationControllerId;
  118347. private _floorMeshes;
  118348. private _quadraticBezierCurve;
  118349. private _selectionFeature;
  118350. private _snapToPositions;
  118351. private _snappedToPoint;
  118352. private _teleportationRingMaterial?;
  118353. private _tmpRay;
  118354. private _tmpVector;
  118355. /**
  118356. * The module's name
  118357. */
  118358. static readonly Name: string;
  118359. /**
  118360. * The (Babylon) version of this module.
  118361. * This is an integer representing the implementation version.
  118362. * This number does not correspond to the webxr specs version
  118363. */
  118364. static readonly Version: number;
  118365. /**
  118366. * Is movement backwards enabled
  118367. */
  118368. backwardsMovementEnabled: boolean;
  118369. /**
  118370. * Distance to travel when moving backwards
  118371. */
  118372. backwardsTeleportationDistance: number;
  118373. /**
  118374. * The distance from the user to the inspection point in the direction of the controller
  118375. * A higher number will allow the user to move further
  118376. * defaults to 5 (meters, in xr units)
  118377. */
  118378. parabolicCheckRadius: number;
  118379. /**
  118380. * Should the module support parabolic ray on top of direct ray
  118381. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118382. * Very helpful when moving between floors / different heights
  118383. */
  118384. parabolicRayEnabled: boolean;
  118385. /**
  118386. * How much rotation should be applied when rotating right and left
  118387. */
  118388. rotationAngle: number;
  118389. /**
  118390. * Is rotation enabled when moving forward?
  118391. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118392. */
  118393. rotationEnabled: boolean;
  118394. /**
  118395. * constructs a new anchor system
  118396. * @param _xrSessionManager an instance of WebXRSessionManager
  118397. * @param _options configuration object for this feature
  118398. */
  118399. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118400. /**
  118401. * Get the snapPointsOnly flag
  118402. */
  118403. get snapPointsOnly(): boolean;
  118404. /**
  118405. * Sets the snapPointsOnly flag
  118406. * @param snapToPoints should teleportation be exclusively to snap points
  118407. */
  118408. set snapPointsOnly(snapToPoints: boolean);
  118409. /**
  118410. * Add a new mesh to the floor meshes array
  118411. * @param mesh the mesh to use as floor mesh
  118412. */
  118413. addFloorMesh(mesh: AbstractMesh): void;
  118414. /**
  118415. * Add a new snap-to point to fix teleportation to this position
  118416. * @param newSnapPoint The new Snap-To point
  118417. */
  118418. addSnapPoint(newSnapPoint: Vector3): void;
  118419. attach(): boolean;
  118420. detach(): boolean;
  118421. dispose(): void;
  118422. /**
  118423. * Remove a mesh from the floor meshes array
  118424. * @param mesh the mesh to remove
  118425. */
  118426. removeFloorMesh(mesh: AbstractMesh): void;
  118427. /**
  118428. * Remove a mesh from the floor meshes array using its name
  118429. * @param name the mesh name to remove
  118430. */
  118431. removeFloorMeshByName(name: string): void;
  118432. /**
  118433. * 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
  118434. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118435. * @returns was the point found and removed or not
  118436. */
  118437. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118438. /**
  118439. * This function sets a selection feature that will be disabled when
  118440. * the forward ray is shown and will be reattached when hidden.
  118441. * This is used to remove the selection rays when moving.
  118442. * @param selectionFeature the feature to disable when forward movement is enabled
  118443. */
  118444. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118445. protected _onXRFrame(_xrFrame: XRFrame): void;
  118446. private _attachController;
  118447. private _createDefaultTargetMesh;
  118448. private _detachController;
  118449. private _findClosestSnapPointWithRadius;
  118450. private _setTargetMeshPosition;
  118451. private _setTargetMeshVisibility;
  118452. private _showParabolicPath;
  118453. private _teleportForward;
  118454. }
  118455. }
  118456. declare module BABYLON {
  118457. /**
  118458. * Options for the default xr helper
  118459. */
  118460. export class WebXRDefaultExperienceOptions {
  118461. /**
  118462. * Enable or disable default UI to enter XR
  118463. */
  118464. disableDefaultUI?: boolean;
  118465. /**
  118466. * Should teleportation not initialize. defaults to false.
  118467. */
  118468. disableTeleportation?: boolean;
  118469. /**
  118470. * Floor meshes that will be used for teleport
  118471. */
  118472. floorMeshes?: Array<AbstractMesh>;
  118473. /**
  118474. * If set to true, the first frame will not be used to reset position
  118475. * The first frame is mainly used when copying transformation from the old camera
  118476. * Mainly used in AR
  118477. */
  118478. ignoreNativeCameraTransformation?: boolean;
  118479. /**
  118480. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118481. */
  118482. inputOptions?: IWebXRInputOptions;
  118483. /**
  118484. * optional configuration for the output canvas
  118485. */
  118486. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118487. /**
  118488. * optional UI options. This can be used among other to change session mode and reference space type
  118489. */
  118490. uiOptions?: WebXREnterExitUIOptions;
  118491. /**
  118492. * When loading teleportation and pointer select, use stable versions instead of latest.
  118493. */
  118494. useStablePlugins?: boolean;
  118495. }
  118496. /**
  118497. * Default experience which provides a similar setup to the previous webVRExperience
  118498. */
  118499. export class WebXRDefaultExperience {
  118500. /**
  118501. * Base experience
  118502. */
  118503. baseExperience: WebXRExperienceHelper;
  118504. /**
  118505. * Enables ui for entering/exiting xr
  118506. */
  118507. enterExitUI: WebXREnterExitUI;
  118508. /**
  118509. * Input experience extension
  118510. */
  118511. input: WebXRInput;
  118512. /**
  118513. * Enables laser pointer and selection
  118514. */
  118515. pointerSelection: WebXRControllerPointerSelection;
  118516. /**
  118517. * Default target xr should render to
  118518. */
  118519. renderTarget: WebXRRenderTarget;
  118520. /**
  118521. * Enables teleportation
  118522. */
  118523. teleportation: WebXRMotionControllerTeleportation;
  118524. private constructor();
  118525. /**
  118526. * Creates the default xr experience
  118527. * @param scene scene
  118528. * @param options options for basic configuration
  118529. * @returns resulting WebXRDefaultExperience
  118530. */
  118531. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118532. /**
  118533. * DIsposes of the experience helper
  118534. */
  118535. dispose(): void;
  118536. }
  118537. }
  118538. declare module BABYLON {
  118539. /**
  118540. * Options to modify the vr teleportation behavior.
  118541. */
  118542. export interface VRTeleportationOptions {
  118543. /**
  118544. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118545. */
  118546. floorMeshName?: string;
  118547. /**
  118548. * A list of meshes to be used as the teleportation floor. (default: empty)
  118549. */
  118550. floorMeshes?: Mesh[];
  118551. /**
  118552. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118553. */
  118554. teleportationMode?: number;
  118555. /**
  118556. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118557. */
  118558. teleportationTime?: number;
  118559. /**
  118560. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118561. */
  118562. teleportationSpeed?: number;
  118563. /**
  118564. * The easing function used in the animation or null for Linear. (default CircleEase)
  118565. */
  118566. easingFunction?: EasingFunction;
  118567. }
  118568. /**
  118569. * Options to modify the vr experience helper's behavior.
  118570. */
  118571. export interface VRExperienceHelperOptions extends WebVROptions {
  118572. /**
  118573. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118574. */
  118575. createDeviceOrientationCamera?: boolean;
  118576. /**
  118577. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118578. */
  118579. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118580. /**
  118581. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118582. */
  118583. laserToggle?: boolean;
  118584. /**
  118585. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118586. */
  118587. floorMeshes?: Mesh[];
  118588. /**
  118589. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118590. */
  118591. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118592. /**
  118593. * Defines if WebXR should be used instead of WebVR (if available)
  118594. */
  118595. useXR?: boolean;
  118596. }
  118597. /**
  118598. * Event containing information after VR has been entered
  118599. */
  118600. export class OnAfterEnteringVRObservableEvent {
  118601. /**
  118602. * If entering vr was successful
  118603. */
  118604. success: boolean;
  118605. }
  118606. /**
  118607. * Helps to quickly add VR support to an existing scene.
  118608. * See http://doc.babylonjs.com/how_to/webvr_helper
  118609. */
  118610. export class VRExperienceHelper {
  118611. /** Options to modify the vr experience helper's behavior. */
  118612. webVROptions: VRExperienceHelperOptions;
  118613. private _scene;
  118614. private _position;
  118615. private _btnVR;
  118616. private _btnVRDisplayed;
  118617. private _webVRsupported;
  118618. private _webVRready;
  118619. private _webVRrequesting;
  118620. private _webVRpresenting;
  118621. private _hasEnteredVR;
  118622. private _fullscreenVRpresenting;
  118623. private _inputElement;
  118624. private _webVRCamera;
  118625. private _vrDeviceOrientationCamera;
  118626. private _deviceOrientationCamera;
  118627. private _existingCamera;
  118628. private _onKeyDown;
  118629. private _onVrDisplayPresentChange;
  118630. private _onVRDisplayChanged;
  118631. private _onVRRequestPresentStart;
  118632. private _onVRRequestPresentComplete;
  118633. /**
  118634. * 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)
  118635. */
  118636. enableGazeEvenWhenNoPointerLock: boolean;
  118637. /**
  118638. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118639. */
  118640. exitVROnDoubleTap: boolean;
  118641. /**
  118642. * Observable raised right before entering VR.
  118643. */
  118644. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118645. /**
  118646. * Observable raised when entering VR has completed.
  118647. */
  118648. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118649. /**
  118650. * Observable raised when exiting VR.
  118651. */
  118652. onExitingVRObservable: Observable<VRExperienceHelper>;
  118653. /**
  118654. * Observable raised when controller mesh is loaded.
  118655. */
  118656. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118657. /** Return this.onEnteringVRObservable
  118658. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118659. */
  118660. get onEnteringVR(): Observable<VRExperienceHelper>;
  118661. /** Return this.onExitingVRObservable
  118662. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118663. */
  118664. get onExitingVR(): Observable<VRExperienceHelper>;
  118665. /** Return this.onControllerMeshLoadedObservable
  118666. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118667. */
  118668. get onControllerMeshLoaded(): Observable<WebVRController>;
  118669. private _rayLength;
  118670. private _useCustomVRButton;
  118671. private _teleportationRequested;
  118672. private _teleportActive;
  118673. private _floorMeshName;
  118674. private _floorMeshesCollection;
  118675. private _teleportationMode;
  118676. private _teleportationTime;
  118677. private _teleportationSpeed;
  118678. private _teleportationEasing;
  118679. private _rotationAllowed;
  118680. private _teleportBackwardsVector;
  118681. private _teleportationTarget;
  118682. private _isDefaultTeleportationTarget;
  118683. private _postProcessMove;
  118684. private _teleportationFillColor;
  118685. private _teleportationBorderColor;
  118686. private _rotationAngle;
  118687. private _haloCenter;
  118688. private _cameraGazer;
  118689. private _padSensibilityUp;
  118690. private _padSensibilityDown;
  118691. private _leftController;
  118692. private _rightController;
  118693. private _gazeColor;
  118694. private _laserColor;
  118695. private _pickedLaserColor;
  118696. private _pickedGazeColor;
  118697. /**
  118698. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118699. */
  118700. onNewMeshSelected: Observable<AbstractMesh>;
  118701. /**
  118702. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118703. * This observable will provide the mesh and the controller used to select the mesh
  118704. */
  118705. onMeshSelectedWithController: Observable<{
  118706. mesh: AbstractMesh;
  118707. controller: WebVRController;
  118708. }>;
  118709. /**
  118710. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118711. */
  118712. onNewMeshPicked: Observable<PickingInfo>;
  118713. private _circleEase;
  118714. /**
  118715. * Observable raised before camera teleportation
  118716. */
  118717. onBeforeCameraTeleport: Observable<Vector3>;
  118718. /**
  118719. * Observable raised after camera teleportation
  118720. */
  118721. onAfterCameraTeleport: Observable<Vector3>;
  118722. /**
  118723. * Observable raised when current selected mesh gets unselected
  118724. */
  118725. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118726. private _raySelectionPredicate;
  118727. /**
  118728. * To be optionaly changed by user to define custom ray selection
  118729. */
  118730. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118731. /**
  118732. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118733. */
  118734. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118735. /**
  118736. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118737. */
  118738. teleportationEnabled: boolean;
  118739. private _defaultHeight;
  118740. private _teleportationInitialized;
  118741. private _interactionsEnabled;
  118742. private _interactionsRequested;
  118743. private _displayGaze;
  118744. private _displayLaserPointer;
  118745. /**
  118746. * The mesh used to display where the user is going to teleport.
  118747. */
  118748. get teleportationTarget(): Mesh;
  118749. /**
  118750. * Sets the mesh to be used to display where the user is going to teleport.
  118751. */
  118752. set teleportationTarget(value: Mesh);
  118753. /**
  118754. * 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
  118755. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118756. * See http://doc.babylonjs.com/resources/baking_transformations
  118757. */
  118758. get gazeTrackerMesh(): Mesh;
  118759. set gazeTrackerMesh(value: Mesh);
  118760. /**
  118761. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118762. */
  118763. updateGazeTrackerScale: boolean;
  118764. /**
  118765. * If the gaze trackers color should be updated when selecting meshes
  118766. */
  118767. updateGazeTrackerColor: boolean;
  118768. /**
  118769. * If the controller laser color should be updated when selecting meshes
  118770. */
  118771. updateControllerLaserColor: boolean;
  118772. /**
  118773. * The gaze tracking mesh corresponding to the left controller
  118774. */
  118775. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118776. /**
  118777. * The gaze tracking mesh corresponding to the right controller
  118778. */
  118779. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118780. /**
  118781. * If the ray of the gaze should be displayed.
  118782. */
  118783. get displayGaze(): boolean;
  118784. /**
  118785. * Sets if the ray of the gaze should be displayed.
  118786. */
  118787. set displayGaze(value: boolean);
  118788. /**
  118789. * If the ray of the LaserPointer should be displayed.
  118790. */
  118791. get displayLaserPointer(): boolean;
  118792. /**
  118793. * Sets if the ray of the LaserPointer should be displayed.
  118794. */
  118795. set displayLaserPointer(value: boolean);
  118796. /**
  118797. * The deviceOrientationCamera used as the camera when not in VR.
  118798. */
  118799. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118800. /**
  118801. * Based on the current WebVR support, returns the current VR camera used.
  118802. */
  118803. get currentVRCamera(): Nullable<Camera>;
  118804. /**
  118805. * The webVRCamera which is used when in VR.
  118806. */
  118807. get webVRCamera(): WebVRFreeCamera;
  118808. /**
  118809. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118810. */
  118811. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118812. /**
  118813. * The html button that is used to trigger entering into VR.
  118814. */
  118815. get vrButton(): Nullable<HTMLButtonElement>;
  118816. private get _teleportationRequestInitiated();
  118817. /**
  118818. * Defines whether or not Pointer lock should be requested when switching to
  118819. * full screen.
  118820. */
  118821. requestPointerLockOnFullScreen: boolean;
  118822. /**
  118823. * If asking to force XR, this will be populated with the default xr experience
  118824. */
  118825. xr: WebXRDefaultExperience;
  118826. /**
  118827. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118828. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118829. */
  118830. xrTestDone: boolean;
  118831. /**
  118832. * Instantiates a VRExperienceHelper.
  118833. * Helps to quickly add VR support to an existing scene.
  118834. * @param scene The scene the VRExperienceHelper belongs to.
  118835. * @param webVROptions Options to modify the vr experience helper's behavior.
  118836. */
  118837. constructor(scene: Scene,
  118838. /** Options to modify the vr experience helper's behavior. */
  118839. webVROptions?: VRExperienceHelperOptions);
  118840. private completeVRInit;
  118841. private _onDefaultMeshLoaded;
  118842. private _onResize;
  118843. private _onFullscreenChange;
  118844. /**
  118845. * Gets a value indicating if we are currently in VR mode.
  118846. */
  118847. get isInVRMode(): boolean;
  118848. private onVrDisplayPresentChange;
  118849. private onVRDisplayChanged;
  118850. private moveButtonToBottomRight;
  118851. private displayVRButton;
  118852. private updateButtonVisibility;
  118853. private _cachedAngularSensibility;
  118854. /**
  118855. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118856. * Otherwise, will use the fullscreen API.
  118857. */
  118858. enterVR(): void;
  118859. /**
  118860. * Attempt to exit VR, or fullscreen.
  118861. */
  118862. exitVR(): void;
  118863. /**
  118864. * The position of the vr experience helper.
  118865. */
  118866. get position(): Vector3;
  118867. /**
  118868. * Sets the position of the vr experience helper.
  118869. */
  118870. set position(value: Vector3);
  118871. /**
  118872. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118873. */
  118874. enableInteractions(): void;
  118875. private get _noControllerIsActive();
  118876. private beforeRender;
  118877. private _isTeleportationFloor;
  118878. /**
  118879. * Adds a floor mesh to be used for teleportation.
  118880. * @param floorMesh the mesh to be used for teleportation.
  118881. */
  118882. addFloorMesh(floorMesh: Mesh): void;
  118883. /**
  118884. * Removes a floor mesh from being used for teleportation.
  118885. * @param floorMesh the mesh to be removed.
  118886. */
  118887. removeFloorMesh(floorMesh: Mesh): void;
  118888. /**
  118889. * Enables interactions and teleportation using the VR controllers and gaze.
  118890. * @param vrTeleportationOptions options to modify teleportation behavior.
  118891. */
  118892. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118893. private _onNewGamepadConnected;
  118894. private _tryEnableInteractionOnController;
  118895. private _onNewGamepadDisconnected;
  118896. private _enableInteractionOnController;
  118897. private _checkTeleportWithRay;
  118898. private _checkRotate;
  118899. private _checkTeleportBackwards;
  118900. private _enableTeleportationOnController;
  118901. private _createTeleportationCircles;
  118902. private _displayTeleportationTarget;
  118903. private _hideTeleportationTarget;
  118904. private _rotateCamera;
  118905. private _moveTeleportationSelectorTo;
  118906. private _workingVector;
  118907. private _workingQuaternion;
  118908. private _workingMatrix;
  118909. /**
  118910. * Time Constant Teleportation Mode
  118911. */
  118912. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118913. /**
  118914. * Speed Constant Teleportation Mode
  118915. */
  118916. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118917. /**
  118918. * Teleports the users feet to the desired location
  118919. * @param location The location where the user's feet should be placed
  118920. */
  118921. teleportCamera(location: Vector3): void;
  118922. private _convertNormalToDirectionOfRay;
  118923. private _castRayAndSelectObject;
  118924. private _notifySelectedMeshUnselected;
  118925. /**
  118926. * Permanently set new colors for the laser pointer
  118927. * @param color the new laser color
  118928. * @param pickedColor the new laser color when picked mesh detected
  118929. */
  118930. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118931. /**
  118932. * Set lighting enabled / disabled on the laser pointer of both controllers
  118933. * @param enabled should the lighting be enabled on the laser pointer
  118934. */
  118935. setLaserLightingState(enabled?: boolean): void;
  118936. /**
  118937. * Permanently set new colors for the gaze pointer
  118938. * @param color the new gaze color
  118939. * @param pickedColor the new gaze color when picked mesh detected
  118940. */
  118941. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118942. /**
  118943. * Sets the color of the laser ray from the vr controllers.
  118944. * @param color new color for the ray.
  118945. */
  118946. changeLaserColor(color: Color3): void;
  118947. /**
  118948. * Sets the color of the ray from the vr headsets gaze.
  118949. * @param color new color for the ray.
  118950. */
  118951. changeGazeColor(color: Color3): void;
  118952. /**
  118953. * Exits VR and disposes of the vr experience helper
  118954. */
  118955. dispose(): void;
  118956. /**
  118957. * Gets the name of the VRExperienceHelper class
  118958. * @returns "VRExperienceHelper"
  118959. */
  118960. getClassName(): string;
  118961. }
  118962. }
  118963. declare module BABYLON {
  118964. /**
  118965. * Contains an array of blocks representing the octree
  118966. */
  118967. export interface IOctreeContainer<T> {
  118968. /**
  118969. * Blocks within the octree
  118970. */
  118971. blocks: Array<OctreeBlock<T>>;
  118972. }
  118973. /**
  118974. * Class used to store a cell in an octree
  118975. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118976. */
  118977. export class OctreeBlock<T> {
  118978. /**
  118979. * Gets the content of the current block
  118980. */
  118981. entries: T[];
  118982. /**
  118983. * Gets the list of block children
  118984. */
  118985. blocks: Array<OctreeBlock<T>>;
  118986. private _depth;
  118987. private _maxDepth;
  118988. private _capacity;
  118989. private _minPoint;
  118990. private _maxPoint;
  118991. private _boundingVectors;
  118992. private _creationFunc;
  118993. /**
  118994. * Creates a new block
  118995. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118996. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118997. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118998. * @param depth defines the current depth of this block in the octree
  118999. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  119000. * @param creationFunc defines a callback to call when an element is added to the block
  119001. */
  119002. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  119003. /**
  119004. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  119005. */
  119006. get capacity(): number;
  119007. /**
  119008. * Gets the minimum vector (in world space) of the block's bounding box
  119009. */
  119010. get minPoint(): Vector3;
  119011. /**
  119012. * Gets the maximum vector (in world space) of the block's bounding box
  119013. */
  119014. get maxPoint(): Vector3;
  119015. /**
  119016. * Add a new element to this block
  119017. * @param entry defines the element to add
  119018. */
  119019. addEntry(entry: T): void;
  119020. /**
  119021. * Remove an element from this block
  119022. * @param entry defines the element to remove
  119023. */
  119024. removeEntry(entry: T): void;
  119025. /**
  119026. * Add an array of elements to this block
  119027. * @param entries defines the array of elements to add
  119028. */
  119029. addEntries(entries: T[]): void;
  119030. /**
  119031. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  119032. * @param frustumPlanes defines the frustum planes to test
  119033. * @param selection defines the array to store current content if selection is positive
  119034. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119035. */
  119036. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  119037. /**
  119038. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  119039. * @param sphereCenter defines the bounding sphere center
  119040. * @param sphereRadius defines the bounding sphere radius
  119041. * @param selection defines the array to store current content if selection is positive
  119042. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119043. */
  119044. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  119045. /**
  119046. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  119047. * @param ray defines the ray to test with
  119048. * @param selection defines the array to store current content if selection is positive
  119049. */
  119050. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  119051. /**
  119052. * Subdivide the content into child blocks (this block will then be empty)
  119053. */
  119054. createInnerBlocks(): void;
  119055. /**
  119056. * @hidden
  119057. */
  119058. 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;
  119059. }
  119060. }
  119061. declare module BABYLON {
  119062. /**
  119063. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  119064. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119065. */
  119066. export class Octree<T> {
  119067. /** 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.) */
  119068. maxDepth: number;
  119069. /**
  119070. * Blocks within the octree containing objects
  119071. */
  119072. blocks: Array<OctreeBlock<T>>;
  119073. /**
  119074. * Content stored in the octree
  119075. */
  119076. dynamicContent: T[];
  119077. private _maxBlockCapacity;
  119078. private _selectionContent;
  119079. private _creationFunc;
  119080. /**
  119081. * Creates a octree
  119082. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119083. * @param creationFunc function to be used to instatiate the octree
  119084. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  119085. * @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.)
  119086. */
  119087. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  119088. /** 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.) */
  119089. maxDepth?: number);
  119090. /**
  119091. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  119092. * @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);
  119093. * @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);
  119094. * @param entries meshes to be added to the octree blocks
  119095. */
  119096. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  119097. /**
  119098. * Adds a mesh to the octree
  119099. * @param entry Mesh to add to the octree
  119100. */
  119101. addMesh(entry: T): void;
  119102. /**
  119103. * Remove an element from the octree
  119104. * @param entry defines the element to remove
  119105. */
  119106. removeMesh(entry: T): void;
  119107. /**
  119108. * Selects an array of meshes within the frustum
  119109. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  119110. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  119111. * @returns array of meshes within the frustum
  119112. */
  119113. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  119114. /**
  119115. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  119116. * @param sphereCenter defines the bounding sphere center
  119117. * @param sphereRadius defines the bounding sphere radius
  119118. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119119. * @returns an array of objects that intersect the sphere
  119120. */
  119121. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  119122. /**
  119123. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  119124. * @param ray defines the ray to test with
  119125. * @returns array of intersected objects
  119126. */
  119127. intersectsRay(ray: Ray): SmartArray<T>;
  119128. /**
  119129. * Adds a mesh into the octree block if it intersects the block
  119130. */
  119131. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  119132. /**
  119133. * Adds a submesh into the octree block if it intersects the block
  119134. */
  119135. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  119136. }
  119137. }
  119138. declare module BABYLON {
  119139. interface Scene {
  119140. /**
  119141. * @hidden
  119142. * Backing Filed
  119143. */
  119144. _selectionOctree: Octree<AbstractMesh>;
  119145. /**
  119146. * Gets the octree used to boost mesh selection (picking)
  119147. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119148. */
  119149. selectionOctree: Octree<AbstractMesh>;
  119150. /**
  119151. * Creates or updates the octree used to boost selection (picking)
  119152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119153. * @param maxCapacity defines the maximum capacity per leaf
  119154. * @param maxDepth defines the maximum depth of the octree
  119155. * @returns an octree of AbstractMesh
  119156. */
  119157. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  119158. }
  119159. interface AbstractMesh {
  119160. /**
  119161. * @hidden
  119162. * Backing Field
  119163. */
  119164. _submeshesOctree: Octree<SubMesh>;
  119165. /**
  119166. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  119167. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  119168. * @param maxCapacity defines the maximum size of each block (64 by default)
  119169. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  119170. * @returns the new octree
  119171. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  119172. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119173. */
  119174. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  119175. }
  119176. /**
  119177. * Defines the octree scene component responsible to manage any octrees
  119178. * in a given scene.
  119179. */
  119180. export class OctreeSceneComponent {
  119181. /**
  119182. * The component name help to identify the component in the list of scene components.
  119183. */
  119184. readonly name: string;
  119185. /**
  119186. * The scene the component belongs to.
  119187. */
  119188. scene: Scene;
  119189. /**
  119190. * Indicates if the meshes have been checked to make sure they are isEnabled()
  119191. */
  119192. readonly checksIsEnabled: boolean;
  119193. /**
  119194. * Creates a new instance of the component for the given scene
  119195. * @param scene Defines the scene to register the component in
  119196. */
  119197. constructor(scene: Scene);
  119198. /**
  119199. * Registers the component in a given scene
  119200. */
  119201. register(): void;
  119202. /**
  119203. * Return the list of active meshes
  119204. * @returns the list of active meshes
  119205. */
  119206. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119207. /**
  119208. * Return the list of active sub meshes
  119209. * @param mesh The mesh to get the candidates sub meshes from
  119210. * @returns the list of active sub meshes
  119211. */
  119212. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119213. private _tempRay;
  119214. /**
  119215. * Return the list of sub meshes intersecting with a given local ray
  119216. * @param mesh defines the mesh to find the submesh for
  119217. * @param localRay defines the ray in local space
  119218. * @returns the list of intersecting sub meshes
  119219. */
  119220. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  119221. /**
  119222. * Return the list of sub meshes colliding with a collider
  119223. * @param mesh defines the mesh to find the submesh for
  119224. * @param collider defines the collider to evaluate the collision against
  119225. * @returns the list of colliding sub meshes
  119226. */
  119227. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  119228. /**
  119229. * Rebuilds the elements related to this component in case of
  119230. * context lost for instance.
  119231. */
  119232. rebuild(): void;
  119233. /**
  119234. * Disposes the component and the associated ressources.
  119235. */
  119236. dispose(): void;
  119237. }
  119238. }
  119239. declare module BABYLON {
  119240. /**
  119241. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  119242. */
  119243. export class Gizmo implements IDisposable {
  119244. /** The utility layer the gizmo will be added to */
  119245. gizmoLayer: UtilityLayerRenderer;
  119246. /**
  119247. * The root mesh of the gizmo
  119248. */
  119249. _rootMesh: Mesh;
  119250. private _attachedMesh;
  119251. /**
  119252. * Ratio for the scale of the gizmo (Default: 1)
  119253. */
  119254. scaleRatio: number;
  119255. /**
  119256. * If a custom mesh has been set (Default: false)
  119257. */
  119258. protected _customMeshSet: boolean;
  119259. /**
  119260. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  119261. * * When set, interactions will be enabled
  119262. */
  119263. get attachedMesh(): Nullable<AbstractMesh>;
  119264. set attachedMesh(value: Nullable<AbstractMesh>);
  119265. /**
  119266. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119267. * @param mesh The mesh to replace the default mesh of the gizmo
  119268. */
  119269. setCustomMesh(mesh: Mesh): void;
  119270. /**
  119271. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  119272. */
  119273. updateGizmoRotationToMatchAttachedMesh: boolean;
  119274. /**
  119275. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  119276. */
  119277. updateGizmoPositionToMatchAttachedMesh: boolean;
  119278. /**
  119279. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  119280. */
  119281. updateScale: boolean;
  119282. protected _interactionsEnabled: boolean;
  119283. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119284. private _beforeRenderObserver;
  119285. private _tempVector;
  119286. /**
  119287. * Creates a gizmo
  119288. * @param gizmoLayer The utility layer the gizmo will be added to
  119289. */
  119290. constructor(
  119291. /** The utility layer the gizmo will be added to */
  119292. gizmoLayer?: UtilityLayerRenderer);
  119293. /**
  119294. * Updates the gizmo to match the attached mesh's position/rotation
  119295. */
  119296. protected _update(): void;
  119297. /**
  119298. * Disposes of the gizmo
  119299. */
  119300. dispose(): void;
  119301. }
  119302. }
  119303. declare module BABYLON {
  119304. /**
  119305. * Single plane drag gizmo
  119306. */
  119307. export class PlaneDragGizmo extends Gizmo {
  119308. /**
  119309. * Drag behavior responsible for the gizmos dragging interactions
  119310. */
  119311. dragBehavior: PointerDragBehavior;
  119312. private _pointerObserver;
  119313. /**
  119314. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119315. */
  119316. snapDistance: number;
  119317. /**
  119318. * Event that fires each time the gizmo snaps to a new location.
  119319. * * snapDistance is the the change in distance
  119320. */
  119321. onSnapObservable: Observable<{
  119322. snapDistance: number;
  119323. }>;
  119324. private _plane;
  119325. private _coloredMaterial;
  119326. private _hoverMaterial;
  119327. private _isEnabled;
  119328. private _parent;
  119329. /** @hidden */
  119330. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119331. /** @hidden */
  119332. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119333. /**
  119334. * Creates a PlaneDragGizmo
  119335. * @param gizmoLayer The utility layer the gizmo will be added to
  119336. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119337. * @param color The color of the gizmo
  119338. */
  119339. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119340. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119341. /**
  119342. * If the gizmo is enabled
  119343. */
  119344. set isEnabled(value: boolean);
  119345. get isEnabled(): boolean;
  119346. /**
  119347. * Disposes of the gizmo
  119348. */
  119349. dispose(): void;
  119350. }
  119351. }
  119352. declare module BABYLON {
  119353. /**
  119354. * Gizmo that enables dragging a mesh along 3 axis
  119355. */
  119356. export class PositionGizmo extends Gizmo {
  119357. /**
  119358. * Internal gizmo used for interactions on the x axis
  119359. */
  119360. xGizmo: AxisDragGizmo;
  119361. /**
  119362. * Internal gizmo used for interactions on the y axis
  119363. */
  119364. yGizmo: AxisDragGizmo;
  119365. /**
  119366. * Internal gizmo used for interactions on the z axis
  119367. */
  119368. zGizmo: AxisDragGizmo;
  119369. /**
  119370. * Internal gizmo used for interactions on the yz plane
  119371. */
  119372. xPlaneGizmo: PlaneDragGizmo;
  119373. /**
  119374. * Internal gizmo used for interactions on the xz plane
  119375. */
  119376. yPlaneGizmo: PlaneDragGizmo;
  119377. /**
  119378. * Internal gizmo used for interactions on the xy plane
  119379. */
  119380. zPlaneGizmo: PlaneDragGizmo;
  119381. /**
  119382. * private variables
  119383. */
  119384. private _meshAttached;
  119385. private _updateGizmoRotationToMatchAttachedMesh;
  119386. private _snapDistance;
  119387. private _scaleRatio;
  119388. /** Fires an event when any of it's sub gizmos are dragged */
  119389. onDragStartObservable: Observable<unknown>;
  119390. /** Fires an event when any of it's sub gizmos are released from dragging */
  119391. onDragEndObservable: Observable<unknown>;
  119392. /**
  119393. * If set to true, planar drag is enabled
  119394. */
  119395. private _planarGizmoEnabled;
  119396. get attachedMesh(): Nullable<AbstractMesh>;
  119397. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119398. /**
  119399. * Creates a PositionGizmo
  119400. * @param gizmoLayer The utility layer the gizmo will be added to
  119401. */
  119402. constructor(gizmoLayer?: UtilityLayerRenderer);
  119403. /**
  119404. * If the planar drag gizmo is enabled
  119405. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119406. */
  119407. set planarGizmoEnabled(value: boolean);
  119408. get planarGizmoEnabled(): boolean;
  119409. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119410. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119411. /**
  119412. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119413. */
  119414. set snapDistance(value: number);
  119415. get snapDistance(): number;
  119416. /**
  119417. * Ratio for the scale of the gizmo (Default: 1)
  119418. */
  119419. set scaleRatio(value: number);
  119420. get scaleRatio(): number;
  119421. /**
  119422. * Disposes of the gizmo
  119423. */
  119424. dispose(): void;
  119425. /**
  119426. * CustomMeshes are not supported by this gizmo
  119427. * @param mesh The mesh to replace the default mesh of the gizmo
  119428. */
  119429. setCustomMesh(mesh: Mesh): void;
  119430. }
  119431. }
  119432. declare module BABYLON {
  119433. /**
  119434. * Single axis drag gizmo
  119435. */
  119436. export class AxisDragGizmo extends Gizmo {
  119437. /**
  119438. * Drag behavior responsible for the gizmos dragging interactions
  119439. */
  119440. dragBehavior: PointerDragBehavior;
  119441. private _pointerObserver;
  119442. /**
  119443. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119444. */
  119445. snapDistance: number;
  119446. /**
  119447. * Event that fires each time the gizmo snaps to a new location.
  119448. * * snapDistance is the the change in distance
  119449. */
  119450. onSnapObservable: Observable<{
  119451. snapDistance: number;
  119452. }>;
  119453. private _isEnabled;
  119454. private _parent;
  119455. private _arrow;
  119456. private _coloredMaterial;
  119457. private _hoverMaterial;
  119458. /** @hidden */
  119459. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119460. /** @hidden */
  119461. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119462. /**
  119463. * Creates an AxisDragGizmo
  119464. * @param gizmoLayer The utility layer the gizmo will be added to
  119465. * @param dragAxis The axis which the gizmo will be able to drag on
  119466. * @param color The color of the gizmo
  119467. */
  119468. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119469. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119470. /**
  119471. * If the gizmo is enabled
  119472. */
  119473. set isEnabled(value: boolean);
  119474. get isEnabled(): boolean;
  119475. /**
  119476. * Disposes of the gizmo
  119477. */
  119478. dispose(): void;
  119479. }
  119480. }
  119481. declare module BABYLON.Debug {
  119482. /**
  119483. * The Axes viewer will show 3 axes in a specific point in space
  119484. */
  119485. export class AxesViewer {
  119486. private _xAxis;
  119487. private _yAxis;
  119488. private _zAxis;
  119489. private _scaleLinesFactor;
  119490. private _instanced;
  119491. /**
  119492. * Gets the hosting scene
  119493. */
  119494. scene: Scene;
  119495. /**
  119496. * Gets or sets a number used to scale line length
  119497. */
  119498. scaleLines: number;
  119499. /** Gets the node hierarchy used to render x-axis */
  119500. get xAxis(): TransformNode;
  119501. /** Gets the node hierarchy used to render y-axis */
  119502. get yAxis(): TransformNode;
  119503. /** Gets the node hierarchy used to render z-axis */
  119504. get zAxis(): TransformNode;
  119505. /**
  119506. * Creates a new AxesViewer
  119507. * @param scene defines the hosting scene
  119508. * @param scaleLines defines a number used to scale line length (1 by default)
  119509. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119510. * @param xAxis defines the node hierarchy used to render the x-axis
  119511. * @param yAxis defines the node hierarchy used to render the y-axis
  119512. * @param zAxis defines the node hierarchy used to render the z-axis
  119513. */
  119514. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119515. /**
  119516. * Force the viewer to update
  119517. * @param position defines the position of the viewer
  119518. * @param xaxis defines the x axis of the viewer
  119519. * @param yaxis defines the y axis of the viewer
  119520. * @param zaxis defines the z axis of the viewer
  119521. */
  119522. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119523. /**
  119524. * Creates an instance of this axes viewer.
  119525. * @returns a new axes viewer with instanced meshes
  119526. */
  119527. createInstance(): AxesViewer;
  119528. /** Releases resources */
  119529. dispose(): void;
  119530. private static _SetRenderingGroupId;
  119531. }
  119532. }
  119533. declare module BABYLON.Debug {
  119534. /**
  119535. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119536. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119537. */
  119538. export class BoneAxesViewer extends AxesViewer {
  119539. /**
  119540. * Gets or sets the target mesh where to display the axes viewer
  119541. */
  119542. mesh: Nullable<Mesh>;
  119543. /**
  119544. * Gets or sets the target bone where to display the axes viewer
  119545. */
  119546. bone: Nullable<Bone>;
  119547. /** Gets current position */
  119548. pos: Vector3;
  119549. /** Gets direction of X axis */
  119550. xaxis: Vector3;
  119551. /** Gets direction of Y axis */
  119552. yaxis: Vector3;
  119553. /** Gets direction of Z axis */
  119554. zaxis: Vector3;
  119555. /**
  119556. * Creates a new BoneAxesViewer
  119557. * @param scene defines the hosting scene
  119558. * @param bone defines the target bone
  119559. * @param mesh defines the target mesh
  119560. * @param scaleLines defines a scaling factor for line length (1 by default)
  119561. */
  119562. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119563. /**
  119564. * Force the viewer to update
  119565. */
  119566. update(): void;
  119567. /** Releases resources */
  119568. dispose(): void;
  119569. }
  119570. }
  119571. declare module BABYLON {
  119572. /**
  119573. * Interface used to define scene explorer extensibility option
  119574. */
  119575. export interface IExplorerExtensibilityOption {
  119576. /**
  119577. * Define the option label
  119578. */
  119579. label: string;
  119580. /**
  119581. * Defines the action to execute on click
  119582. */
  119583. action: (entity: any) => void;
  119584. }
  119585. /**
  119586. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119587. */
  119588. export interface IExplorerExtensibilityGroup {
  119589. /**
  119590. * Defines a predicate to test if a given type mut be extended
  119591. */
  119592. predicate: (entity: any) => boolean;
  119593. /**
  119594. * Gets the list of options added to a type
  119595. */
  119596. entries: IExplorerExtensibilityOption[];
  119597. }
  119598. /**
  119599. * Interface used to define the options to use to create the Inspector
  119600. */
  119601. export interface IInspectorOptions {
  119602. /**
  119603. * Display in overlay mode (default: false)
  119604. */
  119605. overlay?: boolean;
  119606. /**
  119607. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119608. */
  119609. globalRoot?: HTMLElement;
  119610. /**
  119611. * Display the Scene explorer
  119612. */
  119613. showExplorer?: boolean;
  119614. /**
  119615. * Display the property inspector
  119616. */
  119617. showInspector?: boolean;
  119618. /**
  119619. * Display in embed mode (both panes on the right)
  119620. */
  119621. embedMode?: boolean;
  119622. /**
  119623. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119624. */
  119625. handleResize?: boolean;
  119626. /**
  119627. * Allow the panes to popup (default: true)
  119628. */
  119629. enablePopup?: boolean;
  119630. /**
  119631. * Allow the panes to be closed by users (default: true)
  119632. */
  119633. enableClose?: boolean;
  119634. /**
  119635. * Optional list of extensibility entries
  119636. */
  119637. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119638. /**
  119639. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119640. */
  119641. inspectorURL?: string;
  119642. /**
  119643. * Optional initial tab (default to DebugLayerTab.Properties)
  119644. */
  119645. initialTab?: DebugLayerTab;
  119646. }
  119647. interface Scene {
  119648. /**
  119649. * @hidden
  119650. * Backing field
  119651. */
  119652. _debugLayer: DebugLayer;
  119653. /**
  119654. * Gets the debug layer (aka Inspector) associated with the scene
  119655. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119656. */
  119657. debugLayer: DebugLayer;
  119658. }
  119659. /**
  119660. * Enum of inspector action tab
  119661. */
  119662. export enum DebugLayerTab {
  119663. /**
  119664. * Properties tag (default)
  119665. */
  119666. Properties = 0,
  119667. /**
  119668. * Debug tab
  119669. */
  119670. Debug = 1,
  119671. /**
  119672. * Statistics tab
  119673. */
  119674. Statistics = 2,
  119675. /**
  119676. * Tools tab
  119677. */
  119678. Tools = 3,
  119679. /**
  119680. * Settings tab
  119681. */
  119682. Settings = 4
  119683. }
  119684. /**
  119685. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119686. * what is happening in your scene
  119687. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119688. */
  119689. export class DebugLayer {
  119690. /**
  119691. * Define the url to get the inspector script from.
  119692. * By default it uses the babylonjs CDN.
  119693. * @ignoreNaming
  119694. */
  119695. static InspectorURL: string;
  119696. private _scene;
  119697. private BJSINSPECTOR;
  119698. private _onPropertyChangedObservable?;
  119699. /**
  119700. * Observable triggered when a property is changed through the inspector.
  119701. */
  119702. get onPropertyChangedObservable(): any;
  119703. /**
  119704. * Instantiates a new debug layer.
  119705. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119706. * what is happening in your scene
  119707. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119708. * @param scene Defines the scene to inspect
  119709. */
  119710. constructor(scene: Scene);
  119711. /** Creates the inspector window. */
  119712. private _createInspector;
  119713. /**
  119714. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119715. * @param entity defines the entity to select
  119716. * @param lineContainerTitle defines the specific block to highlight
  119717. */
  119718. select(entity: any, lineContainerTitle?: string): void;
  119719. /** Get the inspector from bundle or global */
  119720. private _getGlobalInspector;
  119721. /**
  119722. * Get if the inspector is visible or not.
  119723. * @returns true if visible otherwise, false
  119724. */
  119725. isVisible(): boolean;
  119726. /**
  119727. * Hide the inspector and close its window.
  119728. */
  119729. hide(): void;
  119730. /**
  119731. * Launch the debugLayer.
  119732. * @param config Define the configuration of the inspector
  119733. * @return a promise fulfilled when the debug layer is visible
  119734. */
  119735. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119736. }
  119737. }
  119738. declare module BABYLON {
  119739. /**
  119740. * Class containing static functions to help procedurally build meshes
  119741. */
  119742. export class BoxBuilder {
  119743. /**
  119744. * Creates a box mesh
  119745. * * The parameter `size` sets the size (float) of each box side (default 1)
  119746. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119747. * * 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)
  119748. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119750. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119752. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119753. * @param name defines the name of the mesh
  119754. * @param options defines the options used to create the mesh
  119755. * @param scene defines the hosting scene
  119756. * @returns the box mesh
  119757. */
  119758. static CreateBox(name: string, options: {
  119759. size?: number;
  119760. width?: number;
  119761. height?: number;
  119762. depth?: number;
  119763. faceUV?: Vector4[];
  119764. faceColors?: Color4[];
  119765. sideOrientation?: number;
  119766. frontUVs?: Vector4;
  119767. backUVs?: Vector4;
  119768. wrap?: boolean;
  119769. topBaseAt?: number;
  119770. bottomBaseAt?: number;
  119771. updatable?: boolean;
  119772. }, scene?: Nullable<Scene>): Mesh;
  119773. }
  119774. }
  119775. declare module BABYLON.Debug {
  119776. /**
  119777. * Used to show the physics impostor around the specific mesh
  119778. */
  119779. export class PhysicsViewer {
  119780. /** @hidden */
  119781. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119782. /** @hidden */
  119783. protected _meshes: Array<Nullable<AbstractMesh>>;
  119784. /** @hidden */
  119785. protected _scene: Nullable<Scene>;
  119786. /** @hidden */
  119787. protected _numMeshes: number;
  119788. /** @hidden */
  119789. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119790. private _renderFunction;
  119791. private _utilityLayer;
  119792. private _debugBoxMesh;
  119793. private _debugSphereMesh;
  119794. private _debugCylinderMesh;
  119795. private _debugMaterial;
  119796. private _debugMeshMeshes;
  119797. /**
  119798. * Creates a new PhysicsViewer
  119799. * @param scene defines the hosting scene
  119800. */
  119801. constructor(scene: Scene);
  119802. /** @hidden */
  119803. protected _updateDebugMeshes(): void;
  119804. /**
  119805. * Renders a specified physic impostor
  119806. * @param impostor defines the impostor to render
  119807. * @param targetMesh defines the mesh represented by the impostor
  119808. * @returns the new debug mesh used to render the impostor
  119809. */
  119810. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119811. /**
  119812. * Hides a specified physic impostor
  119813. * @param impostor defines the impostor to hide
  119814. */
  119815. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119816. private _getDebugMaterial;
  119817. private _getDebugBoxMesh;
  119818. private _getDebugSphereMesh;
  119819. private _getDebugCylinderMesh;
  119820. private _getDebugMeshMesh;
  119821. private _getDebugMesh;
  119822. /** Releases all resources */
  119823. dispose(): void;
  119824. }
  119825. }
  119826. declare module BABYLON {
  119827. /**
  119828. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119829. * in order to better appreciate the issue one might have.
  119830. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119831. */
  119832. export class RayHelper {
  119833. /**
  119834. * Defines the ray we are currently tryin to visualize.
  119835. */
  119836. ray: Nullable<Ray>;
  119837. private _renderPoints;
  119838. private _renderLine;
  119839. private _renderFunction;
  119840. private _scene;
  119841. private _updateToMeshFunction;
  119842. private _attachedToMesh;
  119843. private _meshSpaceDirection;
  119844. private _meshSpaceOrigin;
  119845. /**
  119846. * Helper function to create a colored helper in a scene in one line.
  119847. * @param ray Defines the ray we are currently tryin to visualize
  119848. * @param scene Defines the scene the ray is used in
  119849. * @param color Defines the color we want to see the ray in
  119850. * @returns The newly created ray helper.
  119851. */
  119852. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119853. /**
  119854. * Instantiate a new ray helper.
  119855. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119856. * in order to better appreciate the issue one might have.
  119857. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119858. * @param ray Defines the ray we are currently tryin to visualize
  119859. */
  119860. constructor(ray: Ray);
  119861. /**
  119862. * Shows the ray we are willing to debug.
  119863. * @param scene Defines the scene the ray needs to be rendered in
  119864. * @param color Defines the color the ray needs to be rendered in
  119865. */
  119866. show(scene: Scene, color?: Color3): void;
  119867. /**
  119868. * Hides the ray we are debugging.
  119869. */
  119870. hide(): void;
  119871. private _render;
  119872. /**
  119873. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119874. * @param mesh Defines the mesh we want the helper attached to
  119875. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119876. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119877. * @param length Defines the length of the ray
  119878. */
  119879. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119880. /**
  119881. * Detach the ray helper from the mesh it has previously been attached to.
  119882. */
  119883. detachFromMesh(): void;
  119884. private _updateToMesh;
  119885. /**
  119886. * Dispose the helper and release its associated resources.
  119887. */
  119888. dispose(): void;
  119889. }
  119890. }
  119891. declare module BABYLON.Debug {
  119892. /**
  119893. * Class used to render a debug view of a given skeleton
  119894. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119895. */
  119896. export class SkeletonViewer {
  119897. /** defines the skeleton to render */
  119898. skeleton: Skeleton;
  119899. /** defines the mesh attached to the skeleton */
  119900. mesh: AbstractMesh;
  119901. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119902. autoUpdateBonesMatrices: boolean;
  119903. /** defines the rendering group id to use with the viewer */
  119904. renderingGroupId: number;
  119905. /** Gets or sets the color used to render the skeleton */
  119906. color: Color3;
  119907. private _scene;
  119908. private _debugLines;
  119909. private _debugMesh;
  119910. private _isEnabled;
  119911. private _renderFunction;
  119912. private _utilityLayer;
  119913. /**
  119914. * Returns the mesh used to render the bones
  119915. */
  119916. get debugMesh(): Nullable<LinesMesh>;
  119917. /**
  119918. * Creates a new SkeletonViewer
  119919. * @param skeleton defines the skeleton to render
  119920. * @param mesh defines the mesh attached to the skeleton
  119921. * @param scene defines the hosting scene
  119922. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119923. * @param renderingGroupId defines the rendering group id to use with the viewer
  119924. */
  119925. constructor(
  119926. /** defines the skeleton to render */
  119927. skeleton: Skeleton,
  119928. /** defines the mesh attached to the skeleton */
  119929. mesh: AbstractMesh, scene: Scene,
  119930. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119931. autoUpdateBonesMatrices?: boolean,
  119932. /** defines the rendering group id to use with the viewer */
  119933. renderingGroupId?: number);
  119934. /** Gets or sets a boolean indicating if the viewer is enabled */
  119935. set isEnabled(value: boolean);
  119936. get isEnabled(): boolean;
  119937. private _getBonePosition;
  119938. private _getLinesForBonesWithLength;
  119939. private _getLinesForBonesNoLength;
  119940. /** Update the viewer to sync with current skeleton state */
  119941. update(): void;
  119942. /** Release associated resources */
  119943. dispose(): void;
  119944. }
  119945. }
  119946. declare module BABYLON {
  119947. /**
  119948. * Options to create the null engine
  119949. */
  119950. export class NullEngineOptions {
  119951. /**
  119952. * Render width (Default: 512)
  119953. */
  119954. renderWidth: number;
  119955. /**
  119956. * Render height (Default: 256)
  119957. */
  119958. renderHeight: number;
  119959. /**
  119960. * Texture size (Default: 512)
  119961. */
  119962. textureSize: number;
  119963. /**
  119964. * If delta time between frames should be constant
  119965. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119966. */
  119967. deterministicLockstep: boolean;
  119968. /**
  119969. * Maximum about of steps between frames (Default: 4)
  119970. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119971. */
  119972. lockstepMaxSteps: number;
  119973. }
  119974. /**
  119975. * The null engine class provides support for headless version of babylon.js.
  119976. * This can be used in server side scenario or for testing purposes
  119977. */
  119978. export class NullEngine extends Engine {
  119979. private _options;
  119980. /**
  119981. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119982. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119983. * @returns true if engine is in deterministic lock step mode
  119984. */
  119985. isDeterministicLockStep(): boolean;
  119986. /**
  119987. * Gets the max steps when engine is running in deterministic lock step
  119988. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119989. * @returns the max steps
  119990. */
  119991. getLockstepMaxSteps(): number;
  119992. /**
  119993. * Gets the current hardware scaling level.
  119994. * By default the hardware scaling level is computed from the window device ratio.
  119995. * 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.
  119996. * @returns a number indicating the current hardware scaling level
  119997. */
  119998. getHardwareScalingLevel(): number;
  119999. constructor(options?: NullEngineOptions);
  120000. /**
  120001. * Creates a vertex buffer
  120002. * @param vertices the data for the vertex buffer
  120003. * @returns the new WebGL static buffer
  120004. */
  120005. createVertexBuffer(vertices: FloatArray): DataBuffer;
  120006. /**
  120007. * Creates a new index buffer
  120008. * @param indices defines the content of the index buffer
  120009. * @param updatable defines if the index buffer must be updatable
  120010. * @returns a new webGL buffer
  120011. */
  120012. createIndexBuffer(indices: IndicesArray): DataBuffer;
  120013. /**
  120014. * Clear the current render buffer or the current render target (if any is set up)
  120015. * @param color defines the color to use
  120016. * @param backBuffer defines if the back buffer must be cleared
  120017. * @param depth defines if the depth buffer must be cleared
  120018. * @param stencil defines if the stencil buffer must be cleared
  120019. */
  120020. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120021. /**
  120022. * Gets the current render width
  120023. * @param useScreen defines if screen size must be used (or the current render target if any)
  120024. * @returns a number defining the current render width
  120025. */
  120026. getRenderWidth(useScreen?: boolean): number;
  120027. /**
  120028. * Gets the current render height
  120029. * @param useScreen defines if screen size must be used (or the current render target if any)
  120030. * @returns a number defining the current render height
  120031. */
  120032. getRenderHeight(useScreen?: boolean): number;
  120033. /**
  120034. * Set the WebGL's viewport
  120035. * @param viewport defines the viewport element to be used
  120036. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  120037. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  120038. */
  120039. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  120040. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  120041. /**
  120042. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  120043. * @param pipelineContext defines the pipeline context to use
  120044. * @param uniformsNames defines the list of uniform names
  120045. * @returns an array of webGL uniform locations
  120046. */
  120047. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  120048. /**
  120049. * Gets the lsit of active attributes for a given webGL program
  120050. * @param pipelineContext defines the pipeline context to use
  120051. * @param attributesNames defines the list of attribute names to get
  120052. * @returns an array of indices indicating the offset of each attribute
  120053. */
  120054. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120055. /**
  120056. * Binds an effect to the webGL context
  120057. * @param effect defines the effect to bind
  120058. */
  120059. bindSamplers(effect: Effect): void;
  120060. /**
  120061. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  120062. * @param effect defines the effect to activate
  120063. */
  120064. enableEffect(effect: Effect): void;
  120065. /**
  120066. * Set various states to the webGL context
  120067. * @param culling defines backface culling state
  120068. * @param zOffset defines the value to apply to zOffset (0 by default)
  120069. * @param force defines if states must be applied even if cache is up to date
  120070. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  120071. */
  120072. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120073. /**
  120074. * Set the value of an uniform to an array of int32
  120075. * @param uniform defines the webGL uniform location where to store the value
  120076. * @param array defines the array of int32 to store
  120077. */
  120078. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120079. /**
  120080. * Set the value of an uniform to an array of int32 (stored as vec2)
  120081. * @param uniform defines the webGL uniform location where to store the value
  120082. * @param array defines the array of int32 to store
  120083. */
  120084. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120085. /**
  120086. * Set the value of an uniform to an array of int32 (stored as vec3)
  120087. * @param uniform defines the webGL uniform location where to store the value
  120088. * @param array defines the array of int32 to store
  120089. */
  120090. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120091. /**
  120092. * Set the value of an uniform to an array of int32 (stored as vec4)
  120093. * @param uniform defines the webGL uniform location where to store the value
  120094. * @param array defines the array of int32 to store
  120095. */
  120096. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120097. /**
  120098. * Set the value of an uniform to an array of float32
  120099. * @param uniform defines the webGL uniform location where to store the value
  120100. * @param array defines the array of float32 to store
  120101. */
  120102. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120103. /**
  120104. * Set the value of an uniform to an array of float32 (stored as vec2)
  120105. * @param uniform defines the webGL uniform location where to store the value
  120106. * @param array defines the array of float32 to store
  120107. */
  120108. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120109. /**
  120110. * Set the value of an uniform to an array of float32 (stored as vec3)
  120111. * @param uniform defines the webGL uniform location where to store the value
  120112. * @param array defines the array of float32 to store
  120113. */
  120114. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120115. /**
  120116. * Set the value of an uniform to an array of float32 (stored as vec4)
  120117. * @param uniform defines the webGL uniform location where to store the value
  120118. * @param array defines the array of float32 to store
  120119. */
  120120. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120121. /**
  120122. * Set the value of an uniform to an array of number
  120123. * @param uniform defines the webGL uniform location where to store the value
  120124. * @param array defines the array of number to store
  120125. */
  120126. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120127. /**
  120128. * Set the value of an uniform to an array of number (stored as vec2)
  120129. * @param uniform defines the webGL uniform location where to store the value
  120130. * @param array defines the array of number to store
  120131. */
  120132. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120133. /**
  120134. * Set the value of an uniform to an array of number (stored as vec3)
  120135. * @param uniform defines the webGL uniform location where to store the value
  120136. * @param array defines the array of number to store
  120137. */
  120138. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120139. /**
  120140. * Set the value of an uniform to an array of number (stored as vec4)
  120141. * @param uniform defines the webGL uniform location where to store the value
  120142. * @param array defines the array of number to store
  120143. */
  120144. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120145. /**
  120146. * Set the value of an uniform to an array of float32 (stored as matrices)
  120147. * @param uniform defines the webGL uniform location where to store the value
  120148. * @param matrices defines the array of float32 to store
  120149. */
  120150. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120151. /**
  120152. * Set the value of an uniform to a matrix (3x3)
  120153. * @param uniform defines the webGL uniform location where to store the value
  120154. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  120155. */
  120156. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120157. /**
  120158. * Set the value of an uniform to a matrix (2x2)
  120159. * @param uniform defines the webGL uniform location where to store the value
  120160. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  120161. */
  120162. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120163. /**
  120164. * Set the value of an uniform to a number (float)
  120165. * @param uniform defines the webGL uniform location where to store the value
  120166. * @param value defines the float number to store
  120167. */
  120168. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120169. /**
  120170. * Set the value of an uniform to a vec2
  120171. * @param uniform defines the webGL uniform location where to store the value
  120172. * @param x defines the 1st component of the value
  120173. * @param y defines the 2nd component of the value
  120174. */
  120175. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120176. /**
  120177. * Set the value of an uniform to a vec3
  120178. * @param uniform defines the webGL uniform location where to store the value
  120179. * @param x defines the 1st component of the value
  120180. * @param y defines the 2nd component of the value
  120181. * @param z defines the 3rd component of the value
  120182. */
  120183. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120184. /**
  120185. * Set the value of an uniform to a boolean
  120186. * @param uniform defines the webGL uniform location where to store the value
  120187. * @param bool defines the boolean to store
  120188. */
  120189. setBool(uniform: WebGLUniformLocation, bool: number): void;
  120190. /**
  120191. * Set the value of an uniform to a vec4
  120192. * @param uniform defines the webGL uniform location where to store the value
  120193. * @param x defines the 1st component of the value
  120194. * @param y defines the 2nd component of the value
  120195. * @param z defines the 3rd component of the value
  120196. * @param w defines the 4th component of the value
  120197. */
  120198. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120199. /**
  120200. * Sets the current alpha mode
  120201. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  120202. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120203. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120204. */
  120205. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120206. /**
  120207. * Bind webGl buffers directly to the webGL context
  120208. * @param vertexBuffers defines the vertex buffer to bind
  120209. * @param indexBuffer defines the index buffer to bind
  120210. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  120211. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  120212. * @param effect defines the effect associated with the vertex buffer
  120213. */
  120214. bindBuffers(vertexBuffers: {
  120215. [key: string]: VertexBuffer;
  120216. }, indexBuffer: DataBuffer, effect: Effect): void;
  120217. /**
  120218. * Force the entire cache to be cleared
  120219. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120220. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120221. */
  120222. wipeCaches(bruteForce?: boolean): void;
  120223. /**
  120224. * Send a draw order
  120225. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120226. * @param indexStart defines the starting index
  120227. * @param indexCount defines the number of index to draw
  120228. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120229. */
  120230. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120231. /**
  120232. * Draw a list of indexed primitives
  120233. * @param fillMode defines the primitive to use
  120234. * @param indexStart defines the starting index
  120235. * @param indexCount defines the number of index to draw
  120236. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120237. */
  120238. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120239. /**
  120240. * Draw a list of unindexed primitives
  120241. * @param fillMode defines the primitive to use
  120242. * @param verticesStart defines the index of first vertex to draw
  120243. * @param verticesCount defines the count of vertices to draw
  120244. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120245. */
  120246. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120247. /** @hidden */
  120248. _createTexture(): WebGLTexture;
  120249. /** @hidden */
  120250. _releaseTexture(texture: InternalTexture): void;
  120251. /**
  120252. * Usually called from Texture.ts.
  120253. * Passed information to create a WebGLTexture
  120254. * @param urlArg defines a value which contains one of the following:
  120255. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120256. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120257. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120258. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120259. * @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)
  120260. * @param scene needed for loading to the correct scene
  120261. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120262. * @param onLoad optional callback to be called upon successful completion
  120263. * @param onError optional callback to be called upon failure
  120264. * @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
  120265. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120266. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120267. * @param forcedExtension defines the extension to use to pick the right loader
  120268. * @param mimeType defines an optional mime type
  120269. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120270. */
  120271. 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>, mimeType?: string): InternalTexture;
  120272. /**
  120273. * Creates a new render target texture
  120274. * @param size defines the size of the texture
  120275. * @param options defines the options used to create the texture
  120276. * @returns a new render target texture stored in an InternalTexture
  120277. */
  120278. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  120279. /**
  120280. * Update the sampling mode of a given texture
  120281. * @param samplingMode defines the required sampling mode
  120282. * @param texture defines the texture to update
  120283. */
  120284. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120285. /**
  120286. * Binds the frame buffer to the specified texture.
  120287. * @param texture The texture to render to or null for the default canvas
  120288. * @param faceIndex The face of the texture to render to in case of cube texture
  120289. * @param requiredWidth The width of the target to render to
  120290. * @param requiredHeight The height of the target to render to
  120291. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120292. * @param lodLevel defines le lod level to bind to the frame buffer
  120293. */
  120294. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120295. /**
  120296. * Unbind the current render target texture from the webGL context
  120297. * @param texture defines the render target texture to unbind
  120298. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120299. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120300. */
  120301. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120302. /**
  120303. * Creates a dynamic vertex buffer
  120304. * @param vertices the data for the dynamic vertex buffer
  120305. * @returns the new WebGL dynamic buffer
  120306. */
  120307. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  120308. /**
  120309. * Update the content of a dynamic texture
  120310. * @param texture defines the texture to update
  120311. * @param canvas defines the canvas containing the source
  120312. * @param invertY defines if data must be stored with Y axis inverted
  120313. * @param premulAlpha defines if alpha is stored as premultiplied
  120314. * @param format defines the format of the data
  120315. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120316. */
  120317. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  120318. /**
  120319. * Gets a boolean indicating if all created effects are ready
  120320. * @returns true if all effects are ready
  120321. */
  120322. areAllEffectsReady(): boolean;
  120323. /**
  120324. * @hidden
  120325. * Get the current error code of the webGL context
  120326. * @returns the error code
  120327. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120328. */
  120329. getError(): number;
  120330. /** @hidden */
  120331. _getUnpackAlignement(): number;
  120332. /** @hidden */
  120333. _unpackFlipY(value: boolean): void;
  120334. /**
  120335. * Update a dynamic index buffer
  120336. * @param indexBuffer defines the target index buffer
  120337. * @param indices defines the data to update
  120338. * @param offset defines the offset in the target index buffer where update should start
  120339. */
  120340. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120341. /**
  120342. * Updates a dynamic vertex buffer.
  120343. * @param vertexBuffer the vertex buffer to update
  120344. * @param vertices the data used to update the vertex buffer
  120345. * @param byteOffset the byte offset of the data (optional)
  120346. * @param byteLength the byte length of the data (optional)
  120347. */
  120348. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120349. /** @hidden */
  120350. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120351. /** @hidden */
  120352. _bindTexture(channel: number, texture: InternalTexture): void;
  120353. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120354. /**
  120355. * 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
  120356. */
  120357. releaseEffects(): void;
  120358. displayLoadingUI(): void;
  120359. hideLoadingUI(): void;
  120360. /** @hidden */
  120361. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120362. /** @hidden */
  120363. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120364. /** @hidden */
  120365. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120366. /** @hidden */
  120367. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120368. }
  120369. }
  120370. declare module BABYLON {
  120371. /**
  120372. * @hidden
  120373. **/
  120374. export class _TimeToken {
  120375. _startTimeQuery: Nullable<WebGLQuery>;
  120376. _endTimeQuery: Nullable<WebGLQuery>;
  120377. _timeElapsedQuery: Nullable<WebGLQuery>;
  120378. _timeElapsedQueryEnded: boolean;
  120379. }
  120380. }
  120381. declare module BABYLON {
  120382. /** @hidden */
  120383. export class _OcclusionDataStorage {
  120384. /** @hidden */
  120385. occlusionInternalRetryCounter: number;
  120386. /** @hidden */
  120387. isOcclusionQueryInProgress: boolean;
  120388. /** @hidden */
  120389. isOccluded: boolean;
  120390. /** @hidden */
  120391. occlusionRetryCount: number;
  120392. /** @hidden */
  120393. occlusionType: number;
  120394. /** @hidden */
  120395. occlusionQueryAlgorithmType: number;
  120396. }
  120397. interface Engine {
  120398. /**
  120399. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120400. * @return the new query
  120401. */
  120402. createQuery(): WebGLQuery;
  120403. /**
  120404. * Delete and release a webGL query
  120405. * @param query defines the query to delete
  120406. * @return the current engine
  120407. */
  120408. deleteQuery(query: WebGLQuery): Engine;
  120409. /**
  120410. * Check if a given query has resolved and got its value
  120411. * @param query defines the query to check
  120412. * @returns true if the query got its value
  120413. */
  120414. isQueryResultAvailable(query: WebGLQuery): boolean;
  120415. /**
  120416. * Gets the value of a given query
  120417. * @param query defines the query to check
  120418. * @returns the value of the query
  120419. */
  120420. getQueryResult(query: WebGLQuery): number;
  120421. /**
  120422. * Initiates an occlusion query
  120423. * @param algorithmType defines the algorithm to use
  120424. * @param query defines the query to use
  120425. * @returns the current engine
  120426. * @see http://doc.babylonjs.com/features/occlusionquery
  120427. */
  120428. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120429. /**
  120430. * Ends an occlusion query
  120431. * @see http://doc.babylonjs.com/features/occlusionquery
  120432. * @param algorithmType defines the algorithm to use
  120433. * @returns the current engine
  120434. */
  120435. endOcclusionQuery(algorithmType: number): Engine;
  120436. /**
  120437. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120438. * Please note that only one query can be issued at a time
  120439. * @returns a time token used to track the time span
  120440. */
  120441. startTimeQuery(): Nullable<_TimeToken>;
  120442. /**
  120443. * Ends a time query
  120444. * @param token defines the token used to measure the time span
  120445. * @returns the time spent (in ns)
  120446. */
  120447. endTimeQuery(token: _TimeToken): int;
  120448. /** @hidden */
  120449. _currentNonTimestampToken: Nullable<_TimeToken>;
  120450. /** @hidden */
  120451. _createTimeQuery(): WebGLQuery;
  120452. /** @hidden */
  120453. _deleteTimeQuery(query: WebGLQuery): void;
  120454. /** @hidden */
  120455. _getGlAlgorithmType(algorithmType: number): number;
  120456. /** @hidden */
  120457. _getTimeQueryResult(query: WebGLQuery): any;
  120458. /** @hidden */
  120459. _getTimeQueryAvailability(query: WebGLQuery): any;
  120460. }
  120461. interface AbstractMesh {
  120462. /**
  120463. * Backing filed
  120464. * @hidden
  120465. */
  120466. __occlusionDataStorage: _OcclusionDataStorage;
  120467. /**
  120468. * Access property
  120469. * @hidden
  120470. */
  120471. _occlusionDataStorage: _OcclusionDataStorage;
  120472. /**
  120473. * 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.
  120474. * The default value is -1 which means don't break the query and wait till the result
  120475. * @see http://doc.babylonjs.com/features/occlusionquery
  120476. */
  120477. occlusionRetryCount: number;
  120478. /**
  120479. * 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:
  120480. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120481. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120482. * * 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.
  120483. * @see http://doc.babylonjs.com/features/occlusionquery
  120484. */
  120485. occlusionType: number;
  120486. /**
  120487. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120488. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120489. * * 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.
  120490. * @see http://doc.babylonjs.com/features/occlusionquery
  120491. */
  120492. occlusionQueryAlgorithmType: number;
  120493. /**
  120494. * 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
  120495. * @see http://doc.babylonjs.com/features/occlusionquery
  120496. */
  120497. isOccluded: boolean;
  120498. /**
  120499. * Flag to check the progress status of the query
  120500. * @see http://doc.babylonjs.com/features/occlusionquery
  120501. */
  120502. isOcclusionQueryInProgress: boolean;
  120503. }
  120504. }
  120505. declare module BABYLON {
  120506. /** @hidden */
  120507. export var _forceTransformFeedbackToBundle: boolean;
  120508. interface Engine {
  120509. /**
  120510. * Creates a webGL transform feedback object
  120511. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120512. * @returns the webGL transform feedback object
  120513. */
  120514. createTransformFeedback(): WebGLTransformFeedback;
  120515. /**
  120516. * Delete a webGL transform feedback object
  120517. * @param value defines the webGL transform feedback object to delete
  120518. */
  120519. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120520. /**
  120521. * Bind a webGL transform feedback object to the webgl context
  120522. * @param value defines the webGL transform feedback object to bind
  120523. */
  120524. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120525. /**
  120526. * Begins a transform feedback operation
  120527. * @param usePoints defines if points or triangles must be used
  120528. */
  120529. beginTransformFeedback(usePoints: boolean): void;
  120530. /**
  120531. * Ends a transform feedback operation
  120532. */
  120533. endTransformFeedback(): void;
  120534. /**
  120535. * Specify the varyings to use with transform feedback
  120536. * @param program defines the associated webGL program
  120537. * @param value defines the list of strings representing the varying names
  120538. */
  120539. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120540. /**
  120541. * Bind a webGL buffer for a transform feedback operation
  120542. * @param value defines the webGL buffer to bind
  120543. */
  120544. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120545. }
  120546. }
  120547. declare module BABYLON {
  120548. /**
  120549. * Creation options of the multi render target texture.
  120550. */
  120551. export interface IMultiRenderTargetOptions {
  120552. /**
  120553. * Define if the texture needs to create mip maps after render.
  120554. */
  120555. generateMipMaps?: boolean;
  120556. /**
  120557. * Define the types of all the draw buffers we want to create
  120558. */
  120559. types?: number[];
  120560. /**
  120561. * Define the sampling modes of all the draw buffers we want to create
  120562. */
  120563. samplingModes?: number[];
  120564. /**
  120565. * Define if a depth buffer is required
  120566. */
  120567. generateDepthBuffer?: boolean;
  120568. /**
  120569. * Define if a stencil buffer is required
  120570. */
  120571. generateStencilBuffer?: boolean;
  120572. /**
  120573. * Define if a depth texture is required instead of a depth buffer
  120574. */
  120575. generateDepthTexture?: boolean;
  120576. /**
  120577. * Define the number of desired draw buffers
  120578. */
  120579. textureCount?: number;
  120580. /**
  120581. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120582. */
  120583. doNotChangeAspectRatio?: boolean;
  120584. /**
  120585. * Define the default type of the buffers we are creating
  120586. */
  120587. defaultType?: number;
  120588. }
  120589. /**
  120590. * A multi render target, like a render target provides the ability to render to a texture.
  120591. * Unlike the render target, it can render to several draw buffers in one draw.
  120592. * This is specially interesting in deferred rendering or for any effects requiring more than
  120593. * just one color from a single pass.
  120594. */
  120595. export class MultiRenderTarget extends RenderTargetTexture {
  120596. private _internalTextures;
  120597. private _textures;
  120598. private _multiRenderTargetOptions;
  120599. /**
  120600. * Get if draw buffers are currently supported by the used hardware and browser.
  120601. */
  120602. get isSupported(): boolean;
  120603. /**
  120604. * Get the list of textures generated by the multi render target.
  120605. */
  120606. get textures(): Texture[];
  120607. /**
  120608. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120609. */
  120610. get depthTexture(): Texture;
  120611. /**
  120612. * Set the wrapping mode on U of all the textures we are rendering to.
  120613. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120614. */
  120615. set wrapU(wrap: number);
  120616. /**
  120617. * Set the wrapping mode on V of all the textures we are rendering to.
  120618. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120619. */
  120620. set wrapV(wrap: number);
  120621. /**
  120622. * Instantiate a new multi render target texture.
  120623. * A multi render target, like a render target provides the ability to render to a texture.
  120624. * Unlike the render target, it can render to several draw buffers in one draw.
  120625. * This is specially interesting in deferred rendering or for any effects requiring more than
  120626. * just one color from a single pass.
  120627. * @param name Define the name of the texture
  120628. * @param size Define the size of the buffers to render to
  120629. * @param count Define the number of target we are rendering into
  120630. * @param scene Define the scene the texture belongs to
  120631. * @param options Define the options used to create the multi render target
  120632. */
  120633. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120634. /** @hidden */
  120635. _rebuild(): void;
  120636. private _createInternalTextures;
  120637. private _createTextures;
  120638. /**
  120639. * Define the number of samples used if MSAA is enabled.
  120640. */
  120641. get samples(): number;
  120642. set samples(value: number);
  120643. /**
  120644. * Resize all the textures in the multi render target.
  120645. * Be carrefull as it will recreate all the data in the new texture.
  120646. * @param size Define the new size
  120647. */
  120648. resize(size: any): void;
  120649. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120650. /**
  120651. * Dispose the render targets and their associated resources
  120652. */
  120653. dispose(): void;
  120654. /**
  120655. * Release all the underlying texture used as draw buffers.
  120656. */
  120657. releaseInternalTextures(): void;
  120658. }
  120659. }
  120660. declare module BABYLON {
  120661. interface ThinEngine {
  120662. /**
  120663. * Unbind a list of render target textures from the webGL context
  120664. * This is used only when drawBuffer extension or webGL2 are active
  120665. * @param textures defines the render target textures to unbind
  120666. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120667. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120668. */
  120669. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120670. /**
  120671. * Create a multi render target texture
  120672. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120673. * @param size defines the size of the texture
  120674. * @param options defines the creation options
  120675. * @returns the cube texture as an InternalTexture
  120676. */
  120677. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120678. /**
  120679. * Update the sample count for a given multiple render target texture
  120680. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120681. * @param textures defines the textures to update
  120682. * @param samples defines the sample count to set
  120683. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120684. */
  120685. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120686. }
  120687. }
  120688. declare module BABYLON {
  120689. /**
  120690. * Class used to define an additional view for the engine
  120691. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120692. */
  120693. export class EngineView {
  120694. /** Defines the canvas where to render the view */
  120695. target: HTMLCanvasElement;
  120696. /** Defines an optional camera used to render the view (will use active camera else) */
  120697. camera?: Camera;
  120698. }
  120699. interface Engine {
  120700. /**
  120701. * Gets or sets the HTML element to use for attaching events
  120702. */
  120703. inputElement: Nullable<HTMLElement>;
  120704. /**
  120705. * Gets the current engine view
  120706. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120707. */
  120708. activeView: Nullable<EngineView>;
  120709. /** Gets or sets the list of views */
  120710. views: EngineView[];
  120711. /**
  120712. * Register a new child canvas
  120713. * @param canvas defines the canvas to register
  120714. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120715. * @returns the associated view
  120716. */
  120717. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120718. /**
  120719. * Remove a registered child canvas
  120720. * @param canvas defines the canvas to remove
  120721. * @returns the current engine
  120722. */
  120723. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120724. }
  120725. }
  120726. declare module BABYLON {
  120727. /**
  120728. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120729. */
  120730. export interface CubeMapInfo {
  120731. /**
  120732. * The pixel array for the front face.
  120733. * This is stored in format, left to right, up to down format.
  120734. */
  120735. front: Nullable<ArrayBufferView>;
  120736. /**
  120737. * The pixel array for the back face.
  120738. * This is stored in format, left to right, up to down format.
  120739. */
  120740. back: Nullable<ArrayBufferView>;
  120741. /**
  120742. * The pixel array for the left face.
  120743. * This is stored in format, left to right, up to down format.
  120744. */
  120745. left: Nullable<ArrayBufferView>;
  120746. /**
  120747. * The pixel array for the right face.
  120748. * This is stored in format, left to right, up to down format.
  120749. */
  120750. right: Nullable<ArrayBufferView>;
  120751. /**
  120752. * The pixel array for the up face.
  120753. * This is stored in format, left to right, up to down format.
  120754. */
  120755. up: Nullable<ArrayBufferView>;
  120756. /**
  120757. * The pixel array for the down face.
  120758. * This is stored in format, left to right, up to down format.
  120759. */
  120760. down: Nullable<ArrayBufferView>;
  120761. /**
  120762. * The size of the cubemap stored.
  120763. *
  120764. * Each faces will be size * size pixels.
  120765. */
  120766. size: number;
  120767. /**
  120768. * The format of the texture.
  120769. *
  120770. * RGBA, RGB.
  120771. */
  120772. format: number;
  120773. /**
  120774. * The type of the texture data.
  120775. *
  120776. * UNSIGNED_INT, FLOAT.
  120777. */
  120778. type: number;
  120779. /**
  120780. * Specifies whether the texture is in gamma space.
  120781. */
  120782. gammaSpace: boolean;
  120783. }
  120784. /**
  120785. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120786. */
  120787. export class PanoramaToCubeMapTools {
  120788. private static FACE_FRONT;
  120789. private static FACE_BACK;
  120790. private static FACE_RIGHT;
  120791. private static FACE_LEFT;
  120792. private static FACE_DOWN;
  120793. private static FACE_UP;
  120794. /**
  120795. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120796. *
  120797. * @param float32Array The source data.
  120798. * @param inputWidth The width of the input panorama.
  120799. * @param inputHeight The height of the input panorama.
  120800. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120801. * @return The cubemap data
  120802. */
  120803. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120804. private static CreateCubemapTexture;
  120805. private static CalcProjectionSpherical;
  120806. }
  120807. }
  120808. declare module BABYLON {
  120809. /**
  120810. * Helper class dealing with the extraction of spherical polynomial dataArray
  120811. * from a cube map.
  120812. */
  120813. export class CubeMapToSphericalPolynomialTools {
  120814. private static FileFaces;
  120815. /**
  120816. * Converts a texture to the according Spherical Polynomial data.
  120817. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120818. *
  120819. * @param texture The texture to extract the information from.
  120820. * @return The Spherical Polynomial data.
  120821. */
  120822. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120823. /**
  120824. * Converts a cubemap to the according Spherical Polynomial data.
  120825. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120826. *
  120827. * @param cubeInfo The Cube map to extract the information from.
  120828. * @return The Spherical Polynomial data.
  120829. */
  120830. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120831. }
  120832. }
  120833. declare module BABYLON {
  120834. interface BaseTexture {
  120835. /**
  120836. * Get the polynomial representation of the texture data.
  120837. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120838. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120839. */
  120840. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120841. }
  120842. }
  120843. declare module BABYLON {
  120844. /** @hidden */
  120845. export var rgbdEncodePixelShader: {
  120846. name: string;
  120847. shader: string;
  120848. };
  120849. }
  120850. declare module BABYLON {
  120851. /** @hidden */
  120852. export var rgbdDecodePixelShader: {
  120853. name: string;
  120854. shader: string;
  120855. };
  120856. }
  120857. declare module BABYLON {
  120858. /**
  120859. * Raw texture data and descriptor sufficient for WebGL texture upload
  120860. */
  120861. export interface EnvironmentTextureInfo {
  120862. /**
  120863. * Version of the environment map
  120864. */
  120865. version: number;
  120866. /**
  120867. * Width of image
  120868. */
  120869. width: number;
  120870. /**
  120871. * Irradiance information stored in the file.
  120872. */
  120873. irradiance: any;
  120874. /**
  120875. * Specular information stored in the file.
  120876. */
  120877. specular: any;
  120878. }
  120879. /**
  120880. * Defines One Image in the file. It requires only the position in the file
  120881. * as well as the length.
  120882. */
  120883. interface BufferImageData {
  120884. /**
  120885. * Length of the image data.
  120886. */
  120887. length: number;
  120888. /**
  120889. * Position of the data from the null terminator delimiting the end of the JSON.
  120890. */
  120891. position: number;
  120892. }
  120893. /**
  120894. * Defines the specular data enclosed in the file.
  120895. * This corresponds to the version 1 of the data.
  120896. */
  120897. export interface EnvironmentTextureSpecularInfoV1 {
  120898. /**
  120899. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120900. */
  120901. specularDataPosition?: number;
  120902. /**
  120903. * This contains all the images data needed to reconstruct the cubemap.
  120904. */
  120905. mipmaps: Array<BufferImageData>;
  120906. /**
  120907. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120908. */
  120909. lodGenerationScale: number;
  120910. }
  120911. /**
  120912. * Sets of helpers addressing the serialization and deserialization of environment texture
  120913. * stored in a BabylonJS env file.
  120914. * Those files are usually stored as .env files.
  120915. */
  120916. export class EnvironmentTextureTools {
  120917. /**
  120918. * Magic number identifying the env file.
  120919. */
  120920. private static _MagicBytes;
  120921. /**
  120922. * Gets the environment info from an env file.
  120923. * @param data The array buffer containing the .env bytes.
  120924. * @returns the environment file info (the json header) if successfully parsed.
  120925. */
  120926. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120927. /**
  120928. * Creates an environment texture from a loaded cube texture.
  120929. * @param texture defines the cube texture to convert in env file
  120930. * @return a promise containing the environment data if succesfull.
  120931. */
  120932. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120933. /**
  120934. * Creates a JSON representation of the spherical data.
  120935. * @param texture defines the texture containing the polynomials
  120936. * @return the JSON representation of the spherical info
  120937. */
  120938. private static _CreateEnvTextureIrradiance;
  120939. /**
  120940. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120941. * @param data the image data
  120942. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120943. * @return the views described by info providing access to the underlying buffer
  120944. */
  120945. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120946. /**
  120947. * Uploads the texture info contained in the env file to the GPU.
  120948. * @param texture defines the internal texture to upload to
  120949. * @param data defines the data to load
  120950. * @param info defines the texture info retrieved through the GetEnvInfo method
  120951. * @returns a promise
  120952. */
  120953. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120954. private static _OnImageReadyAsync;
  120955. /**
  120956. * Uploads the levels of image data to the GPU.
  120957. * @param texture defines the internal texture to upload to
  120958. * @param imageData defines the array buffer views of image data [mipmap][face]
  120959. * @returns a promise
  120960. */
  120961. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120962. /**
  120963. * Uploads spherical polynomials information to the texture.
  120964. * @param texture defines the texture we are trying to upload the information to
  120965. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120966. */
  120967. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120968. /** @hidden */
  120969. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120970. }
  120971. }
  120972. declare module BABYLON {
  120973. /**
  120974. * Contains position and normal vectors for a vertex
  120975. */
  120976. export class PositionNormalVertex {
  120977. /** the position of the vertex (defaut: 0,0,0) */
  120978. position: Vector3;
  120979. /** the normal of the vertex (defaut: 0,1,0) */
  120980. normal: Vector3;
  120981. /**
  120982. * Creates a PositionNormalVertex
  120983. * @param position the position of the vertex (defaut: 0,0,0)
  120984. * @param normal the normal of the vertex (defaut: 0,1,0)
  120985. */
  120986. constructor(
  120987. /** the position of the vertex (defaut: 0,0,0) */
  120988. position?: Vector3,
  120989. /** the normal of the vertex (defaut: 0,1,0) */
  120990. normal?: Vector3);
  120991. /**
  120992. * Clones the PositionNormalVertex
  120993. * @returns the cloned PositionNormalVertex
  120994. */
  120995. clone(): PositionNormalVertex;
  120996. }
  120997. /**
  120998. * Contains position, normal and uv vectors for a vertex
  120999. */
  121000. export class PositionNormalTextureVertex {
  121001. /** the position of the vertex (defaut: 0,0,0) */
  121002. position: Vector3;
  121003. /** the normal of the vertex (defaut: 0,1,0) */
  121004. normal: Vector3;
  121005. /** the uv of the vertex (default: 0,0) */
  121006. uv: Vector2;
  121007. /**
  121008. * Creates a PositionNormalTextureVertex
  121009. * @param position the position of the vertex (defaut: 0,0,0)
  121010. * @param normal the normal of the vertex (defaut: 0,1,0)
  121011. * @param uv the uv of the vertex (default: 0,0)
  121012. */
  121013. constructor(
  121014. /** the position of the vertex (defaut: 0,0,0) */
  121015. position?: Vector3,
  121016. /** the normal of the vertex (defaut: 0,1,0) */
  121017. normal?: Vector3,
  121018. /** the uv of the vertex (default: 0,0) */
  121019. uv?: Vector2);
  121020. /**
  121021. * Clones the PositionNormalTextureVertex
  121022. * @returns the cloned PositionNormalTextureVertex
  121023. */
  121024. clone(): PositionNormalTextureVertex;
  121025. }
  121026. }
  121027. declare module BABYLON {
  121028. /** @hidden */
  121029. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  121030. private _genericAttributeLocation;
  121031. private _varyingLocationCount;
  121032. private _varyingLocationMap;
  121033. private _replacements;
  121034. private _textureCount;
  121035. private _uniforms;
  121036. lineProcessor(line: string): string;
  121037. attributeProcessor(attribute: string): string;
  121038. varyingProcessor(varying: string, isFragment: boolean): string;
  121039. uniformProcessor(uniform: string): string;
  121040. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  121041. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  121042. }
  121043. }
  121044. declare module BABYLON {
  121045. /**
  121046. * Container for accessors for natively-stored mesh data buffers.
  121047. */
  121048. class NativeDataBuffer extends DataBuffer {
  121049. /**
  121050. * Accessor value used to identify/retrieve a natively-stored index buffer.
  121051. */
  121052. nativeIndexBuffer?: any;
  121053. /**
  121054. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  121055. */
  121056. nativeVertexBuffer?: any;
  121057. }
  121058. /** @hidden */
  121059. class NativeTexture extends InternalTexture {
  121060. getInternalTexture(): InternalTexture;
  121061. getViewCount(): number;
  121062. }
  121063. /** @hidden */
  121064. export class NativeEngine extends Engine {
  121065. private readonly _native;
  121066. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  121067. private readonly INVALID_HANDLE;
  121068. getHardwareScalingLevel(): number;
  121069. constructor();
  121070. /**
  121071. * Can be used to override the current requestAnimationFrame requester.
  121072. * @hidden
  121073. */
  121074. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  121075. /**
  121076. * Override default engine behavior.
  121077. * @param color
  121078. * @param backBuffer
  121079. * @param depth
  121080. * @param stencil
  121081. */
  121082. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  121083. /**
  121084. * Gets host document
  121085. * @returns the host document object
  121086. */
  121087. getHostDocument(): Nullable<Document>;
  121088. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121089. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  121090. createVertexBuffer(data: DataArray): NativeDataBuffer;
  121091. recordVertexArrayObject(vertexBuffers: {
  121092. [key: string]: VertexBuffer;
  121093. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  121094. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  121095. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  121096. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121097. /**
  121098. * Draw a list of indexed primitives
  121099. * @param fillMode defines the primitive to use
  121100. * @param indexStart defines the starting index
  121101. * @param indexCount defines the number of index to draw
  121102. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121103. */
  121104. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121105. /**
  121106. * Draw a list of unindexed primitives
  121107. * @param fillMode defines the primitive to use
  121108. * @param verticesStart defines the index of first vertex to draw
  121109. * @param verticesCount defines the count of vertices to draw
  121110. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121111. */
  121112. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121113. createPipelineContext(): IPipelineContext;
  121114. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  121115. /** @hidden */
  121116. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  121117. /** @hidden */
  121118. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  121119. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  121120. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  121121. protected _setProgram(program: WebGLProgram): void;
  121122. _releaseEffect(effect: Effect): void;
  121123. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121124. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  121125. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  121126. bindSamplers(effect: Effect): void;
  121127. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  121128. getRenderWidth(useScreen?: boolean): number;
  121129. getRenderHeight(useScreen?: boolean): number;
  121130. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  121131. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121132. /**
  121133. * Set the z offset to apply to current rendering
  121134. * @param value defines the offset to apply
  121135. */
  121136. setZOffset(value: number): void;
  121137. /**
  121138. * Gets the current value of the zOffset
  121139. * @returns the current zOffset state
  121140. */
  121141. getZOffset(): number;
  121142. /**
  121143. * Enable or disable depth buffering
  121144. * @param enable defines the state to set
  121145. */
  121146. setDepthBuffer(enable: boolean): void;
  121147. /**
  121148. * Gets a boolean indicating if depth writing is enabled
  121149. * @returns the current depth writing state
  121150. */
  121151. getDepthWrite(): boolean;
  121152. /**
  121153. * Enable or disable depth writing
  121154. * @param enable defines the state to set
  121155. */
  121156. setDepthWrite(enable: boolean): void;
  121157. /**
  121158. * Enable or disable color writing
  121159. * @param enable defines the state to set
  121160. */
  121161. setColorWrite(enable: boolean): void;
  121162. /**
  121163. * Gets a boolean indicating if color writing is enabled
  121164. * @returns the current color writing state
  121165. */
  121166. getColorWrite(): boolean;
  121167. /**
  121168. * Sets alpha constants used by some alpha blending modes
  121169. * @param r defines the red component
  121170. * @param g defines the green component
  121171. * @param b defines the blue component
  121172. * @param a defines the alpha component
  121173. */
  121174. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  121175. /**
  121176. * Sets the current alpha mode
  121177. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  121178. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121179. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121180. */
  121181. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121182. /**
  121183. * Gets the current alpha mode
  121184. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121185. * @returns the current alpha mode
  121186. */
  121187. getAlphaMode(): number;
  121188. setInt(uniform: WebGLUniformLocation, int: number): void;
  121189. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121190. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121191. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121192. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121193. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121194. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121195. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121196. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121197. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121198. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121199. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121200. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121201. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121202. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121203. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121204. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121205. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121206. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121207. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121208. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  121209. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  121210. wipeCaches(bruteForce?: boolean): void;
  121211. _createTexture(): WebGLTexture;
  121212. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  121213. /**
  121214. * Usually called from Texture.ts.
  121215. * Passed information to create a WebGLTexture
  121216. * @param urlArg defines a value which contains one of the following:
  121217. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121218. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121219. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121220. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121221. * @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)
  121222. * @param scene needed for loading to the correct scene
  121223. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121224. * @param onLoad optional callback to be called upon successful completion
  121225. * @param onError optional callback to be called upon failure
  121226. * @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
  121227. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121228. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121229. * @param forcedExtension defines the extension to use to pick the right loader
  121230. * @param mimeType defines an optional mime type
  121231. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121232. */
  121233. 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>, mimeType?: string): InternalTexture;
  121234. /**
  121235. * Creates a cube texture
  121236. * @param rootUrl defines the url where the files to load is located
  121237. * @param scene defines the current scene
  121238. * @param files defines the list of files to load (1 per face)
  121239. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  121240. * @param onLoad defines an optional callback raised when the texture is loaded
  121241. * @param onError defines an optional callback raised if there is an issue to load the texture
  121242. * @param format defines the format of the data
  121243. * @param forcedExtension defines the extension to use to pick the right loader
  121244. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  121245. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121246. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121247. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  121248. * @returns the cube texture as an InternalTexture
  121249. */
  121250. 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;
  121251. private _getSamplingFilter;
  121252. private static _GetNativeTextureFormat;
  121253. createRenderTargetTexture(size: number | {
  121254. width: number;
  121255. height: number;
  121256. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  121257. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121258. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121259. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121260. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121261. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  121262. /**
  121263. * Updates a dynamic vertex buffer.
  121264. * @param vertexBuffer the vertex buffer to update
  121265. * @param data the data used to update the vertex buffer
  121266. * @param byteOffset the byte offset of the data (optional)
  121267. * @param byteLength the byte length of the data (optional)
  121268. */
  121269. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  121270. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121271. private _updateAnisotropicLevel;
  121272. private _getAddressMode;
  121273. /** @hidden */
  121274. _bindTexture(channel: number, texture: InternalTexture): void;
  121275. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  121276. releaseEffects(): void;
  121277. /** @hidden */
  121278. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121279. /** @hidden */
  121280. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121281. /** @hidden */
  121282. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121283. /** @hidden */
  121284. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121285. }
  121286. }
  121287. declare module BABYLON {
  121288. /**
  121289. * Gather the list of clipboard event types as constants.
  121290. */
  121291. export class ClipboardEventTypes {
  121292. /**
  121293. * The clipboard event is fired when a copy command is active (pressed).
  121294. */
  121295. static readonly COPY: number;
  121296. /**
  121297. * The clipboard event is fired when a cut command is active (pressed).
  121298. */
  121299. static readonly CUT: number;
  121300. /**
  121301. * The clipboard event is fired when a paste command is active (pressed).
  121302. */
  121303. static readonly PASTE: number;
  121304. }
  121305. /**
  121306. * This class is used to store clipboard related info for the onClipboardObservable event.
  121307. */
  121308. export class ClipboardInfo {
  121309. /**
  121310. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121311. */
  121312. type: number;
  121313. /**
  121314. * Defines the related dom event
  121315. */
  121316. event: ClipboardEvent;
  121317. /**
  121318. *Creates an instance of ClipboardInfo.
  121319. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  121320. * @param event Defines the related dom event
  121321. */
  121322. constructor(
  121323. /**
  121324. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121325. */
  121326. type: number,
  121327. /**
  121328. * Defines the related dom event
  121329. */
  121330. event: ClipboardEvent);
  121331. /**
  121332. * Get the clipboard event's type from the keycode.
  121333. * @param keyCode Defines the keyCode for the current keyboard event.
  121334. * @return {number}
  121335. */
  121336. static GetTypeFromCharacter(keyCode: number): number;
  121337. }
  121338. }
  121339. declare module BABYLON {
  121340. /**
  121341. * Google Daydream controller
  121342. */
  121343. export class DaydreamController extends WebVRController {
  121344. /**
  121345. * Base Url for the controller model.
  121346. */
  121347. static MODEL_BASE_URL: string;
  121348. /**
  121349. * File name for the controller model.
  121350. */
  121351. static MODEL_FILENAME: string;
  121352. /**
  121353. * Gamepad Id prefix used to identify Daydream Controller.
  121354. */
  121355. static readonly GAMEPAD_ID_PREFIX: string;
  121356. /**
  121357. * Creates a new DaydreamController from a gamepad
  121358. * @param vrGamepad the gamepad that the controller should be created from
  121359. */
  121360. constructor(vrGamepad: any);
  121361. /**
  121362. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121363. * @param scene scene in which to add meshes
  121364. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121365. */
  121366. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121367. /**
  121368. * Called once for each button that changed state since the last frame
  121369. * @param buttonIdx Which button index changed
  121370. * @param state New state of the button
  121371. * @param changes Which properties on the state changed since last frame
  121372. */
  121373. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121374. }
  121375. }
  121376. declare module BABYLON {
  121377. /**
  121378. * Gear VR Controller
  121379. */
  121380. export class GearVRController extends WebVRController {
  121381. /**
  121382. * Base Url for the controller model.
  121383. */
  121384. static MODEL_BASE_URL: string;
  121385. /**
  121386. * File name for the controller model.
  121387. */
  121388. static MODEL_FILENAME: string;
  121389. /**
  121390. * Gamepad Id prefix used to identify this controller.
  121391. */
  121392. static readonly GAMEPAD_ID_PREFIX: string;
  121393. private readonly _buttonIndexToObservableNameMap;
  121394. /**
  121395. * Creates a new GearVRController from a gamepad
  121396. * @param vrGamepad the gamepad that the controller should be created from
  121397. */
  121398. constructor(vrGamepad: any);
  121399. /**
  121400. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121401. * @param scene scene in which to add meshes
  121402. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121403. */
  121404. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121405. /**
  121406. * Called once for each button that changed state since the last frame
  121407. * @param buttonIdx Which button index changed
  121408. * @param state New state of the button
  121409. * @param changes Which properties on the state changed since last frame
  121410. */
  121411. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121412. }
  121413. }
  121414. declare module BABYLON {
  121415. /**
  121416. * Generic Controller
  121417. */
  121418. export class GenericController extends WebVRController {
  121419. /**
  121420. * Base Url for the controller model.
  121421. */
  121422. static readonly MODEL_BASE_URL: string;
  121423. /**
  121424. * File name for the controller model.
  121425. */
  121426. static readonly MODEL_FILENAME: string;
  121427. /**
  121428. * Creates a new GenericController from a gamepad
  121429. * @param vrGamepad the gamepad that the controller should be created from
  121430. */
  121431. constructor(vrGamepad: any);
  121432. /**
  121433. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121434. * @param scene scene in which to add meshes
  121435. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121436. */
  121437. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121438. /**
  121439. * Called once for each button that changed state since the last frame
  121440. * @param buttonIdx Which button index changed
  121441. * @param state New state of the button
  121442. * @param changes Which properties on the state changed since last frame
  121443. */
  121444. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121445. }
  121446. }
  121447. declare module BABYLON {
  121448. /**
  121449. * Oculus Touch Controller
  121450. */
  121451. export class OculusTouchController extends WebVRController {
  121452. /**
  121453. * Base Url for the controller model.
  121454. */
  121455. static MODEL_BASE_URL: string;
  121456. /**
  121457. * File name for the left controller model.
  121458. */
  121459. static MODEL_LEFT_FILENAME: string;
  121460. /**
  121461. * File name for the right controller model.
  121462. */
  121463. static MODEL_RIGHT_FILENAME: string;
  121464. /**
  121465. * Base Url for the Quest controller model.
  121466. */
  121467. static QUEST_MODEL_BASE_URL: string;
  121468. /**
  121469. * @hidden
  121470. * If the controllers are running on a device that needs the updated Quest controller models
  121471. */
  121472. static _IsQuest: boolean;
  121473. /**
  121474. * Fired when the secondary trigger on this controller is modified
  121475. */
  121476. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121477. /**
  121478. * Fired when the thumb rest on this controller is modified
  121479. */
  121480. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121481. /**
  121482. * Creates a new OculusTouchController from a gamepad
  121483. * @param vrGamepad the gamepad that the controller should be created from
  121484. */
  121485. constructor(vrGamepad: any);
  121486. /**
  121487. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121488. * @param scene scene in which to add meshes
  121489. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121490. */
  121491. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121492. /**
  121493. * Fired when the A button on this controller is modified
  121494. */
  121495. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121496. /**
  121497. * Fired when the B button on this controller is modified
  121498. */
  121499. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121500. /**
  121501. * Fired when the X button on this controller is modified
  121502. */
  121503. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121504. /**
  121505. * Fired when the Y button on this controller is modified
  121506. */
  121507. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121508. /**
  121509. * Called once for each button that changed state since the last frame
  121510. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121511. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121512. * 2) secondary trigger (same)
  121513. * 3) A (right) X (left), touch, pressed = value
  121514. * 4) B / Y
  121515. * 5) thumb rest
  121516. * @param buttonIdx Which button index changed
  121517. * @param state New state of the button
  121518. * @param changes Which properties on the state changed since last frame
  121519. */
  121520. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121521. }
  121522. }
  121523. declare module BABYLON {
  121524. /**
  121525. * Vive Controller
  121526. */
  121527. export class ViveController extends WebVRController {
  121528. /**
  121529. * Base Url for the controller model.
  121530. */
  121531. static MODEL_BASE_URL: string;
  121532. /**
  121533. * File name for the controller model.
  121534. */
  121535. static MODEL_FILENAME: string;
  121536. /**
  121537. * Creates a new ViveController from a gamepad
  121538. * @param vrGamepad the gamepad that the controller should be created from
  121539. */
  121540. constructor(vrGamepad: any);
  121541. /**
  121542. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121543. * @param scene scene in which to add meshes
  121544. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121545. */
  121546. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121547. /**
  121548. * Fired when the left button on this controller is modified
  121549. */
  121550. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121551. /**
  121552. * Fired when the right button on this controller is modified
  121553. */
  121554. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121555. /**
  121556. * Fired when the menu button on this controller is modified
  121557. */
  121558. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121559. /**
  121560. * Called once for each button that changed state since the last frame
  121561. * Vive mapping:
  121562. * 0: touchpad
  121563. * 1: trigger
  121564. * 2: left AND right buttons
  121565. * 3: menu button
  121566. * @param buttonIdx Which button index changed
  121567. * @param state New state of the button
  121568. * @param changes Which properties on the state changed since last frame
  121569. */
  121570. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121571. }
  121572. }
  121573. declare module BABYLON {
  121574. /**
  121575. * Defines the WindowsMotionController object that the state of the windows motion controller
  121576. */
  121577. export class WindowsMotionController extends WebVRController {
  121578. /**
  121579. * The base url used to load the left and right controller models
  121580. */
  121581. static MODEL_BASE_URL: string;
  121582. /**
  121583. * The name of the left controller model file
  121584. */
  121585. static MODEL_LEFT_FILENAME: string;
  121586. /**
  121587. * The name of the right controller model file
  121588. */
  121589. static MODEL_RIGHT_FILENAME: string;
  121590. /**
  121591. * The controller name prefix for this controller type
  121592. */
  121593. static readonly GAMEPAD_ID_PREFIX: string;
  121594. /**
  121595. * The controller id pattern for this controller type
  121596. */
  121597. private static readonly GAMEPAD_ID_PATTERN;
  121598. private _loadedMeshInfo;
  121599. protected readonly _mapping: {
  121600. buttons: string[];
  121601. buttonMeshNames: {
  121602. 'trigger': string;
  121603. 'menu': string;
  121604. 'grip': string;
  121605. 'thumbstick': string;
  121606. 'trackpad': string;
  121607. };
  121608. buttonObservableNames: {
  121609. 'trigger': string;
  121610. 'menu': string;
  121611. 'grip': string;
  121612. 'thumbstick': string;
  121613. 'trackpad': string;
  121614. };
  121615. axisMeshNames: string[];
  121616. pointingPoseMeshName: string;
  121617. };
  121618. /**
  121619. * Fired when the trackpad on this controller is clicked
  121620. */
  121621. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121622. /**
  121623. * Fired when the trackpad on this controller is modified
  121624. */
  121625. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121626. /**
  121627. * The current x and y values of this controller's trackpad
  121628. */
  121629. trackpad: StickValues;
  121630. /**
  121631. * Creates a new WindowsMotionController from a gamepad
  121632. * @param vrGamepad the gamepad that the controller should be created from
  121633. */
  121634. constructor(vrGamepad: any);
  121635. /**
  121636. * Fired when the trigger on this controller is modified
  121637. */
  121638. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121639. /**
  121640. * Fired when the menu button on this controller is modified
  121641. */
  121642. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121643. /**
  121644. * Fired when the grip button on this controller is modified
  121645. */
  121646. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121647. /**
  121648. * Fired when the thumbstick button on this controller is modified
  121649. */
  121650. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121651. /**
  121652. * Fired when the touchpad button on this controller is modified
  121653. */
  121654. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121655. /**
  121656. * Fired when the touchpad values on this controller are modified
  121657. */
  121658. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121659. protected _updateTrackpad(): void;
  121660. /**
  121661. * Called once per frame by the engine.
  121662. */
  121663. update(): void;
  121664. /**
  121665. * Called once for each button that changed state since the last frame
  121666. * @param buttonIdx Which button index changed
  121667. * @param state New state of the button
  121668. * @param changes Which properties on the state changed since last frame
  121669. */
  121670. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121671. /**
  121672. * Moves the buttons on the controller mesh based on their current state
  121673. * @param buttonName the name of the button to move
  121674. * @param buttonValue the value of the button which determines the buttons new position
  121675. */
  121676. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121677. /**
  121678. * Moves the axis on the controller mesh based on its current state
  121679. * @param axis the index of the axis
  121680. * @param axisValue the value of the axis which determines the meshes new position
  121681. * @hidden
  121682. */
  121683. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121684. /**
  121685. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121686. * @param scene scene in which to add meshes
  121687. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121688. */
  121689. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121690. /**
  121691. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121692. * can be transformed by button presses and axes values, based on this._mapping.
  121693. *
  121694. * @param scene scene in which the meshes exist
  121695. * @param meshes list of meshes that make up the controller model to process
  121696. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121697. */
  121698. private processModel;
  121699. private createMeshInfo;
  121700. /**
  121701. * Gets the ray of the controller in the direction the controller is pointing
  121702. * @param length the length the resulting ray should be
  121703. * @returns a ray in the direction the controller is pointing
  121704. */
  121705. getForwardRay(length?: number): Ray;
  121706. /**
  121707. * Disposes of the controller
  121708. */
  121709. dispose(): void;
  121710. }
  121711. /**
  121712. * This class represents a new windows motion controller in XR.
  121713. */
  121714. export class XRWindowsMotionController extends WindowsMotionController {
  121715. /**
  121716. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121717. */
  121718. protected readonly _mapping: {
  121719. buttons: string[];
  121720. buttonMeshNames: {
  121721. 'trigger': string;
  121722. 'menu': string;
  121723. 'grip': string;
  121724. 'thumbstick': string;
  121725. 'trackpad': string;
  121726. };
  121727. buttonObservableNames: {
  121728. 'trigger': string;
  121729. 'menu': string;
  121730. 'grip': string;
  121731. 'thumbstick': string;
  121732. 'trackpad': string;
  121733. };
  121734. axisMeshNames: string[];
  121735. pointingPoseMeshName: string;
  121736. };
  121737. /**
  121738. * Construct a new XR-Based windows motion controller
  121739. *
  121740. * @param gamepadInfo the gamepad object from the browser
  121741. */
  121742. constructor(gamepadInfo: any);
  121743. /**
  121744. * holds the thumbstick values (X,Y)
  121745. */
  121746. thumbstickValues: StickValues;
  121747. /**
  121748. * Fired when the thumbstick on this controller is clicked
  121749. */
  121750. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121751. /**
  121752. * Fired when the thumbstick on this controller is modified
  121753. */
  121754. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121755. /**
  121756. * Fired when the touchpad button on this controller is modified
  121757. */
  121758. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121759. /**
  121760. * Fired when the touchpad values on this controller are modified
  121761. */
  121762. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121763. /**
  121764. * Fired when the thumbstick button on this controller is modified
  121765. * here to prevent breaking changes
  121766. */
  121767. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121768. /**
  121769. * updating the thumbstick(!) and not the trackpad.
  121770. * This is named this way due to the difference between WebVR and XR and to avoid
  121771. * changing the parent class.
  121772. */
  121773. protected _updateTrackpad(): void;
  121774. /**
  121775. * Disposes the class with joy
  121776. */
  121777. dispose(): void;
  121778. }
  121779. }
  121780. declare module BABYLON {
  121781. /**
  121782. * Class containing static functions to help procedurally build meshes
  121783. */
  121784. export class PolyhedronBuilder {
  121785. /**
  121786. * Creates a polyhedron mesh
  121787. * * 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
  121788. * * The parameter `size` (positive float, default 1) sets the polygon size
  121789. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121790. * * 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`
  121791. * * 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
  121792. * * 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)`)
  121793. * * 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
  121794. * * 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
  121795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121796. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121798. * @param name defines the name of the mesh
  121799. * @param options defines the options used to create the mesh
  121800. * @param scene defines the hosting scene
  121801. * @returns the polyhedron mesh
  121802. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121803. */
  121804. static CreatePolyhedron(name: string, options: {
  121805. type?: number;
  121806. size?: number;
  121807. sizeX?: number;
  121808. sizeY?: number;
  121809. sizeZ?: number;
  121810. custom?: any;
  121811. faceUV?: Vector4[];
  121812. faceColors?: Color4[];
  121813. flat?: boolean;
  121814. updatable?: boolean;
  121815. sideOrientation?: number;
  121816. frontUVs?: Vector4;
  121817. backUVs?: Vector4;
  121818. }, scene?: Nullable<Scene>): Mesh;
  121819. }
  121820. }
  121821. declare module BABYLON {
  121822. /**
  121823. * Gizmo that enables scaling a mesh along 3 axis
  121824. */
  121825. export class ScaleGizmo extends Gizmo {
  121826. /**
  121827. * Internal gizmo used for interactions on the x axis
  121828. */
  121829. xGizmo: AxisScaleGizmo;
  121830. /**
  121831. * Internal gizmo used for interactions on the y axis
  121832. */
  121833. yGizmo: AxisScaleGizmo;
  121834. /**
  121835. * Internal gizmo used for interactions on the z axis
  121836. */
  121837. zGizmo: AxisScaleGizmo;
  121838. /**
  121839. * Internal gizmo used to scale all axis equally
  121840. */
  121841. uniformScaleGizmo: AxisScaleGizmo;
  121842. private _meshAttached;
  121843. private _updateGizmoRotationToMatchAttachedMesh;
  121844. private _snapDistance;
  121845. private _scaleRatio;
  121846. private _uniformScalingMesh;
  121847. private _octahedron;
  121848. private _sensitivity;
  121849. /** Fires an event when any of it's sub gizmos are dragged */
  121850. onDragStartObservable: Observable<unknown>;
  121851. /** Fires an event when any of it's sub gizmos are released from dragging */
  121852. onDragEndObservable: Observable<unknown>;
  121853. get attachedMesh(): Nullable<AbstractMesh>;
  121854. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121855. /**
  121856. * Creates a ScaleGizmo
  121857. * @param gizmoLayer The utility layer the gizmo will be added to
  121858. */
  121859. constructor(gizmoLayer?: UtilityLayerRenderer);
  121860. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121861. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121862. /**
  121863. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121864. */
  121865. set snapDistance(value: number);
  121866. get snapDistance(): number;
  121867. /**
  121868. * Ratio for the scale of the gizmo (Default: 1)
  121869. */
  121870. set scaleRatio(value: number);
  121871. get scaleRatio(): number;
  121872. /**
  121873. * Sensitivity factor for dragging (Default: 1)
  121874. */
  121875. set sensitivity(value: number);
  121876. get sensitivity(): number;
  121877. /**
  121878. * Disposes of the gizmo
  121879. */
  121880. dispose(): void;
  121881. }
  121882. }
  121883. declare module BABYLON {
  121884. /**
  121885. * Single axis scale gizmo
  121886. */
  121887. export class AxisScaleGizmo extends Gizmo {
  121888. /**
  121889. * Drag behavior responsible for the gizmos dragging interactions
  121890. */
  121891. dragBehavior: PointerDragBehavior;
  121892. private _pointerObserver;
  121893. /**
  121894. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121895. */
  121896. snapDistance: number;
  121897. /**
  121898. * Event that fires each time the gizmo snaps to a new location.
  121899. * * snapDistance is the the change in distance
  121900. */
  121901. onSnapObservable: Observable<{
  121902. snapDistance: number;
  121903. }>;
  121904. /**
  121905. * If the scaling operation should be done on all axis (default: false)
  121906. */
  121907. uniformScaling: boolean;
  121908. /**
  121909. * Custom sensitivity value for the drag strength
  121910. */
  121911. sensitivity: number;
  121912. private _isEnabled;
  121913. private _parent;
  121914. private _arrow;
  121915. private _coloredMaterial;
  121916. private _hoverMaterial;
  121917. /**
  121918. * Creates an AxisScaleGizmo
  121919. * @param gizmoLayer The utility layer the gizmo will be added to
  121920. * @param dragAxis The axis which the gizmo will be able to scale on
  121921. * @param color The color of the gizmo
  121922. */
  121923. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121924. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121925. /**
  121926. * If the gizmo is enabled
  121927. */
  121928. set isEnabled(value: boolean);
  121929. get isEnabled(): boolean;
  121930. /**
  121931. * Disposes of the gizmo
  121932. */
  121933. dispose(): void;
  121934. /**
  121935. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121936. * @param mesh The mesh to replace the default mesh of the gizmo
  121937. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121938. */
  121939. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121940. }
  121941. }
  121942. declare module BABYLON {
  121943. /**
  121944. * Bounding box gizmo
  121945. */
  121946. export class BoundingBoxGizmo extends Gizmo {
  121947. private _lineBoundingBox;
  121948. private _rotateSpheresParent;
  121949. private _scaleBoxesParent;
  121950. private _boundingDimensions;
  121951. private _renderObserver;
  121952. private _pointerObserver;
  121953. private _scaleDragSpeed;
  121954. private _tmpQuaternion;
  121955. private _tmpVector;
  121956. private _tmpRotationMatrix;
  121957. /**
  121958. * 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)
  121959. */
  121960. ignoreChildren: boolean;
  121961. /**
  121962. * 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)
  121963. */
  121964. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121965. /**
  121966. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121967. */
  121968. rotationSphereSize: number;
  121969. /**
  121970. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121971. */
  121972. scaleBoxSize: number;
  121973. /**
  121974. * 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)
  121975. */
  121976. fixedDragMeshScreenSize: boolean;
  121977. /**
  121978. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121979. */
  121980. fixedDragMeshScreenSizeDistanceFactor: number;
  121981. /**
  121982. * Fired when a rotation sphere or scale box is dragged
  121983. */
  121984. onDragStartObservable: Observable<{}>;
  121985. /**
  121986. * Fired when a scale box is dragged
  121987. */
  121988. onScaleBoxDragObservable: Observable<{}>;
  121989. /**
  121990. * Fired when a scale box drag is ended
  121991. */
  121992. onScaleBoxDragEndObservable: Observable<{}>;
  121993. /**
  121994. * Fired when a rotation sphere is dragged
  121995. */
  121996. onRotationSphereDragObservable: Observable<{}>;
  121997. /**
  121998. * Fired when a rotation sphere drag is ended
  121999. */
  122000. onRotationSphereDragEndObservable: Observable<{}>;
  122001. /**
  122002. * 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)
  122003. */
  122004. scalePivot: Nullable<Vector3>;
  122005. /**
  122006. * Mesh used as a pivot to rotate the attached mesh
  122007. */
  122008. private _anchorMesh;
  122009. private _existingMeshScale;
  122010. private _dragMesh;
  122011. private pointerDragBehavior;
  122012. private coloredMaterial;
  122013. private hoverColoredMaterial;
  122014. /**
  122015. * Sets the color of the bounding box gizmo
  122016. * @param color the color to set
  122017. */
  122018. setColor(color: Color3): void;
  122019. /**
  122020. * Creates an BoundingBoxGizmo
  122021. * @param gizmoLayer The utility layer the gizmo will be added to
  122022. * @param color The color of the gizmo
  122023. */
  122024. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  122025. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122026. private _selectNode;
  122027. /**
  122028. * Updates the bounding box information for the Gizmo
  122029. */
  122030. updateBoundingBox(): void;
  122031. private _updateRotationSpheres;
  122032. private _updateScaleBoxes;
  122033. /**
  122034. * Enables rotation on the specified axis and disables rotation on the others
  122035. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  122036. */
  122037. setEnabledRotationAxis(axis: string): void;
  122038. /**
  122039. * Enables/disables scaling
  122040. * @param enable if scaling should be enabled
  122041. */
  122042. setEnabledScaling(enable: boolean): void;
  122043. private _updateDummy;
  122044. /**
  122045. * Enables a pointer drag behavior on the bounding box of the gizmo
  122046. */
  122047. enableDragBehavior(): void;
  122048. /**
  122049. * Disposes of the gizmo
  122050. */
  122051. dispose(): void;
  122052. /**
  122053. * 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)
  122054. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  122055. * @returns the bounding box mesh with the passed in mesh as a child
  122056. */
  122057. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  122058. /**
  122059. * CustomMeshes are not supported by this gizmo
  122060. * @param mesh The mesh to replace the default mesh of the gizmo
  122061. */
  122062. setCustomMesh(mesh: Mesh): void;
  122063. }
  122064. }
  122065. declare module BABYLON {
  122066. /**
  122067. * Single plane rotation gizmo
  122068. */
  122069. export class PlaneRotationGizmo extends Gizmo {
  122070. /**
  122071. * Drag behavior responsible for the gizmos dragging interactions
  122072. */
  122073. dragBehavior: PointerDragBehavior;
  122074. private _pointerObserver;
  122075. /**
  122076. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  122077. */
  122078. snapDistance: number;
  122079. /**
  122080. * Event that fires each time the gizmo snaps to a new location.
  122081. * * snapDistance is the the change in distance
  122082. */
  122083. onSnapObservable: Observable<{
  122084. snapDistance: number;
  122085. }>;
  122086. private _isEnabled;
  122087. private _parent;
  122088. /**
  122089. * Creates a PlaneRotationGizmo
  122090. * @param gizmoLayer The utility layer the gizmo will be added to
  122091. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  122092. * @param color The color of the gizmo
  122093. * @param tessellation Amount of tessellation to be used when creating rotation circles
  122094. * @param useEulerRotation Use and update Euler angle instead of quaternion
  122095. */
  122096. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  122097. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122098. /**
  122099. * If the gizmo is enabled
  122100. */
  122101. set isEnabled(value: boolean);
  122102. get isEnabled(): boolean;
  122103. /**
  122104. * Disposes of the gizmo
  122105. */
  122106. dispose(): void;
  122107. }
  122108. }
  122109. declare module BABYLON {
  122110. /**
  122111. * Gizmo that enables rotating a mesh along 3 axis
  122112. */
  122113. export class RotationGizmo extends Gizmo {
  122114. /**
  122115. * Internal gizmo used for interactions on the x axis
  122116. */
  122117. xGizmo: PlaneRotationGizmo;
  122118. /**
  122119. * Internal gizmo used for interactions on the y axis
  122120. */
  122121. yGizmo: PlaneRotationGizmo;
  122122. /**
  122123. * Internal gizmo used for interactions on the z axis
  122124. */
  122125. zGizmo: PlaneRotationGizmo;
  122126. /** Fires an event when any of it's sub gizmos are dragged */
  122127. onDragStartObservable: Observable<unknown>;
  122128. /** Fires an event when any of it's sub gizmos are released from dragging */
  122129. onDragEndObservable: Observable<unknown>;
  122130. private _meshAttached;
  122131. get attachedMesh(): Nullable<AbstractMesh>;
  122132. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122133. /**
  122134. * Creates a RotationGizmo
  122135. * @param gizmoLayer The utility layer the gizmo will be added to
  122136. * @param tessellation Amount of tessellation to be used when creating rotation circles
  122137. * @param useEulerRotation Use and update Euler angle instead of quaternion
  122138. */
  122139. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  122140. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122141. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122142. /**
  122143. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122144. */
  122145. set snapDistance(value: number);
  122146. get snapDistance(): number;
  122147. /**
  122148. * Ratio for the scale of the gizmo (Default: 1)
  122149. */
  122150. set scaleRatio(value: number);
  122151. get scaleRatio(): number;
  122152. /**
  122153. * Disposes of the gizmo
  122154. */
  122155. dispose(): void;
  122156. /**
  122157. * CustomMeshes are not supported by this gizmo
  122158. * @param mesh The mesh to replace the default mesh of the gizmo
  122159. */
  122160. setCustomMesh(mesh: Mesh): void;
  122161. }
  122162. }
  122163. declare module BABYLON {
  122164. /**
  122165. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  122166. */
  122167. export class GizmoManager implements IDisposable {
  122168. private scene;
  122169. /**
  122170. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  122171. */
  122172. gizmos: {
  122173. positionGizmo: Nullable<PositionGizmo>;
  122174. rotationGizmo: Nullable<RotationGizmo>;
  122175. scaleGizmo: Nullable<ScaleGizmo>;
  122176. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  122177. };
  122178. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  122179. clearGizmoOnEmptyPointerEvent: boolean;
  122180. /** Fires an event when the manager is attached to a mesh */
  122181. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  122182. private _gizmosEnabled;
  122183. private _pointerObserver;
  122184. private _attachedMesh;
  122185. private _boundingBoxColor;
  122186. private _defaultUtilityLayer;
  122187. private _defaultKeepDepthUtilityLayer;
  122188. /**
  122189. * When bounding box gizmo is enabled, this can be used to track drag/end events
  122190. */
  122191. boundingBoxDragBehavior: SixDofDragBehavior;
  122192. /**
  122193. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  122194. */
  122195. attachableMeshes: Nullable<Array<AbstractMesh>>;
  122196. /**
  122197. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  122198. */
  122199. usePointerToAttachGizmos: boolean;
  122200. /**
  122201. * Utility layer that the bounding box gizmo belongs to
  122202. */
  122203. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  122204. /**
  122205. * Utility layer that all gizmos besides bounding box belong to
  122206. */
  122207. get utilityLayer(): UtilityLayerRenderer;
  122208. /**
  122209. * Instatiates a gizmo manager
  122210. * @param scene the scene to overlay the gizmos on top of
  122211. */
  122212. constructor(scene: Scene);
  122213. /**
  122214. * Attaches a set of gizmos to the specified mesh
  122215. * @param mesh The mesh the gizmo's should be attached to
  122216. */
  122217. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  122218. /**
  122219. * If the position gizmo is enabled
  122220. */
  122221. set positionGizmoEnabled(value: boolean);
  122222. get positionGizmoEnabled(): boolean;
  122223. /**
  122224. * If the rotation gizmo is enabled
  122225. */
  122226. set rotationGizmoEnabled(value: boolean);
  122227. get rotationGizmoEnabled(): boolean;
  122228. /**
  122229. * If the scale gizmo is enabled
  122230. */
  122231. set scaleGizmoEnabled(value: boolean);
  122232. get scaleGizmoEnabled(): boolean;
  122233. /**
  122234. * If the boundingBox gizmo is enabled
  122235. */
  122236. set boundingBoxGizmoEnabled(value: boolean);
  122237. get boundingBoxGizmoEnabled(): boolean;
  122238. /**
  122239. * Disposes of the gizmo manager
  122240. */
  122241. dispose(): void;
  122242. }
  122243. }
  122244. declare module BABYLON {
  122245. /**
  122246. * A directional light is defined by a direction (what a surprise!).
  122247. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  122248. * 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.
  122249. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122250. */
  122251. export class DirectionalLight extends ShadowLight {
  122252. private _shadowFrustumSize;
  122253. /**
  122254. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  122255. */
  122256. get shadowFrustumSize(): number;
  122257. /**
  122258. * Specifies a fix frustum size for the shadow generation.
  122259. */
  122260. set shadowFrustumSize(value: number);
  122261. private _shadowOrthoScale;
  122262. /**
  122263. * Gets the shadow projection scale against the optimal computed one.
  122264. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122265. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122266. */
  122267. get shadowOrthoScale(): number;
  122268. /**
  122269. * Sets the shadow projection scale against the optimal computed one.
  122270. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122271. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122272. */
  122273. set shadowOrthoScale(value: number);
  122274. /**
  122275. * Automatically compute the projection matrix to best fit (including all the casters)
  122276. * on each frame.
  122277. */
  122278. autoUpdateExtends: boolean;
  122279. /**
  122280. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  122281. * on each frame. autoUpdateExtends must be set to true for this to work
  122282. */
  122283. autoCalcShadowZBounds: boolean;
  122284. private _orthoLeft;
  122285. private _orthoRight;
  122286. private _orthoTop;
  122287. private _orthoBottom;
  122288. /**
  122289. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  122290. * The directional light is emitted from everywhere in the given direction.
  122291. * It can cast shadows.
  122292. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122293. * @param name The friendly name of the light
  122294. * @param direction The direction of the light
  122295. * @param scene The scene the light belongs to
  122296. */
  122297. constructor(name: string, direction: Vector3, scene: Scene);
  122298. /**
  122299. * Returns the string "DirectionalLight".
  122300. * @return The class name
  122301. */
  122302. getClassName(): string;
  122303. /**
  122304. * Returns the integer 1.
  122305. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122306. */
  122307. getTypeID(): number;
  122308. /**
  122309. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  122310. * Returns the DirectionalLight Shadow projection matrix.
  122311. */
  122312. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122313. /**
  122314. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  122315. * Returns the DirectionalLight Shadow projection matrix.
  122316. */
  122317. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  122318. /**
  122319. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  122320. * Returns the DirectionalLight Shadow projection matrix.
  122321. */
  122322. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122323. protected _buildUniformLayout(): void;
  122324. /**
  122325. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122326. * @param effect The effect to update
  122327. * @param lightIndex The index of the light in the effect to update
  122328. * @returns The directional light
  122329. */
  122330. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122331. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122332. /**
  122333. * Gets the minZ used for shadow according to both the scene and the light.
  122334. *
  122335. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122336. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122337. * @param activeCamera The camera we are returning the min for
  122338. * @returns the depth min z
  122339. */
  122340. getDepthMinZ(activeCamera: Camera): number;
  122341. /**
  122342. * Gets the maxZ used for shadow according to both the scene and the light.
  122343. *
  122344. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122345. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122346. * @param activeCamera The camera we are returning the max for
  122347. * @returns the depth max z
  122348. */
  122349. getDepthMaxZ(activeCamera: Camera): number;
  122350. /**
  122351. * Prepares the list of defines specific to the light type.
  122352. * @param defines the list of defines
  122353. * @param lightIndex defines the index of the light for the effect
  122354. */
  122355. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122356. }
  122357. }
  122358. declare module BABYLON {
  122359. /**
  122360. * Class containing static functions to help procedurally build meshes
  122361. */
  122362. export class HemisphereBuilder {
  122363. /**
  122364. * Creates a hemisphere mesh
  122365. * @param name defines the name of the mesh
  122366. * @param options defines the options used to create the mesh
  122367. * @param scene defines the hosting scene
  122368. * @returns the hemisphere mesh
  122369. */
  122370. static CreateHemisphere(name: string, options: {
  122371. segments?: number;
  122372. diameter?: number;
  122373. sideOrientation?: number;
  122374. }, scene: any): Mesh;
  122375. }
  122376. }
  122377. declare module BABYLON {
  122378. /**
  122379. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122380. * These values define a cone of light starting from the position, emitting toward the direction.
  122381. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122382. * and the exponent defines the speed of the decay of the light with distance (reach).
  122383. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122384. */
  122385. export class SpotLight extends ShadowLight {
  122386. private _angle;
  122387. private _innerAngle;
  122388. private _cosHalfAngle;
  122389. private _lightAngleScale;
  122390. private _lightAngleOffset;
  122391. /**
  122392. * Gets the cone angle of the spot light in Radians.
  122393. */
  122394. get angle(): number;
  122395. /**
  122396. * Sets the cone angle of the spot light in Radians.
  122397. */
  122398. set angle(value: number);
  122399. /**
  122400. * Only used in gltf falloff mode, this defines the angle where
  122401. * the directional falloff will start before cutting at angle which could be seen
  122402. * as outer angle.
  122403. */
  122404. get innerAngle(): number;
  122405. /**
  122406. * Only used in gltf falloff mode, this defines the angle where
  122407. * the directional falloff will start before cutting at angle which could be seen
  122408. * as outer angle.
  122409. */
  122410. set innerAngle(value: number);
  122411. private _shadowAngleScale;
  122412. /**
  122413. * Allows scaling the angle of the light for shadow generation only.
  122414. */
  122415. get shadowAngleScale(): number;
  122416. /**
  122417. * Allows scaling the angle of the light for shadow generation only.
  122418. */
  122419. set shadowAngleScale(value: number);
  122420. /**
  122421. * The light decay speed with the distance from the emission spot.
  122422. */
  122423. exponent: number;
  122424. private _projectionTextureMatrix;
  122425. /**
  122426. * Allows reading the projecton texture
  122427. */
  122428. get projectionTextureMatrix(): Matrix;
  122429. protected _projectionTextureLightNear: number;
  122430. /**
  122431. * Gets the near clip of the Spotlight for texture projection.
  122432. */
  122433. get projectionTextureLightNear(): number;
  122434. /**
  122435. * Sets the near clip of the Spotlight for texture projection.
  122436. */
  122437. set projectionTextureLightNear(value: number);
  122438. protected _projectionTextureLightFar: number;
  122439. /**
  122440. * Gets the far clip of the Spotlight for texture projection.
  122441. */
  122442. get projectionTextureLightFar(): number;
  122443. /**
  122444. * Sets the far clip of the Spotlight for texture projection.
  122445. */
  122446. set projectionTextureLightFar(value: number);
  122447. protected _projectionTextureUpDirection: Vector3;
  122448. /**
  122449. * Gets the Up vector of the Spotlight for texture projection.
  122450. */
  122451. get projectionTextureUpDirection(): Vector3;
  122452. /**
  122453. * Sets the Up vector of the Spotlight for texture projection.
  122454. */
  122455. set projectionTextureUpDirection(value: Vector3);
  122456. private _projectionTexture;
  122457. /**
  122458. * Gets the projection texture of the light.
  122459. */
  122460. get projectionTexture(): Nullable<BaseTexture>;
  122461. /**
  122462. * Sets the projection texture of the light.
  122463. */
  122464. set projectionTexture(value: Nullable<BaseTexture>);
  122465. private _projectionTextureViewLightDirty;
  122466. private _projectionTextureProjectionLightDirty;
  122467. private _projectionTextureDirty;
  122468. private _projectionTextureViewTargetVector;
  122469. private _projectionTextureViewLightMatrix;
  122470. private _projectionTextureProjectionLightMatrix;
  122471. private _projectionTextureScalingMatrix;
  122472. /**
  122473. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122474. * It can cast shadows.
  122475. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122476. * @param name The light friendly name
  122477. * @param position The position of the spot light in the scene
  122478. * @param direction The direction of the light in the scene
  122479. * @param angle The cone angle of the light in Radians
  122480. * @param exponent The light decay speed with the distance from the emission spot
  122481. * @param scene The scene the lights belongs to
  122482. */
  122483. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122484. /**
  122485. * Returns the string "SpotLight".
  122486. * @returns the class name
  122487. */
  122488. getClassName(): string;
  122489. /**
  122490. * Returns the integer 2.
  122491. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122492. */
  122493. getTypeID(): number;
  122494. /**
  122495. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122496. */
  122497. protected _setDirection(value: Vector3): void;
  122498. /**
  122499. * Overrides the position setter to recompute the projection texture view light Matrix.
  122500. */
  122501. protected _setPosition(value: Vector3): void;
  122502. /**
  122503. * 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.
  122504. * Returns the SpotLight.
  122505. */
  122506. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122507. protected _computeProjectionTextureViewLightMatrix(): void;
  122508. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122509. /**
  122510. * Main function for light texture projection matrix computing.
  122511. */
  122512. protected _computeProjectionTextureMatrix(): void;
  122513. protected _buildUniformLayout(): void;
  122514. private _computeAngleValues;
  122515. /**
  122516. * Sets the passed Effect "effect" with the Light textures.
  122517. * @param effect The effect to update
  122518. * @param lightIndex The index of the light in the effect to update
  122519. * @returns The light
  122520. */
  122521. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122522. /**
  122523. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122524. * @param effect The effect to update
  122525. * @param lightIndex The index of the light in the effect to update
  122526. * @returns The spot light
  122527. */
  122528. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122529. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122530. /**
  122531. * Disposes the light and the associated resources.
  122532. */
  122533. dispose(): void;
  122534. /**
  122535. * Prepares the list of defines specific to the light type.
  122536. * @param defines the list of defines
  122537. * @param lightIndex defines the index of the light for the effect
  122538. */
  122539. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122540. }
  122541. }
  122542. declare module BABYLON {
  122543. /**
  122544. * Gizmo that enables viewing a light
  122545. */
  122546. export class LightGizmo extends Gizmo {
  122547. private _lightMesh;
  122548. private _material;
  122549. private _cachedPosition;
  122550. private _cachedForward;
  122551. private _attachedMeshParent;
  122552. /**
  122553. * Creates a LightGizmo
  122554. * @param gizmoLayer The utility layer the gizmo will be added to
  122555. */
  122556. constructor(gizmoLayer?: UtilityLayerRenderer);
  122557. private _light;
  122558. /**
  122559. * The light that the gizmo is attached to
  122560. */
  122561. set light(light: Nullable<Light>);
  122562. get light(): Nullable<Light>;
  122563. /**
  122564. * Gets the material used to render the light gizmo
  122565. */
  122566. get material(): StandardMaterial;
  122567. /**
  122568. * @hidden
  122569. * Updates the gizmo to match the attached mesh's position/rotation
  122570. */
  122571. protected _update(): void;
  122572. private static _Scale;
  122573. /**
  122574. * Creates the lines for a light mesh
  122575. */
  122576. private static _CreateLightLines;
  122577. /**
  122578. * Disposes of the light gizmo
  122579. */
  122580. dispose(): void;
  122581. private static _CreateHemisphericLightMesh;
  122582. private static _CreatePointLightMesh;
  122583. private static _CreateSpotLightMesh;
  122584. private static _CreateDirectionalLightMesh;
  122585. }
  122586. }
  122587. declare module BABYLON {
  122588. /** @hidden */
  122589. export var backgroundFragmentDeclaration: {
  122590. name: string;
  122591. shader: string;
  122592. };
  122593. }
  122594. declare module BABYLON {
  122595. /** @hidden */
  122596. export var backgroundUboDeclaration: {
  122597. name: string;
  122598. shader: string;
  122599. };
  122600. }
  122601. declare module BABYLON {
  122602. /** @hidden */
  122603. export var backgroundPixelShader: {
  122604. name: string;
  122605. shader: string;
  122606. };
  122607. }
  122608. declare module BABYLON {
  122609. /** @hidden */
  122610. export var backgroundVertexDeclaration: {
  122611. name: string;
  122612. shader: string;
  122613. };
  122614. }
  122615. declare module BABYLON {
  122616. /** @hidden */
  122617. export var backgroundVertexShader: {
  122618. name: string;
  122619. shader: string;
  122620. };
  122621. }
  122622. declare module BABYLON {
  122623. /**
  122624. * Background material used to create an efficient environement around your scene.
  122625. */
  122626. export class BackgroundMaterial extends PushMaterial {
  122627. /**
  122628. * Standard reflectance value at parallel view angle.
  122629. */
  122630. static StandardReflectance0: number;
  122631. /**
  122632. * Standard reflectance value at grazing angle.
  122633. */
  122634. static StandardReflectance90: number;
  122635. protected _primaryColor: Color3;
  122636. /**
  122637. * Key light Color (multiply against the environement texture)
  122638. */
  122639. primaryColor: Color3;
  122640. protected __perceptualColor: Nullable<Color3>;
  122641. /**
  122642. * Experimental Internal Use Only.
  122643. *
  122644. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122645. * This acts as a helper to set the primary color to a more "human friendly" value.
  122646. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122647. * output color as close as possible from the chosen value.
  122648. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122649. * part of lighting setup.)
  122650. */
  122651. get _perceptualColor(): Nullable<Color3>;
  122652. set _perceptualColor(value: Nullable<Color3>);
  122653. protected _primaryColorShadowLevel: float;
  122654. /**
  122655. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122656. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122657. */
  122658. get primaryColorShadowLevel(): float;
  122659. set primaryColorShadowLevel(value: float);
  122660. protected _primaryColorHighlightLevel: float;
  122661. /**
  122662. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122663. * The primary color is used at the level chosen to define what the white area would look.
  122664. */
  122665. get primaryColorHighlightLevel(): float;
  122666. set primaryColorHighlightLevel(value: float);
  122667. protected _reflectionTexture: Nullable<BaseTexture>;
  122668. /**
  122669. * Reflection Texture used in the material.
  122670. * Should be author in a specific way for the best result (refer to the documentation).
  122671. */
  122672. reflectionTexture: Nullable<BaseTexture>;
  122673. protected _reflectionBlur: float;
  122674. /**
  122675. * Reflection Texture level of blur.
  122676. *
  122677. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122678. * texture twice.
  122679. */
  122680. reflectionBlur: float;
  122681. protected _diffuseTexture: Nullable<BaseTexture>;
  122682. /**
  122683. * Diffuse Texture used in the material.
  122684. * Should be author in a specific way for the best result (refer to the documentation).
  122685. */
  122686. diffuseTexture: Nullable<BaseTexture>;
  122687. protected _shadowLights: Nullable<IShadowLight[]>;
  122688. /**
  122689. * Specify the list of lights casting shadow on the material.
  122690. * All scene shadow lights will be included if null.
  122691. */
  122692. shadowLights: Nullable<IShadowLight[]>;
  122693. protected _shadowLevel: float;
  122694. /**
  122695. * Helps adjusting the shadow to a softer level if required.
  122696. * 0 means black shadows and 1 means no shadows.
  122697. */
  122698. shadowLevel: float;
  122699. protected _sceneCenter: Vector3;
  122700. /**
  122701. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122702. * It is usually zero but might be interesting to modify according to your setup.
  122703. */
  122704. sceneCenter: Vector3;
  122705. protected _opacityFresnel: boolean;
  122706. /**
  122707. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122708. * This helps ensuring a nice transition when the camera goes under the ground.
  122709. */
  122710. opacityFresnel: boolean;
  122711. protected _reflectionFresnel: boolean;
  122712. /**
  122713. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122714. * This helps adding a mirror texture on the ground.
  122715. */
  122716. reflectionFresnel: boolean;
  122717. protected _reflectionFalloffDistance: number;
  122718. /**
  122719. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122720. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122721. */
  122722. reflectionFalloffDistance: number;
  122723. protected _reflectionAmount: number;
  122724. /**
  122725. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122726. */
  122727. reflectionAmount: number;
  122728. protected _reflectionReflectance0: number;
  122729. /**
  122730. * This specifies the weight of the reflection at grazing angle.
  122731. */
  122732. reflectionReflectance0: number;
  122733. protected _reflectionReflectance90: number;
  122734. /**
  122735. * This specifies the weight of the reflection at a perpendicular point of view.
  122736. */
  122737. reflectionReflectance90: number;
  122738. /**
  122739. * Sets the reflection reflectance fresnel values according to the default standard
  122740. * empirically know to work well :-)
  122741. */
  122742. set reflectionStandardFresnelWeight(value: number);
  122743. protected _useRGBColor: boolean;
  122744. /**
  122745. * Helps to directly use the maps channels instead of their level.
  122746. */
  122747. useRGBColor: boolean;
  122748. protected _enableNoise: boolean;
  122749. /**
  122750. * This helps reducing the banding effect that could occur on the background.
  122751. */
  122752. enableNoise: boolean;
  122753. /**
  122754. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122755. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122756. * Recommended to be keep at 1.0 except for special cases.
  122757. */
  122758. get fovMultiplier(): number;
  122759. set fovMultiplier(value: number);
  122760. private _fovMultiplier;
  122761. /**
  122762. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122763. */
  122764. useEquirectangularFOV: boolean;
  122765. private _maxSimultaneousLights;
  122766. /**
  122767. * Number of Simultaneous lights allowed on the material.
  122768. */
  122769. maxSimultaneousLights: int;
  122770. /**
  122771. * Default configuration related to image processing available in the Background Material.
  122772. */
  122773. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122774. /**
  122775. * Keep track of the image processing observer to allow dispose and replace.
  122776. */
  122777. private _imageProcessingObserver;
  122778. /**
  122779. * Attaches a new image processing configuration to the PBR Material.
  122780. * @param configuration (if null the scene configuration will be use)
  122781. */
  122782. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122783. /**
  122784. * Gets the image processing configuration used either in this material.
  122785. */
  122786. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122787. /**
  122788. * Sets the Default image processing configuration used either in the this material.
  122789. *
  122790. * If sets to null, the scene one is in use.
  122791. */
  122792. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122793. /**
  122794. * Gets wether the color curves effect is enabled.
  122795. */
  122796. get cameraColorCurvesEnabled(): boolean;
  122797. /**
  122798. * Sets wether the color curves effect is enabled.
  122799. */
  122800. set cameraColorCurvesEnabled(value: boolean);
  122801. /**
  122802. * Gets wether the color grading effect is enabled.
  122803. */
  122804. get cameraColorGradingEnabled(): boolean;
  122805. /**
  122806. * Gets wether the color grading effect is enabled.
  122807. */
  122808. set cameraColorGradingEnabled(value: boolean);
  122809. /**
  122810. * Gets wether tonemapping is enabled or not.
  122811. */
  122812. get cameraToneMappingEnabled(): boolean;
  122813. /**
  122814. * Sets wether tonemapping is enabled or not
  122815. */
  122816. set cameraToneMappingEnabled(value: boolean);
  122817. /**
  122818. * The camera exposure used on this material.
  122819. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122820. * This corresponds to a photographic exposure.
  122821. */
  122822. get cameraExposure(): float;
  122823. /**
  122824. * The camera exposure used on this material.
  122825. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122826. * This corresponds to a photographic exposure.
  122827. */
  122828. set cameraExposure(value: float);
  122829. /**
  122830. * Gets The camera contrast used on this material.
  122831. */
  122832. get cameraContrast(): float;
  122833. /**
  122834. * Sets The camera contrast used on this material.
  122835. */
  122836. set cameraContrast(value: float);
  122837. /**
  122838. * Gets the Color Grading 2D Lookup Texture.
  122839. */
  122840. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122841. /**
  122842. * Sets the Color Grading 2D Lookup Texture.
  122843. */
  122844. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122845. /**
  122846. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122847. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122848. * 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;
  122849. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122850. */
  122851. get cameraColorCurves(): Nullable<ColorCurves>;
  122852. /**
  122853. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122854. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122855. * 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;
  122856. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122857. */
  122858. set cameraColorCurves(value: Nullable<ColorCurves>);
  122859. /**
  122860. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122861. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122862. */
  122863. switchToBGR: boolean;
  122864. private _renderTargets;
  122865. private _reflectionControls;
  122866. private _white;
  122867. private _primaryShadowColor;
  122868. private _primaryHighlightColor;
  122869. /**
  122870. * Instantiates a Background Material in the given scene
  122871. * @param name The friendly name of the material
  122872. * @param scene The scene to add the material to
  122873. */
  122874. constructor(name: string, scene: Scene);
  122875. /**
  122876. * Gets a boolean indicating that current material needs to register RTT
  122877. */
  122878. get hasRenderTargetTextures(): boolean;
  122879. /**
  122880. * The entire material has been created in order to prevent overdraw.
  122881. * @returns false
  122882. */
  122883. needAlphaTesting(): boolean;
  122884. /**
  122885. * The entire material has been created in order to prevent overdraw.
  122886. * @returns true if blending is enable
  122887. */
  122888. needAlphaBlending(): boolean;
  122889. /**
  122890. * Checks wether the material is ready to be rendered for a given mesh.
  122891. * @param mesh The mesh to render
  122892. * @param subMesh The submesh to check against
  122893. * @param useInstances Specify wether or not the material is used with instances
  122894. * @returns true if all the dependencies are ready (Textures, Effects...)
  122895. */
  122896. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122897. /**
  122898. * Compute the primary color according to the chosen perceptual color.
  122899. */
  122900. private _computePrimaryColorFromPerceptualColor;
  122901. /**
  122902. * Compute the highlights and shadow colors according to their chosen levels.
  122903. */
  122904. private _computePrimaryColors;
  122905. /**
  122906. * Build the uniform buffer used in the material.
  122907. */
  122908. buildUniformLayout(): void;
  122909. /**
  122910. * Unbind the material.
  122911. */
  122912. unbind(): void;
  122913. /**
  122914. * Bind only the world matrix to the material.
  122915. * @param world The world matrix to bind.
  122916. */
  122917. bindOnlyWorldMatrix(world: Matrix): void;
  122918. /**
  122919. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122920. * @param world The world matrix to bind.
  122921. * @param subMesh The submesh to bind for.
  122922. */
  122923. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122924. /**
  122925. * Checks to see if a texture is used in the material.
  122926. * @param texture - Base texture to use.
  122927. * @returns - Boolean specifying if a texture is used in the material.
  122928. */
  122929. hasTexture(texture: BaseTexture): boolean;
  122930. /**
  122931. * Dispose the material.
  122932. * @param forceDisposeEffect Force disposal of the associated effect.
  122933. * @param forceDisposeTextures Force disposal of the associated textures.
  122934. */
  122935. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122936. /**
  122937. * Clones the material.
  122938. * @param name The cloned name.
  122939. * @returns The cloned material.
  122940. */
  122941. clone(name: string): BackgroundMaterial;
  122942. /**
  122943. * Serializes the current material to its JSON representation.
  122944. * @returns The JSON representation.
  122945. */
  122946. serialize(): any;
  122947. /**
  122948. * Gets the class name of the material
  122949. * @returns "BackgroundMaterial"
  122950. */
  122951. getClassName(): string;
  122952. /**
  122953. * Parse a JSON input to create back a background material.
  122954. * @param source The JSON data to parse
  122955. * @param scene The scene to create the parsed material in
  122956. * @param rootUrl The root url of the assets the material depends upon
  122957. * @returns the instantiated BackgroundMaterial.
  122958. */
  122959. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122960. }
  122961. }
  122962. declare module BABYLON {
  122963. /**
  122964. * Represents the different options available during the creation of
  122965. * a Environment helper.
  122966. *
  122967. * This can control the default ground, skybox and image processing setup of your scene.
  122968. */
  122969. export interface IEnvironmentHelperOptions {
  122970. /**
  122971. * Specifies whether or not to create a ground.
  122972. * True by default.
  122973. */
  122974. createGround: boolean;
  122975. /**
  122976. * Specifies the ground size.
  122977. * 15 by default.
  122978. */
  122979. groundSize: number;
  122980. /**
  122981. * The texture used on the ground for the main color.
  122982. * Comes from the BabylonJS CDN by default.
  122983. *
  122984. * Remarks: Can be either a texture or a url.
  122985. */
  122986. groundTexture: string | BaseTexture;
  122987. /**
  122988. * The color mixed in the ground texture by default.
  122989. * BabylonJS clearColor by default.
  122990. */
  122991. groundColor: Color3;
  122992. /**
  122993. * Specifies the ground opacity.
  122994. * 1 by default.
  122995. */
  122996. groundOpacity: number;
  122997. /**
  122998. * Enables the ground to receive shadows.
  122999. * True by default.
  123000. */
  123001. enableGroundShadow: boolean;
  123002. /**
  123003. * Helps preventing the shadow to be fully black on the ground.
  123004. * 0.5 by default.
  123005. */
  123006. groundShadowLevel: number;
  123007. /**
  123008. * Creates a mirror texture attach to the ground.
  123009. * false by default.
  123010. */
  123011. enableGroundMirror: boolean;
  123012. /**
  123013. * Specifies the ground mirror size ratio.
  123014. * 0.3 by default as the default kernel is 64.
  123015. */
  123016. groundMirrorSizeRatio: number;
  123017. /**
  123018. * Specifies the ground mirror blur kernel size.
  123019. * 64 by default.
  123020. */
  123021. groundMirrorBlurKernel: number;
  123022. /**
  123023. * Specifies the ground mirror visibility amount.
  123024. * 1 by default
  123025. */
  123026. groundMirrorAmount: number;
  123027. /**
  123028. * Specifies the ground mirror reflectance weight.
  123029. * This uses the standard weight of the background material to setup the fresnel effect
  123030. * of the mirror.
  123031. * 1 by default.
  123032. */
  123033. groundMirrorFresnelWeight: number;
  123034. /**
  123035. * Specifies the ground mirror Falloff distance.
  123036. * This can helps reducing the size of the reflection.
  123037. * 0 by Default.
  123038. */
  123039. groundMirrorFallOffDistance: number;
  123040. /**
  123041. * Specifies the ground mirror texture type.
  123042. * Unsigned Int by Default.
  123043. */
  123044. groundMirrorTextureType: number;
  123045. /**
  123046. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  123047. * the shown objects.
  123048. */
  123049. groundYBias: number;
  123050. /**
  123051. * Specifies whether or not to create a skybox.
  123052. * True by default.
  123053. */
  123054. createSkybox: boolean;
  123055. /**
  123056. * Specifies the skybox size.
  123057. * 20 by default.
  123058. */
  123059. skyboxSize: number;
  123060. /**
  123061. * The texture used on the skybox for the main color.
  123062. * Comes from the BabylonJS CDN by default.
  123063. *
  123064. * Remarks: Can be either a texture or a url.
  123065. */
  123066. skyboxTexture: string | BaseTexture;
  123067. /**
  123068. * The color mixed in the skybox texture by default.
  123069. * BabylonJS clearColor by default.
  123070. */
  123071. skyboxColor: Color3;
  123072. /**
  123073. * The background rotation around the Y axis of the scene.
  123074. * This helps aligning the key lights of your scene with the background.
  123075. * 0 by default.
  123076. */
  123077. backgroundYRotation: number;
  123078. /**
  123079. * Compute automatically the size of the elements to best fit with the scene.
  123080. */
  123081. sizeAuto: boolean;
  123082. /**
  123083. * Default position of the rootMesh if autoSize is not true.
  123084. */
  123085. rootPosition: Vector3;
  123086. /**
  123087. * Sets up the image processing in the scene.
  123088. * true by default.
  123089. */
  123090. setupImageProcessing: boolean;
  123091. /**
  123092. * The texture used as your environment texture in the scene.
  123093. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  123094. *
  123095. * Remarks: Can be either a texture or a url.
  123096. */
  123097. environmentTexture: string | BaseTexture;
  123098. /**
  123099. * The value of the exposure to apply to the scene.
  123100. * 0.6 by default if setupImageProcessing is true.
  123101. */
  123102. cameraExposure: number;
  123103. /**
  123104. * The value of the contrast to apply to the scene.
  123105. * 1.6 by default if setupImageProcessing is true.
  123106. */
  123107. cameraContrast: number;
  123108. /**
  123109. * Specifies whether or not tonemapping should be enabled in the scene.
  123110. * true by default if setupImageProcessing is true.
  123111. */
  123112. toneMappingEnabled: boolean;
  123113. }
  123114. /**
  123115. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  123116. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  123117. * It also helps with the default setup of your imageProcessing configuration.
  123118. */
  123119. export class EnvironmentHelper {
  123120. /**
  123121. * Default ground texture URL.
  123122. */
  123123. private static _groundTextureCDNUrl;
  123124. /**
  123125. * Default skybox texture URL.
  123126. */
  123127. private static _skyboxTextureCDNUrl;
  123128. /**
  123129. * Default environment texture URL.
  123130. */
  123131. private static _environmentTextureCDNUrl;
  123132. /**
  123133. * Creates the default options for the helper.
  123134. */
  123135. private static _getDefaultOptions;
  123136. private _rootMesh;
  123137. /**
  123138. * Gets the root mesh created by the helper.
  123139. */
  123140. get rootMesh(): Mesh;
  123141. private _skybox;
  123142. /**
  123143. * Gets the skybox created by the helper.
  123144. */
  123145. get skybox(): Nullable<Mesh>;
  123146. private _skyboxTexture;
  123147. /**
  123148. * Gets the skybox texture created by the helper.
  123149. */
  123150. get skyboxTexture(): Nullable<BaseTexture>;
  123151. private _skyboxMaterial;
  123152. /**
  123153. * Gets the skybox material created by the helper.
  123154. */
  123155. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  123156. private _ground;
  123157. /**
  123158. * Gets the ground mesh created by the helper.
  123159. */
  123160. get ground(): Nullable<Mesh>;
  123161. private _groundTexture;
  123162. /**
  123163. * Gets the ground texture created by the helper.
  123164. */
  123165. get groundTexture(): Nullable<BaseTexture>;
  123166. private _groundMirror;
  123167. /**
  123168. * Gets the ground mirror created by the helper.
  123169. */
  123170. get groundMirror(): Nullable<MirrorTexture>;
  123171. /**
  123172. * Gets the ground mirror render list to helps pushing the meshes
  123173. * you wish in the ground reflection.
  123174. */
  123175. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  123176. private _groundMaterial;
  123177. /**
  123178. * Gets the ground material created by the helper.
  123179. */
  123180. get groundMaterial(): Nullable<BackgroundMaterial>;
  123181. /**
  123182. * Stores the creation options.
  123183. */
  123184. private readonly _scene;
  123185. private _options;
  123186. /**
  123187. * This observable will be notified with any error during the creation of the environment,
  123188. * mainly texture creation errors.
  123189. */
  123190. onErrorObservable: Observable<{
  123191. message?: string;
  123192. exception?: any;
  123193. }>;
  123194. /**
  123195. * constructor
  123196. * @param options Defines the options we want to customize the helper
  123197. * @param scene The scene to add the material to
  123198. */
  123199. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  123200. /**
  123201. * Updates the background according to the new options
  123202. * @param options
  123203. */
  123204. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  123205. /**
  123206. * Sets the primary color of all the available elements.
  123207. * @param color the main color to affect to the ground and the background
  123208. */
  123209. setMainColor(color: Color3): void;
  123210. /**
  123211. * Setup the image processing according to the specified options.
  123212. */
  123213. private _setupImageProcessing;
  123214. /**
  123215. * Setup the environment texture according to the specified options.
  123216. */
  123217. private _setupEnvironmentTexture;
  123218. /**
  123219. * Setup the background according to the specified options.
  123220. */
  123221. private _setupBackground;
  123222. /**
  123223. * Get the scene sizes according to the setup.
  123224. */
  123225. private _getSceneSize;
  123226. /**
  123227. * Setup the ground according to the specified options.
  123228. */
  123229. private _setupGround;
  123230. /**
  123231. * Setup the ground material according to the specified options.
  123232. */
  123233. private _setupGroundMaterial;
  123234. /**
  123235. * Setup the ground diffuse texture according to the specified options.
  123236. */
  123237. private _setupGroundDiffuseTexture;
  123238. /**
  123239. * Setup the ground mirror texture according to the specified options.
  123240. */
  123241. private _setupGroundMirrorTexture;
  123242. /**
  123243. * Setup the ground to receive the mirror texture.
  123244. */
  123245. private _setupMirrorInGroundMaterial;
  123246. /**
  123247. * Setup the skybox according to the specified options.
  123248. */
  123249. private _setupSkybox;
  123250. /**
  123251. * Setup the skybox material according to the specified options.
  123252. */
  123253. private _setupSkyboxMaterial;
  123254. /**
  123255. * Setup the skybox reflection texture according to the specified options.
  123256. */
  123257. private _setupSkyboxReflectionTexture;
  123258. private _errorHandler;
  123259. /**
  123260. * Dispose all the elements created by the Helper.
  123261. */
  123262. dispose(): void;
  123263. }
  123264. }
  123265. declare module BABYLON {
  123266. /**
  123267. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  123268. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  123269. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  123270. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123271. */
  123272. export class PhotoDome extends TransformNode {
  123273. /**
  123274. * Define the image as a Monoscopic panoramic 360 image.
  123275. */
  123276. static readonly MODE_MONOSCOPIC: number;
  123277. /**
  123278. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123279. */
  123280. static readonly MODE_TOPBOTTOM: number;
  123281. /**
  123282. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123283. */
  123284. static readonly MODE_SIDEBYSIDE: number;
  123285. private _useDirectMapping;
  123286. /**
  123287. * The texture being displayed on the sphere
  123288. */
  123289. protected _photoTexture: Texture;
  123290. /**
  123291. * Gets or sets the texture being displayed on the sphere
  123292. */
  123293. get photoTexture(): Texture;
  123294. set photoTexture(value: Texture);
  123295. /**
  123296. * Observable raised when an error occured while loading the 360 image
  123297. */
  123298. onLoadErrorObservable: Observable<string>;
  123299. /**
  123300. * The skybox material
  123301. */
  123302. protected _material: BackgroundMaterial;
  123303. /**
  123304. * The surface used for the skybox
  123305. */
  123306. protected _mesh: Mesh;
  123307. /**
  123308. * Gets the mesh used for the skybox.
  123309. */
  123310. get mesh(): Mesh;
  123311. /**
  123312. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123313. * Also see the options.resolution property.
  123314. */
  123315. get fovMultiplier(): number;
  123316. set fovMultiplier(value: number);
  123317. private _imageMode;
  123318. /**
  123319. * Gets or set the current video mode for the video. It can be:
  123320. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  123321. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123322. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123323. */
  123324. get imageMode(): number;
  123325. set imageMode(value: number);
  123326. /**
  123327. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123328. * @param name Element's name, child elements will append suffixes for their own names.
  123329. * @param urlsOfPhoto defines the url of the photo to display
  123330. * @param options defines an object containing optional or exposed sub element properties
  123331. * @param onError defines a callback called when an error occured while loading the texture
  123332. */
  123333. constructor(name: string, urlOfPhoto: string, options: {
  123334. resolution?: number;
  123335. size?: number;
  123336. useDirectMapping?: boolean;
  123337. faceForward?: boolean;
  123338. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123339. private _onBeforeCameraRenderObserver;
  123340. private _changeImageMode;
  123341. /**
  123342. * Releases resources associated with this node.
  123343. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123344. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123345. */
  123346. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123347. }
  123348. }
  123349. declare module BABYLON {
  123350. /**
  123351. * Class used to host RGBD texture specific utilities
  123352. */
  123353. export class RGBDTextureTools {
  123354. /**
  123355. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123356. * @param texture the texture to expand.
  123357. */
  123358. static ExpandRGBDTexture(texture: Texture): void;
  123359. }
  123360. }
  123361. declare module BABYLON {
  123362. /**
  123363. * Class used to host texture specific utilities
  123364. */
  123365. export class BRDFTextureTools {
  123366. /**
  123367. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123368. * @param scene defines the hosting scene
  123369. * @returns the environment BRDF texture
  123370. */
  123371. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123372. private static _environmentBRDFBase64Texture;
  123373. }
  123374. }
  123375. declare module BABYLON {
  123376. /**
  123377. * @hidden
  123378. */
  123379. export interface IMaterialClearCoatDefines {
  123380. CLEARCOAT: boolean;
  123381. CLEARCOAT_DEFAULTIOR: boolean;
  123382. CLEARCOAT_TEXTURE: boolean;
  123383. CLEARCOAT_TEXTUREDIRECTUV: number;
  123384. CLEARCOAT_BUMP: boolean;
  123385. CLEARCOAT_BUMPDIRECTUV: number;
  123386. CLEARCOAT_TINT: boolean;
  123387. CLEARCOAT_TINT_TEXTURE: boolean;
  123388. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123389. /** @hidden */
  123390. _areTexturesDirty: boolean;
  123391. }
  123392. /**
  123393. * Define the code related to the clear coat parameters of the pbr material.
  123394. */
  123395. export class PBRClearCoatConfiguration {
  123396. /**
  123397. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123398. * The default fits with a polyurethane material.
  123399. */
  123400. private static readonly _DefaultIndexOfRefraction;
  123401. private _isEnabled;
  123402. /**
  123403. * Defines if the clear coat is enabled in the material.
  123404. */
  123405. isEnabled: boolean;
  123406. /**
  123407. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123408. */
  123409. intensity: number;
  123410. /**
  123411. * Defines the clear coat layer roughness.
  123412. */
  123413. roughness: number;
  123414. private _indexOfRefraction;
  123415. /**
  123416. * Defines the index of refraction of the clear coat.
  123417. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123418. * The default fits with a polyurethane material.
  123419. * Changing the default value is more performance intensive.
  123420. */
  123421. indexOfRefraction: number;
  123422. private _texture;
  123423. /**
  123424. * Stores the clear coat values in a texture.
  123425. */
  123426. texture: Nullable<BaseTexture>;
  123427. private _bumpTexture;
  123428. /**
  123429. * Define the clear coat specific bump texture.
  123430. */
  123431. bumpTexture: Nullable<BaseTexture>;
  123432. private _isTintEnabled;
  123433. /**
  123434. * Defines if the clear coat tint is enabled in the material.
  123435. */
  123436. isTintEnabled: boolean;
  123437. /**
  123438. * Defines the clear coat tint of the material.
  123439. * This is only use if tint is enabled
  123440. */
  123441. tintColor: Color3;
  123442. /**
  123443. * Defines the distance at which the tint color should be found in the
  123444. * clear coat media.
  123445. * This is only use if tint is enabled
  123446. */
  123447. tintColorAtDistance: number;
  123448. /**
  123449. * Defines the clear coat layer thickness.
  123450. * This is only use if tint is enabled
  123451. */
  123452. tintThickness: number;
  123453. private _tintTexture;
  123454. /**
  123455. * Stores the clear tint values in a texture.
  123456. * rgb is tint
  123457. * a is a thickness factor
  123458. */
  123459. tintTexture: Nullable<BaseTexture>;
  123460. /** @hidden */
  123461. private _internalMarkAllSubMeshesAsTexturesDirty;
  123462. /** @hidden */
  123463. _markAllSubMeshesAsTexturesDirty(): void;
  123464. /**
  123465. * Instantiate a new istance of clear coat configuration.
  123466. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123467. */
  123468. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123469. /**
  123470. * Gets wehter the submesh is ready to be used or not.
  123471. * @param defines the list of "defines" to update.
  123472. * @param scene defines the scene the material belongs to.
  123473. * @param engine defines the engine the material belongs to.
  123474. * @param disableBumpMap defines wether the material disables bump or not.
  123475. * @returns - boolean indicating that the submesh is ready or not.
  123476. */
  123477. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123478. /**
  123479. * Checks to see if a texture is used in the material.
  123480. * @param defines the list of "defines" to update.
  123481. * @param scene defines the scene to the material belongs to.
  123482. */
  123483. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123484. /**
  123485. * Binds the material data.
  123486. * @param uniformBuffer defines the Uniform buffer to fill in.
  123487. * @param scene defines the scene the material belongs to.
  123488. * @param engine defines the engine the material belongs to.
  123489. * @param disableBumpMap defines wether the material disables bump or not.
  123490. * @param isFrozen defines wether the material is frozen or not.
  123491. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123492. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123493. */
  123494. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123495. /**
  123496. * Checks to see if a texture is used in the material.
  123497. * @param texture - Base texture to use.
  123498. * @returns - Boolean specifying if a texture is used in the material.
  123499. */
  123500. hasTexture(texture: BaseTexture): boolean;
  123501. /**
  123502. * Returns an array of the actively used textures.
  123503. * @param activeTextures Array of BaseTextures
  123504. */
  123505. getActiveTextures(activeTextures: BaseTexture[]): void;
  123506. /**
  123507. * Returns the animatable textures.
  123508. * @param animatables Array of animatable textures.
  123509. */
  123510. getAnimatables(animatables: IAnimatable[]): void;
  123511. /**
  123512. * Disposes the resources of the material.
  123513. * @param forceDisposeTextures - Forces the disposal of all textures.
  123514. */
  123515. dispose(forceDisposeTextures?: boolean): void;
  123516. /**
  123517. * Get the current class name of the texture useful for serialization or dynamic coding.
  123518. * @returns "PBRClearCoatConfiguration"
  123519. */
  123520. getClassName(): string;
  123521. /**
  123522. * Add fallbacks to the effect fallbacks list.
  123523. * @param defines defines the Base texture to use.
  123524. * @param fallbacks defines the current fallback list.
  123525. * @param currentRank defines the current fallback rank.
  123526. * @returns the new fallback rank.
  123527. */
  123528. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123529. /**
  123530. * Add the required uniforms to the current list.
  123531. * @param uniforms defines the current uniform list.
  123532. */
  123533. static AddUniforms(uniforms: string[]): void;
  123534. /**
  123535. * Add the required samplers to the current list.
  123536. * @param samplers defines the current sampler list.
  123537. */
  123538. static AddSamplers(samplers: string[]): void;
  123539. /**
  123540. * Add the required uniforms to the current buffer.
  123541. * @param uniformBuffer defines the current uniform buffer.
  123542. */
  123543. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123544. /**
  123545. * Makes a duplicate of the current configuration into another one.
  123546. * @param clearCoatConfiguration define the config where to copy the info
  123547. */
  123548. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123549. /**
  123550. * Serializes this clear coat configuration.
  123551. * @returns - An object with the serialized config.
  123552. */
  123553. serialize(): any;
  123554. /**
  123555. * Parses a anisotropy Configuration from a serialized object.
  123556. * @param source - Serialized object.
  123557. * @param scene Defines the scene we are parsing for
  123558. * @param rootUrl Defines the rootUrl to load from
  123559. */
  123560. parse(source: any, scene: Scene, rootUrl: string): void;
  123561. }
  123562. }
  123563. declare module BABYLON {
  123564. /**
  123565. * @hidden
  123566. */
  123567. export interface IMaterialAnisotropicDefines {
  123568. ANISOTROPIC: boolean;
  123569. ANISOTROPIC_TEXTURE: boolean;
  123570. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123571. MAINUV1: boolean;
  123572. _areTexturesDirty: boolean;
  123573. _needUVs: boolean;
  123574. }
  123575. /**
  123576. * Define the code related to the anisotropic parameters of the pbr material.
  123577. */
  123578. export class PBRAnisotropicConfiguration {
  123579. private _isEnabled;
  123580. /**
  123581. * Defines if the anisotropy is enabled in the material.
  123582. */
  123583. isEnabled: boolean;
  123584. /**
  123585. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123586. */
  123587. intensity: number;
  123588. /**
  123589. * Defines if the effect is along the tangents, bitangents or in between.
  123590. * By default, the effect is "strectching" the highlights along the tangents.
  123591. */
  123592. direction: Vector2;
  123593. private _texture;
  123594. /**
  123595. * Stores the anisotropy values in a texture.
  123596. * rg is direction (like normal from -1 to 1)
  123597. * b is a intensity
  123598. */
  123599. texture: Nullable<BaseTexture>;
  123600. /** @hidden */
  123601. private _internalMarkAllSubMeshesAsTexturesDirty;
  123602. /** @hidden */
  123603. _markAllSubMeshesAsTexturesDirty(): void;
  123604. /**
  123605. * Instantiate a new istance of anisotropy configuration.
  123606. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123607. */
  123608. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123609. /**
  123610. * Specifies that the submesh is ready to be used.
  123611. * @param defines the list of "defines" to update.
  123612. * @param scene defines the scene the material belongs to.
  123613. * @returns - boolean indicating that the submesh is ready or not.
  123614. */
  123615. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123616. /**
  123617. * Checks to see if a texture is used in the material.
  123618. * @param defines the list of "defines" to update.
  123619. * @param mesh the mesh we are preparing the defines for.
  123620. * @param scene defines the scene the material belongs to.
  123621. */
  123622. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123623. /**
  123624. * Binds the material data.
  123625. * @param uniformBuffer defines the Uniform buffer to fill in.
  123626. * @param scene defines the scene the material belongs to.
  123627. * @param isFrozen defines wether the material is frozen or not.
  123628. */
  123629. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123630. /**
  123631. * Checks to see if a texture is used in the material.
  123632. * @param texture - Base texture to use.
  123633. * @returns - Boolean specifying if a texture is used in the material.
  123634. */
  123635. hasTexture(texture: BaseTexture): boolean;
  123636. /**
  123637. * Returns an array of the actively used textures.
  123638. * @param activeTextures Array of BaseTextures
  123639. */
  123640. getActiveTextures(activeTextures: BaseTexture[]): void;
  123641. /**
  123642. * Returns the animatable textures.
  123643. * @param animatables Array of animatable textures.
  123644. */
  123645. getAnimatables(animatables: IAnimatable[]): void;
  123646. /**
  123647. * Disposes the resources of the material.
  123648. * @param forceDisposeTextures - Forces the disposal of all textures.
  123649. */
  123650. dispose(forceDisposeTextures?: boolean): void;
  123651. /**
  123652. * Get the current class name of the texture useful for serialization or dynamic coding.
  123653. * @returns "PBRAnisotropicConfiguration"
  123654. */
  123655. getClassName(): string;
  123656. /**
  123657. * Add fallbacks to the effect fallbacks list.
  123658. * @param defines defines the Base texture to use.
  123659. * @param fallbacks defines the current fallback list.
  123660. * @param currentRank defines the current fallback rank.
  123661. * @returns the new fallback rank.
  123662. */
  123663. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123664. /**
  123665. * Add the required uniforms to the current list.
  123666. * @param uniforms defines the current uniform list.
  123667. */
  123668. static AddUniforms(uniforms: string[]): void;
  123669. /**
  123670. * Add the required uniforms to the current buffer.
  123671. * @param uniformBuffer defines the current uniform buffer.
  123672. */
  123673. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123674. /**
  123675. * Add the required samplers to the current list.
  123676. * @param samplers defines the current sampler list.
  123677. */
  123678. static AddSamplers(samplers: string[]): void;
  123679. /**
  123680. * Makes a duplicate of the current configuration into another one.
  123681. * @param anisotropicConfiguration define the config where to copy the info
  123682. */
  123683. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123684. /**
  123685. * Serializes this anisotropy configuration.
  123686. * @returns - An object with the serialized config.
  123687. */
  123688. serialize(): any;
  123689. /**
  123690. * Parses a anisotropy Configuration from a serialized object.
  123691. * @param source - Serialized object.
  123692. * @param scene Defines the scene we are parsing for
  123693. * @param rootUrl Defines the rootUrl to load from
  123694. */
  123695. parse(source: any, scene: Scene, rootUrl: string): void;
  123696. }
  123697. }
  123698. declare module BABYLON {
  123699. /**
  123700. * @hidden
  123701. */
  123702. export interface IMaterialBRDFDefines {
  123703. BRDF_V_HEIGHT_CORRELATED: boolean;
  123704. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123705. SPHERICAL_HARMONICS: boolean;
  123706. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123707. /** @hidden */
  123708. _areMiscDirty: boolean;
  123709. }
  123710. /**
  123711. * Define the code related to the BRDF parameters of the pbr material.
  123712. */
  123713. export class PBRBRDFConfiguration {
  123714. /**
  123715. * Default value used for the energy conservation.
  123716. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123717. */
  123718. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123719. /**
  123720. * Default value used for the Smith Visibility Height Correlated mode.
  123721. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123722. */
  123723. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123724. /**
  123725. * Default value used for the IBL diffuse part.
  123726. * This can help switching back to the polynomials mode globally which is a tiny bit
  123727. * less GPU intensive at the drawback of a lower quality.
  123728. */
  123729. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123730. /**
  123731. * Default value used for activating energy conservation for the specular workflow.
  123732. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123733. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123734. */
  123735. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123736. private _useEnergyConservation;
  123737. /**
  123738. * Defines if the material uses energy conservation.
  123739. */
  123740. useEnergyConservation: boolean;
  123741. private _useSmithVisibilityHeightCorrelated;
  123742. /**
  123743. * LEGACY Mode set to false
  123744. * Defines if the material uses height smith correlated visibility term.
  123745. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123746. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123747. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123748. * Not relying on height correlated will also disable energy conservation.
  123749. */
  123750. useSmithVisibilityHeightCorrelated: boolean;
  123751. private _useSphericalHarmonics;
  123752. /**
  123753. * LEGACY Mode set to false
  123754. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123755. * diffuse part of the IBL.
  123756. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123757. * to the ground truth.
  123758. */
  123759. useSphericalHarmonics: boolean;
  123760. private _useSpecularGlossinessInputEnergyConservation;
  123761. /**
  123762. * Defines if the material uses energy conservation, when the specular workflow is active.
  123763. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123764. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123765. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123766. */
  123767. useSpecularGlossinessInputEnergyConservation: boolean;
  123768. /** @hidden */
  123769. private _internalMarkAllSubMeshesAsMiscDirty;
  123770. /** @hidden */
  123771. _markAllSubMeshesAsMiscDirty(): void;
  123772. /**
  123773. * Instantiate a new istance of clear coat configuration.
  123774. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123775. */
  123776. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123777. /**
  123778. * Checks to see if a texture is used in the material.
  123779. * @param defines the list of "defines" to update.
  123780. */
  123781. prepareDefines(defines: IMaterialBRDFDefines): void;
  123782. /**
  123783. * Get the current class name of the texture useful for serialization or dynamic coding.
  123784. * @returns "PBRClearCoatConfiguration"
  123785. */
  123786. getClassName(): string;
  123787. /**
  123788. * Makes a duplicate of the current configuration into another one.
  123789. * @param brdfConfiguration define the config where to copy the info
  123790. */
  123791. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123792. /**
  123793. * Serializes this BRDF configuration.
  123794. * @returns - An object with the serialized config.
  123795. */
  123796. serialize(): any;
  123797. /**
  123798. * Parses a anisotropy Configuration from a serialized object.
  123799. * @param source - Serialized object.
  123800. * @param scene Defines the scene we are parsing for
  123801. * @param rootUrl Defines the rootUrl to load from
  123802. */
  123803. parse(source: any, scene: Scene, rootUrl: string): void;
  123804. }
  123805. }
  123806. declare module BABYLON {
  123807. /**
  123808. * @hidden
  123809. */
  123810. export interface IMaterialSheenDefines {
  123811. SHEEN: boolean;
  123812. SHEEN_TEXTURE: boolean;
  123813. SHEEN_TEXTUREDIRECTUV: number;
  123814. SHEEN_LINKWITHALBEDO: boolean;
  123815. SHEEN_ROUGHNESS: boolean;
  123816. SHEEN_ALBEDOSCALING: boolean;
  123817. /** @hidden */
  123818. _areTexturesDirty: boolean;
  123819. }
  123820. /**
  123821. * Define the code related to the Sheen parameters of the pbr material.
  123822. */
  123823. export class PBRSheenConfiguration {
  123824. private _isEnabled;
  123825. /**
  123826. * Defines if the material uses sheen.
  123827. */
  123828. isEnabled: boolean;
  123829. private _linkSheenWithAlbedo;
  123830. /**
  123831. * Defines if the sheen is linked to the sheen color.
  123832. */
  123833. linkSheenWithAlbedo: boolean;
  123834. /**
  123835. * Defines the sheen intensity.
  123836. */
  123837. intensity: number;
  123838. /**
  123839. * Defines the sheen color.
  123840. */
  123841. color: Color3;
  123842. private _texture;
  123843. /**
  123844. * Stores the sheen tint values in a texture.
  123845. * rgb is tint
  123846. * a is a intensity
  123847. */
  123848. texture: Nullable<BaseTexture>;
  123849. private _roughness;
  123850. /**
  123851. * Defines the sheen roughness.
  123852. * It is not taken into account if linkSheenWithAlbedo is true.
  123853. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  123854. */
  123855. roughness: Nullable<number>;
  123856. private _albedoScaling;
  123857. /**
  123858. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  123859. * It allows the strength of the sheen effect to not depend on the base color of the material,
  123860. * making it easier to setup and tweak the effect
  123861. */
  123862. albedoScaling: boolean;
  123863. /** @hidden */
  123864. private _internalMarkAllSubMeshesAsTexturesDirty;
  123865. /** @hidden */
  123866. _markAllSubMeshesAsTexturesDirty(): void;
  123867. /**
  123868. * Instantiate a new istance of clear coat configuration.
  123869. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123870. */
  123871. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123872. /**
  123873. * Specifies that the submesh is ready to be used.
  123874. * @param defines the list of "defines" to update.
  123875. * @param scene defines the scene the material belongs to.
  123876. * @returns - boolean indicating that the submesh is ready or not.
  123877. */
  123878. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123879. /**
  123880. * Checks to see if a texture is used in the material.
  123881. * @param defines the list of "defines" to update.
  123882. * @param scene defines the scene the material belongs to.
  123883. */
  123884. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123885. /**
  123886. * Binds the material data.
  123887. * @param uniformBuffer defines the Uniform buffer to fill in.
  123888. * @param scene defines the scene the material belongs to.
  123889. * @param isFrozen defines wether the material is frozen or not.
  123890. */
  123891. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123892. /**
  123893. * Checks to see if a texture is used in the material.
  123894. * @param texture - Base texture to use.
  123895. * @returns - Boolean specifying if a texture is used in the material.
  123896. */
  123897. hasTexture(texture: BaseTexture): boolean;
  123898. /**
  123899. * Returns an array of the actively used textures.
  123900. * @param activeTextures Array of BaseTextures
  123901. */
  123902. getActiveTextures(activeTextures: BaseTexture[]): void;
  123903. /**
  123904. * Returns the animatable textures.
  123905. * @param animatables Array of animatable textures.
  123906. */
  123907. getAnimatables(animatables: IAnimatable[]): void;
  123908. /**
  123909. * Disposes the resources of the material.
  123910. * @param forceDisposeTextures - Forces the disposal of all textures.
  123911. */
  123912. dispose(forceDisposeTextures?: boolean): void;
  123913. /**
  123914. * Get the current class name of the texture useful for serialization or dynamic coding.
  123915. * @returns "PBRSheenConfiguration"
  123916. */
  123917. getClassName(): string;
  123918. /**
  123919. * Add fallbacks to the effect fallbacks list.
  123920. * @param defines defines the Base texture to use.
  123921. * @param fallbacks defines the current fallback list.
  123922. * @param currentRank defines the current fallback rank.
  123923. * @returns the new fallback rank.
  123924. */
  123925. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123926. /**
  123927. * Add the required uniforms to the current list.
  123928. * @param uniforms defines the current uniform list.
  123929. */
  123930. static AddUniforms(uniforms: string[]): void;
  123931. /**
  123932. * Add the required uniforms to the current buffer.
  123933. * @param uniformBuffer defines the current uniform buffer.
  123934. */
  123935. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123936. /**
  123937. * Add the required samplers to the current list.
  123938. * @param samplers defines the current sampler list.
  123939. */
  123940. static AddSamplers(samplers: string[]): void;
  123941. /**
  123942. * Makes a duplicate of the current configuration into another one.
  123943. * @param sheenConfiguration define the config where to copy the info
  123944. */
  123945. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123946. /**
  123947. * Serializes this BRDF configuration.
  123948. * @returns - An object with the serialized config.
  123949. */
  123950. serialize(): any;
  123951. /**
  123952. * Parses a anisotropy Configuration from a serialized object.
  123953. * @param source - Serialized object.
  123954. * @param scene Defines the scene we are parsing for
  123955. * @param rootUrl Defines the rootUrl to load from
  123956. */
  123957. parse(source: any, scene: Scene, rootUrl: string): void;
  123958. }
  123959. }
  123960. declare module BABYLON {
  123961. /**
  123962. * @hidden
  123963. */
  123964. export interface IMaterialSubSurfaceDefines {
  123965. SUBSURFACE: boolean;
  123966. SS_REFRACTION: boolean;
  123967. SS_TRANSLUCENCY: boolean;
  123968. SS_SCATERRING: boolean;
  123969. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123970. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123971. SS_REFRACTIONMAP_3D: boolean;
  123972. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123973. SS_LODINREFRACTIONALPHA: boolean;
  123974. SS_GAMMAREFRACTION: boolean;
  123975. SS_RGBDREFRACTION: boolean;
  123976. SS_LINEARSPECULARREFRACTION: boolean;
  123977. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123978. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123979. /** @hidden */
  123980. _areTexturesDirty: boolean;
  123981. }
  123982. /**
  123983. * Define the code related to the sub surface parameters of the pbr material.
  123984. */
  123985. export class PBRSubSurfaceConfiguration {
  123986. private _isRefractionEnabled;
  123987. /**
  123988. * Defines if the refraction is enabled in the material.
  123989. */
  123990. isRefractionEnabled: boolean;
  123991. private _isTranslucencyEnabled;
  123992. /**
  123993. * Defines if the translucency is enabled in the material.
  123994. */
  123995. isTranslucencyEnabled: boolean;
  123996. private _isScatteringEnabled;
  123997. /**
  123998. * Defines the refraction intensity of the material.
  123999. * The refraction when enabled replaces the Diffuse part of the material.
  124000. * The intensity helps transitionning between diffuse and refraction.
  124001. */
  124002. refractionIntensity: number;
  124003. /**
  124004. * Defines the translucency intensity of the material.
  124005. * When translucency has been enabled, this defines how much of the "translucency"
  124006. * is addded to the diffuse part of the material.
  124007. */
  124008. translucencyIntensity: number;
  124009. /**
  124010. * Defines the scattering intensity of the material.
  124011. * When scattering has been enabled, this defines how much of the "scattered light"
  124012. * is addded to the diffuse part of the material.
  124013. */
  124014. scatteringIntensity: number;
  124015. private _thicknessTexture;
  124016. /**
  124017. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  124018. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  124019. * 0 would mean minimumThickness
  124020. * 1 would mean maximumThickness
  124021. * The other channels might be use as a mask to vary the different effects intensity.
  124022. */
  124023. thicknessTexture: Nullable<BaseTexture>;
  124024. private _refractionTexture;
  124025. /**
  124026. * Defines the texture to use for refraction.
  124027. */
  124028. refractionTexture: Nullable<BaseTexture>;
  124029. private _indexOfRefraction;
  124030. /**
  124031. * Defines the index of refraction used in the material.
  124032. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  124033. */
  124034. indexOfRefraction: number;
  124035. private _invertRefractionY;
  124036. /**
  124037. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124038. */
  124039. invertRefractionY: boolean;
  124040. private _linkRefractionWithTransparency;
  124041. /**
  124042. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124043. * Materials half opaque for instance using refraction could benefit from this control.
  124044. */
  124045. linkRefractionWithTransparency: boolean;
  124046. /**
  124047. * Defines the minimum thickness stored in the thickness map.
  124048. * If no thickness map is defined, this value will be used to simulate thickness.
  124049. */
  124050. minimumThickness: number;
  124051. /**
  124052. * Defines the maximum thickness stored in the thickness map.
  124053. */
  124054. maximumThickness: number;
  124055. /**
  124056. * Defines the volume tint of the material.
  124057. * This is used for both translucency and scattering.
  124058. */
  124059. tintColor: Color3;
  124060. /**
  124061. * Defines the distance at which the tint color should be found in the media.
  124062. * This is used for refraction only.
  124063. */
  124064. tintColorAtDistance: number;
  124065. /**
  124066. * Defines how far each channel transmit through the media.
  124067. * It is defined as a color to simplify it selection.
  124068. */
  124069. diffusionDistance: Color3;
  124070. private _useMaskFromThicknessTexture;
  124071. /**
  124072. * Stores the intensity of the different subsurface effects in the thickness texture.
  124073. * * the green channel is the translucency intensity.
  124074. * * the blue channel is the scattering intensity.
  124075. * * the alpha channel is the refraction intensity.
  124076. */
  124077. useMaskFromThicknessTexture: boolean;
  124078. /** @hidden */
  124079. private _internalMarkAllSubMeshesAsTexturesDirty;
  124080. /** @hidden */
  124081. _markAllSubMeshesAsTexturesDirty(): void;
  124082. /**
  124083. * Instantiate a new istance of sub surface configuration.
  124084. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124085. */
  124086. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124087. /**
  124088. * Gets wehter the submesh is ready to be used or not.
  124089. * @param defines the list of "defines" to update.
  124090. * @param scene defines the scene the material belongs to.
  124091. * @returns - boolean indicating that the submesh is ready or not.
  124092. */
  124093. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  124094. /**
  124095. * Checks to see if a texture is used in the material.
  124096. * @param defines the list of "defines" to update.
  124097. * @param scene defines the scene to the material belongs to.
  124098. */
  124099. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  124100. /**
  124101. * Binds the material data.
  124102. * @param uniformBuffer defines the Uniform buffer to fill in.
  124103. * @param scene defines the scene the material belongs to.
  124104. * @param engine defines the engine the material belongs to.
  124105. * @param isFrozen defines wether the material is frozen or not.
  124106. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  124107. */
  124108. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  124109. /**
  124110. * Unbinds the material from the mesh.
  124111. * @param activeEffect defines the effect that should be unbound from.
  124112. * @returns true if unbound, otherwise false
  124113. */
  124114. unbind(activeEffect: Effect): boolean;
  124115. /**
  124116. * Returns the texture used for refraction or null if none is used.
  124117. * @param scene defines the scene the material belongs to.
  124118. * @returns - Refraction texture if present. If no refraction texture and refraction
  124119. * is linked with transparency, returns environment texture. Otherwise, returns null.
  124120. */
  124121. private _getRefractionTexture;
  124122. /**
  124123. * Returns true if alpha blending should be disabled.
  124124. */
  124125. get disableAlphaBlending(): boolean;
  124126. /**
  124127. * Fills the list of render target textures.
  124128. * @param renderTargets the list of render targets to update
  124129. */
  124130. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  124131. /**
  124132. * Checks to see if a texture is used in the material.
  124133. * @param texture - Base texture to use.
  124134. * @returns - Boolean specifying if a texture is used in the material.
  124135. */
  124136. hasTexture(texture: BaseTexture): boolean;
  124137. /**
  124138. * Gets a boolean indicating that current material needs to register RTT
  124139. * @returns true if this uses a render target otherwise false.
  124140. */
  124141. hasRenderTargetTextures(): boolean;
  124142. /**
  124143. * Returns an array of the actively used textures.
  124144. * @param activeTextures Array of BaseTextures
  124145. */
  124146. getActiveTextures(activeTextures: BaseTexture[]): void;
  124147. /**
  124148. * Returns the animatable textures.
  124149. * @param animatables Array of animatable textures.
  124150. */
  124151. getAnimatables(animatables: IAnimatable[]): void;
  124152. /**
  124153. * Disposes the resources of the material.
  124154. * @param forceDisposeTextures - Forces the disposal of all textures.
  124155. */
  124156. dispose(forceDisposeTextures?: boolean): void;
  124157. /**
  124158. * Get the current class name of the texture useful for serialization or dynamic coding.
  124159. * @returns "PBRSubSurfaceConfiguration"
  124160. */
  124161. getClassName(): string;
  124162. /**
  124163. * Add fallbacks to the effect fallbacks list.
  124164. * @param defines defines the Base texture to use.
  124165. * @param fallbacks defines the current fallback list.
  124166. * @param currentRank defines the current fallback rank.
  124167. * @returns the new fallback rank.
  124168. */
  124169. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124170. /**
  124171. * Add the required uniforms to the current list.
  124172. * @param uniforms defines the current uniform list.
  124173. */
  124174. static AddUniforms(uniforms: string[]): void;
  124175. /**
  124176. * Add the required samplers to the current list.
  124177. * @param samplers defines the current sampler list.
  124178. */
  124179. static AddSamplers(samplers: string[]): void;
  124180. /**
  124181. * Add the required uniforms to the current buffer.
  124182. * @param uniformBuffer defines the current uniform buffer.
  124183. */
  124184. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124185. /**
  124186. * Makes a duplicate of the current configuration into another one.
  124187. * @param configuration define the config where to copy the info
  124188. */
  124189. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  124190. /**
  124191. * Serializes this Sub Surface configuration.
  124192. * @returns - An object with the serialized config.
  124193. */
  124194. serialize(): any;
  124195. /**
  124196. * Parses a anisotropy Configuration from a serialized object.
  124197. * @param source - Serialized object.
  124198. * @param scene Defines the scene we are parsing for
  124199. * @param rootUrl Defines the rootUrl to load from
  124200. */
  124201. parse(source: any, scene: Scene, rootUrl: string): void;
  124202. }
  124203. }
  124204. declare module BABYLON {
  124205. /** @hidden */
  124206. export var pbrFragmentDeclaration: {
  124207. name: string;
  124208. shader: string;
  124209. };
  124210. }
  124211. declare module BABYLON {
  124212. /** @hidden */
  124213. export var pbrUboDeclaration: {
  124214. name: string;
  124215. shader: string;
  124216. };
  124217. }
  124218. declare module BABYLON {
  124219. /** @hidden */
  124220. export var pbrFragmentExtraDeclaration: {
  124221. name: string;
  124222. shader: string;
  124223. };
  124224. }
  124225. declare module BABYLON {
  124226. /** @hidden */
  124227. export var pbrFragmentSamplersDeclaration: {
  124228. name: string;
  124229. shader: string;
  124230. };
  124231. }
  124232. declare module BABYLON {
  124233. /** @hidden */
  124234. export var pbrHelperFunctions: {
  124235. name: string;
  124236. shader: string;
  124237. };
  124238. }
  124239. declare module BABYLON {
  124240. /** @hidden */
  124241. export var harmonicsFunctions: {
  124242. name: string;
  124243. shader: string;
  124244. };
  124245. }
  124246. declare module BABYLON {
  124247. /** @hidden */
  124248. export var pbrDirectLightingSetupFunctions: {
  124249. name: string;
  124250. shader: string;
  124251. };
  124252. }
  124253. declare module BABYLON {
  124254. /** @hidden */
  124255. export var pbrDirectLightingFalloffFunctions: {
  124256. name: string;
  124257. shader: string;
  124258. };
  124259. }
  124260. declare module BABYLON {
  124261. /** @hidden */
  124262. export var pbrBRDFFunctions: {
  124263. name: string;
  124264. shader: string;
  124265. };
  124266. }
  124267. declare module BABYLON {
  124268. /** @hidden */
  124269. export var pbrDirectLightingFunctions: {
  124270. name: string;
  124271. shader: string;
  124272. };
  124273. }
  124274. declare module BABYLON {
  124275. /** @hidden */
  124276. export var pbrIBLFunctions: {
  124277. name: string;
  124278. shader: string;
  124279. };
  124280. }
  124281. declare module BABYLON {
  124282. /** @hidden */
  124283. export var pbrDebug: {
  124284. name: string;
  124285. shader: string;
  124286. };
  124287. }
  124288. declare module BABYLON {
  124289. /** @hidden */
  124290. export var pbrPixelShader: {
  124291. name: string;
  124292. shader: string;
  124293. };
  124294. }
  124295. declare module BABYLON {
  124296. /** @hidden */
  124297. export var pbrVertexDeclaration: {
  124298. name: string;
  124299. shader: string;
  124300. };
  124301. }
  124302. declare module BABYLON {
  124303. /** @hidden */
  124304. export var pbrVertexShader: {
  124305. name: string;
  124306. shader: string;
  124307. };
  124308. }
  124309. declare module BABYLON {
  124310. /**
  124311. * Manages the defines for the PBR Material.
  124312. * @hidden
  124313. */
  124314. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  124315. PBR: boolean;
  124316. MAINUV1: boolean;
  124317. MAINUV2: boolean;
  124318. UV1: boolean;
  124319. UV2: boolean;
  124320. ALBEDO: boolean;
  124321. GAMMAALBEDO: boolean;
  124322. ALBEDODIRECTUV: number;
  124323. VERTEXCOLOR: boolean;
  124324. AMBIENT: boolean;
  124325. AMBIENTDIRECTUV: number;
  124326. AMBIENTINGRAYSCALE: boolean;
  124327. OPACITY: boolean;
  124328. VERTEXALPHA: boolean;
  124329. OPACITYDIRECTUV: number;
  124330. OPACITYRGB: boolean;
  124331. ALPHATEST: boolean;
  124332. DEPTHPREPASS: boolean;
  124333. ALPHABLEND: boolean;
  124334. ALPHAFROMALBEDO: boolean;
  124335. ALPHATESTVALUE: string;
  124336. SPECULAROVERALPHA: boolean;
  124337. RADIANCEOVERALPHA: boolean;
  124338. ALPHAFRESNEL: boolean;
  124339. LINEARALPHAFRESNEL: boolean;
  124340. PREMULTIPLYALPHA: boolean;
  124341. EMISSIVE: boolean;
  124342. EMISSIVEDIRECTUV: number;
  124343. REFLECTIVITY: boolean;
  124344. REFLECTIVITYDIRECTUV: number;
  124345. SPECULARTERM: boolean;
  124346. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124347. MICROSURFACEAUTOMATIC: boolean;
  124348. LODBASEDMICROSFURACE: boolean;
  124349. MICROSURFACEMAP: boolean;
  124350. MICROSURFACEMAPDIRECTUV: number;
  124351. METALLICWORKFLOW: boolean;
  124352. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124353. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124354. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124355. AOSTOREINMETALMAPRED: boolean;
  124356. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124357. ENVIRONMENTBRDF: boolean;
  124358. ENVIRONMENTBRDF_RGBD: boolean;
  124359. NORMAL: boolean;
  124360. TANGENT: boolean;
  124361. BUMP: boolean;
  124362. BUMPDIRECTUV: number;
  124363. OBJECTSPACE_NORMALMAP: boolean;
  124364. PARALLAX: boolean;
  124365. PARALLAXOCCLUSION: boolean;
  124366. NORMALXYSCALE: boolean;
  124367. LIGHTMAP: boolean;
  124368. LIGHTMAPDIRECTUV: number;
  124369. USELIGHTMAPASSHADOWMAP: boolean;
  124370. GAMMALIGHTMAP: boolean;
  124371. RGBDLIGHTMAP: boolean;
  124372. REFLECTION: boolean;
  124373. REFLECTIONMAP_3D: boolean;
  124374. REFLECTIONMAP_SPHERICAL: boolean;
  124375. REFLECTIONMAP_PLANAR: boolean;
  124376. REFLECTIONMAP_CUBIC: boolean;
  124377. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124378. REFLECTIONMAP_PROJECTION: boolean;
  124379. REFLECTIONMAP_SKYBOX: boolean;
  124380. REFLECTIONMAP_EXPLICIT: boolean;
  124381. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124382. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124383. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124384. INVERTCUBICMAP: boolean;
  124385. USESPHERICALFROMREFLECTIONMAP: boolean;
  124386. USEIRRADIANCEMAP: boolean;
  124387. SPHERICAL_HARMONICS: boolean;
  124388. USESPHERICALINVERTEX: boolean;
  124389. REFLECTIONMAP_OPPOSITEZ: boolean;
  124390. LODINREFLECTIONALPHA: boolean;
  124391. GAMMAREFLECTION: boolean;
  124392. RGBDREFLECTION: boolean;
  124393. LINEARSPECULARREFLECTION: boolean;
  124394. RADIANCEOCCLUSION: boolean;
  124395. HORIZONOCCLUSION: boolean;
  124396. INSTANCES: boolean;
  124397. NUM_BONE_INFLUENCERS: number;
  124398. BonesPerMesh: number;
  124399. BONETEXTURE: boolean;
  124400. NONUNIFORMSCALING: boolean;
  124401. MORPHTARGETS: boolean;
  124402. MORPHTARGETS_NORMAL: boolean;
  124403. MORPHTARGETS_TANGENT: boolean;
  124404. MORPHTARGETS_UV: boolean;
  124405. NUM_MORPH_INFLUENCERS: number;
  124406. IMAGEPROCESSING: boolean;
  124407. VIGNETTE: boolean;
  124408. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124409. VIGNETTEBLENDMODEOPAQUE: boolean;
  124410. TONEMAPPING: boolean;
  124411. TONEMAPPING_ACES: boolean;
  124412. CONTRAST: boolean;
  124413. COLORCURVES: boolean;
  124414. COLORGRADING: boolean;
  124415. COLORGRADING3D: boolean;
  124416. SAMPLER3DGREENDEPTH: boolean;
  124417. SAMPLER3DBGRMAP: boolean;
  124418. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124419. EXPOSURE: boolean;
  124420. MULTIVIEW: boolean;
  124421. USEPHYSICALLIGHTFALLOFF: boolean;
  124422. USEGLTFLIGHTFALLOFF: boolean;
  124423. TWOSIDEDLIGHTING: boolean;
  124424. SHADOWFLOAT: boolean;
  124425. CLIPPLANE: boolean;
  124426. CLIPPLANE2: boolean;
  124427. CLIPPLANE3: boolean;
  124428. CLIPPLANE4: boolean;
  124429. CLIPPLANE5: boolean;
  124430. CLIPPLANE6: boolean;
  124431. POINTSIZE: boolean;
  124432. FOG: boolean;
  124433. LOGARITHMICDEPTH: boolean;
  124434. FORCENORMALFORWARD: boolean;
  124435. SPECULARAA: boolean;
  124436. CLEARCOAT: boolean;
  124437. CLEARCOAT_DEFAULTIOR: boolean;
  124438. CLEARCOAT_TEXTURE: boolean;
  124439. CLEARCOAT_TEXTUREDIRECTUV: number;
  124440. CLEARCOAT_BUMP: boolean;
  124441. CLEARCOAT_BUMPDIRECTUV: number;
  124442. CLEARCOAT_TINT: boolean;
  124443. CLEARCOAT_TINT_TEXTURE: boolean;
  124444. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124445. ANISOTROPIC: boolean;
  124446. ANISOTROPIC_TEXTURE: boolean;
  124447. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124448. BRDF_V_HEIGHT_CORRELATED: boolean;
  124449. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124450. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124451. SHEEN: boolean;
  124452. SHEEN_TEXTURE: boolean;
  124453. SHEEN_TEXTUREDIRECTUV: number;
  124454. SHEEN_LINKWITHALBEDO: boolean;
  124455. SHEEN_ROUGHNESS: boolean;
  124456. SHEEN_ALBEDOSCALING: boolean;
  124457. SUBSURFACE: boolean;
  124458. SS_REFRACTION: boolean;
  124459. SS_TRANSLUCENCY: boolean;
  124460. SS_SCATERRING: boolean;
  124461. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124462. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124463. SS_REFRACTIONMAP_3D: boolean;
  124464. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124465. SS_LODINREFRACTIONALPHA: boolean;
  124466. SS_GAMMAREFRACTION: boolean;
  124467. SS_RGBDREFRACTION: boolean;
  124468. SS_LINEARSPECULARREFRACTION: boolean;
  124469. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124470. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124471. UNLIT: boolean;
  124472. DEBUGMODE: number;
  124473. /**
  124474. * Initializes the PBR Material defines.
  124475. */
  124476. constructor();
  124477. /**
  124478. * Resets the PBR Material defines.
  124479. */
  124480. reset(): void;
  124481. }
  124482. /**
  124483. * The Physically based material base class of BJS.
  124484. *
  124485. * This offers the main features of a standard PBR material.
  124486. * For more information, please refer to the documentation :
  124487. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124488. */
  124489. export abstract class PBRBaseMaterial extends PushMaterial {
  124490. /**
  124491. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124492. */
  124493. static readonly PBRMATERIAL_OPAQUE: number;
  124494. /**
  124495. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124496. */
  124497. static readonly PBRMATERIAL_ALPHATEST: number;
  124498. /**
  124499. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124500. */
  124501. static readonly PBRMATERIAL_ALPHABLEND: number;
  124502. /**
  124503. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124504. * They are also discarded below the alpha cutoff threshold to improve performances.
  124505. */
  124506. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124507. /**
  124508. * Defines the default value of how much AO map is occluding the analytical lights
  124509. * (point spot...).
  124510. */
  124511. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124512. /**
  124513. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124514. */
  124515. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124516. /**
  124517. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124518. * to enhance interoperability with other engines.
  124519. */
  124520. static readonly LIGHTFALLOFF_GLTF: number;
  124521. /**
  124522. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124523. * to enhance interoperability with other materials.
  124524. */
  124525. static readonly LIGHTFALLOFF_STANDARD: number;
  124526. /**
  124527. * Intensity of the direct lights e.g. the four lights available in your scene.
  124528. * This impacts both the direct diffuse and specular highlights.
  124529. */
  124530. protected _directIntensity: number;
  124531. /**
  124532. * Intensity of the emissive part of the material.
  124533. * This helps controlling the emissive effect without modifying the emissive color.
  124534. */
  124535. protected _emissiveIntensity: number;
  124536. /**
  124537. * Intensity of the environment e.g. how much the environment will light the object
  124538. * either through harmonics for rough material or through the refelction for shiny ones.
  124539. */
  124540. protected _environmentIntensity: number;
  124541. /**
  124542. * This is a special control allowing the reduction of the specular highlights coming from the
  124543. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124544. */
  124545. protected _specularIntensity: number;
  124546. /**
  124547. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124548. */
  124549. private _lightingInfos;
  124550. /**
  124551. * Debug Control allowing disabling the bump map on this material.
  124552. */
  124553. protected _disableBumpMap: boolean;
  124554. /**
  124555. * AKA Diffuse Texture in standard nomenclature.
  124556. */
  124557. protected _albedoTexture: Nullable<BaseTexture>;
  124558. /**
  124559. * AKA Occlusion Texture in other nomenclature.
  124560. */
  124561. protected _ambientTexture: Nullable<BaseTexture>;
  124562. /**
  124563. * AKA Occlusion Texture Intensity in other nomenclature.
  124564. */
  124565. protected _ambientTextureStrength: number;
  124566. /**
  124567. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124568. * 1 means it completely occludes it
  124569. * 0 mean it has no impact
  124570. */
  124571. protected _ambientTextureImpactOnAnalyticalLights: number;
  124572. /**
  124573. * Stores the alpha values in a texture.
  124574. */
  124575. protected _opacityTexture: Nullable<BaseTexture>;
  124576. /**
  124577. * Stores the reflection values in a texture.
  124578. */
  124579. protected _reflectionTexture: Nullable<BaseTexture>;
  124580. /**
  124581. * Stores the emissive values in a texture.
  124582. */
  124583. protected _emissiveTexture: Nullable<BaseTexture>;
  124584. /**
  124585. * AKA Specular texture in other nomenclature.
  124586. */
  124587. protected _reflectivityTexture: Nullable<BaseTexture>;
  124588. /**
  124589. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124590. */
  124591. protected _metallicTexture: Nullable<BaseTexture>;
  124592. /**
  124593. * Specifies the metallic scalar of the metallic/roughness workflow.
  124594. * Can also be used to scale the metalness values of the metallic texture.
  124595. */
  124596. protected _metallic: Nullable<number>;
  124597. /**
  124598. * Specifies the roughness scalar of the metallic/roughness workflow.
  124599. * Can also be used to scale the roughness values of the metallic texture.
  124600. */
  124601. protected _roughness: Nullable<number>;
  124602. /**
  124603. * Specifies the an F0 factor to help configuring the material F0.
  124604. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124605. * to 0.5 the previously hard coded value stays the same.
  124606. * Can also be used to scale the F0 values of the metallic texture.
  124607. */
  124608. protected _metallicF0Factor: number;
  124609. /**
  124610. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124611. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124612. * your expectation as it multiplies with the texture data.
  124613. */
  124614. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124615. /**
  124616. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124617. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124618. */
  124619. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124620. /**
  124621. * Stores surface normal data used to displace a mesh in a texture.
  124622. */
  124623. protected _bumpTexture: Nullable<BaseTexture>;
  124624. /**
  124625. * Stores the pre-calculated light information of a mesh in a texture.
  124626. */
  124627. protected _lightmapTexture: Nullable<BaseTexture>;
  124628. /**
  124629. * The color of a material in ambient lighting.
  124630. */
  124631. protected _ambientColor: Color3;
  124632. /**
  124633. * AKA Diffuse Color in other nomenclature.
  124634. */
  124635. protected _albedoColor: Color3;
  124636. /**
  124637. * AKA Specular Color in other nomenclature.
  124638. */
  124639. protected _reflectivityColor: Color3;
  124640. /**
  124641. * The color applied when light is reflected from a material.
  124642. */
  124643. protected _reflectionColor: Color3;
  124644. /**
  124645. * The color applied when light is emitted from a material.
  124646. */
  124647. protected _emissiveColor: Color3;
  124648. /**
  124649. * AKA Glossiness in other nomenclature.
  124650. */
  124651. protected _microSurface: number;
  124652. /**
  124653. * Specifies that the material will use the light map as a show map.
  124654. */
  124655. protected _useLightmapAsShadowmap: boolean;
  124656. /**
  124657. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124658. * makes the reflect vector face the model (under horizon).
  124659. */
  124660. protected _useHorizonOcclusion: boolean;
  124661. /**
  124662. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124663. * too much the area relying on ambient texture to define their ambient occlusion.
  124664. */
  124665. protected _useRadianceOcclusion: boolean;
  124666. /**
  124667. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124668. */
  124669. protected _useAlphaFromAlbedoTexture: boolean;
  124670. /**
  124671. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124672. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124673. */
  124674. protected _useSpecularOverAlpha: boolean;
  124675. /**
  124676. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124677. */
  124678. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124679. /**
  124680. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124681. */
  124682. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124683. /**
  124684. * Specifies if the metallic texture contains the roughness information in its green channel.
  124685. */
  124686. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124687. /**
  124688. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124689. */
  124690. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124691. /**
  124692. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124693. */
  124694. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124695. /**
  124696. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124697. */
  124698. protected _useAmbientInGrayScale: boolean;
  124699. /**
  124700. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124701. * The material will try to infer what glossiness each pixel should be.
  124702. */
  124703. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124704. /**
  124705. * Defines the falloff type used in this material.
  124706. * It by default is Physical.
  124707. */
  124708. protected _lightFalloff: number;
  124709. /**
  124710. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124711. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124712. */
  124713. protected _useRadianceOverAlpha: boolean;
  124714. /**
  124715. * Allows using an object space normal map (instead of tangent space).
  124716. */
  124717. protected _useObjectSpaceNormalMap: boolean;
  124718. /**
  124719. * Allows using the bump map in parallax mode.
  124720. */
  124721. protected _useParallax: boolean;
  124722. /**
  124723. * Allows using the bump map in parallax occlusion mode.
  124724. */
  124725. protected _useParallaxOcclusion: boolean;
  124726. /**
  124727. * Controls the scale bias of the parallax mode.
  124728. */
  124729. protected _parallaxScaleBias: number;
  124730. /**
  124731. * If sets to true, disables all the lights affecting the material.
  124732. */
  124733. protected _disableLighting: boolean;
  124734. /**
  124735. * Number of Simultaneous lights allowed on the material.
  124736. */
  124737. protected _maxSimultaneousLights: number;
  124738. /**
  124739. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124740. */
  124741. protected _invertNormalMapX: boolean;
  124742. /**
  124743. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124744. */
  124745. protected _invertNormalMapY: boolean;
  124746. /**
  124747. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124748. */
  124749. protected _twoSidedLighting: boolean;
  124750. /**
  124751. * Defines the alpha limits in alpha test mode.
  124752. */
  124753. protected _alphaCutOff: number;
  124754. /**
  124755. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124756. */
  124757. protected _forceAlphaTest: boolean;
  124758. /**
  124759. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124760. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124761. */
  124762. protected _useAlphaFresnel: boolean;
  124763. /**
  124764. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124765. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124766. */
  124767. protected _useLinearAlphaFresnel: boolean;
  124768. /**
  124769. * The transparency mode of the material.
  124770. */
  124771. protected _transparencyMode: Nullable<number>;
  124772. /**
  124773. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124774. * from cos thetav and roughness:
  124775. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124776. */
  124777. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124778. /**
  124779. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124780. */
  124781. protected _forceIrradianceInFragment: boolean;
  124782. /**
  124783. * Force normal to face away from face.
  124784. */
  124785. protected _forceNormalForward: boolean;
  124786. /**
  124787. * Enables specular anti aliasing in the PBR shader.
  124788. * It will both interacts on the Geometry for analytical and IBL lighting.
  124789. * It also prefilter the roughness map based on the bump values.
  124790. */
  124791. protected _enableSpecularAntiAliasing: boolean;
  124792. /**
  124793. * Default configuration related to image processing available in the PBR Material.
  124794. */
  124795. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124796. /**
  124797. * Keep track of the image processing observer to allow dispose and replace.
  124798. */
  124799. private _imageProcessingObserver;
  124800. /**
  124801. * Attaches a new image processing configuration to the PBR Material.
  124802. * @param configuration
  124803. */
  124804. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124805. /**
  124806. * Stores the available render targets.
  124807. */
  124808. private _renderTargets;
  124809. /**
  124810. * Sets the global ambient color for the material used in lighting calculations.
  124811. */
  124812. private _globalAmbientColor;
  124813. /**
  124814. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124815. */
  124816. private _useLogarithmicDepth;
  124817. /**
  124818. * If set to true, no lighting calculations will be applied.
  124819. */
  124820. private _unlit;
  124821. private _debugMode;
  124822. /**
  124823. * @hidden
  124824. * This is reserved for the inspector.
  124825. * Defines the material debug mode.
  124826. * It helps seeing only some components of the material while troubleshooting.
  124827. */
  124828. debugMode: number;
  124829. /**
  124830. * @hidden
  124831. * This is reserved for the inspector.
  124832. * Specify from where on screen the debug mode should start.
  124833. * The value goes from -1 (full screen) to 1 (not visible)
  124834. * It helps with side by side comparison against the final render
  124835. * This defaults to -1
  124836. */
  124837. private debugLimit;
  124838. /**
  124839. * @hidden
  124840. * This is reserved for the inspector.
  124841. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124842. * You can use the factor to better multiply the final value.
  124843. */
  124844. private debugFactor;
  124845. /**
  124846. * Defines the clear coat layer parameters for the material.
  124847. */
  124848. readonly clearCoat: PBRClearCoatConfiguration;
  124849. /**
  124850. * Defines the anisotropic parameters for the material.
  124851. */
  124852. readonly anisotropy: PBRAnisotropicConfiguration;
  124853. /**
  124854. * Defines the BRDF parameters for the material.
  124855. */
  124856. readonly brdf: PBRBRDFConfiguration;
  124857. /**
  124858. * Defines the Sheen parameters for the material.
  124859. */
  124860. readonly sheen: PBRSheenConfiguration;
  124861. /**
  124862. * Defines the SubSurface parameters for the material.
  124863. */
  124864. readonly subSurface: PBRSubSurfaceConfiguration;
  124865. /**
  124866. * Custom callback helping to override the default shader used in the material.
  124867. */
  124868. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124869. protected _rebuildInParallel: boolean;
  124870. /**
  124871. * Instantiates a new PBRMaterial instance.
  124872. *
  124873. * @param name The material name
  124874. * @param scene The scene the material will be use in.
  124875. */
  124876. constructor(name: string, scene: Scene);
  124877. /**
  124878. * Gets a boolean indicating that current material needs to register RTT
  124879. */
  124880. get hasRenderTargetTextures(): boolean;
  124881. /**
  124882. * Gets the name of the material class.
  124883. */
  124884. getClassName(): string;
  124885. /**
  124886. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124887. */
  124888. get useLogarithmicDepth(): boolean;
  124889. /**
  124890. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124891. */
  124892. set useLogarithmicDepth(value: boolean);
  124893. /**
  124894. * Gets the current transparency mode.
  124895. */
  124896. get transparencyMode(): Nullable<number>;
  124897. /**
  124898. * Sets the transparency mode of the material.
  124899. *
  124900. * | Value | Type | Description |
  124901. * | ----- | ----------------------------------- | ----------- |
  124902. * | 0 | OPAQUE | |
  124903. * | 1 | ALPHATEST | |
  124904. * | 2 | ALPHABLEND | |
  124905. * | 3 | ALPHATESTANDBLEND | |
  124906. *
  124907. */
  124908. set transparencyMode(value: Nullable<number>);
  124909. /**
  124910. * Returns true if alpha blending should be disabled.
  124911. */
  124912. private get _disableAlphaBlending();
  124913. /**
  124914. * Specifies whether or not this material should be rendered in alpha blend mode.
  124915. */
  124916. needAlphaBlending(): boolean;
  124917. /**
  124918. * Specifies if the mesh will require alpha blending.
  124919. * @param mesh - BJS mesh.
  124920. */
  124921. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124922. /**
  124923. * Specifies whether or not this material should be rendered in alpha test mode.
  124924. */
  124925. needAlphaTesting(): boolean;
  124926. /**
  124927. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124928. */
  124929. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124930. /**
  124931. * Gets the texture used for the alpha test.
  124932. */
  124933. getAlphaTestTexture(): Nullable<BaseTexture>;
  124934. /**
  124935. * Specifies that the submesh is ready to be used.
  124936. * @param mesh - BJS mesh.
  124937. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124938. * @param useInstances - Specifies that instances should be used.
  124939. * @returns - boolean indicating that the submesh is ready or not.
  124940. */
  124941. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124942. /**
  124943. * Specifies if the material uses metallic roughness workflow.
  124944. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124945. */
  124946. isMetallicWorkflow(): boolean;
  124947. private _prepareEffect;
  124948. private _prepareDefines;
  124949. /**
  124950. * Force shader compilation
  124951. */
  124952. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124953. /**
  124954. * Initializes the uniform buffer layout for the shader.
  124955. */
  124956. buildUniformLayout(): void;
  124957. /**
  124958. * Unbinds the material from the mesh
  124959. */
  124960. unbind(): void;
  124961. /**
  124962. * Binds the submesh data.
  124963. * @param world - The world matrix.
  124964. * @param mesh - The BJS mesh.
  124965. * @param subMesh - A submesh of the BJS mesh.
  124966. */
  124967. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124968. /**
  124969. * Returns the animatable textures.
  124970. * @returns - Array of animatable textures.
  124971. */
  124972. getAnimatables(): IAnimatable[];
  124973. /**
  124974. * Returns the texture used for reflections.
  124975. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124976. */
  124977. private _getReflectionTexture;
  124978. /**
  124979. * Returns an array of the actively used textures.
  124980. * @returns - Array of BaseTextures
  124981. */
  124982. getActiveTextures(): BaseTexture[];
  124983. /**
  124984. * Checks to see if a texture is used in the material.
  124985. * @param texture - Base texture to use.
  124986. * @returns - Boolean specifying if a texture is used in the material.
  124987. */
  124988. hasTexture(texture: BaseTexture): boolean;
  124989. /**
  124990. * Disposes the resources of the material.
  124991. * @param forceDisposeEffect - Forces the disposal of effects.
  124992. * @param forceDisposeTextures - Forces the disposal of all textures.
  124993. */
  124994. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124995. }
  124996. }
  124997. declare module BABYLON {
  124998. /**
  124999. * The Physically based material of BJS.
  125000. *
  125001. * This offers the main features of a standard PBR material.
  125002. * For more information, please refer to the documentation :
  125003. * https://doc.babylonjs.com/how_to/physically_based_rendering
  125004. */
  125005. export class PBRMaterial extends PBRBaseMaterial {
  125006. /**
  125007. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  125008. */
  125009. static readonly PBRMATERIAL_OPAQUE: number;
  125010. /**
  125011. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  125012. */
  125013. static readonly PBRMATERIAL_ALPHATEST: number;
  125014. /**
  125015. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125016. */
  125017. static readonly PBRMATERIAL_ALPHABLEND: number;
  125018. /**
  125019. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125020. * They are also discarded below the alpha cutoff threshold to improve performances.
  125021. */
  125022. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  125023. /**
  125024. * Defines the default value of how much AO map is occluding the analytical lights
  125025. * (point spot...).
  125026. */
  125027. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  125028. /**
  125029. * Intensity of the direct lights e.g. the four lights available in your scene.
  125030. * This impacts both the direct diffuse and specular highlights.
  125031. */
  125032. directIntensity: number;
  125033. /**
  125034. * Intensity of the emissive part of the material.
  125035. * This helps controlling the emissive effect without modifying the emissive color.
  125036. */
  125037. emissiveIntensity: number;
  125038. /**
  125039. * Intensity of the environment e.g. how much the environment will light the object
  125040. * either through harmonics for rough material or through the refelction for shiny ones.
  125041. */
  125042. environmentIntensity: number;
  125043. /**
  125044. * This is a special control allowing the reduction of the specular highlights coming from the
  125045. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  125046. */
  125047. specularIntensity: number;
  125048. /**
  125049. * Debug Control allowing disabling the bump map on this material.
  125050. */
  125051. disableBumpMap: boolean;
  125052. /**
  125053. * AKA Diffuse Texture in standard nomenclature.
  125054. */
  125055. albedoTexture: BaseTexture;
  125056. /**
  125057. * AKA Occlusion Texture in other nomenclature.
  125058. */
  125059. ambientTexture: BaseTexture;
  125060. /**
  125061. * AKA Occlusion Texture Intensity in other nomenclature.
  125062. */
  125063. ambientTextureStrength: number;
  125064. /**
  125065. * Defines how much the AO map is occluding the analytical lights (point spot...).
  125066. * 1 means it completely occludes it
  125067. * 0 mean it has no impact
  125068. */
  125069. ambientTextureImpactOnAnalyticalLights: number;
  125070. /**
  125071. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  125072. */
  125073. opacityTexture: BaseTexture;
  125074. /**
  125075. * Stores the reflection values in a texture.
  125076. */
  125077. reflectionTexture: Nullable<BaseTexture>;
  125078. /**
  125079. * Stores the emissive values in a texture.
  125080. */
  125081. emissiveTexture: BaseTexture;
  125082. /**
  125083. * AKA Specular texture in other nomenclature.
  125084. */
  125085. reflectivityTexture: BaseTexture;
  125086. /**
  125087. * Used to switch from specular/glossiness to metallic/roughness workflow.
  125088. */
  125089. metallicTexture: BaseTexture;
  125090. /**
  125091. * Specifies the metallic scalar of the metallic/roughness workflow.
  125092. * Can also be used to scale the metalness values of the metallic texture.
  125093. */
  125094. metallic: Nullable<number>;
  125095. /**
  125096. * Specifies the roughness scalar of the metallic/roughness workflow.
  125097. * Can also be used to scale the roughness values of the metallic texture.
  125098. */
  125099. roughness: Nullable<number>;
  125100. /**
  125101. * Specifies the an F0 factor to help configuring the material F0.
  125102. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  125103. * to 0.5 the previously hard coded value stays the same.
  125104. * Can also be used to scale the F0 values of the metallic texture.
  125105. */
  125106. metallicF0Factor: number;
  125107. /**
  125108. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  125109. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  125110. * your expectation as it multiplies with the texture data.
  125111. */
  125112. useMetallicF0FactorFromMetallicTexture: boolean;
  125113. /**
  125114. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  125115. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  125116. */
  125117. microSurfaceTexture: BaseTexture;
  125118. /**
  125119. * Stores surface normal data used to displace a mesh in a texture.
  125120. */
  125121. bumpTexture: BaseTexture;
  125122. /**
  125123. * Stores the pre-calculated light information of a mesh in a texture.
  125124. */
  125125. lightmapTexture: BaseTexture;
  125126. /**
  125127. * Stores the refracted light information in a texture.
  125128. */
  125129. get refractionTexture(): Nullable<BaseTexture>;
  125130. set refractionTexture(value: Nullable<BaseTexture>);
  125131. /**
  125132. * The color of a material in ambient lighting.
  125133. */
  125134. ambientColor: Color3;
  125135. /**
  125136. * AKA Diffuse Color in other nomenclature.
  125137. */
  125138. albedoColor: Color3;
  125139. /**
  125140. * AKA Specular Color in other nomenclature.
  125141. */
  125142. reflectivityColor: Color3;
  125143. /**
  125144. * The color reflected from the material.
  125145. */
  125146. reflectionColor: Color3;
  125147. /**
  125148. * The color emitted from the material.
  125149. */
  125150. emissiveColor: Color3;
  125151. /**
  125152. * AKA Glossiness in other nomenclature.
  125153. */
  125154. microSurface: number;
  125155. /**
  125156. * source material index of refraction (IOR)' / 'destination material IOR.
  125157. */
  125158. get indexOfRefraction(): number;
  125159. set indexOfRefraction(value: number);
  125160. /**
  125161. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  125162. */
  125163. get invertRefractionY(): boolean;
  125164. set invertRefractionY(value: boolean);
  125165. /**
  125166. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  125167. * Materials half opaque for instance using refraction could benefit from this control.
  125168. */
  125169. get linkRefractionWithTransparency(): boolean;
  125170. set linkRefractionWithTransparency(value: boolean);
  125171. /**
  125172. * If true, the light map contains occlusion information instead of lighting info.
  125173. */
  125174. useLightmapAsShadowmap: boolean;
  125175. /**
  125176. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  125177. */
  125178. useAlphaFromAlbedoTexture: boolean;
  125179. /**
  125180. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  125181. */
  125182. forceAlphaTest: boolean;
  125183. /**
  125184. * Defines the alpha limits in alpha test mode.
  125185. */
  125186. alphaCutOff: number;
  125187. /**
  125188. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  125189. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  125190. */
  125191. useSpecularOverAlpha: boolean;
  125192. /**
  125193. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  125194. */
  125195. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  125196. /**
  125197. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  125198. */
  125199. useRoughnessFromMetallicTextureAlpha: boolean;
  125200. /**
  125201. * Specifies if the metallic texture contains the roughness information in its green channel.
  125202. */
  125203. useRoughnessFromMetallicTextureGreen: boolean;
  125204. /**
  125205. * Specifies if the metallic texture contains the metallness information in its blue channel.
  125206. */
  125207. useMetallnessFromMetallicTextureBlue: boolean;
  125208. /**
  125209. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  125210. */
  125211. useAmbientOcclusionFromMetallicTextureRed: boolean;
  125212. /**
  125213. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  125214. */
  125215. useAmbientInGrayScale: boolean;
  125216. /**
  125217. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  125218. * The material will try to infer what glossiness each pixel should be.
  125219. */
  125220. useAutoMicroSurfaceFromReflectivityMap: boolean;
  125221. /**
  125222. * BJS is using an harcoded light falloff based on a manually sets up range.
  125223. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125224. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125225. */
  125226. get usePhysicalLightFalloff(): boolean;
  125227. /**
  125228. * BJS is using an harcoded light falloff based on a manually sets up range.
  125229. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125230. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125231. */
  125232. set usePhysicalLightFalloff(value: boolean);
  125233. /**
  125234. * In order to support the falloff compatibility with gltf, a special mode has been added
  125235. * to reproduce the gltf light falloff.
  125236. */
  125237. get useGLTFLightFalloff(): boolean;
  125238. /**
  125239. * In order to support the falloff compatibility with gltf, a special mode has been added
  125240. * to reproduce the gltf light falloff.
  125241. */
  125242. set useGLTFLightFalloff(value: boolean);
  125243. /**
  125244. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  125245. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  125246. */
  125247. useRadianceOverAlpha: boolean;
  125248. /**
  125249. * Allows using an object space normal map (instead of tangent space).
  125250. */
  125251. useObjectSpaceNormalMap: boolean;
  125252. /**
  125253. * Allows using the bump map in parallax mode.
  125254. */
  125255. useParallax: boolean;
  125256. /**
  125257. * Allows using the bump map in parallax occlusion mode.
  125258. */
  125259. useParallaxOcclusion: boolean;
  125260. /**
  125261. * Controls the scale bias of the parallax mode.
  125262. */
  125263. parallaxScaleBias: number;
  125264. /**
  125265. * If sets to true, disables all the lights affecting the material.
  125266. */
  125267. disableLighting: boolean;
  125268. /**
  125269. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125270. */
  125271. forceIrradianceInFragment: boolean;
  125272. /**
  125273. * Number of Simultaneous lights allowed on the material.
  125274. */
  125275. maxSimultaneousLights: number;
  125276. /**
  125277. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  125278. */
  125279. invertNormalMapX: boolean;
  125280. /**
  125281. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  125282. */
  125283. invertNormalMapY: boolean;
  125284. /**
  125285. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125286. */
  125287. twoSidedLighting: boolean;
  125288. /**
  125289. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125290. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125291. */
  125292. useAlphaFresnel: boolean;
  125293. /**
  125294. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125295. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125296. */
  125297. useLinearAlphaFresnel: boolean;
  125298. /**
  125299. * Let user defines the brdf lookup texture used for IBL.
  125300. * A default 8bit version is embedded but you could point at :
  125301. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  125302. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  125303. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  125304. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  125305. */
  125306. environmentBRDFTexture: Nullable<BaseTexture>;
  125307. /**
  125308. * Force normal to face away from face.
  125309. */
  125310. forceNormalForward: boolean;
  125311. /**
  125312. * Enables specular anti aliasing in the PBR shader.
  125313. * It will both interacts on the Geometry for analytical and IBL lighting.
  125314. * It also prefilter the roughness map based on the bump values.
  125315. */
  125316. enableSpecularAntiAliasing: boolean;
  125317. /**
  125318. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125319. * makes the reflect vector face the model (under horizon).
  125320. */
  125321. useHorizonOcclusion: boolean;
  125322. /**
  125323. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125324. * too much the area relying on ambient texture to define their ambient occlusion.
  125325. */
  125326. useRadianceOcclusion: boolean;
  125327. /**
  125328. * If set to true, no lighting calculations will be applied.
  125329. */
  125330. unlit: boolean;
  125331. /**
  125332. * Gets the image processing configuration used either in this material.
  125333. */
  125334. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125335. /**
  125336. * Sets the Default image processing configuration used either in the this material.
  125337. *
  125338. * If sets to null, the scene one is in use.
  125339. */
  125340. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125341. /**
  125342. * Gets wether the color curves effect is enabled.
  125343. */
  125344. get cameraColorCurvesEnabled(): boolean;
  125345. /**
  125346. * Sets wether the color curves effect is enabled.
  125347. */
  125348. set cameraColorCurvesEnabled(value: boolean);
  125349. /**
  125350. * Gets wether the color grading effect is enabled.
  125351. */
  125352. get cameraColorGradingEnabled(): boolean;
  125353. /**
  125354. * Gets wether the color grading effect is enabled.
  125355. */
  125356. set cameraColorGradingEnabled(value: boolean);
  125357. /**
  125358. * Gets wether tonemapping is enabled or not.
  125359. */
  125360. get cameraToneMappingEnabled(): boolean;
  125361. /**
  125362. * Sets wether tonemapping is enabled or not
  125363. */
  125364. set cameraToneMappingEnabled(value: boolean);
  125365. /**
  125366. * The camera exposure used on this material.
  125367. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125368. * This corresponds to a photographic exposure.
  125369. */
  125370. get cameraExposure(): number;
  125371. /**
  125372. * The camera exposure used on this material.
  125373. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125374. * This corresponds to a photographic exposure.
  125375. */
  125376. set cameraExposure(value: number);
  125377. /**
  125378. * Gets The camera contrast used on this material.
  125379. */
  125380. get cameraContrast(): number;
  125381. /**
  125382. * Sets The camera contrast used on this material.
  125383. */
  125384. set cameraContrast(value: number);
  125385. /**
  125386. * Gets the Color Grading 2D Lookup Texture.
  125387. */
  125388. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125389. /**
  125390. * Sets the Color Grading 2D Lookup Texture.
  125391. */
  125392. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125393. /**
  125394. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125395. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125396. * 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;
  125397. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125398. */
  125399. get cameraColorCurves(): Nullable<ColorCurves>;
  125400. /**
  125401. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125402. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125403. * 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;
  125404. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125405. */
  125406. set cameraColorCurves(value: Nullable<ColorCurves>);
  125407. /**
  125408. * Instantiates a new PBRMaterial instance.
  125409. *
  125410. * @param name The material name
  125411. * @param scene The scene the material will be use in.
  125412. */
  125413. constructor(name: string, scene: Scene);
  125414. /**
  125415. * Returns the name of this material class.
  125416. */
  125417. getClassName(): string;
  125418. /**
  125419. * Makes a duplicate of the current material.
  125420. * @param name - name to use for the new material.
  125421. */
  125422. clone(name: string): PBRMaterial;
  125423. /**
  125424. * Serializes this PBR Material.
  125425. * @returns - An object with the serialized material.
  125426. */
  125427. serialize(): any;
  125428. /**
  125429. * Parses a PBR Material from a serialized object.
  125430. * @param source - Serialized object.
  125431. * @param scene - BJS scene instance.
  125432. * @param rootUrl - url for the scene object
  125433. * @returns - PBRMaterial
  125434. */
  125435. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125436. }
  125437. }
  125438. declare module BABYLON {
  125439. /**
  125440. * Direct draw surface info
  125441. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125442. */
  125443. export interface DDSInfo {
  125444. /**
  125445. * Width of the texture
  125446. */
  125447. width: number;
  125448. /**
  125449. * Width of the texture
  125450. */
  125451. height: number;
  125452. /**
  125453. * Number of Mipmaps for the texture
  125454. * @see https://en.wikipedia.org/wiki/Mipmap
  125455. */
  125456. mipmapCount: number;
  125457. /**
  125458. * If the textures format is a known fourCC format
  125459. * @see https://www.fourcc.org/
  125460. */
  125461. isFourCC: boolean;
  125462. /**
  125463. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125464. */
  125465. isRGB: boolean;
  125466. /**
  125467. * If the texture is a lumincance format
  125468. */
  125469. isLuminance: boolean;
  125470. /**
  125471. * If this is a cube texture
  125472. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125473. */
  125474. isCube: boolean;
  125475. /**
  125476. * If the texture is a compressed format eg. FOURCC_DXT1
  125477. */
  125478. isCompressed: boolean;
  125479. /**
  125480. * The dxgiFormat of the texture
  125481. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125482. */
  125483. dxgiFormat: number;
  125484. /**
  125485. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125486. */
  125487. textureType: number;
  125488. /**
  125489. * Sphericle polynomial created for the dds texture
  125490. */
  125491. sphericalPolynomial?: SphericalPolynomial;
  125492. }
  125493. /**
  125494. * Class used to provide DDS decompression tools
  125495. */
  125496. export class DDSTools {
  125497. /**
  125498. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125499. */
  125500. static StoreLODInAlphaChannel: boolean;
  125501. /**
  125502. * Gets DDS information from an array buffer
  125503. * @param data defines the array buffer view to read data from
  125504. * @returns the DDS information
  125505. */
  125506. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125507. private static _FloatView;
  125508. private static _Int32View;
  125509. private static _ToHalfFloat;
  125510. private static _FromHalfFloat;
  125511. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125512. private static _GetHalfFloatRGBAArrayBuffer;
  125513. private static _GetFloatRGBAArrayBuffer;
  125514. private static _GetFloatAsUIntRGBAArrayBuffer;
  125515. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125516. private static _GetRGBAArrayBuffer;
  125517. private static _ExtractLongWordOrder;
  125518. private static _GetRGBArrayBuffer;
  125519. private static _GetLuminanceArrayBuffer;
  125520. /**
  125521. * Uploads DDS Levels to a Babylon Texture
  125522. * @hidden
  125523. */
  125524. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125525. }
  125526. interface ThinEngine {
  125527. /**
  125528. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125529. * @param rootUrl defines the url where the file to load is located
  125530. * @param scene defines the current scene
  125531. * @param lodScale defines scale to apply to the mip map selection
  125532. * @param lodOffset defines offset to apply to the mip map selection
  125533. * @param onLoad defines an optional callback raised when the texture is loaded
  125534. * @param onError defines an optional callback raised if there is an issue to load the texture
  125535. * @param format defines the format of the data
  125536. * @param forcedExtension defines the extension to use to pick the right loader
  125537. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125538. * @returns the cube texture as an InternalTexture
  125539. */
  125540. 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;
  125541. }
  125542. }
  125543. declare module BABYLON {
  125544. /**
  125545. * Implementation of the DDS Texture Loader.
  125546. * @hidden
  125547. */
  125548. export class _DDSTextureLoader implements IInternalTextureLoader {
  125549. /**
  125550. * Defines wether the loader supports cascade loading the different faces.
  125551. */
  125552. readonly supportCascades: boolean;
  125553. /**
  125554. * This returns if the loader support the current file information.
  125555. * @param extension defines the file extension of the file being loaded
  125556. * @returns true if the loader can load the specified file
  125557. */
  125558. canLoad(extension: string): boolean;
  125559. /**
  125560. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125561. * @param data contains the texture data
  125562. * @param texture defines the BabylonJS internal texture
  125563. * @param createPolynomials will be true if polynomials have been requested
  125564. * @param onLoad defines the callback to trigger once the texture is ready
  125565. * @param onError defines the callback to trigger in case of error
  125566. */
  125567. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125568. /**
  125569. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125570. * @param data contains the texture data
  125571. * @param texture defines the BabylonJS internal texture
  125572. * @param callback defines the method to call once ready to upload
  125573. */
  125574. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125575. }
  125576. }
  125577. declare module BABYLON {
  125578. /**
  125579. * Implementation of the ENV Texture Loader.
  125580. * @hidden
  125581. */
  125582. export class _ENVTextureLoader implements IInternalTextureLoader {
  125583. /**
  125584. * Defines wether the loader supports cascade loading the different faces.
  125585. */
  125586. readonly supportCascades: boolean;
  125587. /**
  125588. * This returns if the loader support the current file information.
  125589. * @param extension defines the file extension of the file being loaded
  125590. * @returns true if the loader can load the specified file
  125591. */
  125592. canLoad(extension: string): boolean;
  125593. /**
  125594. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125595. * @param data contains the texture data
  125596. * @param texture defines the BabylonJS internal texture
  125597. * @param createPolynomials will be true if polynomials have been requested
  125598. * @param onLoad defines the callback to trigger once the texture is ready
  125599. * @param onError defines the callback to trigger in case of error
  125600. */
  125601. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125602. /**
  125603. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125604. * @param data contains the texture data
  125605. * @param texture defines the BabylonJS internal texture
  125606. * @param callback defines the method to call once ready to upload
  125607. */
  125608. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125609. }
  125610. }
  125611. declare module BABYLON {
  125612. /**
  125613. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125614. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125615. */
  125616. export class KhronosTextureContainer {
  125617. /** contents of the KTX container file */
  125618. data: ArrayBufferView;
  125619. private static HEADER_LEN;
  125620. private static COMPRESSED_2D;
  125621. private static COMPRESSED_3D;
  125622. private static TEX_2D;
  125623. private static TEX_3D;
  125624. /**
  125625. * Gets the openGL type
  125626. */
  125627. glType: number;
  125628. /**
  125629. * Gets the openGL type size
  125630. */
  125631. glTypeSize: number;
  125632. /**
  125633. * Gets the openGL format
  125634. */
  125635. glFormat: number;
  125636. /**
  125637. * Gets the openGL internal format
  125638. */
  125639. glInternalFormat: number;
  125640. /**
  125641. * Gets the base internal format
  125642. */
  125643. glBaseInternalFormat: number;
  125644. /**
  125645. * Gets image width in pixel
  125646. */
  125647. pixelWidth: number;
  125648. /**
  125649. * Gets image height in pixel
  125650. */
  125651. pixelHeight: number;
  125652. /**
  125653. * Gets image depth in pixels
  125654. */
  125655. pixelDepth: number;
  125656. /**
  125657. * Gets the number of array elements
  125658. */
  125659. numberOfArrayElements: number;
  125660. /**
  125661. * Gets the number of faces
  125662. */
  125663. numberOfFaces: number;
  125664. /**
  125665. * Gets the number of mipmap levels
  125666. */
  125667. numberOfMipmapLevels: number;
  125668. /**
  125669. * Gets the bytes of key value data
  125670. */
  125671. bytesOfKeyValueData: number;
  125672. /**
  125673. * Gets the load type
  125674. */
  125675. loadType: number;
  125676. /**
  125677. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125678. */
  125679. isInvalid: boolean;
  125680. /**
  125681. * Creates a new KhronosTextureContainer
  125682. * @param data contents of the KTX container file
  125683. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125684. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125685. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125686. */
  125687. constructor(
  125688. /** contents of the KTX container file */
  125689. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125690. /**
  125691. * Uploads KTX content to a Babylon Texture.
  125692. * It is assumed that the texture has already been created & is currently bound
  125693. * @hidden
  125694. */
  125695. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125696. private _upload2DCompressedLevels;
  125697. /**
  125698. * Checks if the given data starts with a KTX file identifier.
  125699. * @param data the data to check
  125700. * @returns true if the data is a KTX file or false otherwise
  125701. */
  125702. static IsValid(data: ArrayBufferView): boolean;
  125703. }
  125704. }
  125705. declare module BABYLON {
  125706. /**
  125707. * Class for loading KTX2 files
  125708. * !!! Experimental Extension Subject to Changes !!!
  125709. * @hidden
  125710. */
  125711. export class KhronosTextureContainer2 {
  125712. private static _ModulePromise;
  125713. private static _TranscodeFormat;
  125714. constructor(engine: ThinEngine);
  125715. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  125716. private _determineTranscodeFormat;
  125717. /**
  125718. * Checks if the given data starts with a KTX2 file identifier.
  125719. * @param data the data to check
  125720. * @returns true if the data is a KTX2 file or false otherwise
  125721. */
  125722. static IsValid(data: ArrayBufferView): boolean;
  125723. }
  125724. }
  125725. declare module BABYLON {
  125726. /**
  125727. * Implementation of the KTX Texture Loader.
  125728. * @hidden
  125729. */
  125730. export class _KTXTextureLoader implements IInternalTextureLoader {
  125731. /**
  125732. * Defines wether the loader supports cascade loading the different faces.
  125733. */
  125734. readonly supportCascades: boolean;
  125735. /**
  125736. * This returns if the loader support the current file information.
  125737. * @param extension defines the file extension of the file being loaded
  125738. * @returns true if the loader can load the specified file
  125739. */
  125740. canLoad(extension: string): boolean;
  125741. /**
  125742. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125743. * @param data contains the texture data
  125744. * @param texture defines the BabylonJS internal texture
  125745. * @param createPolynomials will be true if polynomials have been requested
  125746. * @param onLoad defines the callback to trigger once the texture is ready
  125747. * @param onError defines the callback to trigger in case of error
  125748. */
  125749. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125750. /**
  125751. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125752. * @param data contains the texture data
  125753. * @param texture defines the BabylonJS internal texture
  125754. * @param callback defines the method to call once ready to upload
  125755. */
  125756. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125757. }
  125758. }
  125759. declare module BABYLON {
  125760. /** @hidden */
  125761. export var _forceSceneHelpersToBundle: boolean;
  125762. interface Scene {
  125763. /**
  125764. * Creates a default light for the scene.
  125765. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125766. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125767. */
  125768. createDefaultLight(replace?: boolean): void;
  125769. /**
  125770. * Creates a default camera for the scene.
  125771. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125772. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125773. * @param replace has default false, when true replaces the active camera in the scene
  125774. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125775. */
  125776. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125777. /**
  125778. * Creates a default camera and a default light.
  125779. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125780. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125781. * @param replace has the default false, when true replaces the active camera/light in the scene
  125782. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125783. */
  125784. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125785. /**
  125786. * Creates a new sky box
  125787. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125788. * @param environmentTexture defines the texture to use as environment texture
  125789. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125790. * @param scale defines the overall scale of the skybox
  125791. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125792. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125793. * @returns a new mesh holding the sky box
  125794. */
  125795. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125796. /**
  125797. * Creates a new environment
  125798. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125799. * @param options defines the options you can use to configure the environment
  125800. * @returns the new EnvironmentHelper
  125801. */
  125802. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125803. /**
  125804. * Creates a new VREXperienceHelper
  125805. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125806. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125807. * @returns a new VREXperienceHelper
  125808. */
  125809. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125810. /**
  125811. * Creates a new WebXRDefaultExperience
  125812. * @see http://doc.babylonjs.com/how_to/webxr
  125813. * @param options experience options
  125814. * @returns a promise for a new WebXRDefaultExperience
  125815. */
  125816. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125817. }
  125818. }
  125819. declare module BABYLON {
  125820. /**
  125821. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125822. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125823. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125824. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125825. */
  125826. export class VideoDome extends TransformNode {
  125827. /**
  125828. * Define the video source as a Monoscopic panoramic 360 video.
  125829. */
  125830. static readonly MODE_MONOSCOPIC: number;
  125831. /**
  125832. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125833. */
  125834. static readonly MODE_TOPBOTTOM: number;
  125835. /**
  125836. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125837. */
  125838. static readonly MODE_SIDEBYSIDE: number;
  125839. private _halfDome;
  125840. private _useDirectMapping;
  125841. /**
  125842. * The video texture being displayed on the sphere
  125843. */
  125844. protected _videoTexture: VideoTexture;
  125845. /**
  125846. * Gets the video texture being displayed on the sphere
  125847. */
  125848. get videoTexture(): VideoTexture;
  125849. /**
  125850. * The skybox material
  125851. */
  125852. protected _material: BackgroundMaterial;
  125853. /**
  125854. * The surface used for the skybox
  125855. */
  125856. protected _mesh: Mesh;
  125857. /**
  125858. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125859. */
  125860. private _halfDomeMask;
  125861. /**
  125862. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125863. * Also see the options.resolution property.
  125864. */
  125865. get fovMultiplier(): number;
  125866. set fovMultiplier(value: number);
  125867. private _videoMode;
  125868. /**
  125869. * Gets or set the current video mode for the video. It can be:
  125870. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125871. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125872. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125873. */
  125874. get videoMode(): number;
  125875. set videoMode(value: number);
  125876. /**
  125877. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125878. *
  125879. */
  125880. get halfDome(): boolean;
  125881. /**
  125882. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125883. */
  125884. set halfDome(enabled: boolean);
  125885. /**
  125886. * Oberserver used in Stereoscopic VR Mode.
  125887. */
  125888. private _onBeforeCameraRenderObserver;
  125889. /**
  125890. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125891. * @param name Element's name, child elements will append suffixes for their own names.
  125892. * @param urlsOrVideo defines the url(s) or the video element to use
  125893. * @param options An object containing optional or exposed sub element properties
  125894. */
  125895. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125896. resolution?: number;
  125897. clickToPlay?: boolean;
  125898. autoPlay?: boolean;
  125899. loop?: boolean;
  125900. size?: number;
  125901. poster?: string;
  125902. faceForward?: boolean;
  125903. useDirectMapping?: boolean;
  125904. halfDomeMode?: boolean;
  125905. }, scene: Scene);
  125906. private _changeVideoMode;
  125907. /**
  125908. * Releases resources associated with this node.
  125909. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125910. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125911. */
  125912. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125913. }
  125914. }
  125915. declare module BABYLON {
  125916. /**
  125917. * This class can be used to get instrumentation data from a Babylon engine
  125918. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125919. */
  125920. export class EngineInstrumentation implements IDisposable {
  125921. /**
  125922. * Define the instrumented engine.
  125923. */
  125924. engine: Engine;
  125925. private _captureGPUFrameTime;
  125926. private _gpuFrameTimeToken;
  125927. private _gpuFrameTime;
  125928. private _captureShaderCompilationTime;
  125929. private _shaderCompilationTime;
  125930. private _onBeginFrameObserver;
  125931. private _onEndFrameObserver;
  125932. private _onBeforeShaderCompilationObserver;
  125933. private _onAfterShaderCompilationObserver;
  125934. /**
  125935. * Gets the perf counter used for GPU frame time
  125936. */
  125937. get gpuFrameTimeCounter(): PerfCounter;
  125938. /**
  125939. * Gets the GPU frame time capture status
  125940. */
  125941. get captureGPUFrameTime(): boolean;
  125942. /**
  125943. * Enable or disable the GPU frame time capture
  125944. */
  125945. set captureGPUFrameTime(value: boolean);
  125946. /**
  125947. * Gets the perf counter used for shader compilation time
  125948. */
  125949. get shaderCompilationTimeCounter(): PerfCounter;
  125950. /**
  125951. * Gets the shader compilation time capture status
  125952. */
  125953. get captureShaderCompilationTime(): boolean;
  125954. /**
  125955. * Enable or disable the shader compilation time capture
  125956. */
  125957. set captureShaderCompilationTime(value: boolean);
  125958. /**
  125959. * Instantiates a new engine instrumentation.
  125960. * This class can be used to get instrumentation data from a Babylon engine
  125961. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125962. * @param engine Defines the engine to instrument
  125963. */
  125964. constructor(
  125965. /**
  125966. * Define the instrumented engine.
  125967. */
  125968. engine: Engine);
  125969. /**
  125970. * Dispose and release associated resources.
  125971. */
  125972. dispose(): void;
  125973. }
  125974. }
  125975. declare module BABYLON {
  125976. /**
  125977. * This class can be used to get instrumentation data from a Babylon engine
  125978. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125979. */
  125980. export class SceneInstrumentation implements IDisposable {
  125981. /**
  125982. * Defines the scene to instrument
  125983. */
  125984. scene: Scene;
  125985. private _captureActiveMeshesEvaluationTime;
  125986. private _activeMeshesEvaluationTime;
  125987. private _captureRenderTargetsRenderTime;
  125988. private _renderTargetsRenderTime;
  125989. private _captureFrameTime;
  125990. private _frameTime;
  125991. private _captureRenderTime;
  125992. private _renderTime;
  125993. private _captureInterFrameTime;
  125994. private _interFrameTime;
  125995. private _captureParticlesRenderTime;
  125996. private _particlesRenderTime;
  125997. private _captureSpritesRenderTime;
  125998. private _spritesRenderTime;
  125999. private _capturePhysicsTime;
  126000. private _physicsTime;
  126001. private _captureAnimationsTime;
  126002. private _animationsTime;
  126003. private _captureCameraRenderTime;
  126004. private _cameraRenderTime;
  126005. private _onBeforeActiveMeshesEvaluationObserver;
  126006. private _onAfterActiveMeshesEvaluationObserver;
  126007. private _onBeforeRenderTargetsRenderObserver;
  126008. private _onAfterRenderTargetsRenderObserver;
  126009. private _onAfterRenderObserver;
  126010. private _onBeforeDrawPhaseObserver;
  126011. private _onAfterDrawPhaseObserver;
  126012. private _onBeforeAnimationsObserver;
  126013. private _onBeforeParticlesRenderingObserver;
  126014. private _onAfterParticlesRenderingObserver;
  126015. private _onBeforeSpritesRenderingObserver;
  126016. private _onAfterSpritesRenderingObserver;
  126017. private _onBeforePhysicsObserver;
  126018. private _onAfterPhysicsObserver;
  126019. private _onAfterAnimationsObserver;
  126020. private _onBeforeCameraRenderObserver;
  126021. private _onAfterCameraRenderObserver;
  126022. /**
  126023. * Gets the perf counter used for active meshes evaluation time
  126024. */
  126025. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  126026. /**
  126027. * Gets the active meshes evaluation time capture status
  126028. */
  126029. get captureActiveMeshesEvaluationTime(): boolean;
  126030. /**
  126031. * Enable or disable the active meshes evaluation time capture
  126032. */
  126033. set captureActiveMeshesEvaluationTime(value: boolean);
  126034. /**
  126035. * Gets the perf counter used for render targets render time
  126036. */
  126037. get renderTargetsRenderTimeCounter(): PerfCounter;
  126038. /**
  126039. * Gets the render targets render time capture status
  126040. */
  126041. get captureRenderTargetsRenderTime(): boolean;
  126042. /**
  126043. * Enable or disable the render targets render time capture
  126044. */
  126045. set captureRenderTargetsRenderTime(value: boolean);
  126046. /**
  126047. * Gets the perf counter used for particles render time
  126048. */
  126049. get particlesRenderTimeCounter(): PerfCounter;
  126050. /**
  126051. * Gets the particles render time capture status
  126052. */
  126053. get captureParticlesRenderTime(): boolean;
  126054. /**
  126055. * Enable or disable the particles render time capture
  126056. */
  126057. set captureParticlesRenderTime(value: boolean);
  126058. /**
  126059. * Gets the perf counter used for sprites render time
  126060. */
  126061. get spritesRenderTimeCounter(): PerfCounter;
  126062. /**
  126063. * Gets the sprites render time capture status
  126064. */
  126065. get captureSpritesRenderTime(): boolean;
  126066. /**
  126067. * Enable or disable the sprites render time capture
  126068. */
  126069. set captureSpritesRenderTime(value: boolean);
  126070. /**
  126071. * Gets the perf counter used for physics time
  126072. */
  126073. get physicsTimeCounter(): PerfCounter;
  126074. /**
  126075. * Gets the physics time capture status
  126076. */
  126077. get capturePhysicsTime(): boolean;
  126078. /**
  126079. * Enable or disable the physics time capture
  126080. */
  126081. set capturePhysicsTime(value: boolean);
  126082. /**
  126083. * Gets the perf counter used for animations time
  126084. */
  126085. get animationsTimeCounter(): PerfCounter;
  126086. /**
  126087. * Gets the animations time capture status
  126088. */
  126089. get captureAnimationsTime(): boolean;
  126090. /**
  126091. * Enable or disable the animations time capture
  126092. */
  126093. set captureAnimationsTime(value: boolean);
  126094. /**
  126095. * Gets the perf counter used for frame time capture
  126096. */
  126097. get frameTimeCounter(): PerfCounter;
  126098. /**
  126099. * Gets the frame time capture status
  126100. */
  126101. get captureFrameTime(): boolean;
  126102. /**
  126103. * Enable or disable the frame time capture
  126104. */
  126105. set captureFrameTime(value: boolean);
  126106. /**
  126107. * Gets the perf counter used for inter-frames time capture
  126108. */
  126109. get interFrameTimeCounter(): PerfCounter;
  126110. /**
  126111. * Gets the inter-frames time capture status
  126112. */
  126113. get captureInterFrameTime(): boolean;
  126114. /**
  126115. * Enable or disable the inter-frames time capture
  126116. */
  126117. set captureInterFrameTime(value: boolean);
  126118. /**
  126119. * Gets the perf counter used for render time capture
  126120. */
  126121. get renderTimeCounter(): PerfCounter;
  126122. /**
  126123. * Gets the render time capture status
  126124. */
  126125. get captureRenderTime(): boolean;
  126126. /**
  126127. * Enable or disable the render time capture
  126128. */
  126129. set captureRenderTime(value: boolean);
  126130. /**
  126131. * Gets the perf counter used for camera render time capture
  126132. */
  126133. get cameraRenderTimeCounter(): PerfCounter;
  126134. /**
  126135. * Gets the camera render time capture status
  126136. */
  126137. get captureCameraRenderTime(): boolean;
  126138. /**
  126139. * Enable or disable the camera render time capture
  126140. */
  126141. set captureCameraRenderTime(value: boolean);
  126142. /**
  126143. * Gets the perf counter used for draw calls
  126144. */
  126145. get drawCallsCounter(): PerfCounter;
  126146. /**
  126147. * Instantiates a new scene instrumentation.
  126148. * This class can be used to get instrumentation data from a Babylon engine
  126149. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  126150. * @param scene Defines the scene to instrument
  126151. */
  126152. constructor(
  126153. /**
  126154. * Defines the scene to instrument
  126155. */
  126156. scene: Scene);
  126157. /**
  126158. * Dispose and release associated resources.
  126159. */
  126160. dispose(): void;
  126161. }
  126162. }
  126163. declare module BABYLON {
  126164. /** @hidden */
  126165. export var glowMapGenerationPixelShader: {
  126166. name: string;
  126167. shader: string;
  126168. };
  126169. }
  126170. declare module BABYLON {
  126171. /** @hidden */
  126172. export var glowMapGenerationVertexShader: {
  126173. name: string;
  126174. shader: string;
  126175. };
  126176. }
  126177. declare module BABYLON {
  126178. /**
  126179. * Effect layer options. This helps customizing the behaviour
  126180. * of the effect layer.
  126181. */
  126182. export interface IEffectLayerOptions {
  126183. /**
  126184. * Multiplication factor apply to the canvas size to compute the render target size
  126185. * used to generated the objects (the smaller the faster).
  126186. */
  126187. mainTextureRatio: number;
  126188. /**
  126189. * Enforces a fixed size texture to ensure effect stability across devices.
  126190. */
  126191. mainTextureFixedSize?: number;
  126192. /**
  126193. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  126194. */
  126195. alphaBlendingMode: number;
  126196. /**
  126197. * The camera attached to the layer.
  126198. */
  126199. camera: Nullable<Camera>;
  126200. /**
  126201. * The rendering group to draw the layer in.
  126202. */
  126203. renderingGroupId: number;
  126204. }
  126205. /**
  126206. * The effect layer Helps adding post process effect blended with the main pass.
  126207. *
  126208. * This can be for instance use to generate glow or higlight effects on the scene.
  126209. *
  126210. * The effect layer class can not be used directly and is intented to inherited from to be
  126211. * customized per effects.
  126212. */
  126213. export abstract class EffectLayer {
  126214. private _vertexBuffers;
  126215. private _indexBuffer;
  126216. private _cachedDefines;
  126217. private _effectLayerMapGenerationEffect;
  126218. private _effectLayerOptions;
  126219. private _mergeEffect;
  126220. protected _scene: Scene;
  126221. protected _engine: Engine;
  126222. protected _maxSize: number;
  126223. protected _mainTextureDesiredSize: ISize;
  126224. protected _mainTexture: RenderTargetTexture;
  126225. protected _shouldRender: boolean;
  126226. protected _postProcesses: PostProcess[];
  126227. protected _textures: BaseTexture[];
  126228. protected _emissiveTextureAndColor: {
  126229. texture: Nullable<BaseTexture>;
  126230. color: Color4;
  126231. };
  126232. /**
  126233. * The name of the layer
  126234. */
  126235. name: string;
  126236. /**
  126237. * The clear color of the texture used to generate the glow map.
  126238. */
  126239. neutralColor: Color4;
  126240. /**
  126241. * Specifies whether the highlight layer is enabled or not.
  126242. */
  126243. isEnabled: boolean;
  126244. /**
  126245. * Gets the camera attached to the layer.
  126246. */
  126247. get camera(): Nullable<Camera>;
  126248. /**
  126249. * Gets the rendering group id the layer should render in.
  126250. */
  126251. get renderingGroupId(): number;
  126252. set renderingGroupId(renderingGroupId: number);
  126253. /**
  126254. * An event triggered when the effect layer has been disposed.
  126255. */
  126256. onDisposeObservable: Observable<EffectLayer>;
  126257. /**
  126258. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  126259. */
  126260. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  126261. /**
  126262. * An event triggered when the generated texture is being merged in the scene.
  126263. */
  126264. onBeforeComposeObservable: Observable<EffectLayer>;
  126265. /**
  126266. * An event triggered when the mesh is rendered into the effect render target.
  126267. */
  126268. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  126269. /**
  126270. * An event triggered after the mesh has been rendered into the effect render target.
  126271. */
  126272. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  126273. /**
  126274. * An event triggered when the generated texture has been merged in the scene.
  126275. */
  126276. onAfterComposeObservable: Observable<EffectLayer>;
  126277. /**
  126278. * An event triggered when the efffect layer changes its size.
  126279. */
  126280. onSizeChangedObservable: Observable<EffectLayer>;
  126281. /** @hidden */
  126282. static _SceneComponentInitialization: (scene: Scene) => void;
  126283. /**
  126284. * Instantiates a new effect Layer and references it in the scene.
  126285. * @param name The name of the layer
  126286. * @param scene The scene to use the layer in
  126287. */
  126288. constructor(
  126289. /** The Friendly of the effect in the scene */
  126290. name: string, scene: Scene);
  126291. /**
  126292. * Get the effect name of the layer.
  126293. * @return The effect name
  126294. */
  126295. abstract getEffectName(): string;
  126296. /**
  126297. * Checks for the readiness of the element composing the layer.
  126298. * @param subMesh the mesh to check for
  126299. * @param useInstances specify whether or not to use instances to render the mesh
  126300. * @return true if ready otherwise, false
  126301. */
  126302. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126303. /**
  126304. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126305. * @returns true if the effect requires stencil during the main canvas render pass.
  126306. */
  126307. abstract needStencil(): boolean;
  126308. /**
  126309. * Create the merge effect. This is the shader use to blit the information back
  126310. * to the main canvas at the end of the scene rendering.
  126311. * @returns The effect containing the shader used to merge the effect on the main canvas
  126312. */
  126313. protected abstract _createMergeEffect(): Effect;
  126314. /**
  126315. * Creates the render target textures and post processes used in the effect layer.
  126316. */
  126317. protected abstract _createTextureAndPostProcesses(): void;
  126318. /**
  126319. * Implementation specific of rendering the generating effect on the main canvas.
  126320. * @param effect The effect used to render through
  126321. */
  126322. protected abstract _internalRender(effect: Effect): void;
  126323. /**
  126324. * Sets the required values for both the emissive texture and and the main color.
  126325. */
  126326. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126327. /**
  126328. * Free any resources and references associated to a mesh.
  126329. * Internal use
  126330. * @param mesh The mesh to free.
  126331. */
  126332. abstract _disposeMesh(mesh: Mesh): void;
  126333. /**
  126334. * Serializes this layer (Glow or Highlight for example)
  126335. * @returns a serialized layer object
  126336. */
  126337. abstract serialize?(): any;
  126338. /**
  126339. * Initializes the effect layer with the required options.
  126340. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126341. */
  126342. protected _init(options: Partial<IEffectLayerOptions>): void;
  126343. /**
  126344. * Generates the index buffer of the full screen quad blending to the main canvas.
  126345. */
  126346. private _generateIndexBuffer;
  126347. /**
  126348. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126349. */
  126350. private _generateVertexBuffer;
  126351. /**
  126352. * Sets the main texture desired size which is the closest power of two
  126353. * of the engine canvas size.
  126354. */
  126355. private _setMainTextureSize;
  126356. /**
  126357. * Creates the main texture for the effect layer.
  126358. */
  126359. protected _createMainTexture(): void;
  126360. /**
  126361. * Adds specific effects defines.
  126362. * @param defines The defines to add specifics to.
  126363. */
  126364. protected _addCustomEffectDefines(defines: string[]): void;
  126365. /**
  126366. * Checks for the readiness of the element composing the layer.
  126367. * @param subMesh the mesh to check for
  126368. * @param useInstances specify whether or not to use instances to render the mesh
  126369. * @param emissiveTexture the associated emissive texture used to generate the glow
  126370. * @return true if ready otherwise, false
  126371. */
  126372. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126373. /**
  126374. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126375. */
  126376. render(): void;
  126377. /**
  126378. * Determine if a given mesh will be used in the current effect.
  126379. * @param mesh mesh to test
  126380. * @returns true if the mesh will be used
  126381. */
  126382. hasMesh(mesh: AbstractMesh): boolean;
  126383. /**
  126384. * Returns true if the layer contains information to display, otherwise false.
  126385. * @returns true if the glow layer should be rendered
  126386. */
  126387. shouldRender(): boolean;
  126388. /**
  126389. * Returns true if the mesh should render, otherwise false.
  126390. * @param mesh The mesh to render
  126391. * @returns true if it should render otherwise false
  126392. */
  126393. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126394. /**
  126395. * Returns true if the mesh can be rendered, otherwise false.
  126396. * @param mesh The mesh to render
  126397. * @param material The material used on the mesh
  126398. * @returns true if it can be rendered otherwise false
  126399. */
  126400. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126401. /**
  126402. * Returns true if the mesh should render, otherwise false.
  126403. * @param mesh The mesh to render
  126404. * @returns true if it should render otherwise false
  126405. */
  126406. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126407. /**
  126408. * Renders the submesh passed in parameter to the generation map.
  126409. */
  126410. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126411. /**
  126412. * Defines whether the current material of the mesh should be use to render the effect.
  126413. * @param mesh defines the current mesh to render
  126414. */
  126415. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126416. /**
  126417. * Rebuild the required buffers.
  126418. * @hidden Internal use only.
  126419. */
  126420. _rebuild(): void;
  126421. /**
  126422. * Dispose only the render target textures and post process.
  126423. */
  126424. private _disposeTextureAndPostProcesses;
  126425. /**
  126426. * Dispose the highlight layer and free resources.
  126427. */
  126428. dispose(): void;
  126429. /**
  126430. * Gets the class name of the effect layer
  126431. * @returns the string with the class name of the effect layer
  126432. */
  126433. getClassName(): string;
  126434. /**
  126435. * Creates an effect layer from parsed effect layer data
  126436. * @param parsedEffectLayer defines effect layer data
  126437. * @param scene defines the current scene
  126438. * @param rootUrl defines the root URL containing the effect layer information
  126439. * @returns a parsed effect Layer
  126440. */
  126441. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126442. }
  126443. }
  126444. declare module BABYLON {
  126445. interface AbstractScene {
  126446. /**
  126447. * The list of effect layers (highlights/glow) added to the scene
  126448. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126449. * @see http://doc.babylonjs.com/how_to/glow_layer
  126450. */
  126451. effectLayers: Array<EffectLayer>;
  126452. /**
  126453. * Removes the given effect layer from this scene.
  126454. * @param toRemove defines the effect layer to remove
  126455. * @returns the index of the removed effect layer
  126456. */
  126457. removeEffectLayer(toRemove: EffectLayer): number;
  126458. /**
  126459. * Adds the given effect layer to this scene
  126460. * @param newEffectLayer defines the effect layer to add
  126461. */
  126462. addEffectLayer(newEffectLayer: EffectLayer): void;
  126463. }
  126464. /**
  126465. * Defines the layer scene component responsible to manage any effect layers
  126466. * in a given scene.
  126467. */
  126468. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126469. /**
  126470. * The component name helpfull to identify the component in the list of scene components.
  126471. */
  126472. readonly name: string;
  126473. /**
  126474. * The scene the component belongs to.
  126475. */
  126476. scene: Scene;
  126477. private _engine;
  126478. private _renderEffects;
  126479. private _needStencil;
  126480. private _previousStencilState;
  126481. /**
  126482. * Creates a new instance of the component for the given scene
  126483. * @param scene Defines the scene to register the component in
  126484. */
  126485. constructor(scene: Scene);
  126486. /**
  126487. * Registers the component in a given scene
  126488. */
  126489. register(): void;
  126490. /**
  126491. * Rebuilds the elements related to this component in case of
  126492. * context lost for instance.
  126493. */
  126494. rebuild(): void;
  126495. /**
  126496. * Serializes the component data to the specified json object
  126497. * @param serializationObject The object to serialize to
  126498. */
  126499. serialize(serializationObject: any): void;
  126500. /**
  126501. * Adds all the elements from the container to the scene
  126502. * @param container the container holding the elements
  126503. */
  126504. addFromContainer(container: AbstractScene): void;
  126505. /**
  126506. * Removes all the elements in the container from the scene
  126507. * @param container contains the elements to remove
  126508. * @param dispose if the removed element should be disposed (default: false)
  126509. */
  126510. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126511. /**
  126512. * Disposes the component and the associated ressources.
  126513. */
  126514. dispose(): void;
  126515. private _isReadyForMesh;
  126516. private _renderMainTexture;
  126517. private _setStencil;
  126518. private _setStencilBack;
  126519. private _draw;
  126520. private _drawCamera;
  126521. private _drawRenderingGroup;
  126522. }
  126523. }
  126524. declare module BABYLON {
  126525. /** @hidden */
  126526. export var glowMapMergePixelShader: {
  126527. name: string;
  126528. shader: string;
  126529. };
  126530. }
  126531. declare module BABYLON {
  126532. /** @hidden */
  126533. export var glowMapMergeVertexShader: {
  126534. name: string;
  126535. shader: string;
  126536. };
  126537. }
  126538. declare module BABYLON {
  126539. interface AbstractScene {
  126540. /**
  126541. * Return a the first highlight layer of the scene with a given name.
  126542. * @param name The name of the highlight layer to look for.
  126543. * @return The highlight layer if found otherwise null.
  126544. */
  126545. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126546. }
  126547. /**
  126548. * Glow layer options. This helps customizing the behaviour
  126549. * of the glow layer.
  126550. */
  126551. export interface IGlowLayerOptions {
  126552. /**
  126553. * Multiplication factor apply to the canvas size to compute the render target size
  126554. * used to generated the glowing objects (the smaller the faster).
  126555. */
  126556. mainTextureRatio: number;
  126557. /**
  126558. * Enforces a fixed size texture to ensure resize independant blur.
  126559. */
  126560. mainTextureFixedSize?: number;
  126561. /**
  126562. * How big is the kernel of the blur texture.
  126563. */
  126564. blurKernelSize: number;
  126565. /**
  126566. * The camera attached to the layer.
  126567. */
  126568. camera: Nullable<Camera>;
  126569. /**
  126570. * Enable MSAA by chosing the number of samples.
  126571. */
  126572. mainTextureSamples?: number;
  126573. /**
  126574. * The rendering group to draw the layer in.
  126575. */
  126576. renderingGroupId: number;
  126577. }
  126578. /**
  126579. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126580. *
  126581. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126582. *
  126583. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126584. */
  126585. export class GlowLayer extends EffectLayer {
  126586. /**
  126587. * Effect Name of the layer.
  126588. */
  126589. static readonly EffectName: string;
  126590. /**
  126591. * The default blur kernel size used for the glow.
  126592. */
  126593. static DefaultBlurKernelSize: number;
  126594. /**
  126595. * The default texture size ratio used for the glow.
  126596. */
  126597. static DefaultTextureRatio: number;
  126598. /**
  126599. * Sets the kernel size of the blur.
  126600. */
  126601. set blurKernelSize(value: number);
  126602. /**
  126603. * Gets the kernel size of the blur.
  126604. */
  126605. get blurKernelSize(): number;
  126606. /**
  126607. * Sets the glow intensity.
  126608. */
  126609. set intensity(value: number);
  126610. /**
  126611. * Gets the glow intensity.
  126612. */
  126613. get intensity(): number;
  126614. private _options;
  126615. private _intensity;
  126616. private _horizontalBlurPostprocess1;
  126617. private _verticalBlurPostprocess1;
  126618. private _horizontalBlurPostprocess2;
  126619. private _verticalBlurPostprocess2;
  126620. private _blurTexture1;
  126621. private _blurTexture2;
  126622. private _postProcesses1;
  126623. private _postProcesses2;
  126624. private _includedOnlyMeshes;
  126625. private _excludedMeshes;
  126626. private _meshesUsingTheirOwnMaterials;
  126627. /**
  126628. * Callback used to let the user override the color selection on a per mesh basis
  126629. */
  126630. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126631. /**
  126632. * Callback used to let the user override the texture selection on a per mesh basis
  126633. */
  126634. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126635. /**
  126636. * Instantiates a new glow Layer and references it to the scene.
  126637. * @param name The name of the layer
  126638. * @param scene The scene to use the layer in
  126639. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126640. */
  126641. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126642. /**
  126643. * Get the effect name of the layer.
  126644. * @return The effect name
  126645. */
  126646. getEffectName(): string;
  126647. /**
  126648. * Create the merge effect. This is the shader use to blit the information back
  126649. * to the main canvas at the end of the scene rendering.
  126650. */
  126651. protected _createMergeEffect(): Effect;
  126652. /**
  126653. * Creates the render target textures and post processes used in the glow layer.
  126654. */
  126655. protected _createTextureAndPostProcesses(): void;
  126656. /**
  126657. * Checks for the readiness of the element composing the layer.
  126658. * @param subMesh the mesh to check for
  126659. * @param useInstances specify wether or not to use instances to render the mesh
  126660. * @param emissiveTexture the associated emissive texture used to generate the glow
  126661. * @return true if ready otherwise, false
  126662. */
  126663. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126664. /**
  126665. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126666. */
  126667. needStencil(): boolean;
  126668. /**
  126669. * Returns true if the mesh can be rendered, otherwise false.
  126670. * @param mesh The mesh to render
  126671. * @param material The material used on the mesh
  126672. * @returns true if it can be rendered otherwise false
  126673. */
  126674. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126675. /**
  126676. * Implementation specific of rendering the generating effect on the main canvas.
  126677. * @param effect The effect used to render through
  126678. */
  126679. protected _internalRender(effect: Effect): void;
  126680. /**
  126681. * Sets the required values for both the emissive texture and and the main color.
  126682. */
  126683. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126684. /**
  126685. * Returns true if the mesh should render, otherwise false.
  126686. * @param mesh The mesh to render
  126687. * @returns true if it should render otherwise false
  126688. */
  126689. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126690. /**
  126691. * Adds specific effects defines.
  126692. * @param defines The defines to add specifics to.
  126693. */
  126694. protected _addCustomEffectDefines(defines: string[]): void;
  126695. /**
  126696. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126697. * @param mesh The mesh to exclude from the glow layer
  126698. */
  126699. addExcludedMesh(mesh: Mesh): void;
  126700. /**
  126701. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126702. * @param mesh The mesh to remove
  126703. */
  126704. removeExcludedMesh(mesh: Mesh): void;
  126705. /**
  126706. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126707. * @param mesh The mesh to include in the glow layer
  126708. */
  126709. addIncludedOnlyMesh(mesh: Mesh): void;
  126710. /**
  126711. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126712. * @param mesh The mesh to remove
  126713. */
  126714. removeIncludedOnlyMesh(mesh: Mesh): void;
  126715. /**
  126716. * Determine if a given mesh will be used in the glow layer
  126717. * @param mesh The mesh to test
  126718. * @returns true if the mesh will be highlighted by the current glow layer
  126719. */
  126720. hasMesh(mesh: AbstractMesh): boolean;
  126721. /**
  126722. * Defines whether the current material of the mesh should be use to render the effect.
  126723. * @param mesh defines the current mesh to render
  126724. */
  126725. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126726. /**
  126727. * Add a mesh to be rendered through its own material and not with emissive only.
  126728. * @param mesh The mesh for which we need to use its material
  126729. */
  126730. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126731. /**
  126732. * Remove a mesh from being rendered through its own material and not with emissive only.
  126733. * @param mesh The mesh for which we need to not use its material
  126734. */
  126735. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126736. /**
  126737. * Free any resources and references associated to a mesh.
  126738. * Internal use
  126739. * @param mesh The mesh to free.
  126740. * @hidden
  126741. */
  126742. _disposeMesh(mesh: Mesh): void;
  126743. /**
  126744. * Gets the class name of the effect layer
  126745. * @returns the string with the class name of the effect layer
  126746. */
  126747. getClassName(): string;
  126748. /**
  126749. * Serializes this glow layer
  126750. * @returns a serialized glow layer object
  126751. */
  126752. serialize(): any;
  126753. /**
  126754. * Creates a Glow Layer from parsed glow layer data
  126755. * @param parsedGlowLayer defines glow layer data
  126756. * @param scene defines the current scene
  126757. * @param rootUrl defines the root URL containing the glow layer information
  126758. * @returns a parsed Glow Layer
  126759. */
  126760. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126761. }
  126762. }
  126763. declare module BABYLON {
  126764. /** @hidden */
  126765. export var glowBlurPostProcessPixelShader: {
  126766. name: string;
  126767. shader: string;
  126768. };
  126769. }
  126770. declare module BABYLON {
  126771. interface AbstractScene {
  126772. /**
  126773. * Return a the first highlight layer of the scene with a given name.
  126774. * @param name The name of the highlight layer to look for.
  126775. * @return The highlight layer if found otherwise null.
  126776. */
  126777. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126778. }
  126779. /**
  126780. * Highlight layer options. This helps customizing the behaviour
  126781. * of the highlight layer.
  126782. */
  126783. export interface IHighlightLayerOptions {
  126784. /**
  126785. * Multiplication factor apply to the canvas size to compute the render target size
  126786. * used to generated the glowing objects (the smaller the faster).
  126787. */
  126788. mainTextureRatio: number;
  126789. /**
  126790. * Enforces a fixed size texture to ensure resize independant blur.
  126791. */
  126792. mainTextureFixedSize?: number;
  126793. /**
  126794. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126795. * of the picture to blur (the smaller the faster).
  126796. */
  126797. blurTextureSizeRatio: number;
  126798. /**
  126799. * How big in texel of the blur texture is the vertical blur.
  126800. */
  126801. blurVerticalSize: number;
  126802. /**
  126803. * How big in texel of the blur texture is the horizontal blur.
  126804. */
  126805. blurHorizontalSize: number;
  126806. /**
  126807. * Alpha blending mode used to apply the blur. Default is combine.
  126808. */
  126809. alphaBlendingMode: number;
  126810. /**
  126811. * The camera attached to the layer.
  126812. */
  126813. camera: Nullable<Camera>;
  126814. /**
  126815. * Should we display highlight as a solid stroke?
  126816. */
  126817. isStroke?: boolean;
  126818. /**
  126819. * The rendering group to draw the layer in.
  126820. */
  126821. renderingGroupId: number;
  126822. }
  126823. /**
  126824. * The highlight layer Helps adding a glow effect around a mesh.
  126825. *
  126826. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126827. * glowy meshes to your scene.
  126828. *
  126829. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126830. */
  126831. export class HighlightLayer extends EffectLayer {
  126832. name: string;
  126833. /**
  126834. * Effect Name of the highlight layer.
  126835. */
  126836. static readonly EffectName: string;
  126837. /**
  126838. * The neutral color used during the preparation of the glow effect.
  126839. * This is black by default as the blend operation is a blend operation.
  126840. */
  126841. static NeutralColor: Color4;
  126842. /**
  126843. * Stencil value used for glowing meshes.
  126844. */
  126845. static GlowingMeshStencilReference: number;
  126846. /**
  126847. * Stencil value used for the other meshes in the scene.
  126848. */
  126849. static NormalMeshStencilReference: number;
  126850. /**
  126851. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126852. */
  126853. innerGlow: boolean;
  126854. /**
  126855. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126856. */
  126857. outerGlow: boolean;
  126858. /**
  126859. * Specifies the horizontal size of the blur.
  126860. */
  126861. set blurHorizontalSize(value: number);
  126862. /**
  126863. * Specifies the vertical size of the blur.
  126864. */
  126865. set blurVerticalSize(value: number);
  126866. /**
  126867. * Gets the horizontal size of the blur.
  126868. */
  126869. get blurHorizontalSize(): number;
  126870. /**
  126871. * Gets the vertical size of the blur.
  126872. */
  126873. get blurVerticalSize(): number;
  126874. /**
  126875. * An event triggered when the highlight layer is being blurred.
  126876. */
  126877. onBeforeBlurObservable: Observable<HighlightLayer>;
  126878. /**
  126879. * An event triggered when the highlight layer has been blurred.
  126880. */
  126881. onAfterBlurObservable: Observable<HighlightLayer>;
  126882. private _instanceGlowingMeshStencilReference;
  126883. private _options;
  126884. private _downSamplePostprocess;
  126885. private _horizontalBlurPostprocess;
  126886. private _verticalBlurPostprocess;
  126887. private _blurTexture;
  126888. private _meshes;
  126889. private _excludedMeshes;
  126890. /**
  126891. * Instantiates a new highlight Layer and references it to the scene..
  126892. * @param name The name of the layer
  126893. * @param scene The scene to use the layer in
  126894. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126895. */
  126896. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126897. /**
  126898. * Get the effect name of the layer.
  126899. * @return The effect name
  126900. */
  126901. getEffectName(): string;
  126902. /**
  126903. * Create the merge effect. This is the shader use to blit the information back
  126904. * to the main canvas at the end of the scene rendering.
  126905. */
  126906. protected _createMergeEffect(): Effect;
  126907. /**
  126908. * Creates the render target textures and post processes used in the highlight layer.
  126909. */
  126910. protected _createTextureAndPostProcesses(): void;
  126911. /**
  126912. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126913. */
  126914. needStencil(): boolean;
  126915. /**
  126916. * Checks for the readiness of the element composing the layer.
  126917. * @param subMesh the mesh to check for
  126918. * @param useInstances specify wether or not to use instances to render the mesh
  126919. * @param emissiveTexture the associated emissive texture used to generate the glow
  126920. * @return true if ready otherwise, false
  126921. */
  126922. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126923. /**
  126924. * Implementation specific of rendering the generating effect on the main canvas.
  126925. * @param effect The effect used to render through
  126926. */
  126927. protected _internalRender(effect: Effect): void;
  126928. /**
  126929. * Returns true if the layer contains information to display, otherwise false.
  126930. */
  126931. shouldRender(): boolean;
  126932. /**
  126933. * Returns true if the mesh should render, otherwise false.
  126934. * @param mesh The mesh to render
  126935. * @returns true if it should render otherwise false
  126936. */
  126937. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126938. /**
  126939. * Sets the required values for both the emissive texture and and the main color.
  126940. */
  126941. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126942. /**
  126943. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126944. * @param mesh The mesh to exclude from the highlight layer
  126945. */
  126946. addExcludedMesh(mesh: Mesh): void;
  126947. /**
  126948. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126949. * @param mesh The mesh to highlight
  126950. */
  126951. removeExcludedMesh(mesh: Mesh): void;
  126952. /**
  126953. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126954. * @param mesh mesh to test
  126955. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126956. */
  126957. hasMesh(mesh: AbstractMesh): boolean;
  126958. /**
  126959. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126960. * @param mesh The mesh to highlight
  126961. * @param color The color of the highlight
  126962. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126963. */
  126964. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126965. /**
  126966. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126967. * @param mesh The mesh to highlight
  126968. */
  126969. removeMesh(mesh: Mesh): void;
  126970. /**
  126971. * Remove all the meshes currently referenced in the highlight layer
  126972. */
  126973. removeAllMeshes(): void;
  126974. /**
  126975. * Force the stencil to the normal expected value for none glowing parts
  126976. */
  126977. private _defaultStencilReference;
  126978. /**
  126979. * Free any resources and references associated to a mesh.
  126980. * Internal use
  126981. * @param mesh The mesh to free.
  126982. * @hidden
  126983. */
  126984. _disposeMesh(mesh: Mesh): void;
  126985. /**
  126986. * Dispose the highlight layer and free resources.
  126987. */
  126988. dispose(): void;
  126989. /**
  126990. * Gets the class name of the effect layer
  126991. * @returns the string with the class name of the effect layer
  126992. */
  126993. getClassName(): string;
  126994. /**
  126995. * Serializes this Highlight layer
  126996. * @returns a serialized Highlight layer object
  126997. */
  126998. serialize(): any;
  126999. /**
  127000. * Creates a Highlight layer from parsed Highlight layer data
  127001. * @param parsedHightlightLayer defines the Highlight layer data
  127002. * @param scene defines the current scene
  127003. * @param rootUrl defines the root URL containing the Highlight layer information
  127004. * @returns a parsed Highlight layer
  127005. */
  127006. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  127007. }
  127008. }
  127009. declare module BABYLON {
  127010. interface AbstractScene {
  127011. /**
  127012. * The list of layers (background and foreground) of the scene
  127013. */
  127014. layers: Array<Layer>;
  127015. }
  127016. /**
  127017. * Defines the layer scene component responsible to manage any layers
  127018. * in a given scene.
  127019. */
  127020. export class LayerSceneComponent implements ISceneComponent {
  127021. /**
  127022. * The component name helpfull to identify the component in the list of scene components.
  127023. */
  127024. readonly name: string;
  127025. /**
  127026. * The scene the component belongs to.
  127027. */
  127028. scene: Scene;
  127029. private _engine;
  127030. /**
  127031. * Creates a new instance of the component for the given scene
  127032. * @param scene Defines the scene to register the component in
  127033. */
  127034. constructor(scene: Scene);
  127035. /**
  127036. * Registers the component in a given scene
  127037. */
  127038. register(): void;
  127039. /**
  127040. * Rebuilds the elements related to this component in case of
  127041. * context lost for instance.
  127042. */
  127043. rebuild(): void;
  127044. /**
  127045. * Disposes the component and the associated ressources.
  127046. */
  127047. dispose(): void;
  127048. private _draw;
  127049. private _drawCameraPredicate;
  127050. private _drawCameraBackground;
  127051. private _drawCameraForeground;
  127052. private _drawRenderTargetPredicate;
  127053. private _drawRenderTargetBackground;
  127054. private _drawRenderTargetForeground;
  127055. /**
  127056. * Adds all the elements from the container to the scene
  127057. * @param container the container holding the elements
  127058. */
  127059. addFromContainer(container: AbstractScene): void;
  127060. /**
  127061. * Removes all the elements in the container from the scene
  127062. * @param container contains the elements to remove
  127063. * @param dispose if the removed element should be disposed (default: false)
  127064. */
  127065. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127066. }
  127067. }
  127068. declare module BABYLON {
  127069. /** @hidden */
  127070. export var layerPixelShader: {
  127071. name: string;
  127072. shader: string;
  127073. };
  127074. }
  127075. declare module BABYLON {
  127076. /** @hidden */
  127077. export var layerVertexShader: {
  127078. name: string;
  127079. shader: string;
  127080. };
  127081. }
  127082. declare module BABYLON {
  127083. /**
  127084. * This represents a full screen 2d layer.
  127085. * This can be useful to display a picture in the background of your scene for instance.
  127086. * @see https://www.babylonjs-playground.com/#08A2BS#1
  127087. */
  127088. export class Layer {
  127089. /**
  127090. * Define the name of the layer.
  127091. */
  127092. name: string;
  127093. /**
  127094. * Define the texture the layer should display.
  127095. */
  127096. texture: Nullable<Texture>;
  127097. /**
  127098. * Is the layer in background or foreground.
  127099. */
  127100. isBackground: boolean;
  127101. /**
  127102. * Define the color of the layer (instead of texture).
  127103. */
  127104. color: Color4;
  127105. /**
  127106. * Define the scale of the layer in order to zoom in out of the texture.
  127107. */
  127108. scale: Vector2;
  127109. /**
  127110. * Define an offset for the layer in order to shift the texture.
  127111. */
  127112. offset: Vector2;
  127113. /**
  127114. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  127115. */
  127116. alphaBlendingMode: number;
  127117. /**
  127118. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  127119. * Alpha test will not mix with the background color in case of transparency.
  127120. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  127121. */
  127122. alphaTest: boolean;
  127123. /**
  127124. * Define a mask to restrict the layer to only some of the scene cameras.
  127125. */
  127126. layerMask: number;
  127127. /**
  127128. * Define the list of render target the layer is visible into.
  127129. */
  127130. renderTargetTextures: RenderTargetTexture[];
  127131. /**
  127132. * Define if the layer is only used in renderTarget or if it also
  127133. * renders in the main frame buffer of the canvas.
  127134. */
  127135. renderOnlyInRenderTargetTextures: boolean;
  127136. private _scene;
  127137. private _vertexBuffers;
  127138. private _indexBuffer;
  127139. private _effect;
  127140. private _previousDefines;
  127141. /**
  127142. * An event triggered when the layer is disposed.
  127143. */
  127144. onDisposeObservable: Observable<Layer>;
  127145. private _onDisposeObserver;
  127146. /**
  127147. * Back compatibility with callback before the onDisposeObservable existed.
  127148. * The set callback will be triggered when the layer has been disposed.
  127149. */
  127150. set onDispose(callback: () => void);
  127151. /**
  127152. * An event triggered before rendering the scene
  127153. */
  127154. onBeforeRenderObservable: Observable<Layer>;
  127155. private _onBeforeRenderObserver;
  127156. /**
  127157. * Back compatibility with callback before the onBeforeRenderObservable existed.
  127158. * The set callback will be triggered just before rendering the layer.
  127159. */
  127160. set onBeforeRender(callback: () => void);
  127161. /**
  127162. * An event triggered after rendering the scene
  127163. */
  127164. onAfterRenderObservable: Observable<Layer>;
  127165. private _onAfterRenderObserver;
  127166. /**
  127167. * Back compatibility with callback before the onAfterRenderObservable existed.
  127168. * The set callback will be triggered just after rendering the layer.
  127169. */
  127170. set onAfterRender(callback: () => void);
  127171. /**
  127172. * Instantiates a new layer.
  127173. * This represents a full screen 2d layer.
  127174. * This can be useful to display a picture in the background of your scene for instance.
  127175. * @see https://www.babylonjs-playground.com/#08A2BS#1
  127176. * @param name Define the name of the layer in the scene
  127177. * @param imgUrl Define the url of the texture to display in the layer
  127178. * @param scene Define the scene the layer belongs to
  127179. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  127180. * @param color Defines a color for the layer
  127181. */
  127182. constructor(
  127183. /**
  127184. * Define the name of the layer.
  127185. */
  127186. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  127187. private _createIndexBuffer;
  127188. /** @hidden */
  127189. _rebuild(): void;
  127190. /**
  127191. * Renders the layer in the scene.
  127192. */
  127193. render(): void;
  127194. /**
  127195. * Disposes and releases the associated ressources.
  127196. */
  127197. dispose(): void;
  127198. }
  127199. }
  127200. declare module BABYLON {
  127201. /** @hidden */
  127202. export var lensFlarePixelShader: {
  127203. name: string;
  127204. shader: string;
  127205. };
  127206. }
  127207. declare module BABYLON {
  127208. /** @hidden */
  127209. export var lensFlareVertexShader: {
  127210. name: string;
  127211. shader: string;
  127212. };
  127213. }
  127214. declare module BABYLON {
  127215. /**
  127216. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127217. * It is usually composed of several `lensFlare`.
  127218. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127219. */
  127220. export class LensFlareSystem {
  127221. /**
  127222. * Define the name of the lens flare system
  127223. */
  127224. name: string;
  127225. /**
  127226. * List of lens flares used in this system.
  127227. */
  127228. lensFlares: LensFlare[];
  127229. /**
  127230. * Define a limit from the border the lens flare can be visible.
  127231. */
  127232. borderLimit: number;
  127233. /**
  127234. * Define a viewport border we do not want to see the lens flare in.
  127235. */
  127236. viewportBorder: number;
  127237. /**
  127238. * Define a predicate which could limit the list of meshes able to occlude the effect.
  127239. */
  127240. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127241. /**
  127242. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  127243. */
  127244. layerMask: number;
  127245. /**
  127246. * Define the id of the lens flare system in the scene.
  127247. * (equal to name by default)
  127248. */
  127249. id: string;
  127250. private _scene;
  127251. private _emitter;
  127252. private _vertexBuffers;
  127253. private _indexBuffer;
  127254. private _effect;
  127255. private _positionX;
  127256. private _positionY;
  127257. private _isEnabled;
  127258. /** @hidden */
  127259. static _SceneComponentInitialization: (scene: Scene) => void;
  127260. /**
  127261. * Instantiates a lens flare system.
  127262. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127263. * It is usually composed of several `lensFlare`.
  127264. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127265. * @param name Define the name of the lens flare system in the scene
  127266. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  127267. * @param scene Define the scene the lens flare system belongs to
  127268. */
  127269. constructor(
  127270. /**
  127271. * Define the name of the lens flare system
  127272. */
  127273. name: string, emitter: any, scene: Scene);
  127274. /**
  127275. * Define if the lens flare system is enabled.
  127276. */
  127277. get isEnabled(): boolean;
  127278. set isEnabled(value: boolean);
  127279. /**
  127280. * Get the scene the effects belongs to.
  127281. * @returns the scene holding the lens flare system
  127282. */
  127283. getScene(): Scene;
  127284. /**
  127285. * Get the emitter of the lens flare system.
  127286. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127287. * @returns the emitter of the lens flare system
  127288. */
  127289. getEmitter(): any;
  127290. /**
  127291. * Set the emitter of the lens flare system.
  127292. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127293. * @param newEmitter Define the new emitter of the system
  127294. */
  127295. setEmitter(newEmitter: any): void;
  127296. /**
  127297. * Get the lens flare system emitter position.
  127298. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  127299. * @returns the position
  127300. */
  127301. getEmitterPosition(): Vector3;
  127302. /**
  127303. * @hidden
  127304. */
  127305. computeEffectivePosition(globalViewport: Viewport): boolean;
  127306. /** @hidden */
  127307. _isVisible(): boolean;
  127308. /**
  127309. * @hidden
  127310. */
  127311. render(): boolean;
  127312. /**
  127313. * Dispose and release the lens flare with its associated resources.
  127314. */
  127315. dispose(): void;
  127316. /**
  127317. * Parse a lens flare system from a JSON repressentation
  127318. * @param parsedLensFlareSystem Define the JSON to parse
  127319. * @param scene Define the scene the parsed system should be instantiated in
  127320. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127321. * @returns the parsed system
  127322. */
  127323. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127324. /**
  127325. * Serialize the current Lens Flare System into a JSON representation.
  127326. * @returns the serialized JSON
  127327. */
  127328. serialize(): any;
  127329. }
  127330. }
  127331. declare module BABYLON {
  127332. /**
  127333. * This represents one of the lens effect in a `lensFlareSystem`.
  127334. * It controls one of the indiviual texture used in the effect.
  127335. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127336. */
  127337. export class LensFlare {
  127338. /**
  127339. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127340. */
  127341. size: number;
  127342. /**
  127343. * 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.
  127344. */
  127345. position: number;
  127346. /**
  127347. * Define the lens color.
  127348. */
  127349. color: Color3;
  127350. /**
  127351. * Define the lens texture.
  127352. */
  127353. texture: Nullable<Texture>;
  127354. /**
  127355. * Define the alpha mode to render this particular lens.
  127356. */
  127357. alphaMode: number;
  127358. private _system;
  127359. /**
  127360. * Creates a new Lens Flare.
  127361. * This represents one of the lens effect in a `lensFlareSystem`.
  127362. * It controls one of the indiviual texture used in the effect.
  127363. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127364. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127365. * @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.
  127366. * @param color Define the lens color
  127367. * @param imgUrl Define the lens texture url
  127368. * @param system Define the `lensFlareSystem` this flare is part of
  127369. * @returns The newly created Lens Flare
  127370. */
  127371. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127372. /**
  127373. * Instantiates a new Lens Flare.
  127374. * This represents one of the lens effect in a `lensFlareSystem`.
  127375. * It controls one of the indiviual texture used in the effect.
  127376. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127377. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127378. * @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.
  127379. * @param color Define the lens color
  127380. * @param imgUrl Define the lens texture url
  127381. * @param system Define the `lensFlareSystem` this flare is part of
  127382. */
  127383. constructor(
  127384. /**
  127385. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127386. */
  127387. size: number,
  127388. /**
  127389. * 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.
  127390. */
  127391. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127392. /**
  127393. * Dispose and release the lens flare with its associated resources.
  127394. */
  127395. dispose(): void;
  127396. }
  127397. }
  127398. declare module BABYLON {
  127399. interface AbstractScene {
  127400. /**
  127401. * The list of lens flare system added to the scene
  127402. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127403. */
  127404. lensFlareSystems: Array<LensFlareSystem>;
  127405. /**
  127406. * Removes the given lens flare system from this scene.
  127407. * @param toRemove The lens flare system to remove
  127408. * @returns The index of the removed lens flare system
  127409. */
  127410. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127411. /**
  127412. * Adds the given lens flare system to this scene
  127413. * @param newLensFlareSystem The lens flare system to add
  127414. */
  127415. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127416. /**
  127417. * Gets a lens flare system using its name
  127418. * @param name defines the name to look for
  127419. * @returns the lens flare system or null if not found
  127420. */
  127421. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127422. /**
  127423. * Gets a lens flare system using its id
  127424. * @param id defines the id to look for
  127425. * @returns the lens flare system or null if not found
  127426. */
  127427. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127428. }
  127429. /**
  127430. * Defines the lens flare scene component responsible to manage any lens flares
  127431. * in a given scene.
  127432. */
  127433. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127434. /**
  127435. * The component name helpfull to identify the component in the list of scene components.
  127436. */
  127437. readonly name: string;
  127438. /**
  127439. * The scene the component belongs to.
  127440. */
  127441. scene: Scene;
  127442. /**
  127443. * Creates a new instance of the component for the given scene
  127444. * @param scene Defines the scene to register the component in
  127445. */
  127446. constructor(scene: Scene);
  127447. /**
  127448. * Registers the component in a given scene
  127449. */
  127450. register(): void;
  127451. /**
  127452. * Rebuilds the elements related to this component in case of
  127453. * context lost for instance.
  127454. */
  127455. rebuild(): void;
  127456. /**
  127457. * Adds all the elements from the container to the scene
  127458. * @param container the container holding the elements
  127459. */
  127460. addFromContainer(container: AbstractScene): void;
  127461. /**
  127462. * Removes all the elements in the container from the scene
  127463. * @param container contains the elements to remove
  127464. * @param dispose if the removed element should be disposed (default: false)
  127465. */
  127466. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127467. /**
  127468. * Serializes the component data to the specified json object
  127469. * @param serializationObject The object to serialize to
  127470. */
  127471. serialize(serializationObject: any): void;
  127472. /**
  127473. * Disposes the component and the associated ressources.
  127474. */
  127475. dispose(): void;
  127476. private _draw;
  127477. }
  127478. }
  127479. declare module BABYLON {
  127480. /** @hidden */
  127481. export var depthPixelShader: {
  127482. name: string;
  127483. shader: string;
  127484. };
  127485. }
  127486. declare module BABYLON {
  127487. /** @hidden */
  127488. export var depthVertexShader: {
  127489. name: string;
  127490. shader: string;
  127491. };
  127492. }
  127493. declare module BABYLON {
  127494. /**
  127495. * This represents a depth renderer in Babylon.
  127496. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127497. */
  127498. export class DepthRenderer {
  127499. private _scene;
  127500. private _depthMap;
  127501. private _effect;
  127502. private readonly _storeNonLinearDepth;
  127503. private readonly _clearColor;
  127504. /** Get if the depth renderer is using packed depth or not */
  127505. readonly isPacked: boolean;
  127506. private _cachedDefines;
  127507. private _camera;
  127508. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127509. enabled: boolean;
  127510. /**
  127511. * Specifiess that the depth renderer will only be used within
  127512. * the camera it is created for.
  127513. * This can help forcing its rendering during the camera processing.
  127514. */
  127515. useOnlyInActiveCamera: boolean;
  127516. /** @hidden */
  127517. static _SceneComponentInitialization: (scene: Scene) => void;
  127518. /**
  127519. * Instantiates a depth renderer
  127520. * @param scene The scene the renderer belongs to
  127521. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127522. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127523. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127524. */
  127525. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127526. /**
  127527. * Creates the depth rendering effect and checks if the effect is ready.
  127528. * @param subMesh The submesh to be used to render the depth map of
  127529. * @param useInstances If multiple world instances should be used
  127530. * @returns if the depth renderer is ready to render the depth map
  127531. */
  127532. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127533. /**
  127534. * Gets the texture which the depth map will be written to.
  127535. * @returns The depth map texture
  127536. */
  127537. getDepthMap(): RenderTargetTexture;
  127538. /**
  127539. * Disposes of the depth renderer.
  127540. */
  127541. dispose(): void;
  127542. }
  127543. }
  127544. declare module BABYLON {
  127545. /** @hidden */
  127546. export var minmaxReduxPixelShader: {
  127547. name: string;
  127548. shader: string;
  127549. };
  127550. }
  127551. declare module BABYLON {
  127552. /**
  127553. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127554. * and maximum values from all values of the texture.
  127555. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127556. * The source values are read from the red channel of the texture.
  127557. */
  127558. export class MinMaxReducer {
  127559. /**
  127560. * Observable triggered when the computation has been performed
  127561. */
  127562. onAfterReductionPerformed: Observable<{
  127563. min: number;
  127564. max: number;
  127565. }>;
  127566. protected _camera: Camera;
  127567. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127568. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127569. protected _postProcessManager: PostProcessManager;
  127570. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127571. protected _forceFullscreenViewport: boolean;
  127572. /**
  127573. * Creates a min/max reducer
  127574. * @param camera The camera to use for the post processes
  127575. */
  127576. constructor(camera: Camera);
  127577. /**
  127578. * Gets the texture used to read the values from.
  127579. */
  127580. get sourceTexture(): Nullable<RenderTargetTexture>;
  127581. /**
  127582. * Sets the source texture to read the values from.
  127583. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127584. * because in such textures '1' value must not be taken into account to compute the maximum
  127585. * as this value is used to clear the texture.
  127586. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127587. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127588. * @param depthRedux Indicates if the texture is a depth texture or not
  127589. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127590. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127591. */
  127592. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127593. /**
  127594. * Defines the refresh rate of the computation.
  127595. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127596. */
  127597. get refreshRate(): number;
  127598. set refreshRate(value: number);
  127599. protected _activated: boolean;
  127600. /**
  127601. * Gets the activation status of the reducer
  127602. */
  127603. get activated(): boolean;
  127604. /**
  127605. * Activates the reduction computation.
  127606. * When activated, the observers registered in onAfterReductionPerformed are
  127607. * called after the compuation is performed
  127608. */
  127609. activate(): void;
  127610. /**
  127611. * Deactivates the reduction computation.
  127612. */
  127613. deactivate(): void;
  127614. /**
  127615. * Disposes the min/max reducer
  127616. * @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.
  127617. */
  127618. dispose(disposeAll?: boolean): void;
  127619. }
  127620. }
  127621. declare module BABYLON {
  127622. /**
  127623. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127624. */
  127625. export class DepthReducer extends MinMaxReducer {
  127626. private _depthRenderer;
  127627. private _depthRendererId;
  127628. /**
  127629. * Gets the depth renderer used for the computation.
  127630. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127631. */
  127632. get depthRenderer(): Nullable<DepthRenderer>;
  127633. /**
  127634. * Creates a depth reducer
  127635. * @param camera The camera used to render the depth texture
  127636. */
  127637. constructor(camera: Camera);
  127638. /**
  127639. * Sets the depth renderer to use to generate the depth map
  127640. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127641. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127642. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127643. */
  127644. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127645. /** @hidden */
  127646. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127647. /**
  127648. * Activates the reduction computation.
  127649. * When activated, the observers registered in onAfterReductionPerformed are
  127650. * called after the compuation is performed
  127651. */
  127652. activate(): void;
  127653. /**
  127654. * Deactivates the reduction computation.
  127655. */
  127656. deactivate(): void;
  127657. /**
  127658. * Disposes the depth reducer
  127659. * @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.
  127660. */
  127661. dispose(disposeAll?: boolean): void;
  127662. }
  127663. }
  127664. declare module BABYLON {
  127665. /**
  127666. * A CSM implementation allowing casting shadows on large scenes.
  127667. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127668. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127669. */
  127670. export class CascadedShadowGenerator extends ShadowGenerator {
  127671. private static readonly frustumCornersNDCSpace;
  127672. /**
  127673. * Name of the CSM class
  127674. */
  127675. static CLASSNAME: string;
  127676. /**
  127677. * Defines the default number of cascades used by the CSM.
  127678. */
  127679. static readonly DEFAULT_CASCADES_COUNT: number;
  127680. /**
  127681. * Defines the minimum number of cascades used by the CSM.
  127682. */
  127683. static readonly MIN_CASCADES_COUNT: number;
  127684. /**
  127685. * Defines the maximum number of cascades used by the CSM.
  127686. */
  127687. static readonly MAX_CASCADES_COUNT: number;
  127688. protected _validateFilter(filter: number): number;
  127689. /**
  127690. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127691. */
  127692. penumbraDarkness: number;
  127693. private _numCascades;
  127694. /**
  127695. * Gets or set the number of cascades used by the CSM.
  127696. */
  127697. get numCascades(): number;
  127698. set numCascades(value: number);
  127699. /**
  127700. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127701. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127702. */
  127703. stabilizeCascades: boolean;
  127704. private _freezeShadowCastersBoundingInfo;
  127705. private _freezeShadowCastersBoundingInfoObservable;
  127706. /**
  127707. * Enables or disables the shadow casters bounding info computation.
  127708. * If your shadow casters don't move, you can disable this feature.
  127709. * If it is enabled, the bounding box computation is done every frame.
  127710. */
  127711. get freezeShadowCastersBoundingInfo(): boolean;
  127712. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127713. private _scbiMin;
  127714. private _scbiMax;
  127715. protected _computeShadowCastersBoundingInfo(): void;
  127716. protected _shadowCastersBoundingInfo: BoundingInfo;
  127717. /**
  127718. * Gets or sets the shadow casters bounding info.
  127719. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127720. * so that the system won't overwrite the bounds you provide
  127721. */
  127722. get shadowCastersBoundingInfo(): BoundingInfo;
  127723. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127724. protected _breaksAreDirty: boolean;
  127725. protected _minDistance: number;
  127726. protected _maxDistance: number;
  127727. /**
  127728. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127729. *
  127730. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127731. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127732. * @param min minimal distance for the breaks (default to 0.)
  127733. * @param max maximal distance for the breaks (default to 1.)
  127734. */
  127735. setMinMaxDistance(min: number, max: number): void;
  127736. /** Gets the minimal distance used in the cascade break computation */
  127737. get minDistance(): number;
  127738. /** Gets the maximal distance used in the cascade break computation */
  127739. get maxDistance(): number;
  127740. /**
  127741. * Gets the class name of that object
  127742. * @returns "CascadedShadowGenerator"
  127743. */
  127744. getClassName(): string;
  127745. private _cascadeMinExtents;
  127746. private _cascadeMaxExtents;
  127747. /**
  127748. * Gets a cascade minimum extents
  127749. * @param cascadeIndex index of the cascade
  127750. * @returns the minimum cascade extents
  127751. */
  127752. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127753. /**
  127754. * Gets a cascade maximum extents
  127755. * @param cascadeIndex index of the cascade
  127756. * @returns the maximum cascade extents
  127757. */
  127758. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127759. private _cascades;
  127760. private _currentLayer;
  127761. private _viewSpaceFrustumsZ;
  127762. private _viewMatrices;
  127763. private _projectionMatrices;
  127764. private _transformMatrices;
  127765. private _transformMatricesAsArray;
  127766. private _frustumLengths;
  127767. private _lightSizeUVCorrection;
  127768. private _depthCorrection;
  127769. private _frustumCornersWorldSpace;
  127770. private _frustumCenter;
  127771. private _shadowCameraPos;
  127772. private _shadowMaxZ;
  127773. /**
  127774. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127775. * It defaults to camera.maxZ
  127776. */
  127777. get shadowMaxZ(): number;
  127778. /**
  127779. * Sets the shadow max z distance.
  127780. */
  127781. set shadowMaxZ(value: number);
  127782. protected _debug: boolean;
  127783. /**
  127784. * Gets or sets the debug flag.
  127785. * When enabled, the cascades are materialized by different colors on the screen.
  127786. */
  127787. get debug(): boolean;
  127788. set debug(dbg: boolean);
  127789. private _depthClamp;
  127790. /**
  127791. * Gets or sets the depth clamping value.
  127792. *
  127793. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127794. * to account for the shadow casters far away.
  127795. *
  127796. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127797. */
  127798. get depthClamp(): boolean;
  127799. set depthClamp(value: boolean);
  127800. private _cascadeBlendPercentage;
  127801. /**
  127802. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127803. * It defaults to 0.1 (10% blending).
  127804. */
  127805. get cascadeBlendPercentage(): number;
  127806. set cascadeBlendPercentage(value: number);
  127807. private _lambda;
  127808. /**
  127809. * Gets or set the lambda parameter.
  127810. * This parameter is used to split the camera frustum and create the cascades.
  127811. * 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.
  127812. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127813. */
  127814. get lambda(): number;
  127815. set lambda(value: number);
  127816. /**
  127817. * Gets the view matrix corresponding to a given cascade
  127818. * @param cascadeNum cascade to retrieve the view matrix from
  127819. * @returns the cascade view matrix
  127820. */
  127821. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127822. /**
  127823. * Gets the projection matrix corresponding to a given cascade
  127824. * @param cascadeNum cascade to retrieve the projection matrix from
  127825. * @returns the cascade projection matrix
  127826. */
  127827. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127828. /**
  127829. * Gets the transformation matrix corresponding to a given cascade
  127830. * @param cascadeNum cascade to retrieve the transformation matrix from
  127831. * @returns the cascade transformation matrix
  127832. */
  127833. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127834. private _depthRenderer;
  127835. /**
  127836. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127837. *
  127838. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127839. *
  127840. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127841. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127842. * @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
  127843. */
  127844. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127845. private _depthReducer;
  127846. private _autoCalcDepthBounds;
  127847. /**
  127848. * Gets or sets the autoCalcDepthBounds property.
  127849. *
  127850. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127851. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127852. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127853. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127854. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127855. */
  127856. get autoCalcDepthBounds(): boolean;
  127857. set autoCalcDepthBounds(value: boolean);
  127858. /**
  127859. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127860. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127861. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127862. * for setting the refresh rate on the renderer yourself!
  127863. */
  127864. get autoCalcDepthBoundsRefreshRate(): number;
  127865. set autoCalcDepthBoundsRefreshRate(value: number);
  127866. /**
  127867. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127868. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127869. * you change the camera near/far planes!
  127870. */
  127871. splitFrustum(): void;
  127872. private _splitFrustum;
  127873. private _computeMatrices;
  127874. private _computeFrustumInWorldSpace;
  127875. private _computeCascadeFrustum;
  127876. /** @hidden */
  127877. static _SceneComponentInitialization: (scene: Scene) => void;
  127878. /**
  127879. * Creates a Cascaded Shadow Generator object.
  127880. * A ShadowGenerator is the required tool to use the shadows.
  127881. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127882. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127883. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127884. * @param light The directional light object generating the shadows.
  127885. * @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.
  127886. */
  127887. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127888. protected _initializeGenerator(): void;
  127889. protected _createTargetRenderTexture(): void;
  127890. protected _initializeShadowMap(): void;
  127891. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127892. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127893. /**
  127894. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127895. * @param defines Defines of the material we want to update
  127896. * @param lightIndex Index of the light in the enabled light list of the material
  127897. */
  127898. prepareDefines(defines: any, lightIndex: number): void;
  127899. /**
  127900. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127901. * defined in the generator but impacting the effect).
  127902. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127903. * @param effect The effect we are binfing the information for
  127904. */
  127905. bindShadowLight(lightIndex: string, effect: Effect): void;
  127906. /**
  127907. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127908. * (eq to view projection * shadow projection matrices)
  127909. * @returns The transform matrix used to create the shadow map
  127910. */
  127911. getTransformMatrix(): Matrix;
  127912. /**
  127913. * Disposes the ShadowGenerator.
  127914. * Returns nothing.
  127915. */
  127916. dispose(): void;
  127917. /**
  127918. * Serializes the shadow generator setup to a json object.
  127919. * @returns The serialized JSON object
  127920. */
  127921. serialize(): any;
  127922. /**
  127923. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127924. * @param parsedShadowGenerator The JSON object to parse
  127925. * @param scene The scene to create the shadow map for
  127926. * @returns The parsed shadow generator
  127927. */
  127928. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127929. }
  127930. }
  127931. declare module BABYLON {
  127932. /**
  127933. * Defines the shadow generator component responsible to manage any shadow generators
  127934. * in a given scene.
  127935. */
  127936. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127937. /**
  127938. * The component name helpfull to identify the component in the list of scene components.
  127939. */
  127940. readonly name: string;
  127941. /**
  127942. * The scene the component belongs to.
  127943. */
  127944. scene: Scene;
  127945. /**
  127946. * Creates a new instance of the component for the given scene
  127947. * @param scene Defines the scene to register the component in
  127948. */
  127949. constructor(scene: Scene);
  127950. /**
  127951. * Registers the component in a given scene
  127952. */
  127953. register(): void;
  127954. /**
  127955. * Rebuilds the elements related to this component in case of
  127956. * context lost for instance.
  127957. */
  127958. rebuild(): void;
  127959. /**
  127960. * Serializes the component data to the specified json object
  127961. * @param serializationObject The object to serialize to
  127962. */
  127963. serialize(serializationObject: any): void;
  127964. /**
  127965. * Adds all the elements from the container to the scene
  127966. * @param container the container holding the elements
  127967. */
  127968. addFromContainer(container: AbstractScene): void;
  127969. /**
  127970. * Removes all the elements in the container from the scene
  127971. * @param container contains the elements to remove
  127972. * @param dispose if the removed element should be disposed (default: false)
  127973. */
  127974. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127975. /**
  127976. * Rebuilds the elements related to this component in case of
  127977. * context lost for instance.
  127978. */
  127979. dispose(): void;
  127980. private _gatherRenderTargets;
  127981. }
  127982. }
  127983. declare module BABYLON {
  127984. /**
  127985. * A point light is a light defined by an unique point in world space.
  127986. * The light is emitted in every direction from this point.
  127987. * A good example of a point light is a standard light bulb.
  127988. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127989. */
  127990. export class PointLight extends ShadowLight {
  127991. private _shadowAngle;
  127992. /**
  127993. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127994. * This specifies what angle the shadow will use to be created.
  127995. *
  127996. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127997. */
  127998. get shadowAngle(): number;
  127999. /**
  128000. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128001. * This specifies what angle the shadow will use to be created.
  128002. *
  128003. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  128004. */
  128005. set shadowAngle(value: number);
  128006. /**
  128007. * Gets the direction if it has been set.
  128008. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128009. */
  128010. get direction(): Vector3;
  128011. /**
  128012. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128013. */
  128014. set direction(value: Vector3);
  128015. /**
  128016. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  128017. * A PointLight emits the light in every direction.
  128018. * It can cast shadows.
  128019. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  128020. * ```javascript
  128021. * var pointLight = new PointLight("pl", camera.position, scene);
  128022. * ```
  128023. * Documentation : https://doc.babylonjs.com/babylon101/lights
  128024. * @param name The light friendly name
  128025. * @param position The position of the point light in the scene
  128026. * @param scene The scene the lights belongs to
  128027. */
  128028. constructor(name: string, position: Vector3, scene: Scene);
  128029. /**
  128030. * Returns the string "PointLight"
  128031. * @returns the class name
  128032. */
  128033. getClassName(): string;
  128034. /**
  128035. * Returns the integer 0.
  128036. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  128037. */
  128038. getTypeID(): number;
  128039. /**
  128040. * Specifies wether or not the shadowmap should be a cube texture.
  128041. * @returns true if the shadowmap needs to be a cube texture.
  128042. */
  128043. needCube(): boolean;
  128044. /**
  128045. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  128046. * @param faceIndex The index of the face we are computed the direction to generate shadow
  128047. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  128048. */
  128049. getShadowDirection(faceIndex?: number): Vector3;
  128050. /**
  128051. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  128052. * - fov = PI / 2
  128053. * - aspect ratio : 1.0
  128054. * - z-near and far equal to the active camera minZ and maxZ.
  128055. * Returns the PointLight.
  128056. */
  128057. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  128058. protected _buildUniformLayout(): void;
  128059. /**
  128060. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  128061. * @param effect The effect to update
  128062. * @param lightIndex The index of the light in the effect to update
  128063. * @returns The point light
  128064. */
  128065. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  128066. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  128067. /**
  128068. * Prepares the list of defines specific to the light type.
  128069. * @param defines the list of defines
  128070. * @param lightIndex defines the index of the light for the effect
  128071. */
  128072. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  128073. }
  128074. }
  128075. declare module BABYLON {
  128076. /**
  128077. * Header information of HDR texture files.
  128078. */
  128079. export interface HDRInfo {
  128080. /**
  128081. * The height of the texture in pixels.
  128082. */
  128083. height: number;
  128084. /**
  128085. * The width of the texture in pixels.
  128086. */
  128087. width: number;
  128088. /**
  128089. * The index of the beginning of the data in the binary file.
  128090. */
  128091. dataPosition: number;
  128092. }
  128093. /**
  128094. * This groups tools to convert HDR texture to native colors array.
  128095. */
  128096. export class HDRTools {
  128097. private static Ldexp;
  128098. private static Rgbe2float;
  128099. private static readStringLine;
  128100. /**
  128101. * Reads header information from an RGBE texture stored in a native array.
  128102. * More information on this format are available here:
  128103. * https://en.wikipedia.org/wiki/RGBE_image_format
  128104. *
  128105. * @param uint8array The binary file stored in native array.
  128106. * @return The header information.
  128107. */
  128108. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  128109. /**
  128110. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  128111. * This RGBE texture needs to store the information as a panorama.
  128112. *
  128113. * More information on this format are available here:
  128114. * https://en.wikipedia.org/wiki/RGBE_image_format
  128115. *
  128116. * @param buffer The binary file stored in an array buffer.
  128117. * @param size The expected size of the extracted cubemap.
  128118. * @return The Cube Map information.
  128119. */
  128120. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  128121. /**
  128122. * Returns the pixels data extracted from an RGBE texture.
  128123. * This pixels will be stored left to right up to down in the R G B order in one array.
  128124. *
  128125. * More information on this format are available here:
  128126. * https://en.wikipedia.org/wiki/RGBE_image_format
  128127. *
  128128. * @param uint8array The binary file stored in an array buffer.
  128129. * @param hdrInfo The header information of the file.
  128130. * @return The pixels data in RGB right to left up to down order.
  128131. */
  128132. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  128133. private static RGBE_ReadPixels_RLE;
  128134. }
  128135. }
  128136. declare module BABYLON {
  128137. /**
  128138. * This represents a texture coming from an HDR input.
  128139. *
  128140. * The only supported format is currently panorama picture stored in RGBE format.
  128141. * Example of such files can be found on HDRLib: http://hdrlib.com/
  128142. */
  128143. export class HDRCubeTexture extends BaseTexture {
  128144. private static _facesMapping;
  128145. private _generateHarmonics;
  128146. private _noMipmap;
  128147. private _textureMatrix;
  128148. private _size;
  128149. private _onLoad;
  128150. private _onError;
  128151. /**
  128152. * The texture URL.
  128153. */
  128154. url: string;
  128155. /**
  128156. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  128157. */
  128158. coordinatesMode: number;
  128159. protected _isBlocking: boolean;
  128160. /**
  128161. * Sets wether or not the texture is blocking during loading.
  128162. */
  128163. set isBlocking(value: boolean);
  128164. /**
  128165. * Gets wether or not the texture is blocking during loading.
  128166. */
  128167. get isBlocking(): boolean;
  128168. protected _rotationY: number;
  128169. /**
  128170. * Sets texture matrix rotation angle around Y axis in radians.
  128171. */
  128172. set rotationY(value: number);
  128173. /**
  128174. * Gets texture matrix rotation angle around Y axis radians.
  128175. */
  128176. get rotationY(): number;
  128177. /**
  128178. * Gets or sets the center of the bounding box associated with the cube texture
  128179. * It must define where the camera used to render the texture was set
  128180. */
  128181. boundingBoxPosition: Vector3;
  128182. private _boundingBoxSize;
  128183. /**
  128184. * Gets or sets the size of the bounding box associated with the cube texture
  128185. * When defined, the cubemap will switch to local mode
  128186. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  128187. * @example https://www.babylonjs-playground.com/#RNASML
  128188. */
  128189. set boundingBoxSize(value: Vector3);
  128190. get boundingBoxSize(): Vector3;
  128191. /**
  128192. * Instantiates an HDRTexture from the following parameters.
  128193. *
  128194. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  128195. * @param scene The scene the texture will be used in
  128196. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  128197. * @param noMipmap Forces to not generate the mipmap if true
  128198. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  128199. * @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)
  128200. * @param reserved Reserved flag for internal use.
  128201. */
  128202. 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>);
  128203. /**
  128204. * Get the current class name of the texture useful for serialization or dynamic coding.
  128205. * @returns "HDRCubeTexture"
  128206. */
  128207. getClassName(): string;
  128208. /**
  128209. * Occurs when the file is raw .hdr file.
  128210. */
  128211. private loadTexture;
  128212. clone(): HDRCubeTexture;
  128213. delayLoad(): void;
  128214. /**
  128215. * Get the texture reflection matrix used to rotate/transform the reflection.
  128216. * @returns the reflection matrix
  128217. */
  128218. getReflectionTextureMatrix(): Matrix;
  128219. /**
  128220. * Set the texture reflection matrix used to rotate/transform the reflection.
  128221. * @param value Define the reflection matrix to set
  128222. */
  128223. setReflectionTextureMatrix(value: Matrix): void;
  128224. /**
  128225. * Parses a JSON representation of an HDR Texture in order to create the texture
  128226. * @param parsedTexture Define the JSON representation
  128227. * @param scene Define the scene the texture should be created in
  128228. * @param rootUrl Define the root url in case we need to load relative dependencies
  128229. * @returns the newly created texture after parsing
  128230. */
  128231. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  128232. serialize(): any;
  128233. }
  128234. }
  128235. declare module BABYLON {
  128236. /**
  128237. * Class used to control physics engine
  128238. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  128239. */
  128240. export class PhysicsEngine implements IPhysicsEngine {
  128241. private _physicsPlugin;
  128242. /**
  128243. * Global value used to control the smallest number supported by the simulation
  128244. */
  128245. static Epsilon: number;
  128246. private _impostors;
  128247. private _joints;
  128248. private _subTimeStep;
  128249. /**
  128250. * Gets the gravity vector used by the simulation
  128251. */
  128252. gravity: Vector3;
  128253. /**
  128254. * Factory used to create the default physics plugin.
  128255. * @returns The default physics plugin
  128256. */
  128257. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  128258. /**
  128259. * Creates a new Physics Engine
  128260. * @param gravity defines the gravity vector used by the simulation
  128261. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  128262. */
  128263. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  128264. /**
  128265. * Sets the gravity vector used by the simulation
  128266. * @param gravity defines the gravity vector to use
  128267. */
  128268. setGravity(gravity: Vector3): void;
  128269. /**
  128270. * Set the time step of the physics engine.
  128271. * Default is 1/60.
  128272. * To slow it down, enter 1/600 for example.
  128273. * To speed it up, 1/30
  128274. * @param newTimeStep defines the new timestep to apply to this world.
  128275. */
  128276. setTimeStep(newTimeStep?: number): void;
  128277. /**
  128278. * Get the time step of the physics engine.
  128279. * @returns the current time step
  128280. */
  128281. getTimeStep(): number;
  128282. /**
  128283. * Set the sub time step of the physics engine.
  128284. * Default is 0 meaning there is no sub steps
  128285. * To increase physics resolution precision, set a small value (like 1 ms)
  128286. * @param subTimeStep defines the new sub timestep used for physics resolution.
  128287. */
  128288. setSubTimeStep(subTimeStep?: number): void;
  128289. /**
  128290. * Get the sub time step of the physics engine.
  128291. * @returns the current sub time step
  128292. */
  128293. getSubTimeStep(): number;
  128294. /**
  128295. * Release all resources
  128296. */
  128297. dispose(): void;
  128298. /**
  128299. * Gets the name of the current physics plugin
  128300. * @returns the name of the plugin
  128301. */
  128302. getPhysicsPluginName(): string;
  128303. /**
  128304. * Adding a new impostor for the impostor tracking.
  128305. * This will be done by the impostor itself.
  128306. * @param impostor the impostor to add
  128307. */
  128308. addImpostor(impostor: PhysicsImpostor): void;
  128309. /**
  128310. * Remove an impostor from the engine.
  128311. * This impostor and its mesh will not longer be updated by the physics engine.
  128312. * @param impostor the impostor to remove
  128313. */
  128314. removeImpostor(impostor: PhysicsImpostor): void;
  128315. /**
  128316. * Add a joint to the physics engine
  128317. * @param mainImpostor defines the main impostor to which the joint is added.
  128318. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128319. * @param joint defines the joint that will connect both impostors.
  128320. */
  128321. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128322. /**
  128323. * Removes a joint from the simulation
  128324. * @param mainImpostor defines the impostor used with the joint
  128325. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128326. * @param joint defines the joint to remove
  128327. */
  128328. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128329. /**
  128330. * Called by the scene. No need to call it.
  128331. * @param delta defines the timespam between frames
  128332. */
  128333. _step(delta: number): void;
  128334. /**
  128335. * Gets the current plugin used to run the simulation
  128336. * @returns current plugin
  128337. */
  128338. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128339. /**
  128340. * Gets the list of physic impostors
  128341. * @returns an array of PhysicsImpostor
  128342. */
  128343. getImpostors(): Array<PhysicsImpostor>;
  128344. /**
  128345. * Gets the impostor for a physics enabled object
  128346. * @param object defines the object impersonated by the impostor
  128347. * @returns the PhysicsImpostor or null if not found
  128348. */
  128349. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128350. /**
  128351. * Gets the impostor for a physics body object
  128352. * @param body defines physics body used by the impostor
  128353. * @returns the PhysicsImpostor or null if not found
  128354. */
  128355. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128356. /**
  128357. * Does a raycast in the physics world
  128358. * @param from when should the ray start?
  128359. * @param to when should the ray end?
  128360. * @returns PhysicsRaycastResult
  128361. */
  128362. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128363. }
  128364. }
  128365. declare module BABYLON {
  128366. /** @hidden */
  128367. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128368. private _useDeltaForWorldStep;
  128369. world: any;
  128370. name: string;
  128371. private _physicsMaterials;
  128372. private _fixedTimeStep;
  128373. private _cannonRaycastResult;
  128374. private _raycastResult;
  128375. private _physicsBodysToRemoveAfterStep;
  128376. BJSCANNON: any;
  128377. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128378. setGravity(gravity: Vector3): void;
  128379. setTimeStep(timeStep: number): void;
  128380. getTimeStep(): number;
  128381. executeStep(delta: number): void;
  128382. private _removeMarkedPhysicsBodiesFromWorld;
  128383. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128384. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128385. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128386. private _processChildMeshes;
  128387. removePhysicsBody(impostor: PhysicsImpostor): void;
  128388. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128389. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128390. private _addMaterial;
  128391. private _checkWithEpsilon;
  128392. private _createShape;
  128393. private _createHeightmap;
  128394. private _minus90X;
  128395. private _plus90X;
  128396. private _tmpPosition;
  128397. private _tmpDeltaPosition;
  128398. private _tmpUnityRotation;
  128399. private _updatePhysicsBodyTransformation;
  128400. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128401. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128402. isSupported(): boolean;
  128403. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128404. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128405. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128406. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128407. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128408. getBodyMass(impostor: PhysicsImpostor): number;
  128409. getBodyFriction(impostor: PhysicsImpostor): number;
  128410. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128411. getBodyRestitution(impostor: PhysicsImpostor): number;
  128412. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128413. sleepBody(impostor: PhysicsImpostor): void;
  128414. wakeUpBody(impostor: PhysicsImpostor): void;
  128415. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128416. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128417. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128418. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128419. getRadius(impostor: PhysicsImpostor): number;
  128420. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128421. dispose(): void;
  128422. private _extendNamespace;
  128423. /**
  128424. * Does a raycast in the physics world
  128425. * @param from when should the ray start?
  128426. * @param to when should the ray end?
  128427. * @returns PhysicsRaycastResult
  128428. */
  128429. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128430. }
  128431. }
  128432. declare module BABYLON {
  128433. /** @hidden */
  128434. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128435. world: any;
  128436. name: string;
  128437. BJSOIMO: any;
  128438. private _raycastResult;
  128439. constructor(iterations?: number, oimoInjection?: any);
  128440. setGravity(gravity: Vector3): void;
  128441. setTimeStep(timeStep: number): void;
  128442. getTimeStep(): number;
  128443. private _tmpImpostorsArray;
  128444. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128445. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128446. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128447. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128448. private _tmpPositionVector;
  128449. removePhysicsBody(impostor: PhysicsImpostor): void;
  128450. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128451. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128452. isSupported(): boolean;
  128453. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128454. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128455. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128456. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128457. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128458. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128459. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128460. getBodyMass(impostor: PhysicsImpostor): number;
  128461. getBodyFriction(impostor: PhysicsImpostor): number;
  128462. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128463. getBodyRestitution(impostor: PhysicsImpostor): number;
  128464. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128465. sleepBody(impostor: PhysicsImpostor): void;
  128466. wakeUpBody(impostor: PhysicsImpostor): void;
  128467. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128468. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128469. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128470. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128471. getRadius(impostor: PhysicsImpostor): number;
  128472. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128473. dispose(): void;
  128474. /**
  128475. * Does a raycast in the physics world
  128476. * @param from when should the ray start?
  128477. * @param to when should the ray end?
  128478. * @returns PhysicsRaycastResult
  128479. */
  128480. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128481. }
  128482. }
  128483. declare module BABYLON {
  128484. /**
  128485. * Class containing static functions to help procedurally build meshes
  128486. */
  128487. export class RibbonBuilder {
  128488. /**
  128489. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128490. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128491. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128492. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128493. * * 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
  128494. * * 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
  128495. * * 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
  128496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128498. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128499. * * 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
  128500. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128501. * * 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
  128502. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128504. * @param name defines the name of the mesh
  128505. * @param options defines the options used to create the mesh
  128506. * @param scene defines the hosting scene
  128507. * @returns the ribbon mesh
  128508. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128509. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128510. */
  128511. static CreateRibbon(name: string, options: {
  128512. pathArray: Vector3[][];
  128513. closeArray?: boolean;
  128514. closePath?: boolean;
  128515. offset?: number;
  128516. updatable?: boolean;
  128517. sideOrientation?: number;
  128518. frontUVs?: Vector4;
  128519. backUVs?: Vector4;
  128520. instance?: Mesh;
  128521. invertUV?: boolean;
  128522. uvs?: Vector2[];
  128523. colors?: Color4[];
  128524. }, scene?: Nullable<Scene>): Mesh;
  128525. }
  128526. }
  128527. declare module BABYLON {
  128528. /**
  128529. * Class containing static functions to help procedurally build meshes
  128530. */
  128531. export class ShapeBuilder {
  128532. /**
  128533. * 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.
  128534. * * 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.
  128535. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128536. * * 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.
  128537. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128538. * * 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
  128539. * * 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
  128540. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128543. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128545. * @param name defines the name of the mesh
  128546. * @param options defines the options used to create the mesh
  128547. * @param scene defines the hosting scene
  128548. * @returns the extruded shape mesh
  128549. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128550. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128551. */
  128552. static ExtrudeShape(name: string, options: {
  128553. shape: Vector3[];
  128554. path: Vector3[];
  128555. scale?: number;
  128556. rotation?: number;
  128557. cap?: number;
  128558. updatable?: boolean;
  128559. sideOrientation?: number;
  128560. frontUVs?: Vector4;
  128561. backUVs?: Vector4;
  128562. instance?: Mesh;
  128563. invertUV?: boolean;
  128564. }, scene?: Nullable<Scene>): Mesh;
  128565. /**
  128566. * Creates an custom extruded shape mesh.
  128567. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128568. * * 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.
  128569. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128570. * * 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
  128571. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128572. * * 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
  128573. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128574. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128575. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128576. * * 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
  128577. * * 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
  128578. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128581. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128583. * @param name defines the name of the mesh
  128584. * @param options defines the options used to create the mesh
  128585. * @param scene defines the hosting scene
  128586. * @returns the custom extruded shape mesh
  128587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128588. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128590. */
  128591. static ExtrudeShapeCustom(name: string, options: {
  128592. shape: Vector3[];
  128593. path: Vector3[];
  128594. scaleFunction?: any;
  128595. rotationFunction?: any;
  128596. ribbonCloseArray?: boolean;
  128597. ribbonClosePath?: boolean;
  128598. cap?: number;
  128599. updatable?: boolean;
  128600. sideOrientation?: number;
  128601. frontUVs?: Vector4;
  128602. backUVs?: Vector4;
  128603. instance?: Mesh;
  128604. invertUV?: boolean;
  128605. }, scene?: Nullable<Scene>): Mesh;
  128606. private static _ExtrudeShapeGeneric;
  128607. }
  128608. }
  128609. declare module BABYLON {
  128610. /**
  128611. * AmmoJS Physics plugin
  128612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128613. * @see https://github.com/kripken/ammo.js/
  128614. */
  128615. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128616. private _useDeltaForWorldStep;
  128617. /**
  128618. * Reference to the Ammo library
  128619. */
  128620. bjsAMMO: any;
  128621. /**
  128622. * Created ammoJS world which physics bodies are added to
  128623. */
  128624. world: any;
  128625. /**
  128626. * Name of the plugin
  128627. */
  128628. name: string;
  128629. private _timeStep;
  128630. private _fixedTimeStep;
  128631. private _maxSteps;
  128632. private _tmpQuaternion;
  128633. private _tmpAmmoTransform;
  128634. private _tmpAmmoQuaternion;
  128635. private _tmpAmmoConcreteContactResultCallback;
  128636. private _collisionConfiguration;
  128637. private _dispatcher;
  128638. private _overlappingPairCache;
  128639. private _solver;
  128640. private _softBodySolver;
  128641. private _tmpAmmoVectorA;
  128642. private _tmpAmmoVectorB;
  128643. private _tmpAmmoVectorC;
  128644. private _tmpAmmoVectorD;
  128645. private _tmpContactCallbackResult;
  128646. private _tmpAmmoVectorRCA;
  128647. private _tmpAmmoVectorRCB;
  128648. private _raycastResult;
  128649. private static readonly DISABLE_COLLISION_FLAG;
  128650. private static readonly KINEMATIC_FLAG;
  128651. private static readonly DISABLE_DEACTIVATION_FLAG;
  128652. /**
  128653. * Initializes the ammoJS plugin
  128654. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128655. * @param ammoInjection can be used to inject your own ammo reference
  128656. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128657. */
  128658. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128659. /**
  128660. * Sets the gravity of the physics world (m/(s^2))
  128661. * @param gravity Gravity to set
  128662. */
  128663. setGravity(gravity: Vector3): void;
  128664. /**
  128665. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128666. * @param timeStep timestep to use in seconds
  128667. */
  128668. setTimeStep(timeStep: number): void;
  128669. /**
  128670. * 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)
  128671. * @param fixedTimeStep fixedTimeStep to use in seconds
  128672. */
  128673. setFixedTimeStep(fixedTimeStep: number): void;
  128674. /**
  128675. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128676. * @param maxSteps the maximum number of steps by the physics engine per frame
  128677. */
  128678. setMaxSteps(maxSteps: number): void;
  128679. /**
  128680. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128681. * @returns the current timestep in seconds
  128682. */
  128683. getTimeStep(): number;
  128684. /**
  128685. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128686. */
  128687. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128688. private _isImpostorInContact;
  128689. private _isImpostorPairInContact;
  128690. private _stepSimulation;
  128691. /**
  128692. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128693. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128694. * After the step the babylon meshes are set to the position of the physics imposters
  128695. * @param delta amount of time to step forward
  128696. * @param impostors array of imposters to update before/after the step
  128697. */
  128698. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128699. /**
  128700. * Update babylon mesh to match physics world object
  128701. * @param impostor imposter to match
  128702. */
  128703. private _afterSoftStep;
  128704. /**
  128705. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128706. * @param impostor imposter to match
  128707. */
  128708. private _ropeStep;
  128709. /**
  128710. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128711. * @param impostor imposter to match
  128712. */
  128713. private _softbodyOrClothStep;
  128714. private _tmpVector;
  128715. private _tmpMatrix;
  128716. /**
  128717. * Applies an impulse on the imposter
  128718. * @param impostor imposter to apply impulse to
  128719. * @param force amount of force to be applied to the imposter
  128720. * @param contactPoint the location to apply the impulse on the imposter
  128721. */
  128722. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128723. /**
  128724. * Applies a force on the imposter
  128725. * @param impostor imposter to apply force
  128726. * @param force amount of force to be applied to the imposter
  128727. * @param contactPoint the location to apply the force on the imposter
  128728. */
  128729. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128730. /**
  128731. * Creates a physics body using the plugin
  128732. * @param impostor the imposter to create the physics body on
  128733. */
  128734. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128735. /**
  128736. * Removes the physics body from the imposter and disposes of the body's memory
  128737. * @param impostor imposter to remove the physics body from
  128738. */
  128739. removePhysicsBody(impostor: PhysicsImpostor): void;
  128740. /**
  128741. * Generates a joint
  128742. * @param impostorJoint the imposter joint to create the joint with
  128743. */
  128744. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128745. /**
  128746. * Removes a joint
  128747. * @param impostorJoint the imposter joint to remove the joint from
  128748. */
  128749. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128750. private _addMeshVerts;
  128751. /**
  128752. * Initialise the soft body vertices to match its object's (mesh) vertices
  128753. * Softbody vertices (nodes) are in world space and to match this
  128754. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128755. * @param impostor to create the softbody for
  128756. */
  128757. private _softVertexData;
  128758. /**
  128759. * Create an impostor's soft body
  128760. * @param impostor to create the softbody for
  128761. */
  128762. private _createSoftbody;
  128763. /**
  128764. * Create cloth for an impostor
  128765. * @param impostor to create the softbody for
  128766. */
  128767. private _createCloth;
  128768. /**
  128769. * Create rope for an impostor
  128770. * @param impostor to create the softbody for
  128771. */
  128772. private _createRope;
  128773. /**
  128774. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128775. * @param impostor to create the custom physics shape for
  128776. */
  128777. private _createCustom;
  128778. private _addHullVerts;
  128779. private _createShape;
  128780. /**
  128781. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128782. * @param impostor imposter containing the physics body and babylon object
  128783. */
  128784. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128785. /**
  128786. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128787. * @param impostor imposter containing the physics body and babylon object
  128788. * @param newPosition new position
  128789. * @param newRotation new rotation
  128790. */
  128791. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128792. /**
  128793. * If this plugin is supported
  128794. * @returns true if its supported
  128795. */
  128796. isSupported(): boolean;
  128797. /**
  128798. * Sets the linear velocity of the physics body
  128799. * @param impostor imposter to set the velocity on
  128800. * @param velocity velocity to set
  128801. */
  128802. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128803. /**
  128804. * Sets the angular velocity of the physics body
  128805. * @param impostor imposter to set the velocity on
  128806. * @param velocity velocity to set
  128807. */
  128808. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128809. /**
  128810. * gets the linear velocity
  128811. * @param impostor imposter to get linear velocity from
  128812. * @returns linear velocity
  128813. */
  128814. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128815. /**
  128816. * gets the angular velocity
  128817. * @param impostor imposter to get angular velocity from
  128818. * @returns angular velocity
  128819. */
  128820. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128821. /**
  128822. * Sets the mass of physics body
  128823. * @param impostor imposter to set the mass on
  128824. * @param mass mass to set
  128825. */
  128826. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128827. /**
  128828. * Gets the mass of the physics body
  128829. * @param impostor imposter to get the mass from
  128830. * @returns mass
  128831. */
  128832. getBodyMass(impostor: PhysicsImpostor): number;
  128833. /**
  128834. * Gets friction of the impostor
  128835. * @param impostor impostor to get friction from
  128836. * @returns friction value
  128837. */
  128838. getBodyFriction(impostor: PhysicsImpostor): number;
  128839. /**
  128840. * Sets friction of the impostor
  128841. * @param impostor impostor to set friction on
  128842. * @param friction friction value
  128843. */
  128844. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128845. /**
  128846. * Gets restitution of the impostor
  128847. * @param impostor impostor to get restitution from
  128848. * @returns restitution value
  128849. */
  128850. getBodyRestitution(impostor: PhysicsImpostor): number;
  128851. /**
  128852. * Sets resitution of the impostor
  128853. * @param impostor impostor to set resitution on
  128854. * @param restitution resitution value
  128855. */
  128856. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128857. /**
  128858. * Gets pressure inside the impostor
  128859. * @param impostor impostor to get pressure from
  128860. * @returns pressure value
  128861. */
  128862. getBodyPressure(impostor: PhysicsImpostor): number;
  128863. /**
  128864. * Sets pressure inside a soft body impostor
  128865. * Cloth and rope must remain 0 pressure
  128866. * @param impostor impostor to set pressure on
  128867. * @param pressure pressure value
  128868. */
  128869. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128870. /**
  128871. * Gets stiffness of the impostor
  128872. * @param impostor impostor to get stiffness from
  128873. * @returns pressure value
  128874. */
  128875. getBodyStiffness(impostor: PhysicsImpostor): number;
  128876. /**
  128877. * Sets stiffness of the impostor
  128878. * @param impostor impostor to set stiffness on
  128879. * @param stiffness stiffness value from 0 to 1
  128880. */
  128881. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128882. /**
  128883. * Gets velocityIterations of the impostor
  128884. * @param impostor impostor to get velocity iterations from
  128885. * @returns velocityIterations value
  128886. */
  128887. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128888. /**
  128889. * Sets velocityIterations of the impostor
  128890. * @param impostor impostor to set velocity iterations on
  128891. * @param velocityIterations velocityIterations value
  128892. */
  128893. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128894. /**
  128895. * Gets positionIterations of the impostor
  128896. * @param impostor impostor to get position iterations from
  128897. * @returns positionIterations value
  128898. */
  128899. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128900. /**
  128901. * Sets positionIterations of the impostor
  128902. * @param impostor impostor to set position on
  128903. * @param positionIterations positionIterations value
  128904. */
  128905. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128906. /**
  128907. * Append an anchor to a cloth object
  128908. * @param impostor is the cloth impostor to add anchor to
  128909. * @param otherImpostor is the rigid impostor to anchor to
  128910. * @param width ratio across width from 0 to 1
  128911. * @param height ratio up height from 0 to 1
  128912. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128913. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128914. */
  128915. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128916. /**
  128917. * Append an hook to a rope object
  128918. * @param impostor is the rope impostor to add hook to
  128919. * @param otherImpostor is the rigid impostor to hook to
  128920. * @param length ratio along the rope from 0 to 1
  128921. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128922. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128923. */
  128924. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128925. /**
  128926. * Sleeps the physics body and stops it from being active
  128927. * @param impostor impostor to sleep
  128928. */
  128929. sleepBody(impostor: PhysicsImpostor): void;
  128930. /**
  128931. * Activates the physics body
  128932. * @param impostor impostor to activate
  128933. */
  128934. wakeUpBody(impostor: PhysicsImpostor): void;
  128935. /**
  128936. * Updates the distance parameters of the joint
  128937. * @param joint joint to update
  128938. * @param maxDistance maximum distance of the joint
  128939. * @param minDistance minimum distance of the joint
  128940. */
  128941. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128942. /**
  128943. * Sets a motor on the joint
  128944. * @param joint joint to set motor on
  128945. * @param speed speed of the motor
  128946. * @param maxForce maximum force of the motor
  128947. * @param motorIndex index of the motor
  128948. */
  128949. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128950. /**
  128951. * Sets the motors limit
  128952. * @param joint joint to set limit on
  128953. * @param upperLimit upper limit
  128954. * @param lowerLimit lower limit
  128955. */
  128956. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128957. /**
  128958. * Syncs the position and rotation of a mesh with the impostor
  128959. * @param mesh mesh to sync
  128960. * @param impostor impostor to update the mesh with
  128961. */
  128962. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128963. /**
  128964. * Gets the radius of the impostor
  128965. * @param impostor impostor to get radius from
  128966. * @returns the radius
  128967. */
  128968. getRadius(impostor: PhysicsImpostor): number;
  128969. /**
  128970. * Gets the box size of the impostor
  128971. * @param impostor impostor to get box size from
  128972. * @param result the resulting box size
  128973. */
  128974. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128975. /**
  128976. * Disposes of the impostor
  128977. */
  128978. dispose(): void;
  128979. /**
  128980. * Does a raycast in the physics world
  128981. * @param from when should the ray start?
  128982. * @param to when should the ray end?
  128983. * @returns PhysicsRaycastResult
  128984. */
  128985. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128986. }
  128987. }
  128988. declare module BABYLON {
  128989. interface AbstractScene {
  128990. /**
  128991. * The list of reflection probes added to the scene
  128992. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128993. */
  128994. reflectionProbes: Array<ReflectionProbe>;
  128995. /**
  128996. * Removes the given reflection probe from this scene.
  128997. * @param toRemove The reflection probe to remove
  128998. * @returns The index of the removed reflection probe
  128999. */
  129000. removeReflectionProbe(toRemove: ReflectionProbe): number;
  129001. /**
  129002. * Adds the given reflection probe to this scene.
  129003. * @param newReflectionProbe The reflection probe to add
  129004. */
  129005. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  129006. }
  129007. /**
  129008. * Class used to generate realtime reflection / refraction cube textures
  129009. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  129010. */
  129011. export class ReflectionProbe {
  129012. /** defines the name of the probe */
  129013. name: string;
  129014. private _scene;
  129015. private _renderTargetTexture;
  129016. private _projectionMatrix;
  129017. private _viewMatrix;
  129018. private _target;
  129019. private _add;
  129020. private _attachedMesh;
  129021. private _invertYAxis;
  129022. /** Gets or sets probe position (center of the cube map) */
  129023. position: Vector3;
  129024. /**
  129025. * Creates a new reflection probe
  129026. * @param name defines the name of the probe
  129027. * @param size defines the texture resolution (for each face)
  129028. * @param scene defines the hosting scene
  129029. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  129030. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  129031. */
  129032. constructor(
  129033. /** defines the name of the probe */
  129034. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  129035. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  129036. get samples(): number;
  129037. set samples(value: number);
  129038. /** Gets or sets the refresh rate to use (on every frame by default) */
  129039. get refreshRate(): number;
  129040. set refreshRate(value: number);
  129041. /**
  129042. * Gets the hosting scene
  129043. * @returns a Scene
  129044. */
  129045. getScene(): Scene;
  129046. /** Gets the internal CubeTexture used to render to */
  129047. get cubeTexture(): RenderTargetTexture;
  129048. /** Gets the list of meshes to render */
  129049. get renderList(): Nullable<AbstractMesh[]>;
  129050. /**
  129051. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  129052. * @param mesh defines the mesh to attach to
  129053. */
  129054. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  129055. /**
  129056. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  129057. * @param renderingGroupId The rendering group id corresponding to its index
  129058. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  129059. */
  129060. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  129061. /**
  129062. * Clean all associated resources
  129063. */
  129064. dispose(): void;
  129065. /**
  129066. * Converts the reflection probe information to a readable string for debug purpose.
  129067. * @param fullDetails Supports for multiple levels of logging within scene loading
  129068. * @returns the human readable reflection probe info
  129069. */
  129070. toString(fullDetails?: boolean): string;
  129071. /**
  129072. * Get the class name of the relfection probe.
  129073. * @returns "ReflectionProbe"
  129074. */
  129075. getClassName(): string;
  129076. /**
  129077. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  129078. * @returns The JSON representation of the texture
  129079. */
  129080. serialize(): any;
  129081. /**
  129082. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  129083. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  129084. * @param scene Define the scene the parsed reflection probe should be instantiated in
  129085. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  129086. * @returns The parsed reflection probe if successful
  129087. */
  129088. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  129089. }
  129090. }
  129091. declare module BABYLON {
  129092. /** @hidden */
  129093. export var _BabylonLoaderRegistered: boolean;
  129094. /**
  129095. * Helps setting up some configuration for the babylon file loader.
  129096. */
  129097. export class BabylonFileLoaderConfiguration {
  129098. /**
  129099. * The loader does not allow injecting custom physix engine into the plugins.
  129100. * Unfortunately in ES6, we need to manually inject them into the plugin.
  129101. * So you could set this variable to your engine import to make it work.
  129102. */
  129103. static LoaderInjectedPhysicsEngine: any;
  129104. }
  129105. }
  129106. declare module BABYLON {
  129107. /**
  129108. * The Physically based simple base material of BJS.
  129109. *
  129110. * This enables better naming and convention enforcements on top of the pbrMaterial.
  129111. * It is used as the base class for both the specGloss and metalRough conventions.
  129112. */
  129113. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  129114. /**
  129115. * Number of Simultaneous lights allowed on the material.
  129116. */
  129117. maxSimultaneousLights: number;
  129118. /**
  129119. * If sets to true, disables all the lights affecting the material.
  129120. */
  129121. disableLighting: boolean;
  129122. /**
  129123. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  129124. */
  129125. environmentTexture: BaseTexture;
  129126. /**
  129127. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  129128. */
  129129. invertNormalMapX: boolean;
  129130. /**
  129131. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  129132. */
  129133. invertNormalMapY: boolean;
  129134. /**
  129135. * Normal map used in the model.
  129136. */
  129137. normalTexture: BaseTexture;
  129138. /**
  129139. * Emissivie color used to self-illuminate the model.
  129140. */
  129141. emissiveColor: Color3;
  129142. /**
  129143. * Emissivie texture used to self-illuminate the model.
  129144. */
  129145. emissiveTexture: BaseTexture;
  129146. /**
  129147. * Occlusion Channel Strenght.
  129148. */
  129149. occlusionStrength: number;
  129150. /**
  129151. * Occlusion Texture of the material (adding extra occlusion effects).
  129152. */
  129153. occlusionTexture: BaseTexture;
  129154. /**
  129155. * Defines the alpha limits in alpha test mode.
  129156. */
  129157. alphaCutOff: number;
  129158. /**
  129159. * Gets the current double sided mode.
  129160. */
  129161. get doubleSided(): boolean;
  129162. /**
  129163. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  129164. */
  129165. set doubleSided(value: boolean);
  129166. /**
  129167. * Stores the pre-calculated light information of a mesh in a texture.
  129168. */
  129169. lightmapTexture: BaseTexture;
  129170. /**
  129171. * If true, the light map contains occlusion information instead of lighting info.
  129172. */
  129173. useLightmapAsShadowmap: boolean;
  129174. /**
  129175. * Instantiates a new PBRMaterial instance.
  129176. *
  129177. * @param name The material name
  129178. * @param scene The scene the material will be use in.
  129179. */
  129180. constructor(name: string, scene: Scene);
  129181. getClassName(): string;
  129182. }
  129183. }
  129184. declare module BABYLON {
  129185. /**
  129186. * The PBR material of BJS following the metal roughness convention.
  129187. *
  129188. * This fits to the PBR convention in the GLTF definition:
  129189. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  129190. */
  129191. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  129192. /**
  129193. * The base color has two different interpretations depending on the value of metalness.
  129194. * When the material is a metal, the base color is the specific measured reflectance value
  129195. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  129196. * of the material.
  129197. */
  129198. baseColor: Color3;
  129199. /**
  129200. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  129201. * well as opacity information in the alpha channel.
  129202. */
  129203. baseTexture: BaseTexture;
  129204. /**
  129205. * Specifies the metallic scalar value of the material.
  129206. * Can also be used to scale the metalness values of the metallic texture.
  129207. */
  129208. metallic: number;
  129209. /**
  129210. * Specifies the roughness scalar value of the material.
  129211. * Can also be used to scale the roughness values of the metallic texture.
  129212. */
  129213. roughness: number;
  129214. /**
  129215. * Texture containing both the metallic value in the B channel and the
  129216. * roughness value in the G channel to keep better precision.
  129217. */
  129218. metallicRoughnessTexture: BaseTexture;
  129219. /**
  129220. * Instantiates a new PBRMetalRoughnessMaterial instance.
  129221. *
  129222. * @param name The material name
  129223. * @param scene The scene the material will be use in.
  129224. */
  129225. constructor(name: string, scene: Scene);
  129226. /**
  129227. * Return the currrent class name of the material.
  129228. */
  129229. getClassName(): string;
  129230. /**
  129231. * Makes a duplicate of the current material.
  129232. * @param name - name to use for the new material.
  129233. */
  129234. clone(name: string): PBRMetallicRoughnessMaterial;
  129235. /**
  129236. * Serialize the material to a parsable JSON object.
  129237. */
  129238. serialize(): any;
  129239. /**
  129240. * Parses a JSON object correponding to the serialize function.
  129241. */
  129242. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  129243. }
  129244. }
  129245. declare module BABYLON {
  129246. /**
  129247. * The PBR material of BJS following the specular glossiness convention.
  129248. *
  129249. * This fits to the PBR convention in the GLTF definition:
  129250. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  129251. */
  129252. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  129253. /**
  129254. * Specifies the diffuse color of the material.
  129255. */
  129256. diffuseColor: Color3;
  129257. /**
  129258. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  129259. * channel.
  129260. */
  129261. diffuseTexture: BaseTexture;
  129262. /**
  129263. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  129264. */
  129265. specularColor: Color3;
  129266. /**
  129267. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  129268. */
  129269. glossiness: number;
  129270. /**
  129271. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  129272. */
  129273. specularGlossinessTexture: BaseTexture;
  129274. /**
  129275. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  129276. *
  129277. * @param name The material name
  129278. * @param scene The scene the material will be use in.
  129279. */
  129280. constructor(name: string, scene: Scene);
  129281. /**
  129282. * Return the currrent class name of the material.
  129283. */
  129284. getClassName(): string;
  129285. /**
  129286. * Makes a duplicate of the current material.
  129287. * @param name - name to use for the new material.
  129288. */
  129289. clone(name: string): PBRSpecularGlossinessMaterial;
  129290. /**
  129291. * Serialize the material to a parsable JSON object.
  129292. */
  129293. serialize(): any;
  129294. /**
  129295. * Parses a JSON object correponding to the serialize function.
  129296. */
  129297. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  129298. }
  129299. }
  129300. declare module BABYLON {
  129301. /**
  129302. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  129303. * It can help converting any input color in a desired output one. This can then be used to create effects
  129304. * from sepia, black and white to sixties or futuristic rendering...
  129305. *
  129306. * The only supported format is currently 3dl.
  129307. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  129308. */
  129309. export class ColorGradingTexture extends BaseTexture {
  129310. /**
  129311. * The current texture matrix. (will always be identity in color grading texture)
  129312. */
  129313. private _textureMatrix;
  129314. /**
  129315. * The texture URL.
  129316. */
  129317. url: string;
  129318. /**
  129319. * Empty line regex stored for GC.
  129320. */
  129321. private static _noneEmptyLineRegex;
  129322. private _engine;
  129323. /**
  129324. * Instantiates a ColorGradingTexture from the following parameters.
  129325. *
  129326. * @param url The location of the color gradind data (currently only supporting 3dl)
  129327. * @param scene The scene the texture will be used in
  129328. */
  129329. constructor(url: string, scene: Scene);
  129330. /**
  129331. * Returns the texture matrix used in most of the material.
  129332. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129333. */
  129334. getTextureMatrix(): Matrix;
  129335. /**
  129336. * Occurs when the file being loaded is a .3dl LUT file.
  129337. */
  129338. private load3dlTexture;
  129339. /**
  129340. * Starts the loading process of the texture.
  129341. */
  129342. private loadTexture;
  129343. /**
  129344. * Clones the color gradind texture.
  129345. */
  129346. clone(): ColorGradingTexture;
  129347. /**
  129348. * Called during delayed load for textures.
  129349. */
  129350. delayLoad(): void;
  129351. /**
  129352. * Parses a color grading texture serialized by Babylon.
  129353. * @param parsedTexture The texture information being parsedTexture
  129354. * @param scene The scene to load the texture in
  129355. * @param rootUrl The root url of the data assets to load
  129356. * @return A color gradind texture
  129357. */
  129358. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129359. /**
  129360. * Serializes the LUT texture to json format.
  129361. */
  129362. serialize(): any;
  129363. }
  129364. }
  129365. declare module BABYLON {
  129366. /**
  129367. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129368. */
  129369. export class EquiRectangularCubeTexture extends BaseTexture {
  129370. /** The six faces of the cube. */
  129371. private static _FacesMapping;
  129372. private _noMipmap;
  129373. private _onLoad;
  129374. private _onError;
  129375. /** The size of the cubemap. */
  129376. private _size;
  129377. /** The buffer of the image. */
  129378. private _buffer;
  129379. /** The width of the input image. */
  129380. private _width;
  129381. /** The height of the input image. */
  129382. private _height;
  129383. /** The URL to the image. */
  129384. url: string;
  129385. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129386. coordinatesMode: number;
  129387. /**
  129388. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129389. * @param url The location of the image
  129390. * @param scene The scene the texture will be used in
  129391. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129392. * @param noMipmap Forces to not generate the mipmap if true
  129393. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129394. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129395. * @param onLoad — defines a callback called when texture is loaded
  129396. * @param onError — defines a callback called if there is an error
  129397. */
  129398. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129399. /**
  129400. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129401. */
  129402. private loadImage;
  129403. /**
  129404. * Convert the image buffer into a cubemap and create a CubeTexture.
  129405. */
  129406. private loadTexture;
  129407. /**
  129408. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129409. * @param buffer The ArrayBuffer that should be converted.
  129410. * @returns The buffer as Float32Array.
  129411. */
  129412. private getFloat32ArrayFromArrayBuffer;
  129413. /**
  129414. * Get the current class name of the texture useful for serialization or dynamic coding.
  129415. * @returns "EquiRectangularCubeTexture"
  129416. */
  129417. getClassName(): string;
  129418. /**
  129419. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129420. * @returns A clone of the current EquiRectangularCubeTexture.
  129421. */
  129422. clone(): EquiRectangularCubeTexture;
  129423. }
  129424. }
  129425. declare module BABYLON {
  129426. /**
  129427. * Based on jsTGALoader - Javascript loader for TGA file
  129428. * By Vincent Thibault
  129429. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129430. */
  129431. export class TGATools {
  129432. private static _TYPE_INDEXED;
  129433. private static _TYPE_RGB;
  129434. private static _TYPE_GREY;
  129435. private static _TYPE_RLE_INDEXED;
  129436. private static _TYPE_RLE_RGB;
  129437. private static _TYPE_RLE_GREY;
  129438. private static _ORIGIN_MASK;
  129439. private static _ORIGIN_SHIFT;
  129440. private static _ORIGIN_BL;
  129441. private static _ORIGIN_BR;
  129442. private static _ORIGIN_UL;
  129443. private static _ORIGIN_UR;
  129444. /**
  129445. * Gets the header of a TGA file
  129446. * @param data defines the TGA data
  129447. * @returns the header
  129448. */
  129449. static GetTGAHeader(data: Uint8Array): any;
  129450. /**
  129451. * Uploads TGA content to a Babylon Texture
  129452. * @hidden
  129453. */
  129454. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129455. /** @hidden */
  129456. 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;
  129457. /** @hidden */
  129458. 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;
  129459. /** @hidden */
  129460. 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;
  129461. /** @hidden */
  129462. 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;
  129463. /** @hidden */
  129464. 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;
  129465. /** @hidden */
  129466. 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;
  129467. }
  129468. }
  129469. declare module BABYLON {
  129470. /**
  129471. * Implementation of the TGA Texture Loader.
  129472. * @hidden
  129473. */
  129474. export class _TGATextureLoader implements IInternalTextureLoader {
  129475. /**
  129476. * Defines wether the loader supports cascade loading the different faces.
  129477. */
  129478. readonly supportCascades: boolean;
  129479. /**
  129480. * This returns if the loader support the current file information.
  129481. * @param extension defines the file extension of the file being loaded
  129482. * @returns true if the loader can load the specified file
  129483. */
  129484. canLoad(extension: string): boolean;
  129485. /**
  129486. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129487. * @param data contains the texture data
  129488. * @param texture defines the BabylonJS internal texture
  129489. * @param createPolynomials will be true if polynomials have been requested
  129490. * @param onLoad defines the callback to trigger once the texture is ready
  129491. * @param onError defines the callback to trigger in case of error
  129492. */
  129493. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129494. /**
  129495. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129496. * @param data contains the texture data
  129497. * @param texture defines the BabylonJS internal texture
  129498. * @param callback defines the method to call once ready to upload
  129499. */
  129500. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129501. }
  129502. }
  129503. declare module BABYLON {
  129504. /**
  129505. * Info about the .basis files
  129506. */
  129507. class BasisFileInfo {
  129508. /**
  129509. * If the file has alpha
  129510. */
  129511. hasAlpha: boolean;
  129512. /**
  129513. * Info about each image of the basis file
  129514. */
  129515. images: Array<{
  129516. levels: Array<{
  129517. width: number;
  129518. height: number;
  129519. transcodedPixels: ArrayBufferView;
  129520. }>;
  129521. }>;
  129522. }
  129523. /**
  129524. * Result of transcoding a basis file
  129525. */
  129526. class TranscodeResult {
  129527. /**
  129528. * Info about the .basis file
  129529. */
  129530. fileInfo: BasisFileInfo;
  129531. /**
  129532. * Format to use when loading the file
  129533. */
  129534. format: number;
  129535. }
  129536. /**
  129537. * Configuration options for the Basis transcoder
  129538. */
  129539. export class BasisTranscodeConfiguration {
  129540. /**
  129541. * Supported compression formats used to determine the supported output format of the transcoder
  129542. */
  129543. supportedCompressionFormats?: {
  129544. /**
  129545. * etc1 compression format
  129546. */
  129547. etc1?: boolean;
  129548. /**
  129549. * s3tc compression format
  129550. */
  129551. s3tc?: boolean;
  129552. /**
  129553. * pvrtc compression format
  129554. */
  129555. pvrtc?: boolean;
  129556. /**
  129557. * etc2 compression format
  129558. */
  129559. etc2?: boolean;
  129560. };
  129561. /**
  129562. * If mipmap levels should be loaded for transcoded images (Default: true)
  129563. */
  129564. loadMipmapLevels?: boolean;
  129565. /**
  129566. * Index of a single image to load (Default: all images)
  129567. */
  129568. loadSingleImage?: number;
  129569. }
  129570. /**
  129571. * Used to load .Basis files
  129572. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129573. */
  129574. export class BasisTools {
  129575. private static _IgnoreSupportedFormats;
  129576. /**
  129577. * URL to use when loading the basis transcoder
  129578. */
  129579. static JSModuleURL: string;
  129580. /**
  129581. * URL to use when loading the wasm module for the transcoder
  129582. */
  129583. static WasmModuleURL: string;
  129584. /**
  129585. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129586. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129587. * @returns internal format corresponding to the Basis format
  129588. */
  129589. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129590. private static _WorkerPromise;
  129591. private static _Worker;
  129592. private static _actionId;
  129593. private static _CreateWorkerAsync;
  129594. /**
  129595. * Transcodes a loaded image file to compressed pixel data
  129596. * @param data image data to transcode
  129597. * @param config configuration options for the transcoding
  129598. * @returns a promise resulting in the transcoded image
  129599. */
  129600. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129601. /**
  129602. * Loads a texture from the transcode result
  129603. * @param texture texture load to
  129604. * @param transcodeResult the result of transcoding the basis file to load from
  129605. */
  129606. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129607. }
  129608. }
  129609. declare module BABYLON {
  129610. /**
  129611. * Loader for .basis file format
  129612. */
  129613. export class _BasisTextureLoader implements IInternalTextureLoader {
  129614. /**
  129615. * Defines whether the loader supports cascade loading the different faces.
  129616. */
  129617. readonly supportCascades: boolean;
  129618. /**
  129619. * This returns if the loader support the current file information.
  129620. * @param extension defines the file extension of the file being loaded
  129621. * @returns true if the loader can load the specified file
  129622. */
  129623. canLoad(extension: string): boolean;
  129624. /**
  129625. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129626. * @param data contains the texture data
  129627. * @param texture defines the BabylonJS internal texture
  129628. * @param createPolynomials will be true if polynomials have been requested
  129629. * @param onLoad defines the callback to trigger once the texture is ready
  129630. * @param onError defines the callback to trigger in case of error
  129631. */
  129632. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129633. /**
  129634. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129635. * @param data contains the texture data
  129636. * @param texture defines the BabylonJS internal texture
  129637. * @param callback defines the method to call once ready to upload
  129638. */
  129639. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129640. }
  129641. }
  129642. declare module BABYLON {
  129643. /**
  129644. * 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.
  129645. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129646. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129647. */
  129648. export class CustomProceduralTexture extends ProceduralTexture {
  129649. private _animate;
  129650. private _time;
  129651. private _config;
  129652. private _texturePath;
  129653. /**
  129654. * Instantiates a new Custom Procedural Texture.
  129655. * 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.
  129656. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129657. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129658. * @param name Define the name of the texture
  129659. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129660. * @param size Define the size of the texture to create
  129661. * @param scene Define the scene the texture belongs to
  129662. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129663. * @param generateMipMaps Define if the texture should creates mip maps or not
  129664. */
  129665. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129666. private _loadJson;
  129667. /**
  129668. * Is the texture ready to be used ? (rendered at least once)
  129669. * @returns true if ready, otherwise, false.
  129670. */
  129671. isReady(): boolean;
  129672. /**
  129673. * Render the texture to its associated render target.
  129674. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129675. */
  129676. render(useCameraPostProcess?: boolean): void;
  129677. /**
  129678. * Update the list of dependant textures samplers in the shader.
  129679. */
  129680. updateTextures(): void;
  129681. /**
  129682. * Update the uniform values of the procedural texture in the shader.
  129683. */
  129684. updateShaderUniforms(): void;
  129685. /**
  129686. * Define if the texture animates or not.
  129687. */
  129688. get animate(): boolean;
  129689. set animate(value: boolean);
  129690. }
  129691. }
  129692. declare module BABYLON {
  129693. /** @hidden */
  129694. export var noisePixelShader: {
  129695. name: string;
  129696. shader: string;
  129697. };
  129698. }
  129699. declare module BABYLON {
  129700. /**
  129701. * Class used to generate noise procedural textures
  129702. */
  129703. export class NoiseProceduralTexture extends ProceduralTexture {
  129704. private _time;
  129705. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129706. brightness: number;
  129707. /** Defines the number of octaves to process */
  129708. octaves: number;
  129709. /** Defines the level of persistence (0.8 by default) */
  129710. persistence: number;
  129711. /** Gets or sets animation speed factor (default is 1) */
  129712. animationSpeedFactor: number;
  129713. /**
  129714. * Creates a new NoiseProceduralTexture
  129715. * @param name defines the name fo the texture
  129716. * @param size defines the size of the texture (default is 256)
  129717. * @param scene defines the hosting scene
  129718. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129719. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129720. */
  129721. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129722. private _updateShaderUniforms;
  129723. protected _getDefines(): string;
  129724. /** Generate the current state of the procedural texture */
  129725. render(useCameraPostProcess?: boolean): void;
  129726. /**
  129727. * Serializes this noise procedural texture
  129728. * @returns a serialized noise procedural texture object
  129729. */
  129730. serialize(): any;
  129731. /**
  129732. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129733. * @param parsedTexture defines parsed texture data
  129734. * @param scene defines the current scene
  129735. * @param rootUrl defines the root URL containing noise procedural texture information
  129736. * @returns a parsed NoiseProceduralTexture
  129737. */
  129738. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129739. }
  129740. }
  129741. declare module BABYLON {
  129742. /**
  129743. * Raw cube texture where the raw buffers are passed in
  129744. */
  129745. export class RawCubeTexture extends CubeTexture {
  129746. /**
  129747. * Creates a cube texture where the raw buffers are passed in.
  129748. * @param scene defines the scene the texture is attached to
  129749. * @param data defines the array of data to use to create each face
  129750. * @param size defines the size of the textures
  129751. * @param format defines the format of the data
  129752. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129753. * @param generateMipMaps defines if the engine should generate the mip levels
  129754. * @param invertY defines if data must be stored with Y axis inverted
  129755. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129756. * @param compression defines the compression used (null by default)
  129757. */
  129758. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129759. /**
  129760. * Updates the raw cube texture.
  129761. * @param data defines the data to store
  129762. * @param format defines the data format
  129763. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129764. * @param invertY defines if data must be stored with Y axis inverted
  129765. * @param compression defines the compression used (null by default)
  129766. * @param level defines which level of the texture to update
  129767. */
  129768. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129769. /**
  129770. * Updates a raw cube texture with RGBD encoded data.
  129771. * @param data defines the array of data [mipmap][face] to use to create each face
  129772. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129773. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129774. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129775. * @returns a promsie that resolves when the operation is complete
  129776. */
  129777. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129778. /**
  129779. * Clones the raw cube texture.
  129780. * @return a new cube texture
  129781. */
  129782. clone(): CubeTexture;
  129783. /** @hidden */
  129784. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129785. }
  129786. }
  129787. declare module BABYLON {
  129788. /**
  129789. * Class used to store 3D textures containing user data
  129790. */
  129791. export class RawTexture3D extends Texture {
  129792. /** Gets or sets the texture format to use */
  129793. format: number;
  129794. private _engine;
  129795. /**
  129796. * Create a new RawTexture3D
  129797. * @param data defines the data of the texture
  129798. * @param width defines the width of the texture
  129799. * @param height defines the height of the texture
  129800. * @param depth defines the depth of the texture
  129801. * @param format defines the texture format to use
  129802. * @param scene defines the hosting scene
  129803. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129804. * @param invertY defines if texture must be stored with Y axis inverted
  129805. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129806. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129807. */
  129808. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129809. /** Gets or sets the texture format to use */
  129810. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129811. /**
  129812. * Update the texture with new data
  129813. * @param data defines the data to store in the texture
  129814. */
  129815. update(data: ArrayBufferView): void;
  129816. }
  129817. }
  129818. declare module BABYLON {
  129819. /**
  129820. * Class used to store 2D array textures containing user data
  129821. */
  129822. export class RawTexture2DArray extends Texture {
  129823. /** Gets or sets the texture format to use */
  129824. format: number;
  129825. private _engine;
  129826. /**
  129827. * Create a new RawTexture2DArray
  129828. * @param data defines the data of the texture
  129829. * @param width defines the width of the texture
  129830. * @param height defines the height of the texture
  129831. * @param depth defines the number of layers of the texture
  129832. * @param format defines the texture format to use
  129833. * @param scene defines the hosting scene
  129834. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129835. * @param invertY defines if texture must be stored with Y axis inverted
  129836. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129837. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129838. */
  129839. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129840. /** Gets or sets the texture format to use */
  129841. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129842. /**
  129843. * Update the texture with new data
  129844. * @param data defines the data to store in the texture
  129845. */
  129846. update(data: ArrayBufferView): void;
  129847. }
  129848. }
  129849. declare module BABYLON {
  129850. /**
  129851. * Creates a refraction texture used by refraction channel of the standard material.
  129852. * It is like a mirror but to see through a material.
  129853. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129854. */
  129855. export class RefractionTexture extends RenderTargetTexture {
  129856. /**
  129857. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129858. * 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.
  129859. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129860. */
  129861. refractionPlane: Plane;
  129862. /**
  129863. * Define how deep under the surface we should see.
  129864. */
  129865. depth: number;
  129866. /**
  129867. * Creates a refraction texture used by refraction channel of the standard material.
  129868. * It is like a mirror but to see through a material.
  129869. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129870. * @param name Define the texture name
  129871. * @param size Define the size of the underlying texture
  129872. * @param scene Define the scene the refraction belongs to
  129873. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129874. */
  129875. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129876. /**
  129877. * Clone the refraction texture.
  129878. * @returns the cloned texture
  129879. */
  129880. clone(): RefractionTexture;
  129881. /**
  129882. * Serialize the texture to a JSON representation you could use in Parse later on
  129883. * @returns the serialized JSON representation
  129884. */
  129885. serialize(): any;
  129886. }
  129887. }
  129888. declare module BABYLON {
  129889. /**
  129890. * Defines the options related to the creation of an HtmlElementTexture
  129891. */
  129892. export interface IHtmlElementTextureOptions {
  129893. /**
  129894. * Defines wether mip maps should be created or not.
  129895. */
  129896. generateMipMaps?: boolean;
  129897. /**
  129898. * Defines the sampling mode of the texture.
  129899. */
  129900. samplingMode?: number;
  129901. /**
  129902. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129903. */
  129904. engine: Nullable<ThinEngine>;
  129905. /**
  129906. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129907. */
  129908. scene: Nullable<Scene>;
  129909. }
  129910. /**
  129911. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129912. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129913. * is automatically managed.
  129914. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129915. * in your application.
  129916. *
  129917. * As the update is not automatic, you need to call them manually.
  129918. */
  129919. export class HtmlElementTexture extends BaseTexture {
  129920. /**
  129921. * The texture URL.
  129922. */
  129923. element: HTMLVideoElement | HTMLCanvasElement;
  129924. private static readonly DefaultOptions;
  129925. private _textureMatrix;
  129926. private _engine;
  129927. private _isVideo;
  129928. private _generateMipMaps;
  129929. private _samplingMode;
  129930. /**
  129931. * Instantiates a HtmlElementTexture from the following parameters.
  129932. *
  129933. * @param name Defines the name of the texture
  129934. * @param element Defines the video or canvas the texture is filled with
  129935. * @param options Defines the other none mandatory texture creation options
  129936. */
  129937. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129938. private _createInternalTexture;
  129939. /**
  129940. * Returns the texture matrix used in most of the material.
  129941. */
  129942. getTextureMatrix(): Matrix;
  129943. /**
  129944. * Updates the content of the texture.
  129945. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129946. */
  129947. update(invertY?: Nullable<boolean>): void;
  129948. }
  129949. }
  129950. declare module BABYLON {
  129951. /**
  129952. * Defines the basic options interface of a TexturePacker Frame
  129953. */
  129954. export interface ITexturePackerFrame {
  129955. /**
  129956. * The frame ID
  129957. */
  129958. id: number;
  129959. /**
  129960. * The frames Scale
  129961. */
  129962. scale: Vector2;
  129963. /**
  129964. * The Frames offset
  129965. */
  129966. offset: Vector2;
  129967. }
  129968. /**
  129969. * This is a support class for frame Data on texture packer sets.
  129970. */
  129971. export class TexturePackerFrame implements ITexturePackerFrame {
  129972. /**
  129973. * The frame ID
  129974. */
  129975. id: number;
  129976. /**
  129977. * The frames Scale
  129978. */
  129979. scale: Vector2;
  129980. /**
  129981. * The Frames offset
  129982. */
  129983. offset: Vector2;
  129984. /**
  129985. * Initializes a texture package frame.
  129986. * @param id The numerical frame identifier
  129987. * @param scale Scalar Vector2 for UV frame
  129988. * @param offset Vector2 for the frame position in UV units.
  129989. * @returns TexturePackerFrame
  129990. */
  129991. constructor(id: number, scale: Vector2, offset: Vector2);
  129992. }
  129993. }
  129994. declare module BABYLON {
  129995. /**
  129996. * Defines the basic options interface of a TexturePacker
  129997. */
  129998. export interface ITexturePackerOptions {
  129999. /**
  130000. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  130001. */
  130002. map?: string[];
  130003. /**
  130004. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  130005. */
  130006. uvsIn?: string;
  130007. /**
  130008. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  130009. */
  130010. uvsOut?: string;
  130011. /**
  130012. * number representing the layout style. Defaults to LAYOUT_STRIP
  130013. */
  130014. layout?: number;
  130015. /**
  130016. * number of columns if using custom column count layout(2). This defaults to 4.
  130017. */
  130018. colnum?: number;
  130019. /**
  130020. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  130021. */
  130022. updateInputMeshes?: boolean;
  130023. /**
  130024. * boolean flag to dispose all the source textures. Defaults to true.
  130025. */
  130026. disposeSources?: boolean;
  130027. /**
  130028. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  130029. */
  130030. fillBlanks?: boolean;
  130031. /**
  130032. * string value representing the context fill style color. Defaults to 'black'.
  130033. */
  130034. customFillColor?: string;
  130035. /**
  130036. * Width and Height Value of each Frame in the TexturePacker Sets
  130037. */
  130038. frameSize?: number;
  130039. /**
  130040. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  130041. */
  130042. paddingRatio?: number;
  130043. /**
  130044. * Number that declares the fill method for the padding gutter.
  130045. */
  130046. paddingMode?: number;
  130047. /**
  130048. * If in SUBUV_COLOR padding mode what color to use.
  130049. */
  130050. paddingColor?: Color3 | Color4;
  130051. }
  130052. /**
  130053. * Defines the basic interface of a TexturePacker JSON File
  130054. */
  130055. export interface ITexturePackerJSON {
  130056. /**
  130057. * The frame ID
  130058. */
  130059. name: string;
  130060. /**
  130061. * The base64 channel data
  130062. */
  130063. sets: any;
  130064. /**
  130065. * The options of the Packer
  130066. */
  130067. options: ITexturePackerOptions;
  130068. /**
  130069. * The frame data of the Packer
  130070. */
  130071. frames: Array<number>;
  130072. }
  130073. /**
  130074. * This is a support class that generates a series of packed texture sets.
  130075. * @see https://doc.babylonjs.com/babylon101/materials
  130076. */
  130077. export class TexturePacker {
  130078. /** Packer Layout Constant 0 */
  130079. static readonly LAYOUT_STRIP: number;
  130080. /** Packer Layout Constant 1 */
  130081. static readonly LAYOUT_POWER2: number;
  130082. /** Packer Layout Constant 2 */
  130083. static readonly LAYOUT_COLNUM: number;
  130084. /** Packer Layout Constant 0 */
  130085. static readonly SUBUV_WRAP: number;
  130086. /** Packer Layout Constant 1 */
  130087. static readonly SUBUV_EXTEND: number;
  130088. /** Packer Layout Constant 2 */
  130089. static readonly SUBUV_COLOR: number;
  130090. /** The Name of the Texture Package */
  130091. name: string;
  130092. /** The scene scope of the TexturePacker */
  130093. scene: Scene;
  130094. /** The Meshes to target */
  130095. meshes: AbstractMesh[];
  130096. /** Arguments passed with the Constructor */
  130097. options: ITexturePackerOptions;
  130098. /** The promise that is started upon initialization */
  130099. promise: Nullable<Promise<TexturePacker | string>>;
  130100. /** The Container object for the channel sets that are generated */
  130101. sets: object;
  130102. /** The Container array for the frames that are generated */
  130103. frames: TexturePackerFrame[];
  130104. /** The expected number of textures the system is parsing. */
  130105. private _expecting;
  130106. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  130107. private _paddingValue;
  130108. /**
  130109. * Initializes a texture package series from an array of meshes or a single mesh.
  130110. * @param name The name of the package
  130111. * @param meshes The target meshes to compose the package from
  130112. * @param options The arguments that texture packer should follow while building.
  130113. * @param scene The scene which the textures are scoped to.
  130114. * @returns TexturePacker
  130115. */
  130116. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  130117. /**
  130118. * Starts the package process
  130119. * @param resolve The promises resolution function
  130120. * @returns TexturePacker
  130121. */
  130122. private _createFrames;
  130123. /**
  130124. * Calculates the Size of the Channel Sets
  130125. * @returns Vector2
  130126. */
  130127. private _calculateSize;
  130128. /**
  130129. * Calculates the UV data for the frames.
  130130. * @param baseSize the base frameSize
  130131. * @param padding the base frame padding
  130132. * @param dtSize size of the Dynamic Texture for that channel
  130133. * @param dtUnits is 1/dtSize
  130134. * @param update flag to update the input meshes
  130135. */
  130136. private _calculateMeshUVFrames;
  130137. /**
  130138. * Calculates the frames Offset.
  130139. * @param index of the frame
  130140. * @returns Vector2
  130141. */
  130142. private _getFrameOffset;
  130143. /**
  130144. * Updates a Mesh to the frame data
  130145. * @param mesh that is the target
  130146. * @param frameID or the frame index
  130147. */
  130148. private _updateMeshUV;
  130149. /**
  130150. * Updates a Meshes materials to use the texture packer channels
  130151. * @param m is the mesh to target
  130152. * @param force all channels on the packer to be set.
  130153. */
  130154. private _updateTextureReferences;
  130155. /**
  130156. * Public method to set a Mesh to a frame
  130157. * @param m that is the target
  130158. * @param frameID or the frame index
  130159. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  130160. */
  130161. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  130162. /**
  130163. * Starts the async promise to compile the texture packer.
  130164. * @returns Promise<void>
  130165. */
  130166. processAsync(): Promise<void>;
  130167. /**
  130168. * Disposes all textures associated with this packer
  130169. */
  130170. dispose(): void;
  130171. /**
  130172. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  130173. * @param imageType is the image type to use.
  130174. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  130175. */
  130176. download(imageType?: string, quality?: number): void;
  130177. /**
  130178. * Public method to load a texturePacker JSON file.
  130179. * @param data of the JSON file in string format.
  130180. */
  130181. updateFromJSON(data: string): void;
  130182. }
  130183. }
  130184. declare module BABYLON {
  130185. /**
  130186. * Enum used to define the target of a block
  130187. */
  130188. export enum NodeMaterialBlockTargets {
  130189. /** Vertex shader */
  130190. Vertex = 1,
  130191. /** Fragment shader */
  130192. Fragment = 2,
  130193. /** Neutral */
  130194. Neutral = 4,
  130195. /** Vertex and Fragment */
  130196. VertexAndFragment = 3
  130197. }
  130198. }
  130199. declare module BABYLON {
  130200. /**
  130201. * Defines the kind of connection point for node based material
  130202. */
  130203. export enum NodeMaterialBlockConnectionPointTypes {
  130204. /** Float */
  130205. Float = 1,
  130206. /** Int */
  130207. Int = 2,
  130208. /** Vector2 */
  130209. Vector2 = 4,
  130210. /** Vector3 */
  130211. Vector3 = 8,
  130212. /** Vector4 */
  130213. Vector4 = 16,
  130214. /** Color3 */
  130215. Color3 = 32,
  130216. /** Color4 */
  130217. Color4 = 64,
  130218. /** Matrix */
  130219. Matrix = 128,
  130220. /** Detect type based on connection */
  130221. AutoDetect = 1024,
  130222. /** Output type that will be defined by input type */
  130223. BasedOnInput = 2048
  130224. }
  130225. }
  130226. declare module BABYLON {
  130227. /**
  130228. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  130229. */
  130230. export enum NodeMaterialBlockConnectionPointMode {
  130231. /** Value is an uniform */
  130232. Uniform = 0,
  130233. /** Value is a mesh attribute */
  130234. Attribute = 1,
  130235. /** Value is a varying between vertex and fragment shaders */
  130236. Varying = 2,
  130237. /** Mode is undefined */
  130238. Undefined = 3
  130239. }
  130240. }
  130241. declare module BABYLON {
  130242. /**
  130243. * Enum used to define system values e.g. values automatically provided by the system
  130244. */
  130245. export enum NodeMaterialSystemValues {
  130246. /** World */
  130247. World = 1,
  130248. /** View */
  130249. View = 2,
  130250. /** Projection */
  130251. Projection = 3,
  130252. /** ViewProjection */
  130253. ViewProjection = 4,
  130254. /** WorldView */
  130255. WorldView = 5,
  130256. /** WorldViewProjection */
  130257. WorldViewProjection = 6,
  130258. /** CameraPosition */
  130259. CameraPosition = 7,
  130260. /** Fog Color */
  130261. FogColor = 8,
  130262. /** Delta time */
  130263. DeltaTime = 9
  130264. }
  130265. }
  130266. declare module BABYLON {
  130267. /**
  130268. * Root class for all node material optimizers
  130269. */
  130270. export class NodeMaterialOptimizer {
  130271. /**
  130272. * Function used to optimize a NodeMaterial graph
  130273. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  130274. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  130275. */
  130276. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  130277. }
  130278. }
  130279. declare module BABYLON {
  130280. /**
  130281. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  130282. */
  130283. export class TransformBlock extends NodeMaterialBlock {
  130284. /**
  130285. * Defines the value to use to complement W value to transform it to a Vector4
  130286. */
  130287. complementW: number;
  130288. /**
  130289. * Defines the value to use to complement z value to transform it to a Vector4
  130290. */
  130291. complementZ: number;
  130292. /**
  130293. * Creates a new TransformBlock
  130294. * @param name defines the block name
  130295. */
  130296. constructor(name: string);
  130297. /**
  130298. * Gets the current class name
  130299. * @returns the class name
  130300. */
  130301. getClassName(): string;
  130302. /**
  130303. * Gets the vector input
  130304. */
  130305. get vector(): NodeMaterialConnectionPoint;
  130306. /**
  130307. * Gets the output component
  130308. */
  130309. get output(): NodeMaterialConnectionPoint;
  130310. /**
  130311. * Gets the xyz output component
  130312. */
  130313. get xyz(): NodeMaterialConnectionPoint;
  130314. /**
  130315. * Gets the matrix transform input
  130316. */
  130317. get transform(): NodeMaterialConnectionPoint;
  130318. protected _buildBlock(state: NodeMaterialBuildState): this;
  130319. serialize(): any;
  130320. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130321. protected _dumpPropertiesCode(): string;
  130322. }
  130323. }
  130324. declare module BABYLON {
  130325. /**
  130326. * Block used to output the vertex position
  130327. */
  130328. export class VertexOutputBlock extends NodeMaterialBlock {
  130329. /**
  130330. * Creates a new VertexOutputBlock
  130331. * @param name defines the block name
  130332. */
  130333. constructor(name: string);
  130334. /**
  130335. * Gets the current class name
  130336. * @returns the class name
  130337. */
  130338. getClassName(): string;
  130339. /**
  130340. * Gets the vector input component
  130341. */
  130342. get vector(): NodeMaterialConnectionPoint;
  130343. protected _buildBlock(state: NodeMaterialBuildState): this;
  130344. }
  130345. }
  130346. declare module BABYLON {
  130347. /**
  130348. * Block used to output the final color
  130349. */
  130350. export class FragmentOutputBlock extends NodeMaterialBlock {
  130351. /**
  130352. * Create a new FragmentOutputBlock
  130353. * @param name defines the block name
  130354. */
  130355. constructor(name: string);
  130356. /**
  130357. * Gets the current class name
  130358. * @returns the class name
  130359. */
  130360. getClassName(): string;
  130361. /**
  130362. * Gets the rgba input component
  130363. */
  130364. get rgba(): NodeMaterialConnectionPoint;
  130365. /**
  130366. * Gets the rgb input component
  130367. */
  130368. get rgb(): NodeMaterialConnectionPoint;
  130369. /**
  130370. * Gets the a input component
  130371. */
  130372. get a(): NodeMaterialConnectionPoint;
  130373. protected _buildBlock(state: NodeMaterialBuildState): this;
  130374. }
  130375. }
  130376. declare module BABYLON {
  130377. /**
  130378. * Block used to read a reflection texture from a sampler
  130379. */
  130380. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130381. private _define3DName;
  130382. private _defineCubicName;
  130383. private _defineExplicitName;
  130384. private _defineProjectionName;
  130385. private _defineLocalCubicName;
  130386. private _defineSphericalName;
  130387. private _definePlanarName;
  130388. private _defineEquirectangularName;
  130389. private _defineMirroredEquirectangularFixedName;
  130390. private _defineEquirectangularFixedName;
  130391. private _defineSkyboxName;
  130392. private _cubeSamplerName;
  130393. private _2DSamplerName;
  130394. private _positionUVWName;
  130395. private _directionWName;
  130396. private _reflectionCoordsName;
  130397. private _reflection2DCoordsName;
  130398. private _reflectionColorName;
  130399. private _reflectionMatrixName;
  130400. /**
  130401. * Gets or sets the texture associated with the node
  130402. */
  130403. texture: Nullable<BaseTexture>;
  130404. /**
  130405. * Create a new TextureBlock
  130406. * @param name defines the block name
  130407. */
  130408. constructor(name: string);
  130409. /**
  130410. * Gets the current class name
  130411. * @returns the class name
  130412. */
  130413. getClassName(): string;
  130414. /**
  130415. * Gets the world position input component
  130416. */
  130417. get position(): NodeMaterialConnectionPoint;
  130418. /**
  130419. * Gets the world position input component
  130420. */
  130421. get worldPosition(): NodeMaterialConnectionPoint;
  130422. /**
  130423. * Gets the world normal input component
  130424. */
  130425. get worldNormal(): NodeMaterialConnectionPoint;
  130426. /**
  130427. * Gets the world input component
  130428. */
  130429. get world(): NodeMaterialConnectionPoint;
  130430. /**
  130431. * Gets the camera (or eye) position component
  130432. */
  130433. get cameraPosition(): NodeMaterialConnectionPoint;
  130434. /**
  130435. * Gets the view input component
  130436. */
  130437. get view(): NodeMaterialConnectionPoint;
  130438. /**
  130439. * Gets the rgb output component
  130440. */
  130441. get rgb(): NodeMaterialConnectionPoint;
  130442. /**
  130443. * Gets the r output component
  130444. */
  130445. get r(): NodeMaterialConnectionPoint;
  130446. /**
  130447. * Gets the g output component
  130448. */
  130449. get g(): NodeMaterialConnectionPoint;
  130450. /**
  130451. * Gets the b output component
  130452. */
  130453. get b(): NodeMaterialConnectionPoint;
  130454. autoConfigure(material: NodeMaterial): void;
  130455. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130456. isReady(): boolean;
  130457. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130458. private _injectVertexCode;
  130459. private _writeOutput;
  130460. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130461. protected _dumpPropertiesCode(): string;
  130462. serialize(): any;
  130463. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130464. }
  130465. }
  130466. declare module BABYLON {
  130467. /**
  130468. * Interface used to configure the node material editor
  130469. */
  130470. export interface INodeMaterialEditorOptions {
  130471. /** Define the URl to load node editor script */
  130472. editorURL?: string;
  130473. }
  130474. /** @hidden */
  130475. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130476. NORMAL: boolean;
  130477. TANGENT: boolean;
  130478. UV1: boolean;
  130479. /** BONES */
  130480. NUM_BONE_INFLUENCERS: number;
  130481. BonesPerMesh: number;
  130482. BONETEXTURE: boolean;
  130483. /** MORPH TARGETS */
  130484. MORPHTARGETS: boolean;
  130485. MORPHTARGETS_NORMAL: boolean;
  130486. MORPHTARGETS_TANGENT: boolean;
  130487. MORPHTARGETS_UV: boolean;
  130488. NUM_MORPH_INFLUENCERS: number;
  130489. /** IMAGE PROCESSING */
  130490. IMAGEPROCESSING: boolean;
  130491. VIGNETTE: boolean;
  130492. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130493. VIGNETTEBLENDMODEOPAQUE: boolean;
  130494. TONEMAPPING: boolean;
  130495. TONEMAPPING_ACES: boolean;
  130496. CONTRAST: boolean;
  130497. EXPOSURE: boolean;
  130498. COLORCURVES: boolean;
  130499. COLORGRADING: boolean;
  130500. COLORGRADING3D: boolean;
  130501. SAMPLER3DGREENDEPTH: boolean;
  130502. SAMPLER3DBGRMAP: boolean;
  130503. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130504. /** MISC. */
  130505. BUMPDIRECTUV: number;
  130506. constructor();
  130507. setValue(name: string, value: boolean): void;
  130508. }
  130509. /**
  130510. * Class used to configure NodeMaterial
  130511. */
  130512. export interface INodeMaterialOptions {
  130513. /**
  130514. * Defines if blocks should emit comments
  130515. */
  130516. emitComments: boolean;
  130517. }
  130518. /**
  130519. * Class used to create a node based material built by assembling shader blocks
  130520. */
  130521. export class NodeMaterial extends PushMaterial {
  130522. private static _BuildIdGenerator;
  130523. private _options;
  130524. private _vertexCompilationState;
  130525. private _fragmentCompilationState;
  130526. private _sharedData;
  130527. private _buildId;
  130528. private _buildWasSuccessful;
  130529. private _cachedWorldViewMatrix;
  130530. private _cachedWorldViewProjectionMatrix;
  130531. private _optimizers;
  130532. private _animationFrame;
  130533. /** Define the Url to load node editor script */
  130534. static EditorURL: string;
  130535. /** Define the Url to load snippets */
  130536. static SnippetUrl: string;
  130537. private BJSNODEMATERIALEDITOR;
  130538. /** Get the inspector from bundle or global */
  130539. private _getGlobalNodeMaterialEditor;
  130540. /**
  130541. * Gets or sets data used by visual editor
  130542. * @see https://nme.babylonjs.com
  130543. */
  130544. editorData: any;
  130545. /**
  130546. * 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)
  130547. */
  130548. ignoreAlpha: boolean;
  130549. /**
  130550. * Defines the maximum number of lights that can be used in the material
  130551. */
  130552. maxSimultaneousLights: number;
  130553. /**
  130554. * Observable raised when the material is built
  130555. */
  130556. onBuildObservable: Observable<NodeMaterial>;
  130557. /**
  130558. * Gets or sets the root nodes of the material vertex shader
  130559. */
  130560. _vertexOutputNodes: NodeMaterialBlock[];
  130561. /**
  130562. * Gets or sets the root nodes of the material fragment (pixel) shader
  130563. */
  130564. _fragmentOutputNodes: NodeMaterialBlock[];
  130565. /** Gets or sets options to control the node material overall behavior */
  130566. get options(): INodeMaterialOptions;
  130567. set options(options: INodeMaterialOptions);
  130568. /**
  130569. * Default configuration related to image processing available in the standard Material.
  130570. */
  130571. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130572. /**
  130573. * Gets the image processing configuration used either in this material.
  130574. */
  130575. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130576. /**
  130577. * Sets the Default image processing configuration used either in the this material.
  130578. *
  130579. * If sets to null, the scene one is in use.
  130580. */
  130581. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130582. /**
  130583. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130584. */
  130585. attachedBlocks: NodeMaterialBlock[];
  130586. /**
  130587. * Create a new node based material
  130588. * @param name defines the material name
  130589. * @param scene defines the hosting scene
  130590. * @param options defines creation option
  130591. */
  130592. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130593. /**
  130594. * Gets the current class name of the material e.g. "NodeMaterial"
  130595. * @returns the class name
  130596. */
  130597. getClassName(): string;
  130598. /**
  130599. * Keep track of the image processing observer to allow dispose and replace.
  130600. */
  130601. private _imageProcessingObserver;
  130602. /**
  130603. * Attaches a new image processing configuration to the Standard Material.
  130604. * @param configuration
  130605. */
  130606. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130607. /**
  130608. * Get a block by its name
  130609. * @param name defines the name of the block to retrieve
  130610. * @returns the required block or null if not found
  130611. */
  130612. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130613. /**
  130614. * Get a block by its name
  130615. * @param predicate defines the predicate used to find the good candidate
  130616. * @returns the required block or null if not found
  130617. */
  130618. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130619. /**
  130620. * Get an input block by its name
  130621. * @param predicate defines the predicate used to find the good candidate
  130622. * @returns the required input block or null if not found
  130623. */
  130624. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130625. /**
  130626. * Gets the list of input blocks attached to this material
  130627. * @returns an array of InputBlocks
  130628. */
  130629. getInputBlocks(): InputBlock[];
  130630. /**
  130631. * Adds a new optimizer to the list of optimizers
  130632. * @param optimizer defines the optimizers to add
  130633. * @returns the current material
  130634. */
  130635. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130636. /**
  130637. * Remove an optimizer from the list of optimizers
  130638. * @param optimizer defines the optimizers to remove
  130639. * @returns the current material
  130640. */
  130641. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130642. /**
  130643. * Add a new block to the list of output nodes
  130644. * @param node defines the node to add
  130645. * @returns the current material
  130646. */
  130647. addOutputNode(node: NodeMaterialBlock): this;
  130648. /**
  130649. * Remove a block from the list of root nodes
  130650. * @param node defines the node to remove
  130651. * @returns the current material
  130652. */
  130653. removeOutputNode(node: NodeMaterialBlock): this;
  130654. private _addVertexOutputNode;
  130655. private _removeVertexOutputNode;
  130656. private _addFragmentOutputNode;
  130657. private _removeFragmentOutputNode;
  130658. /**
  130659. * Specifies if the material will require alpha blending
  130660. * @returns a boolean specifying if alpha blending is needed
  130661. */
  130662. needAlphaBlending(): boolean;
  130663. /**
  130664. * Specifies if this material should be rendered in alpha test mode
  130665. * @returns a boolean specifying if an alpha test is needed.
  130666. */
  130667. needAlphaTesting(): boolean;
  130668. private _initializeBlock;
  130669. private _resetDualBlocks;
  130670. /**
  130671. * Remove a block from the current node material
  130672. * @param block defines the block to remove
  130673. */
  130674. removeBlock(block: NodeMaterialBlock): void;
  130675. /**
  130676. * Build the material and generates the inner effect
  130677. * @param verbose defines if the build should log activity
  130678. */
  130679. build(verbose?: boolean): void;
  130680. /**
  130681. * Runs an otpimization phase to try to improve the shader code
  130682. */
  130683. optimize(): void;
  130684. private _prepareDefinesForAttributes;
  130685. /**
  130686. * Get if the submesh is ready to be used and all its information available.
  130687. * Child classes can use it to update shaders
  130688. * @param mesh defines the mesh to check
  130689. * @param subMesh defines which submesh to check
  130690. * @param useInstances specifies that instances should be used
  130691. * @returns a boolean indicating that the submesh is ready or not
  130692. */
  130693. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130694. /**
  130695. * Get a string representing the shaders built by the current node graph
  130696. */
  130697. get compiledShaders(): string;
  130698. /**
  130699. * Binds the world matrix to the material
  130700. * @param world defines the world transformation matrix
  130701. */
  130702. bindOnlyWorldMatrix(world: Matrix): void;
  130703. /**
  130704. * Binds the submesh to this material by preparing the effect and shader to draw
  130705. * @param world defines the world transformation matrix
  130706. * @param mesh defines the mesh containing the submesh
  130707. * @param subMesh defines the submesh to bind the material to
  130708. */
  130709. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130710. /**
  130711. * Gets the active textures from the material
  130712. * @returns an array of textures
  130713. */
  130714. getActiveTextures(): BaseTexture[];
  130715. /**
  130716. * Gets the list of texture blocks
  130717. * @returns an array of texture blocks
  130718. */
  130719. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130720. /**
  130721. * Specifies if the material uses a texture
  130722. * @param texture defines the texture to check against the material
  130723. * @returns a boolean specifying if the material uses the texture
  130724. */
  130725. hasTexture(texture: BaseTexture): boolean;
  130726. /**
  130727. * Disposes the material
  130728. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130729. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130730. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130731. */
  130732. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130733. /** Creates the node editor window. */
  130734. private _createNodeEditor;
  130735. /**
  130736. * Launch the node material editor
  130737. * @param config Define the configuration of the editor
  130738. * @return a promise fulfilled when the node editor is visible
  130739. */
  130740. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130741. /**
  130742. * Clear the current material
  130743. */
  130744. clear(): void;
  130745. /**
  130746. * Clear the current material and set it to a default state
  130747. */
  130748. setToDefault(): void;
  130749. /**
  130750. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130751. * @param url defines the url to load from
  130752. * @returns a promise that will fullfil when the material is fully loaded
  130753. */
  130754. loadAsync(url: string): Promise<void>;
  130755. private _gatherBlocks;
  130756. /**
  130757. * Generate a string containing the code declaration required to create an equivalent of this material
  130758. * @returns a string
  130759. */
  130760. generateCode(): string;
  130761. /**
  130762. * Serializes this material in a JSON representation
  130763. * @returns the serialized material object
  130764. */
  130765. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130766. private _restoreConnections;
  130767. /**
  130768. * Clear the current graph and load a new one from a serialization object
  130769. * @param source defines the JSON representation of the material
  130770. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130771. */
  130772. loadFromSerialization(source: any, rootUrl?: string): void;
  130773. /**
  130774. * Creates a node material from parsed material data
  130775. * @param source defines the JSON representation of the material
  130776. * @param scene defines the hosting scene
  130777. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130778. * @returns a new node material
  130779. */
  130780. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130781. /**
  130782. * Creates a node material from a snippet saved in a remote file
  130783. * @param name defines the name of the material to create
  130784. * @param url defines the url to load from
  130785. * @param scene defines the hosting scene
  130786. * @returns a promise that will resolve to the new node material
  130787. */
  130788. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130789. /**
  130790. * Creates a node material from a snippet saved by the node material editor
  130791. * @param snippetId defines the snippet to load
  130792. * @param scene defines the hosting scene
  130793. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130794. * @returns a promise that will resolve to the new node material
  130795. */
  130796. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130797. /**
  130798. * Creates a new node material set to default basic configuration
  130799. * @param name defines the name of the material
  130800. * @param scene defines the hosting scene
  130801. * @returns a new NodeMaterial
  130802. */
  130803. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130804. }
  130805. }
  130806. declare module BABYLON {
  130807. /**
  130808. * Block used to read a texture from a sampler
  130809. */
  130810. export class TextureBlock extends NodeMaterialBlock {
  130811. private _defineName;
  130812. private _linearDefineName;
  130813. private _tempTextureRead;
  130814. private _samplerName;
  130815. private _transformedUVName;
  130816. private _textureTransformName;
  130817. private _textureInfoName;
  130818. private _mainUVName;
  130819. private _mainUVDefineName;
  130820. /**
  130821. * Gets or sets the texture associated with the node
  130822. */
  130823. texture: Nullable<Texture>;
  130824. /**
  130825. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130826. */
  130827. convertToGammaSpace: boolean;
  130828. /**
  130829. * Create a new TextureBlock
  130830. * @param name defines the block name
  130831. */
  130832. constructor(name: string);
  130833. /**
  130834. * Gets the current class name
  130835. * @returns the class name
  130836. */
  130837. getClassName(): string;
  130838. /**
  130839. * Gets the uv input component
  130840. */
  130841. get uv(): NodeMaterialConnectionPoint;
  130842. /**
  130843. * Gets the rgba output component
  130844. */
  130845. get rgba(): NodeMaterialConnectionPoint;
  130846. /**
  130847. * Gets the rgb output component
  130848. */
  130849. get rgb(): NodeMaterialConnectionPoint;
  130850. /**
  130851. * Gets the r output component
  130852. */
  130853. get r(): NodeMaterialConnectionPoint;
  130854. /**
  130855. * Gets the g output component
  130856. */
  130857. get g(): NodeMaterialConnectionPoint;
  130858. /**
  130859. * Gets the b output component
  130860. */
  130861. get b(): NodeMaterialConnectionPoint;
  130862. /**
  130863. * Gets the a output component
  130864. */
  130865. get a(): NodeMaterialConnectionPoint;
  130866. get target(): NodeMaterialBlockTargets;
  130867. autoConfigure(material: NodeMaterial): void;
  130868. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130869. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130870. isReady(): boolean;
  130871. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130872. private get _isMixed();
  130873. private _injectVertexCode;
  130874. private _writeTextureRead;
  130875. private _writeOutput;
  130876. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130877. protected _dumpPropertiesCode(): string;
  130878. serialize(): any;
  130879. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130880. }
  130881. }
  130882. declare module BABYLON {
  130883. /**
  130884. * Class used to store shared data between 2 NodeMaterialBuildState
  130885. */
  130886. export class NodeMaterialBuildStateSharedData {
  130887. /**
  130888. * Gets the list of emitted varyings
  130889. */
  130890. temps: string[];
  130891. /**
  130892. * Gets the list of emitted varyings
  130893. */
  130894. varyings: string[];
  130895. /**
  130896. * Gets the varying declaration string
  130897. */
  130898. varyingDeclaration: string;
  130899. /**
  130900. * Input blocks
  130901. */
  130902. inputBlocks: InputBlock[];
  130903. /**
  130904. * Input blocks
  130905. */
  130906. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130907. /**
  130908. * Bindable blocks (Blocks that need to set data to the effect)
  130909. */
  130910. bindableBlocks: NodeMaterialBlock[];
  130911. /**
  130912. * List of blocks that can provide a compilation fallback
  130913. */
  130914. blocksWithFallbacks: NodeMaterialBlock[];
  130915. /**
  130916. * List of blocks that can provide a define update
  130917. */
  130918. blocksWithDefines: NodeMaterialBlock[];
  130919. /**
  130920. * List of blocks that can provide a repeatable content
  130921. */
  130922. repeatableContentBlocks: NodeMaterialBlock[];
  130923. /**
  130924. * List of blocks that can provide a dynamic list of uniforms
  130925. */
  130926. dynamicUniformBlocks: NodeMaterialBlock[];
  130927. /**
  130928. * List of blocks that can block the isReady function for the material
  130929. */
  130930. blockingBlocks: NodeMaterialBlock[];
  130931. /**
  130932. * Gets the list of animated inputs
  130933. */
  130934. animatedInputs: InputBlock[];
  130935. /**
  130936. * Build Id used to avoid multiple recompilations
  130937. */
  130938. buildId: number;
  130939. /** List of emitted variables */
  130940. variableNames: {
  130941. [key: string]: number;
  130942. };
  130943. /** List of emitted defines */
  130944. defineNames: {
  130945. [key: string]: number;
  130946. };
  130947. /** Should emit comments? */
  130948. emitComments: boolean;
  130949. /** Emit build activity */
  130950. verbose: boolean;
  130951. /** Gets or sets the hosting scene */
  130952. scene: Scene;
  130953. /**
  130954. * Gets the compilation hints emitted at compilation time
  130955. */
  130956. hints: {
  130957. needWorldViewMatrix: boolean;
  130958. needWorldViewProjectionMatrix: boolean;
  130959. needAlphaBlending: boolean;
  130960. needAlphaTesting: boolean;
  130961. };
  130962. /**
  130963. * List of compilation checks
  130964. */
  130965. checks: {
  130966. emitVertex: boolean;
  130967. emitFragment: boolean;
  130968. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130969. };
  130970. /** Creates a new shared data */
  130971. constructor();
  130972. /**
  130973. * Emits console errors and exceptions if there is a failing check
  130974. */
  130975. emitErrors(): void;
  130976. }
  130977. }
  130978. declare module BABYLON {
  130979. /**
  130980. * Class used to store node based material build state
  130981. */
  130982. export class NodeMaterialBuildState {
  130983. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130984. supportUniformBuffers: boolean;
  130985. /**
  130986. * Gets the list of emitted attributes
  130987. */
  130988. attributes: string[];
  130989. /**
  130990. * Gets the list of emitted uniforms
  130991. */
  130992. uniforms: string[];
  130993. /**
  130994. * Gets the list of emitted constants
  130995. */
  130996. constants: string[];
  130997. /**
  130998. * Gets the list of emitted samplers
  130999. */
  131000. samplers: string[];
  131001. /**
  131002. * Gets the list of emitted functions
  131003. */
  131004. functions: {
  131005. [key: string]: string;
  131006. };
  131007. /**
  131008. * Gets the list of emitted extensions
  131009. */
  131010. extensions: {
  131011. [key: string]: string;
  131012. };
  131013. /**
  131014. * Gets the target of the compilation state
  131015. */
  131016. target: NodeMaterialBlockTargets;
  131017. /**
  131018. * Gets the list of emitted counters
  131019. */
  131020. counters: {
  131021. [key: string]: number;
  131022. };
  131023. /**
  131024. * Shared data between multiple NodeMaterialBuildState instances
  131025. */
  131026. sharedData: NodeMaterialBuildStateSharedData;
  131027. /** @hidden */
  131028. _vertexState: NodeMaterialBuildState;
  131029. /** @hidden */
  131030. _attributeDeclaration: string;
  131031. /** @hidden */
  131032. _uniformDeclaration: string;
  131033. /** @hidden */
  131034. _constantDeclaration: string;
  131035. /** @hidden */
  131036. _samplerDeclaration: string;
  131037. /** @hidden */
  131038. _varyingTransfer: string;
  131039. private _repeatableContentAnchorIndex;
  131040. /** @hidden */
  131041. _builtCompilationString: string;
  131042. /**
  131043. * Gets the emitted compilation strings
  131044. */
  131045. compilationString: string;
  131046. /**
  131047. * Finalize the compilation strings
  131048. * @param state defines the current compilation state
  131049. */
  131050. finalize(state: NodeMaterialBuildState): void;
  131051. /** @hidden */
  131052. get _repeatableContentAnchor(): string;
  131053. /** @hidden */
  131054. _getFreeVariableName(prefix: string): string;
  131055. /** @hidden */
  131056. _getFreeDefineName(prefix: string): string;
  131057. /** @hidden */
  131058. _excludeVariableName(name: string): void;
  131059. /** @hidden */
  131060. _emit2DSampler(name: string): void;
  131061. /** @hidden */
  131062. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  131063. /** @hidden */
  131064. _emitExtension(name: string, extension: string): void;
  131065. /** @hidden */
  131066. _emitFunction(name: string, code: string, comments: string): void;
  131067. /** @hidden */
  131068. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  131069. replaceStrings?: {
  131070. search: RegExp;
  131071. replace: string;
  131072. }[];
  131073. repeatKey?: string;
  131074. }): string;
  131075. /** @hidden */
  131076. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  131077. repeatKey?: string;
  131078. removeAttributes?: boolean;
  131079. removeUniforms?: boolean;
  131080. removeVaryings?: boolean;
  131081. removeIfDef?: boolean;
  131082. replaceStrings?: {
  131083. search: RegExp;
  131084. replace: string;
  131085. }[];
  131086. }, storeKey?: string): void;
  131087. /** @hidden */
  131088. _registerTempVariable(name: string): boolean;
  131089. /** @hidden */
  131090. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  131091. /** @hidden */
  131092. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  131093. /** @hidden */
  131094. _emitFloat(value: number): string;
  131095. }
  131096. }
  131097. declare module BABYLON {
  131098. /**
  131099. * Defines a block that can be used inside a node based material
  131100. */
  131101. export class NodeMaterialBlock {
  131102. private _buildId;
  131103. private _buildTarget;
  131104. private _target;
  131105. private _isFinalMerger;
  131106. private _isInput;
  131107. protected _isUnique: boolean;
  131108. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  131109. inputsAreExclusive: boolean;
  131110. /** @hidden */
  131111. _codeVariableName: string;
  131112. /** @hidden */
  131113. _inputs: NodeMaterialConnectionPoint[];
  131114. /** @hidden */
  131115. _outputs: NodeMaterialConnectionPoint[];
  131116. /** @hidden */
  131117. _preparationId: number;
  131118. /**
  131119. * Gets or sets the name of the block
  131120. */
  131121. name: string;
  131122. /**
  131123. * Gets or sets the unique id of the node
  131124. */
  131125. uniqueId: number;
  131126. /**
  131127. * Gets or sets the comments associated with this block
  131128. */
  131129. comments: string;
  131130. /**
  131131. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  131132. */
  131133. get isUnique(): boolean;
  131134. /**
  131135. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  131136. */
  131137. get isFinalMerger(): boolean;
  131138. /**
  131139. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  131140. */
  131141. get isInput(): boolean;
  131142. /**
  131143. * Gets or sets the build Id
  131144. */
  131145. get buildId(): number;
  131146. set buildId(value: number);
  131147. /**
  131148. * Gets or sets the target of the block
  131149. */
  131150. get target(): NodeMaterialBlockTargets;
  131151. set target(value: NodeMaterialBlockTargets);
  131152. /**
  131153. * Gets the list of input points
  131154. */
  131155. get inputs(): NodeMaterialConnectionPoint[];
  131156. /** Gets the list of output points */
  131157. get outputs(): NodeMaterialConnectionPoint[];
  131158. /**
  131159. * Find an input by its name
  131160. * @param name defines the name of the input to look for
  131161. * @returns the input or null if not found
  131162. */
  131163. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131164. /**
  131165. * Find an output by its name
  131166. * @param name defines the name of the outputto look for
  131167. * @returns the output or null if not found
  131168. */
  131169. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131170. /**
  131171. * Creates a new NodeMaterialBlock
  131172. * @param name defines the block name
  131173. * @param target defines the target of that block (Vertex by default)
  131174. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  131175. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  131176. */
  131177. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  131178. /**
  131179. * Initialize the block and prepare the context for build
  131180. * @param state defines the state that will be used for the build
  131181. */
  131182. initialize(state: NodeMaterialBuildState): void;
  131183. /**
  131184. * Bind data to effect. Will only be called for blocks with isBindable === true
  131185. * @param effect defines the effect to bind data to
  131186. * @param nodeMaterial defines the hosting NodeMaterial
  131187. * @param mesh defines the mesh that will be rendered
  131188. */
  131189. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131190. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  131191. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  131192. protected _writeFloat(value: number): string;
  131193. /**
  131194. * Gets the current class name e.g. "NodeMaterialBlock"
  131195. * @returns the class name
  131196. */
  131197. getClassName(): string;
  131198. /**
  131199. * Register a new input. Must be called inside a block constructor
  131200. * @param name defines the connection point name
  131201. * @param type defines the connection point type
  131202. * @param isOptional defines a boolean indicating that this input can be omitted
  131203. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131204. * @returns the current block
  131205. */
  131206. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  131207. /**
  131208. * Register a new output. Must be called inside a block constructor
  131209. * @param name defines the connection point name
  131210. * @param type defines the connection point type
  131211. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131212. * @returns the current block
  131213. */
  131214. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  131215. /**
  131216. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  131217. * @param forOutput defines an optional connection point to check compatibility with
  131218. * @returns the first available input or null
  131219. */
  131220. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  131221. /**
  131222. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  131223. * @param forBlock defines an optional block to check compatibility with
  131224. * @returns the first available input or null
  131225. */
  131226. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  131227. /**
  131228. * Gets the sibling of the given output
  131229. * @param current defines the current output
  131230. * @returns the next output in the list or null
  131231. */
  131232. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  131233. /**
  131234. * Connect current block with another block
  131235. * @param other defines the block to connect with
  131236. * @param options define the various options to help pick the right connections
  131237. * @returns the current block
  131238. */
  131239. connectTo(other: NodeMaterialBlock, options?: {
  131240. input?: string;
  131241. output?: string;
  131242. outputSwizzle?: string;
  131243. }): this | undefined;
  131244. protected _buildBlock(state: NodeMaterialBuildState): void;
  131245. /**
  131246. * Add uniforms, samplers and uniform buffers at compilation time
  131247. * @param state defines the state to update
  131248. * @param nodeMaterial defines the node material requesting the update
  131249. * @param defines defines the material defines to update
  131250. * @param uniformBuffers defines the list of uniform buffer names
  131251. */
  131252. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131253. /**
  131254. * Add potential fallbacks if shader compilation fails
  131255. * @param mesh defines the mesh to be rendered
  131256. * @param fallbacks defines the current prioritized list of fallbacks
  131257. */
  131258. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131259. /**
  131260. * Initialize defines for shader compilation
  131261. * @param mesh defines the mesh to be rendered
  131262. * @param nodeMaterial defines the node material requesting the update
  131263. * @param defines defines the material defines to update
  131264. * @param useInstances specifies that instances should be used
  131265. */
  131266. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131267. /**
  131268. * Update defines for shader compilation
  131269. * @param mesh defines the mesh to be rendered
  131270. * @param nodeMaterial defines the node material requesting the update
  131271. * @param defines defines the material defines to update
  131272. * @param useInstances specifies that instances should be used
  131273. */
  131274. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131275. /**
  131276. * Lets the block try to connect some inputs automatically
  131277. * @param material defines the hosting NodeMaterial
  131278. */
  131279. autoConfigure(material: NodeMaterial): void;
  131280. /**
  131281. * Function called when a block is declared as repeatable content generator
  131282. * @param vertexShaderState defines the current compilation state for the vertex shader
  131283. * @param fragmentShaderState defines the current compilation state for the fragment shader
  131284. * @param mesh defines the mesh to be rendered
  131285. * @param defines defines the material defines to update
  131286. */
  131287. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131288. /**
  131289. * Checks if the block is ready
  131290. * @param mesh defines the mesh to be rendered
  131291. * @param nodeMaterial defines the node material requesting the update
  131292. * @param defines defines the material defines to update
  131293. * @param useInstances specifies that instances should be used
  131294. * @returns true if the block is ready
  131295. */
  131296. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131297. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131298. private _processBuild;
  131299. /**
  131300. * Compile the current node and generate the shader code
  131301. * @param state defines the current compilation state (uniforms, samplers, current string)
  131302. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131303. * @returns true if already built
  131304. */
  131305. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131306. protected _inputRename(name: string): string;
  131307. protected _outputRename(name: string): string;
  131308. protected _dumpPropertiesCode(): string;
  131309. /** @hidden */
  131310. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131311. /** @hidden */
  131312. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131313. /**
  131314. * Clone the current block to a new identical block
  131315. * @param scene defines the hosting scene
  131316. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131317. * @returns a copy of the current block
  131318. */
  131319. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131320. /**
  131321. * Serializes this block in a JSON representation
  131322. * @returns the serialized block object
  131323. */
  131324. serialize(): any;
  131325. /** @hidden */
  131326. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131327. /**
  131328. * Release resources
  131329. */
  131330. dispose(): void;
  131331. }
  131332. }
  131333. declare module BABYLON {
  131334. /**
  131335. * Enum defining the type of animations supported by InputBlock
  131336. */
  131337. export enum AnimatedInputBlockTypes {
  131338. /** No animation */
  131339. None = 0,
  131340. /** Time based animation. Will only work for floats */
  131341. Time = 1
  131342. }
  131343. }
  131344. declare module BABYLON {
  131345. /**
  131346. * Block used to expose an input value
  131347. */
  131348. export class InputBlock extends NodeMaterialBlock {
  131349. private _mode;
  131350. private _associatedVariableName;
  131351. private _storedValue;
  131352. private _valueCallback;
  131353. private _type;
  131354. private _animationType;
  131355. /** Gets or set a value used to limit the range of float values */
  131356. min: number;
  131357. /** Gets or set a value used to limit the range of float values */
  131358. max: number;
  131359. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131360. isBoolean: boolean;
  131361. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131362. matrixMode: number;
  131363. /** @hidden */
  131364. _systemValue: Nullable<NodeMaterialSystemValues>;
  131365. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131366. visibleInInspector: boolean;
  131367. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131368. isConstant: boolean;
  131369. /** Gets or sets the group to use to display this block in the Inspector */
  131370. groupInInspector: string;
  131371. /** Gets an observable raised when the value is changed */
  131372. onValueChangedObservable: Observable<InputBlock>;
  131373. /**
  131374. * Gets or sets the connection point type (default is float)
  131375. */
  131376. get type(): NodeMaterialBlockConnectionPointTypes;
  131377. /**
  131378. * Creates a new InputBlock
  131379. * @param name defines the block name
  131380. * @param target defines the target of that block (Vertex by default)
  131381. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131382. */
  131383. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131384. /**
  131385. * Gets the output component
  131386. */
  131387. get output(): NodeMaterialConnectionPoint;
  131388. /**
  131389. * Set the source of this connection point to a vertex attribute
  131390. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131391. * @returns the current connection point
  131392. */
  131393. setAsAttribute(attributeName?: string): InputBlock;
  131394. /**
  131395. * Set the source of this connection point to a system value
  131396. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131397. * @returns the current connection point
  131398. */
  131399. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131400. /**
  131401. * Gets or sets the value of that point.
  131402. * Please note that this value will be ignored if valueCallback is defined
  131403. */
  131404. get value(): any;
  131405. set value(value: any);
  131406. /**
  131407. * Gets or sets a callback used to get the value of that point.
  131408. * Please note that setting this value will force the connection point to ignore the value property
  131409. */
  131410. get valueCallback(): () => any;
  131411. set valueCallback(value: () => any);
  131412. /**
  131413. * Gets or sets the associated variable name in the shader
  131414. */
  131415. get associatedVariableName(): string;
  131416. set associatedVariableName(value: string);
  131417. /** Gets or sets the type of animation applied to the input */
  131418. get animationType(): AnimatedInputBlockTypes;
  131419. set animationType(value: AnimatedInputBlockTypes);
  131420. /**
  131421. * Gets a boolean indicating that this connection point not defined yet
  131422. */
  131423. get isUndefined(): boolean;
  131424. /**
  131425. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131426. * In this case the connection point name must be the name of the uniform to use.
  131427. * Can only be set on inputs
  131428. */
  131429. get isUniform(): boolean;
  131430. set isUniform(value: boolean);
  131431. /**
  131432. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131433. * In this case the connection point name must be the name of the attribute to use
  131434. * Can only be set on inputs
  131435. */
  131436. get isAttribute(): boolean;
  131437. set isAttribute(value: boolean);
  131438. /**
  131439. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131440. * Can only be set on exit points
  131441. */
  131442. get isVarying(): boolean;
  131443. set isVarying(value: boolean);
  131444. /**
  131445. * Gets a boolean indicating that the current connection point is a system value
  131446. */
  131447. get isSystemValue(): boolean;
  131448. /**
  131449. * Gets or sets the current well known value or null if not defined as a system value
  131450. */
  131451. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131452. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131453. /**
  131454. * Gets the current class name
  131455. * @returns the class name
  131456. */
  131457. getClassName(): string;
  131458. /**
  131459. * Animate the input if animationType !== None
  131460. * @param scene defines the rendering scene
  131461. */
  131462. animate(scene: Scene): void;
  131463. private _emitDefine;
  131464. initialize(state: NodeMaterialBuildState): void;
  131465. /**
  131466. * Set the input block to its default value (based on its type)
  131467. */
  131468. setDefaultValue(): void;
  131469. private _emitConstant;
  131470. private _emit;
  131471. /** @hidden */
  131472. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131473. /** @hidden */
  131474. _transmit(effect: Effect, scene: Scene): void;
  131475. protected _buildBlock(state: NodeMaterialBuildState): void;
  131476. protected _dumpPropertiesCode(): string;
  131477. dispose(): void;
  131478. serialize(): any;
  131479. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131480. }
  131481. }
  131482. declare module BABYLON {
  131483. /**
  131484. * Enum used to define the compatibility state between two connection points
  131485. */
  131486. export enum NodeMaterialConnectionPointCompatibilityStates {
  131487. /** Points are compatibles */
  131488. Compatible = 0,
  131489. /** Points are incompatible because of their types */
  131490. TypeIncompatible = 1,
  131491. /** Points are incompatible because of their targets (vertex vs fragment) */
  131492. TargetIncompatible = 2
  131493. }
  131494. /**
  131495. * Defines the direction of a connection point
  131496. */
  131497. export enum NodeMaterialConnectionPointDirection {
  131498. /** Input */
  131499. Input = 0,
  131500. /** Output */
  131501. Output = 1
  131502. }
  131503. /**
  131504. * Defines a connection point for a block
  131505. */
  131506. export class NodeMaterialConnectionPoint {
  131507. /** @hidden */
  131508. _ownerBlock: NodeMaterialBlock;
  131509. /** @hidden */
  131510. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131511. private _endpoints;
  131512. private _associatedVariableName;
  131513. private _direction;
  131514. /** @hidden */
  131515. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131516. /** @hidden */
  131517. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131518. private _type;
  131519. /** @hidden */
  131520. _enforceAssociatedVariableName: boolean;
  131521. /** Gets the direction of the point */
  131522. get direction(): NodeMaterialConnectionPointDirection;
  131523. /**
  131524. * Gets or sets the additional types supported by this connection point
  131525. */
  131526. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131527. /**
  131528. * Gets or sets the additional types excluded by this connection point
  131529. */
  131530. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131531. /**
  131532. * Observable triggered when this point is connected
  131533. */
  131534. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131535. /**
  131536. * Gets or sets the associated variable name in the shader
  131537. */
  131538. get associatedVariableName(): string;
  131539. set associatedVariableName(value: string);
  131540. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  131541. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131542. /**
  131543. * Gets or sets the connection point type (default is float)
  131544. */
  131545. get type(): NodeMaterialBlockConnectionPointTypes;
  131546. set type(value: NodeMaterialBlockConnectionPointTypes);
  131547. /**
  131548. * Gets or sets the connection point name
  131549. */
  131550. name: string;
  131551. /**
  131552. * Gets or sets a boolean indicating that this connection point can be omitted
  131553. */
  131554. isOptional: boolean;
  131555. /**
  131556. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131557. */
  131558. define: string;
  131559. /** @hidden */
  131560. _prioritizeVertex: boolean;
  131561. private _target;
  131562. /** Gets or sets the target of that connection point */
  131563. get target(): NodeMaterialBlockTargets;
  131564. set target(value: NodeMaterialBlockTargets);
  131565. /**
  131566. * Gets a boolean indicating that the current point is connected
  131567. */
  131568. get isConnected(): boolean;
  131569. /**
  131570. * Gets a boolean indicating that the current point is connected to an input block
  131571. */
  131572. get isConnectedToInputBlock(): boolean;
  131573. /**
  131574. * Gets a the connected input block (if any)
  131575. */
  131576. get connectInputBlock(): Nullable<InputBlock>;
  131577. /** Get the other side of the connection (if any) */
  131578. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131579. /** Get the block that owns this connection point */
  131580. get ownerBlock(): NodeMaterialBlock;
  131581. /** Get the block connected on the other side of this connection (if any) */
  131582. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131583. /** Get the block connected on the endpoints of this connection (if any) */
  131584. get connectedBlocks(): Array<NodeMaterialBlock>;
  131585. /** Gets the list of connected endpoints */
  131586. get endpoints(): NodeMaterialConnectionPoint[];
  131587. /** Gets a boolean indicating if that output point is connected to at least one input */
  131588. get hasEndpoints(): boolean;
  131589. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131590. get isConnectedInVertexShader(): boolean;
  131591. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131592. get isConnectedInFragmentShader(): boolean;
  131593. /**
  131594. * Creates a new connection point
  131595. * @param name defines the connection point name
  131596. * @param ownerBlock defines the block hosting this connection point
  131597. * @param direction defines the direction of the connection point
  131598. */
  131599. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131600. /**
  131601. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131602. * @returns the class name
  131603. */
  131604. getClassName(): string;
  131605. /**
  131606. * Gets a boolean indicating if the current point can be connected to another point
  131607. * @param connectionPoint defines the other connection point
  131608. * @returns a boolean
  131609. */
  131610. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131611. /**
  131612. * Gets a number indicating if the current point can be connected to another point
  131613. * @param connectionPoint defines the other connection point
  131614. * @returns a number defining the compatibility state
  131615. */
  131616. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131617. /**
  131618. * Connect this point to another connection point
  131619. * @param connectionPoint defines the other connection point
  131620. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131621. * @returns the current connection point
  131622. */
  131623. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131624. /**
  131625. * Disconnect this point from one of his endpoint
  131626. * @param endpoint defines the other connection point
  131627. * @returns the current connection point
  131628. */
  131629. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131630. /**
  131631. * Serializes this point in a JSON representation
  131632. * @returns the serialized point object
  131633. */
  131634. serialize(): any;
  131635. /**
  131636. * Release resources
  131637. */
  131638. dispose(): void;
  131639. }
  131640. }
  131641. declare module BABYLON {
  131642. /**
  131643. * Block used to add support for vertex skinning (bones)
  131644. */
  131645. export class BonesBlock extends NodeMaterialBlock {
  131646. /**
  131647. * Creates a new BonesBlock
  131648. * @param name defines the block name
  131649. */
  131650. constructor(name: string);
  131651. /**
  131652. * Initialize the block and prepare the context for build
  131653. * @param state defines the state that will be used for the build
  131654. */
  131655. initialize(state: NodeMaterialBuildState): void;
  131656. /**
  131657. * Gets the current class name
  131658. * @returns the class name
  131659. */
  131660. getClassName(): string;
  131661. /**
  131662. * Gets the matrix indices input component
  131663. */
  131664. get matricesIndices(): NodeMaterialConnectionPoint;
  131665. /**
  131666. * Gets the matrix weights input component
  131667. */
  131668. get matricesWeights(): NodeMaterialConnectionPoint;
  131669. /**
  131670. * Gets the extra matrix indices input component
  131671. */
  131672. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131673. /**
  131674. * Gets the extra matrix weights input component
  131675. */
  131676. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131677. /**
  131678. * Gets the world input component
  131679. */
  131680. get world(): NodeMaterialConnectionPoint;
  131681. /**
  131682. * Gets the output component
  131683. */
  131684. get output(): NodeMaterialConnectionPoint;
  131685. autoConfigure(material: NodeMaterial): void;
  131686. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131687. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131688. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131689. protected _buildBlock(state: NodeMaterialBuildState): this;
  131690. }
  131691. }
  131692. declare module BABYLON {
  131693. /**
  131694. * Block used to add support for instances
  131695. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131696. */
  131697. export class InstancesBlock extends NodeMaterialBlock {
  131698. /**
  131699. * Creates a new InstancesBlock
  131700. * @param name defines the block name
  131701. */
  131702. constructor(name: string);
  131703. /**
  131704. * Gets the current class name
  131705. * @returns the class name
  131706. */
  131707. getClassName(): string;
  131708. /**
  131709. * Gets the first world row input component
  131710. */
  131711. get world0(): NodeMaterialConnectionPoint;
  131712. /**
  131713. * Gets the second world row input component
  131714. */
  131715. get world1(): NodeMaterialConnectionPoint;
  131716. /**
  131717. * Gets the third world row input component
  131718. */
  131719. get world2(): NodeMaterialConnectionPoint;
  131720. /**
  131721. * Gets the forth world row input component
  131722. */
  131723. get world3(): NodeMaterialConnectionPoint;
  131724. /**
  131725. * Gets the world input component
  131726. */
  131727. get world(): NodeMaterialConnectionPoint;
  131728. /**
  131729. * Gets the output component
  131730. */
  131731. get output(): NodeMaterialConnectionPoint;
  131732. /**
  131733. * Gets the isntanceID component
  131734. */
  131735. get instanceID(): NodeMaterialConnectionPoint;
  131736. autoConfigure(material: NodeMaterial): void;
  131737. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131738. protected _buildBlock(state: NodeMaterialBuildState): this;
  131739. }
  131740. }
  131741. declare module BABYLON {
  131742. /**
  131743. * Block used to add morph targets support to vertex shader
  131744. */
  131745. export class MorphTargetsBlock extends NodeMaterialBlock {
  131746. private _repeatableContentAnchor;
  131747. /**
  131748. * Create a new MorphTargetsBlock
  131749. * @param name defines the block name
  131750. */
  131751. constructor(name: string);
  131752. /**
  131753. * Gets the current class name
  131754. * @returns the class name
  131755. */
  131756. getClassName(): string;
  131757. /**
  131758. * Gets the position input component
  131759. */
  131760. get position(): NodeMaterialConnectionPoint;
  131761. /**
  131762. * Gets the normal input component
  131763. */
  131764. get normal(): NodeMaterialConnectionPoint;
  131765. /**
  131766. * Gets the tangent input component
  131767. */
  131768. get tangent(): NodeMaterialConnectionPoint;
  131769. /**
  131770. * Gets the tangent input component
  131771. */
  131772. get uv(): NodeMaterialConnectionPoint;
  131773. /**
  131774. * Gets the position output component
  131775. */
  131776. get positionOutput(): NodeMaterialConnectionPoint;
  131777. /**
  131778. * Gets the normal output component
  131779. */
  131780. get normalOutput(): NodeMaterialConnectionPoint;
  131781. /**
  131782. * Gets the tangent output component
  131783. */
  131784. get tangentOutput(): NodeMaterialConnectionPoint;
  131785. /**
  131786. * Gets the tangent output component
  131787. */
  131788. get uvOutput(): NodeMaterialConnectionPoint;
  131789. initialize(state: NodeMaterialBuildState): void;
  131790. autoConfigure(material: NodeMaterial): void;
  131791. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131792. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131793. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131794. protected _buildBlock(state: NodeMaterialBuildState): this;
  131795. }
  131796. }
  131797. declare module BABYLON {
  131798. /**
  131799. * Block used to get data information from a light
  131800. */
  131801. export class LightInformationBlock extends NodeMaterialBlock {
  131802. private _lightDataUniformName;
  131803. private _lightColorUniformName;
  131804. private _lightTypeDefineName;
  131805. /**
  131806. * Gets or sets the light associated with this block
  131807. */
  131808. light: Nullable<Light>;
  131809. /**
  131810. * Creates a new LightInformationBlock
  131811. * @param name defines the block name
  131812. */
  131813. constructor(name: string);
  131814. /**
  131815. * Gets the current class name
  131816. * @returns the class name
  131817. */
  131818. getClassName(): string;
  131819. /**
  131820. * Gets the world position input component
  131821. */
  131822. get worldPosition(): NodeMaterialConnectionPoint;
  131823. /**
  131824. * Gets the direction output component
  131825. */
  131826. get direction(): NodeMaterialConnectionPoint;
  131827. /**
  131828. * Gets the direction output component
  131829. */
  131830. get color(): NodeMaterialConnectionPoint;
  131831. /**
  131832. * Gets the direction output component
  131833. */
  131834. get intensity(): NodeMaterialConnectionPoint;
  131835. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131836. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131837. protected _buildBlock(state: NodeMaterialBuildState): this;
  131838. serialize(): any;
  131839. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131840. }
  131841. }
  131842. declare module BABYLON {
  131843. /**
  131844. * Block used to add image processing support to fragment shader
  131845. */
  131846. export class ImageProcessingBlock extends NodeMaterialBlock {
  131847. /**
  131848. * Create a new ImageProcessingBlock
  131849. * @param name defines the block name
  131850. */
  131851. constructor(name: string);
  131852. /**
  131853. * Gets the current class name
  131854. * @returns the class name
  131855. */
  131856. getClassName(): string;
  131857. /**
  131858. * Gets the color input component
  131859. */
  131860. get color(): NodeMaterialConnectionPoint;
  131861. /**
  131862. * Gets the output component
  131863. */
  131864. get output(): NodeMaterialConnectionPoint;
  131865. /**
  131866. * Initialize the block and prepare the context for build
  131867. * @param state defines the state that will be used for the build
  131868. */
  131869. initialize(state: NodeMaterialBuildState): void;
  131870. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131871. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131872. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131873. protected _buildBlock(state: NodeMaterialBuildState): this;
  131874. }
  131875. }
  131876. declare module BABYLON {
  131877. /**
  131878. * Block used to pertub normals based on a normal map
  131879. */
  131880. export class PerturbNormalBlock extends NodeMaterialBlock {
  131881. private _tangentSpaceParameterName;
  131882. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131883. invertX: boolean;
  131884. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131885. invertY: boolean;
  131886. /**
  131887. * Create a new PerturbNormalBlock
  131888. * @param name defines the block name
  131889. */
  131890. constructor(name: string);
  131891. /**
  131892. * Gets the current class name
  131893. * @returns the class name
  131894. */
  131895. getClassName(): string;
  131896. /**
  131897. * Gets the world position input component
  131898. */
  131899. get worldPosition(): NodeMaterialConnectionPoint;
  131900. /**
  131901. * Gets the world normal input component
  131902. */
  131903. get worldNormal(): NodeMaterialConnectionPoint;
  131904. /**
  131905. * Gets the world tangent input component
  131906. */
  131907. get worldTangent(): NodeMaterialConnectionPoint;
  131908. /**
  131909. * Gets the uv input component
  131910. */
  131911. get uv(): NodeMaterialConnectionPoint;
  131912. /**
  131913. * Gets the normal map color input component
  131914. */
  131915. get normalMapColor(): NodeMaterialConnectionPoint;
  131916. /**
  131917. * Gets the strength input component
  131918. */
  131919. get strength(): NodeMaterialConnectionPoint;
  131920. /**
  131921. * Gets the output component
  131922. */
  131923. get output(): NodeMaterialConnectionPoint;
  131924. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131925. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131926. autoConfigure(material: NodeMaterial): void;
  131927. protected _buildBlock(state: NodeMaterialBuildState): this;
  131928. protected _dumpPropertiesCode(): string;
  131929. serialize(): any;
  131930. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131931. }
  131932. }
  131933. declare module BABYLON {
  131934. /**
  131935. * Block used to discard a pixel if a value is smaller than a cutoff
  131936. */
  131937. export class DiscardBlock extends NodeMaterialBlock {
  131938. /**
  131939. * Create a new DiscardBlock
  131940. * @param name defines the block name
  131941. */
  131942. constructor(name: string);
  131943. /**
  131944. * Gets the current class name
  131945. * @returns the class name
  131946. */
  131947. getClassName(): string;
  131948. /**
  131949. * Gets the color input component
  131950. */
  131951. get value(): NodeMaterialConnectionPoint;
  131952. /**
  131953. * Gets the cutoff input component
  131954. */
  131955. get cutoff(): NodeMaterialConnectionPoint;
  131956. protected _buildBlock(state: NodeMaterialBuildState): this;
  131957. }
  131958. }
  131959. declare module BABYLON {
  131960. /**
  131961. * Block used to test if the fragment shader is front facing
  131962. */
  131963. export class FrontFacingBlock extends NodeMaterialBlock {
  131964. /**
  131965. * Creates a new FrontFacingBlock
  131966. * @param name defines the block name
  131967. */
  131968. constructor(name: string);
  131969. /**
  131970. * Gets the current class name
  131971. * @returns the class name
  131972. */
  131973. getClassName(): string;
  131974. /**
  131975. * Gets the output component
  131976. */
  131977. get output(): NodeMaterialConnectionPoint;
  131978. protected _buildBlock(state: NodeMaterialBuildState): this;
  131979. }
  131980. }
  131981. declare module BABYLON {
  131982. /**
  131983. * Block used to get the derivative value on x and y of a given input
  131984. */
  131985. export class DerivativeBlock extends NodeMaterialBlock {
  131986. /**
  131987. * Create a new DerivativeBlock
  131988. * @param name defines the block name
  131989. */
  131990. constructor(name: string);
  131991. /**
  131992. * Gets the current class name
  131993. * @returns the class name
  131994. */
  131995. getClassName(): string;
  131996. /**
  131997. * Gets the input component
  131998. */
  131999. get input(): NodeMaterialConnectionPoint;
  132000. /**
  132001. * Gets the derivative output on x
  132002. */
  132003. get dx(): NodeMaterialConnectionPoint;
  132004. /**
  132005. * Gets the derivative output on y
  132006. */
  132007. get dy(): NodeMaterialConnectionPoint;
  132008. protected _buildBlock(state: NodeMaterialBuildState): this;
  132009. }
  132010. }
  132011. declare module BABYLON {
  132012. /**
  132013. * Block used to add support for scene fog
  132014. */
  132015. export class FogBlock extends NodeMaterialBlock {
  132016. private _fogDistanceName;
  132017. private _fogParameters;
  132018. /**
  132019. * Create a new FogBlock
  132020. * @param name defines the block name
  132021. */
  132022. constructor(name: string);
  132023. /**
  132024. * Gets the current class name
  132025. * @returns the class name
  132026. */
  132027. getClassName(): string;
  132028. /**
  132029. * Gets the world position input component
  132030. */
  132031. get worldPosition(): NodeMaterialConnectionPoint;
  132032. /**
  132033. * Gets the view input component
  132034. */
  132035. get view(): NodeMaterialConnectionPoint;
  132036. /**
  132037. * Gets the color input component
  132038. */
  132039. get input(): NodeMaterialConnectionPoint;
  132040. /**
  132041. * Gets the fog color input component
  132042. */
  132043. get fogColor(): NodeMaterialConnectionPoint;
  132044. /**
  132045. * Gets the output component
  132046. */
  132047. get output(): NodeMaterialConnectionPoint;
  132048. autoConfigure(material: NodeMaterial): void;
  132049. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132050. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132051. protected _buildBlock(state: NodeMaterialBuildState): this;
  132052. }
  132053. }
  132054. declare module BABYLON {
  132055. /**
  132056. * Block used to add light in the fragment shader
  132057. */
  132058. export class LightBlock extends NodeMaterialBlock {
  132059. private _lightId;
  132060. /**
  132061. * Gets or sets the light associated with this block
  132062. */
  132063. light: Nullable<Light>;
  132064. /**
  132065. * Create a new LightBlock
  132066. * @param name defines the block name
  132067. */
  132068. constructor(name: string);
  132069. /**
  132070. * Gets the current class name
  132071. * @returns the class name
  132072. */
  132073. getClassName(): string;
  132074. /**
  132075. * Gets the world position input component
  132076. */
  132077. get worldPosition(): NodeMaterialConnectionPoint;
  132078. /**
  132079. * Gets the world normal input component
  132080. */
  132081. get worldNormal(): NodeMaterialConnectionPoint;
  132082. /**
  132083. * Gets the camera (or eye) position component
  132084. */
  132085. get cameraPosition(): NodeMaterialConnectionPoint;
  132086. /**
  132087. * Gets the glossiness component
  132088. */
  132089. get glossiness(): NodeMaterialConnectionPoint;
  132090. /**
  132091. * Gets the glossinness power component
  132092. */
  132093. get glossPower(): NodeMaterialConnectionPoint;
  132094. /**
  132095. * Gets the diffuse color component
  132096. */
  132097. get diffuseColor(): NodeMaterialConnectionPoint;
  132098. /**
  132099. * Gets the specular color component
  132100. */
  132101. get specularColor(): NodeMaterialConnectionPoint;
  132102. /**
  132103. * Gets the diffuse output component
  132104. */
  132105. get diffuseOutput(): NodeMaterialConnectionPoint;
  132106. /**
  132107. * Gets the specular output component
  132108. */
  132109. get specularOutput(): NodeMaterialConnectionPoint;
  132110. /**
  132111. * Gets the shadow output component
  132112. */
  132113. get shadow(): NodeMaterialConnectionPoint;
  132114. autoConfigure(material: NodeMaterial): void;
  132115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132116. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  132117. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132118. private _injectVertexCode;
  132119. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132120. serialize(): any;
  132121. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132122. }
  132123. }
  132124. declare module BABYLON {
  132125. /**
  132126. * Block used to multiply 2 values
  132127. */
  132128. export class MultiplyBlock extends NodeMaterialBlock {
  132129. /**
  132130. * Creates a new MultiplyBlock
  132131. * @param name defines the block name
  132132. */
  132133. constructor(name: string);
  132134. /**
  132135. * Gets the current class name
  132136. * @returns the class name
  132137. */
  132138. getClassName(): string;
  132139. /**
  132140. * Gets the left operand input component
  132141. */
  132142. get left(): NodeMaterialConnectionPoint;
  132143. /**
  132144. * Gets the right operand input component
  132145. */
  132146. get right(): NodeMaterialConnectionPoint;
  132147. /**
  132148. * Gets the output component
  132149. */
  132150. get output(): NodeMaterialConnectionPoint;
  132151. protected _buildBlock(state: NodeMaterialBuildState): this;
  132152. }
  132153. }
  132154. declare module BABYLON {
  132155. /**
  132156. * Block used to add 2 vectors
  132157. */
  132158. export class AddBlock extends NodeMaterialBlock {
  132159. /**
  132160. * Creates a new AddBlock
  132161. * @param name defines the block name
  132162. */
  132163. constructor(name: string);
  132164. /**
  132165. * Gets the current class name
  132166. * @returns the class name
  132167. */
  132168. getClassName(): string;
  132169. /**
  132170. * Gets the left operand input component
  132171. */
  132172. get left(): NodeMaterialConnectionPoint;
  132173. /**
  132174. * Gets the right operand input component
  132175. */
  132176. get right(): NodeMaterialConnectionPoint;
  132177. /**
  132178. * Gets the output component
  132179. */
  132180. get output(): NodeMaterialConnectionPoint;
  132181. protected _buildBlock(state: NodeMaterialBuildState): this;
  132182. }
  132183. }
  132184. declare module BABYLON {
  132185. /**
  132186. * Block used to scale a vector by a float
  132187. */
  132188. export class ScaleBlock extends NodeMaterialBlock {
  132189. /**
  132190. * Creates a new ScaleBlock
  132191. * @param name defines the block name
  132192. */
  132193. constructor(name: string);
  132194. /**
  132195. * Gets the current class name
  132196. * @returns the class name
  132197. */
  132198. getClassName(): string;
  132199. /**
  132200. * Gets the input component
  132201. */
  132202. get input(): NodeMaterialConnectionPoint;
  132203. /**
  132204. * Gets the factor input component
  132205. */
  132206. get factor(): NodeMaterialConnectionPoint;
  132207. /**
  132208. * Gets the output component
  132209. */
  132210. get output(): NodeMaterialConnectionPoint;
  132211. protected _buildBlock(state: NodeMaterialBuildState): this;
  132212. }
  132213. }
  132214. declare module BABYLON {
  132215. /**
  132216. * Block used to clamp a float
  132217. */
  132218. export class ClampBlock extends NodeMaterialBlock {
  132219. /** Gets or sets the minimum range */
  132220. minimum: number;
  132221. /** Gets or sets the maximum range */
  132222. maximum: number;
  132223. /**
  132224. * Creates a new ClampBlock
  132225. * @param name defines the block name
  132226. */
  132227. constructor(name: string);
  132228. /**
  132229. * Gets the current class name
  132230. * @returns the class name
  132231. */
  132232. getClassName(): string;
  132233. /**
  132234. * Gets the value input component
  132235. */
  132236. get value(): NodeMaterialConnectionPoint;
  132237. /**
  132238. * Gets the output component
  132239. */
  132240. get output(): NodeMaterialConnectionPoint;
  132241. protected _buildBlock(state: NodeMaterialBuildState): this;
  132242. protected _dumpPropertiesCode(): string;
  132243. serialize(): any;
  132244. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132245. }
  132246. }
  132247. declare module BABYLON {
  132248. /**
  132249. * Block used to apply a cross product between 2 vectors
  132250. */
  132251. export class CrossBlock extends NodeMaterialBlock {
  132252. /**
  132253. * Creates a new CrossBlock
  132254. * @param name defines the block name
  132255. */
  132256. constructor(name: string);
  132257. /**
  132258. * Gets the current class name
  132259. * @returns the class name
  132260. */
  132261. getClassName(): string;
  132262. /**
  132263. * Gets the left operand input component
  132264. */
  132265. get left(): NodeMaterialConnectionPoint;
  132266. /**
  132267. * Gets the right operand input component
  132268. */
  132269. get right(): NodeMaterialConnectionPoint;
  132270. /**
  132271. * Gets the output component
  132272. */
  132273. get output(): NodeMaterialConnectionPoint;
  132274. protected _buildBlock(state: NodeMaterialBuildState): this;
  132275. }
  132276. }
  132277. declare module BABYLON {
  132278. /**
  132279. * Block used to apply a dot product between 2 vectors
  132280. */
  132281. export class DotBlock extends NodeMaterialBlock {
  132282. /**
  132283. * Creates a new DotBlock
  132284. * @param name defines the block name
  132285. */
  132286. constructor(name: string);
  132287. /**
  132288. * Gets the current class name
  132289. * @returns the class name
  132290. */
  132291. getClassName(): string;
  132292. /**
  132293. * Gets the left operand input component
  132294. */
  132295. get left(): NodeMaterialConnectionPoint;
  132296. /**
  132297. * Gets the right operand input component
  132298. */
  132299. get right(): NodeMaterialConnectionPoint;
  132300. /**
  132301. * Gets the output component
  132302. */
  132303. get output(): NodeMaterialConnectionPoint;
  132304. protected _buildBlock(state: NodeMaterialBuildState): this;
  132305. }
  132306. }
  132307. declare module BABYLON {
  132308. /**
  132309. * Block used to remap a float from a range to a new one
  132310. */
  132311. export class RemapBlock extends NodeMaterialBlock {
  132312. /**
  132313. * Gets or sets the source range
  132314. */
  132315. sourceRange: Vector2;
  132316. /**
  132317. * Gets or sets the target range
  132318. */
  132319. targetRange: Vector2;
  132320. /**
  132321. * Creates a new RemapBlock
  132322. * @param name defines the block name
  132323. */
  132324. constructor(name: string);
  132325. /**
  132326. * Gets the current class name
  132327. * @returns the class name
  132328. */
  132329. getClassName(): string;
  132330. /**
  132331. * Gets the input component
  132332. */
  132333. get input(): NodeMaterialConnectionPoint;
  132334. /**
  132335. * Gets the source min input component
  132336. */
  132337. get sourceMin(): NodeMaterialConnectionPoint;
  132338. /**
  132339. * Gets the source max input component
  132340. */
  132341. get sourceMax(): NodeMaterialConnectionPoint;
  132342. /**
  132343. * Gets the target min input component
  132344. */
  132345. get targetMin(): NodeMaterialConnectionPoint;
  132346. /**
  132347. * Gets the target max input component
  132348. */
  132349. get targetMax(): NodeMaterialConnectionPoint;
  132350. /**
  132351. * Gets the output component
  132352. */
  132353. get output(): NodeMaterialConnectionPoint;
  132354. protected _buildBlock(state: NodeMaterialBuildState): this;
  132355. protected _dumpPropertiesCode(): string;
  132356. serialize(): any;
  132357. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132358. }
  132359. }
  132360. declare module BABYLON {
  132361. /**
  132362. * Block used to normalize a vector
  132363. */
  132364. export class NormalizeBlock extends NodeMaterialBlock {
  132365. /**
  132366. * Creates a new NormalizeBlock
  132367. * @param name defines the block name
  132368. */
  132369. constructor(name: string);
  132370. /**
  132371. * Gets the current class name
  132372. * @returns the class name
  132373. */
  132374. getClassName(): string;
  132375. /**
  132376. * Gets the input component
  132377. */
  132378. get input(): NodeMaterialConnectionPoint;
  132379. /**
  132380. * Gets the output component
  132381. */
  132382. get output(): NodeMaterialConnectionPoint;
  132383. protected _buildBlock(state: NodeMaterialBuildState): this;
  132384. }
  132385. }
  132386. declare module BABYLON {
  132387. /**
  132388. * Operations supported by the Trigonometry block
  132389. */
  132390. export enum TrigonometryBlockOperations {
  132391. /** Cos */
  132392. Cos = 0,
  132393. /** Sin */
  132394. Sin = 1,
  132395. /** Abs */
  132396. Abs = 2,
  132397. /** Exp */
  132398. Exp = 3,
  132399. /** Exp2 */
  132400. Exp2 = 4,
  132401. /** Round */
  132402. Round = 5,
  132403. /** Floor */
  132404. Floor = 6,
  132405. /** Ceiling */
  132406. Ceiling = 7,
  132407. /** Square root */
  132408. Sqrt = 8,
  132409. /** Log */
  132410. Log = 9,
  132411. /** Tangent */
  132412. Tan = 10,
  132413. /** Arc tangent */
  132414. ArcTan = 11,
  132415. /** Arc cosinus */
  132416. ArcCos = 12,
  132417. /** Arc sinus */
  132418. ArcSin = 13,
  132419. /** Fraction */
  132420. Fract = 14,
  132421. /** Sign */
  132422. Sign = 15,
  132423. /** To radians (from degrees) */
  132424. Radians = 16,
  132425. /** To degrees (from radians) */
  132426. Degrees = 17
  132427. }
  132428. /**
  132429. * Block used to apply trigonometry operation to floats
  132430. */
  132431. export class TrigonometryBlock extends NodeMaterialBlock {
  132432. /**
  132433. * Gets or sets the operation applied by the block
  132434. */
  132435. operation: TrigonometryBlockOperations;
  132436. /**
  132437. * Creates a new TrigonometryBlock
  132438. * @param name defines the block name
  132439. */
  132440. constructor(name: string);
  132441. /**
  132442. * Gets the current class name
  132443. * @returns the class name
  132444. */
  132445. getClassName(): string;
  132446. /**
  132447. * Gets the input component
  132448. */
  132449. get input(): NodeMaterialConnectionPoint;
  132450. /**
  132451. * Gets the output component
  132452. */
  132453. get output(): NodeMaterialConnectionPoint;
  132454. protected _buildBlock(state: NodeMaterialBuildState): this;
  132455. serialize(): any;
  132456. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132457. protected _dumpPropertiesCode(): string;
  132458. }
  132459. }
  132460. declare module BABYLON {
  132461. /**
  132462. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132463. */
  132464. export class ColorMergerBlock extends NodeMaterialBlock {
  132465. /**
  132466. * Create a new ColorMergerBlock
  132467. * @param name defines the block name
  132468. */
  132469. constructor(name: string);
  132470. /**
  132471. * Gets the current class name
  132472. * @returns the class name
  132473. */
  132474. getClassName(): string;
  132475. /**
  132476. * Gets the rgb component (input)
  132477. */
  132478. get rgbIn(): NodeMaterialConnectionPoint;
  132479. /**
  132480. * Gets the r component (input)
  132481. */
  132482. get r(): NodeMaterialConnectionPoint;
  132483. /**
  132484. * Gets the g component (input)
  132485. */
  132486. get g(): NodeMaterialConnectionPoint;
  132487. /**
  132488. * Gets the b component (input)
  132489. */
  132490. get b(): NodeMaterialConnectionPoint;
  132491. /**
  132492. * Gets the a component (input)
  132493. */
  132494. get a(): NodeMaterialConnectionPoint;
  132495. /**
  132496. * Gets the rgba component (output)
  132497. */
  132498. get rgba(): NodeMaterialConnectionPoint;
  132499. /**
  132500. * Gets the rgb component (output)
  132501. */
  132502. get rgbOut(): NodeMaterialConnectionPoint;
  132503. /**
  132504. * Gets the rgb component (output)
  132505. * @deprecated Please use rgbOut instead.
  132506. */
  132507. get rgb(): NodeMaterialConnectionPoint;
  132508. protected _buildBlock(state: NodeMaterialBuildState): this;
  132509. }
  132510. }
  132511. declare module BABYLON {
  132512. /**
  132513. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132514. */
  132515. export class VectorMergerBlock extends NodeMaterialBlock {
  132516. /**
  132517. * Create a new VectorMergerBlock
  132518. * @param name defines the block name
  132519. */
  132520. constructor(name: string);
  132521. /**
  132522. * Gets the current class name
  132523. * @returns the class name
  132524. */
  132525. getClassName(): string;
  132526. /**
  132527. * Gets the xyz component (input)
  132528. */
  132529. get xyzIn(): NodeMaterialConnectionPoint;
  132530. /**
  132531. * Gets the xy component (input)
  132532. */
  132533. get xyIn(): NodeMaterialConnectionPoint;
  132534. /**
  132535. * Gets the x component (input)
  132536. */
  132537. get x(): NodeMaterialConnectionPoint;
  132538. /**
  132539. * Gets the y component (input)
  132540. */
  132541. get y(): NodeMaterialConnectionPoint;
  132542. /**
  132543. * Gets the z component (input)
  132544. */
  132545. get z(): NodeMaterialConnectionPoint;
  132546. /**
  132547. * Gets the w component (input)
  132548. */
  132549. get w(): NodeMaterialConnectionPoint;
  132550. /**
  132551. * Gets the xyzw component (output)
  132552. */
  132553. get xyzw(): NodeMaterialConnectionPoint;
  132554. /**
  132555. * Gets the xyz component (output)
  132556. */
  132557. get xyzOut(): NodeMaterialConnectionPoint;
  132558. /**
  132559. * Gets the xy component (output)
  132560. */
  132561. get xyOut(): NodeMaterialConnectionPoint;
  132562. /**
  132563. * Gets the xy component (output)
  132564. * @deprecated Please use xyOut instead.
  132565. */
  132566. get xy(): NodeMaterialConnectionPoint;
  132567. /**
  132568. * Gets the xyz component (output)
  132569. * @deprecated Please use xyzOut instead.
  132570. */
  132571. get xyz(): NodeMaterialConnectionPoint;
  132572. protected _buildBlock(state: NodeMaterialBuildState): this;
  132573. }
  132574. }
  132575. declare module BABYLON {
  132576. /**
  132577. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132578. */
  132579. export class ColorSplitterBlock extends NodeMaterialBlock {
  132580. /**
  132581. * Create a new ColorSplitterBlock
  132582. * @param name defines the block name
  132583. */
  132584. constructor(name: string);
  132585. /**
  132586. * Gets the current class name
  132587. * @returns the class name
  132588. */
  132589. getClassName(): string;
  132590. /**
  132591. * Gets the rgba component (input)
  132592. */
  132593. get rgba(): NodeMaterialConnectionPoint;
  132594. /**
  132595. * Gets the rgb component (input)
  132596. */
  132597. get rgbIn(): NodeMaterialConnectionPoint;
  132598. /**
  132599. * Gets the rgb component (output)
  132600. */
  132601. get rgbOut(): NodeMaterialConnectionPoint;
  132602. /**
  132603. * Gets the r component (output)
  132604. */
  132605. get r(): NodeMaterialConnectionPoint;
  132606. /**
  132607. * Gets the g component (output)
  132608. */
  132609. get g(): NodeMaterialConnectionPoint;
  132610. /**
  132611. * Gets the b component (output)
  132612. */
  132613. get b(): NodeMaterialConnectionPoint;
  132614. /**
  132615. * Gets the a component (output)
  132616. */
  132617. get a(): NodeMaterialConnectionPoint;
  132618. protected _inputRename(name: string): string;
  132619. protected _outputRename(name: string): string;
  132620. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132621. }
  132622. }
  132623. declare module BABYLON {
  132624. /**
  132625. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132626. */
  132627. export class VectorSplitterBlock extends NodeMaterialBlock {
  132628. /**
  132629. * Create a new VectorSplitterBlock
  132630. * @param name defines the block name
  132631. */
  132632. constructor(name: string);
  132633. /**
  132634. * Gets the current class name
  132635. * @returns the class name
  132636. */
  132637. getClassName(): string;
  132638. /**
  132639. * Gets the xyzw component (input)
  132640. */
  132641. get xyzw(): NodeMaterialConnectionPoint;
  132642. /**
  132643. * Gets the xyz component (input)
  132644. */
  132645. get xyzIn(): NodeMaterialConnectionPoint;
  132646. /**
  132647. * Gets the xy component (input)
  132648. */
  132649. get xyIn(): NodeMaterialConnectionPoint;
  132650. /**
  132651. * Gets the xyz component (output)
  132652. */
  132653. get xyzOut(): NodeMaterialConnectionPoint;
  132654. /**
  132655. * Gets the xy component (output)
  132656. */
  132657. get xyOut(): NodeMaterialConnectionPoint;
  132658. /**
  132659. * Gets the x component (output)
  132660. */
  132661. get x(): NodeMaterialConnectionPoint;
  132662. /**
  132663. * Gets the y component (output)
  132664. */
  132665. get y(): NodeMaterialConnectionPoint;
  132666. /**
  132667. * Gets the z component (output)
  132668. */
  132669. get z(): NodeMaterialConnectionPoint;
  132670. /**
  132671. * Gets the w component (output)
  132672. */
  132673. get w(): NodeMaterialConnectionPoint;
  132674. protected _inputRename(name: string): string;
  132675. protected _outputRename(name: string): string;
  132676. protected _buildBlock(state: NodeMaterialBuildState): this;
  132677. }
  132678. }
  132679. declare module BABYLON {
  132680. /**
  132681. * Block used to lerp between 2 values
  132682. */
  132683. export class LerpBlock extends NodeMaterialBlock {
  132684. /**
  132685. * Creates a new LerpBlock
  132686. * @param name defines the block name
  132687. */
  132688. constructor(name: string);
  132689. /**
  132690. * Gets the current class name
  132691. * @returns the class name
  132692. */
  132693. getClassName(): string;
  132694. /**
  132695. * Gets the left operand input component
  132696. */
  132697. get left(): NodeMaterialConnectionPoint;
  132698. /**
  132699. * Gets the right operand input component
  132700. */
  132701. get right(): NodeMaterialConnectionPoint;
  132702. /**
  132703. * Gets the gradient operand input component
  132704. */
  132705. get gradient(): NodeMaterialConnectionPoint;
  132706. /**
  132707. * Gets the output component
  132708. */
  132709. get output(): NodeMaterialConnectionPoint;
  132710. protected _buildBlock(state: NodeMaterialBuildState): this;
  132711. }
  132712. }
  132713. declare module BABYLON {
  132714. /**
  132715. * Block used to divide 2 vectors
  132716. */
  132717. export class DivideBlock extends NodeMaterialBlock {
  132718. /**
  132719. * Creates a new DivideBlock
  132720. * @param name defines the block name
  132721. */
  132722. constructor(name: string);
  132723. /**
  132724. * Gets the current class name
  132725. * @returns the class name
  132726. */
  132727. getClassName(): string;
  132728. /**
  132729. * Gets the left operand input component
  132730. */
  132731. get left(): NodeMaterialConnectionPoint;
  132732. /**
  132733. * Gets the right operand input component
  132734. */
  132735. get right(): NodeMaterialConnectionPoint;
  132736. /**
  132737. * Gets the output component
  132738. */
  132739. get output(): NodeMaterialConnectionPoint;
  132740. protected _buildBlock(state: NodeMaterialBuildState): this;
  132741. }
  132742. }
  132743. declare module BABYLON {
  132744. /**
  132745. * Block used to subtract 2 vectors
  132746. */
  132747. export class SubtractBlock extends NodeMaterialBlock {
  132748. /**
  132749. * Creates a new SubtractBlock
  132750. * @param name defines the block name
  132751. */
  132752. constructor(name: string);
  132753. /**
  132754. * Gets the current class name
  132755. * @returns the class name
  132756. */
  132757. getClassName(): string;
  132758. /**
  132759. * Gets the left operand input component
  132760. */
  132761. get left(): NodeMaterialConnectionPoint;
  132762. /**
  132763. * Gets the right operand input component
  132764. */
  132765. get right(): NodeMaterialConnectionPoint;
  132766. /**
  132767. * Gets the output component
  132768. */
  132769. get output(): NodeMaterialConnectionPoint;
  132770. protected _buildBlock(state: NodeMaterialBuildState): this;
  132771. }
  132772. }
  132773. declare module BABYLON {
  132774. /**
  132775. * Block used to step a value
  132776. */
  132777. export class StepBlock extends NodeMaterialBlock {
  132778. /**
  132779. * Creates a new StepBlock
  132780. * @param name defines the block name
  132781. */
  132782. constructor(name: string);
  132783. /**
  132784. * Gets the current class name
  132785. * @returns the class name
  132786. */
  132787. getClassName(): string;
  132788. /**
  132789. * Gets the value operand input component
  132790. */
  132791. get value(): NodeMaterialConnectionPoint;
  132792. /**
  132793. * Gets the edge operand input component
  132794. */
  132795. get edge(): NodeMaterialConnectionPoint;
  132796. /**
  132797. * Gets the output component
  132798. */
  132799. get output(): NodeMaterialConnectionPoint;
  132800. protected _buildBlock(state: NodeMaterialBuildState): this;
  132801. }
  132802. }
  132803. declare module BABYLON {
  132804. /**
  132805. * Block used to get the opposite (1 - x) of a value
  132806. */
  132807. export class OneMinusBlock extends NodeMaterialBlock {
  132808. /**
  132809. * Creates a new OneMinusBlock
  132810. * @param name defines the block name
  132811. */
  132812. constructor(name: string);
  132813. /**
  132814. * Gets the current class name
  132815. * @returns the class name
  132816. */
  132817. getClassName(): string;
  132818. /**
  132819. * Gets the input component
  132820. */
  132821. get input(): NodeMaterialConnectionPoint;
  132822. /**
  132823. * Gets the output component
  132824. */
  132825. get output(): NodeMaterialConnectionPoint;
  132826. protected _buildBlock(state: NodeMaterialBuildState): this;
  132827. }
  132828. }
  132829. declare module BABYLON {
  132830. /**
  132831. * Block used to get the view direction
  132832. */
  132833. export class ViewDirectionBlock extends NodeMaterialBlock {
  132834. /**
  132835. * Creates a new ViewDirectionBlock
  132836. * @param name defines the block name
  132837. */
  132838. constructor(name: string);
  132839. /**
  132840. * Gets the current class name
  132841. * @returns the class name
  132842. */
  132843. getClassName(): string;
  132844. /**
  132845. * Gets the world position component
  132846. */
  132847. get worldPosition(): NodeMaterialConnectionPoint;
  132848. /**
  132849. * Gets the camera position component
  132850. */
  132851. get cameraPosition(): NodeMaterialConnectionPoint;
  132852. /**
  132853. * Gets the output component
  132854. */
  132855. get output(): NodeMaterialConnectionPoint;
  132856. autoConfigure(material: NodeMaterial): void;
  132857. protected _buildBlock(state: NodeMaterialBuildState): this;
  132858. }
  132859. }
  132860. declare module BABYLON {
  132861. /**
  132862. * Block used to compute fresnel value
  132863. */
  132864. export class FresnelBlock extends NodeMaterialBlock {
  132865. /**
  132866. * Create a new FresnelBlock
  132867. * @param name defines the block name
  132868. */
  132869. constructor(name: string);
  132870. /**
  132871. * Gets the current class name
  132872. * @returns the class name
  132873. */
  132874. getClassName(): string;
  132875. /**
  132876. * Gets the world normal input component
  132877. */
  132878. get worldNormal(): NodeMaterialConnectionPoint;
  132879. /**
  132880. * Gets the view direction input component
  132881. */
  132882. get viewDirection(): NodeMaterialConnectionPoint;
  132883. /**
  132884. * Gets the bias input component
  132885. */
  132886. get bias(): NodeMaterialConnectionPoint;
  132887. /**
  132888. * Gets the camera (or eye) position component
  132889. */
  132890. get power(): NodeMaterialConnectionPoint;
  132891. /**
  132892. * Gets the fresnel output component
  132893. */
  132894. get fresnel(): NodeMaterialConnectionPoint;
  132895. autoConfigure(material: NodeMaterial): void;
  132896. protected _buildBlock(state: NodeMaterialBuildState): this;
  132897. }
  132898. }
  132899. declare module BABYLON {
  132900. /**
  132901. * Block used to get the max of 2 values
  132902. */
  132903. export class MaxBlock extends NodeMaterialBlock {
  132904. /**
  132905. * Creates a new MaxBlock
  132906. * @param name defines the block name
  132907. */
  132908. constructor(name: string);
  132909. /**
  132910. * Gets the current class name
  132911. * @returns the class name
  132912. */
  132913. getClassName(): string;
  132914. /**
  132915. * Gets the left operand input component
  132916. */
  132917. get left(): NodeMaterialConnectionPoint;
  132918. /**
  132919. * Gets the right operand input component
  132920. */
  132921. get right(): NodeMaterialConnectionPoint;
  132922. /**
  132923. * Gets the output component
  132924. */
  132925. get output(): NodeMaterialConnectionPoint;
  132926. protected _buildBlock(state: NodeMaterialBuildState): this;
  132927. }
  132928. }
  132929. declare module BABYLON {
  132930. /**
  132931. * Block used to get the min of 2 values
  132932. */
  132933. export class MinBlock extends NodeMaterialBlock {
  132934. /**
  132935. * Creates a new MinBlock
  132936. * @param name defines the block name
  132937. */
  132938. constructor(name: string);
  132939. /**
  132940. * Gets the current class name
  132941. * @returns the class name
  132942. */
  132943. getClassName(): string;
  132944. /**
  132945. * Gets the left operand input component
  132946. */
  132947. get left(): NodeMaterialConnectionPoint;
  132948. /**
  132949. * Gets the right operand input component
  132950. */
  132951. get right(): NodeMaterialConnectionPoint;
  132952. /**
  132953. * Gets the output component
  132954. */
  132955. get output(): NodeMaterialConnectionPoint;
  132956. protected _buildBlock(state: NodeMaterialBuildState): this;
  132957. }
  132958. }
  132959. declare module BABYLON {
  132960. /**
  132961. * Block used to get the distance between 2 values
  132962. */
  132963. export class DistanceBlock extends NodeMaterialBlock {
  132964. /**
  132965. * Creates a new DistanceBlock
  132966. * @param name defines the block name
  132967. */
  132968. constructor(name: string);
  132969. /**
  132970. * Gets the current class name
  132971. * @returns the class name
  132972. */
  132973. getClassName(): string;
  132974. /**
  132975. * Gets the left operand input component
  132976. */
  132977. get left(): NodeMaterialConnectionPoint;
  132978. /**
  132979. * Gets the right operand input component
  132980. */
  132981. get right(): NodeMaterialConnectionPoint;
  132982. /**
  132983. * Gets the output component
  132984. */
  132985. get output(): NodeMaterialConnectionPoint;
  132986. protected _buildBlock(state: NodeMaterialBuildState): this;
  132987. }
  132988. }
  132989. declare module BABYLON {
  132990. /**
  132991. * Block used to get the length of a vector
  132992. */
  132993. export class LengthBlock extends NodeMaterialBlock {
  132994. /**
  132995. * Creates a new LengthBlock
  132996. * @param name defines the block name
  132997. */
  132998. constructor(name: string);
  132999. /**
  133000. * Gets the current class name
  133001. * @returns the class name
  133002. */
  133003. getClassName(): string;
  133004. /**
  133005. * Gets the value input component
  133006. */
  133007. get value(): NodeMaterialConnectionPoint;
  133008. /**
  133009. * Gets the output component
  133010. */
  133011. get output(): NodeMaterialConnectionPoint;
  133012. protected _buildBlock(state: NodeMaterialBuildState): this;
  133013. }
  133014. }
  133015. declare module BABYLON {
  133016. /**
  133017. * Block used to get negative version of a value (i.e. x * -1)
  133018. */
  133019. export class NegateBlock extends NodeMaterialBlock {
  133020. /**
  133021. * Creates a new NegateBlock
  133022. * @param name defines the block name
  133023. */
  133024. constructor(name: string);
  133025. /**
  133026. * Gets the current class name
  133027. * @returns the class name
  133028. */
  133029. getClassName(): string;
  133030. /**
  133031. * Gets the value input component
  133032. */
  133033. get value(): NodeMaterialConnectionPoint;
  133034. /**
  133035. * Gets the output component
  133036. */
  133037. get output(): NodeMaterialConnectionPoint;
  133038. protected _buildBlock(state: NodeMaterialBuildState): this;
  133039. }
  133040. }
  133041. declare module BABYLON {
  133042. /**
  133043. * Block used to get the value of the first parameter raised to the power of the second
  133044. */
  133045. export class PowBlock extends NodeMaterialBlock {
  133046. /**
  133047. * Creates a new PowBlock
  133048. * @param name defines the block name
  133049. */
  133050. constructor(name: string);
  133051. /**
  133052. * Gets the current class name
  133053. * @returns the class name
  133054. */
  133055. getClassName(): string;
  133056. /**
  133057. * Gets the value operand input component
  133058. */
  133059. get value(): NodeMaterialConnectionPoint;
  133060. /**
  133061. * Gets the power operand input component
  133062. */
  133063. get power(): NodeMaterialConnectionPoint;
  133064. /**
  133065. * Gets the output component
  133066. */
  133067. get output(): NodeMaterialConnectionPoint;
  133068. protected _buildBlock(state: NodeMaterialBuildState): this;
  133069. }
  133070. }
  133071. declare module BABYLON {
  133072. /**
  133073. * Block used to get a random number
  133074. */
  133075. export class RandomNumberBlock extends NodeMaterialBlock {
  133076. /**
  133077. * Creates a new RandomNumberBlock
  133078. * @param name defines the block name
  133079. */
  133080. constructor(name: string);
  133081. /**
  133082. * Gets the current class name
  133083. * @returns the class name
  133084. */
  133085. getClassName(): string;
  133086. /**
  133087. * Gets the seed input component
  133088. */
  133089. get seed(): NodeMaterialConnectionPoint;
  133090. /**
  133091. * Gets the output component
  133092. */
  133093. get output(): NodeMaterialConnectionPoint;
  133094. protected _buildBlock(state: NodeMaterialBuildState): this;
  133095. }
  133096. }
  133097. declare module BABYLON {
  133098. /**
  133099. * Block used to compute arc tangent of 2 values
  133100. */
  133101. export class ArcTan2Block extends NodeMaterialBlock {
  133102. /**
  133103. * Creates a new ArcTan2Block
  133104. * @param name defines the block name
  133105. */
  133106. constructor(name: string);
  133107. /**
  133108. * Gets the current class name
  133109. * @returns the class name
  133110. */
  133111. getClassName(): string;
  133112. /**
  133113. * Gets the x operand input component
  133114. */
  133115. get x(): NodeMaterialConnectionPoint;
  133116. /**
  133117. * Gets the y operand input component
  133118. */
  133119. get y(): NodeMaterialConnectionPoint;
  133120. /**
  133121. * Gets the output component
  133122. */
  133123. get output(): NodeMaterialConnectionPoint;
  133124. protected _buildBlock(state: NodeMaterialBuildState): this;
  133125. }
  133126. }
  133127. declare module BABYLON {
  133128. /**
  133129. * Block used to smooth step a value
  133130. */
  133131. export class SmoothStepBlock extends NodeMaterialBlock {
  133132. /**
  133133. * Creates a new SmoothStepBlock
  133134. * @param name defines the block name
  133135. */
  133136. constructor(name: string);
  133137. /**
  133138. * Gets the current class name
  133139. * @returns the class name
  133140. */
  133141. getClassName(): string;
  133142. /**
  133143. * Gets the value operand input component
  133144. */
  133145. get value(): NodeMaterialConnectionPoint;
  133146. /**
  133147. * Gets the first edge operand input component
  133148. */
  133149. get edge0(): NodeMaterialConnectionPoint;
  133150. /**
  133151. * Gets the second edge operand input component
  133152. */
  133153. get edge1(): NodeMaterialConnectionPoint;
  133154. /**
  133155. * Gets the output component
  133156. */
  133157. get output(): NodeMaterialConnectionPoint;
  133158. protected _buildBlock(state: NodeMaterialBuildState): this;
  133159. }
  133160. }
  133161. declare module BABYLON {
  133162. /**
  133163. * Block used to get the reciprocal (1 / x) of a value
  133164. */
  133165. export class ReciprocalBlock extends NodeMaterialBlock {
  133166. /**
  133167. * Creates a new ReciprocalBlock
  133168. * @param name defines the block name
  133169. */
  133170. constructor(name: string);
  133171. /**
  133172. * Gets the current class name
  133173. * @returns the class name
  133174. */
  133175. getClassName(): string;
  133176. /**
  133177. * Gets the input component
  133178. */
  133179. get input(): NodeMaterialConnectionPoint;
  133180. /**
  133181. * Gets the output component
  133182. */
  133183. get output(): NodeMaterialConnectionPoint;
  133184. protected _buildBlock(state: NodeMaterialBuildState): this;
  133185. }
  133186. }
  133187. declare module BABYLON {
  133188. /**
  133189. * Block used to replace a color by another one
  133190. */
  133191. export class ReplaceColorBlock extends NodeMaterialBlock {
  133192. /**
  133193. * Creates a new ReplaceColorBlock
  133194. * @param name defines the block name
  133195. */
  133196. constructor(name: string);
  133197. /**
  133198. * Gets the current class name
  133199. * @returns the class name
  133200. */
  133201. getClassName(): string;
  133202. /**
  133203. * Gets the value input component
  133204. */
  133205. get value(): NodeMaterialConnectionPoint;
  133206. /**
  133207. * Gets the reference input component
  133208. */
  133209. get reference(): NodeMaterialConnectionPoint;
  133210. /**
  133211. * Gets the distance input component
  133212. */
  133213. get distance(): NodeMaterialConnectionPoint;
  133214. /**
  133215. * Gets the replacement input component
  133216. */
  133217. get replacement(): NodeMaterialConnectionPoint;
  133218. /**
  133219. * Gets the output component
  133220. */
  133221. get output(): NodeMaterialConnectionPoint;
  133222. protected _buildBlock(state: NodeMaterialBuildState): this;
  133223. }
  133224. }
  133225. declare module BABYLON {
  133226. /**
  133227. * Block used to posterize a value
  133228. * @see https://en.wikipedia.org/wiki/Posterization
  133229. */
  133230. export class PosterizeBlock extends NodeMaterialBlock {
  133231. /**
  133232. * Creates a new PosterizeBlock
  133233. * @param name defines the block name
  133234. */
  133235. constructor(name: string);
  133236. /**
  133237. * Gets the current class name
  133238. * @returns the class name
  133239. */
  133240. getClassName(): string;
  133241. /**
  133242. * Gets the value input component
  133243. */
  133244. get value(): NodeMaterialConnectionPoint;
  133245. /**
  133246. * Gets the steps input component
  133247. */
  133248. get steps(): NodeMaterialConnectionPoint;
  133249. /**
  133250. * Gets the output component
  133251. */
  133252. get output(): NodeMaterialConnectionPoint;
  133253. protected _buildBlock(state: NodeMaterialBuildState): this;
  133254. }
  133255. }
  133256. declare module BABYLON {
  133257. /**
  133258. * Operations supported by the Wave block
  133259. */
  133260. export enum WaveBlockKind {
  133261. /** SawTooth */
  133262. SawTooth = 0,
  133263. /** Square */
  133264. Square = 1,
  133265. /** Triangle */
  133266. Triangle = 2
  133267. }
  133268. /**
  133269. * Block used to apply wave operation to floats
  133270. */
  133271. export class WaveBlock extends NodeMaterialBlock {
  133272. /**
  133273. * Gets or sets the kibnd of wave to be applied by the block
  133274. */
  133275. kind: WaveBlockKind;
  133276. /**
  133277. * Creates a new WaveBlock
  133278. * @param name defines the block name
  133279. */
  133280. constructor(name: string);
  133281. /**
  133282. * Gets the current class name
  133283. * @returns the class name
  133284. */
  133285. getClassName(): string;
  133286. /**
  133287. * Gets the input component
  133288. */
  133289. get input(): NodeMaterialConnectionPoint;
  133290. /**
  133291. * Gets the output component
  133292. */
  133293. get output(): NodeMaterialConnectionPoint;
  133294. protected _buildBlock(state: NodeMaterialBuildState): this;
  133295. serialize(): any;
  133296. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133297. }
  133298. }
  133299. declare module BABYLON {
  133300. /**
  133301. * Class used to store a color step for the GradientBlock
  133302. */
  133303. export class GradientBlockColorStep {
  133304. /**
  133305. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133306. */
  133307. step: number;
  133308. /**
  133309. * Gets or sets the color associated with this step
  133310. */
  133311. color: Color3;
  133312. /**
  133313. * Creates a new GradientBlockColorStep
  133314. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133315. * @param color defines the color associated with this step
  133316. */
  133317. constructor(
  133318. /**
  133319. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133320. */
  133321. step: number,
  133322. /**
  133323. * Gets or sets the color associated with this step
  133324. */
  133325. color: Color3);
  133326. }
  133327. /**
  133328. * Block used to return a color from a gradient based on an input value between 0 and 1
  133329. */
  133330. export class GradientBlock extends NodeMaterialBlock {
  133331. /**
  133332. * Gets or sets the list of color steps
  133333. */
  133334. colorSteps: GradientBlockColorStep[];
  133335. /**
  133336. * Creates a new GradientBlock
  133337. * @param name defines the block name
  133338. */
  133339. constructor(name: string);
  133340. /**
  133341. * Gets the current class name
  133342. * @returns the class name
  133343. */
  133344. getClassName(): string;
  133345. /**
  133346. * Gets the gradient input component
  133347. */
  133348. get gradient(): NodeMaterialConnectionPoint;
  133349. /**
  133350. * Gets the output component
  133351. */
  133352. get output(): NodeMaterialConnectionPoint;
  133353. private _writeColorConstant;
  133354. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133355. serialize(): any;
  133356. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133357. protected _dumpPropertiesCode(): string;
  133358. }
  133359. }
  133360. declare module BABYLON {
  133361. /**
  133362. * Block used to normalize lerp between 2 values
  133363. */
  133364. export class NLerpBlock extends NodeMaterialBlock {
  133365. /**
  133366. * Creates a new NLerpBlock
  133367. * @param name defines the block name
  133368. */
  133369. constructor(name: string);
  133370. /**
  133371. * Gets the current class name
  133372. * @returns the class name
  133373. */
  133374. getClassName(): string;
  133375. /**
  133376. * Gets the left operand input component
  133377. */
  133378. get left(): NodeMaterialConnectionPoint;
  133379. /**
  133380. * Gets the right operand input component
  133381. */
  133382. get right(): NodeMaterialConnectionPoint;
  133383. /**
  133384. * Gets the gradient operand input component
  133385. */
  133386. get gradient(): NodeMaterialConnectionPoint;
  133387. /**
  133388. * Gets the output component
  133389. */
  133390. get output(): NodeMaterialConnectionPoint;
  133391. protected _buildBlock(state: NodeMaterialBuildState): this;
  133392. }
  133393. }
  133394. declare module BABYLON {
  133395. /**
  133396. * block used to Generate a Worley Noise 3D Noise Pattern
  133397. */
  133398. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133399. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133400. manhattanDistance: boolean;
  133401. /**
  133402. * Creates a new WorleyNoise3DBlock
  133403. * @param name defines the block name
  133404. */
  133405. constructor(name: string);
  133406. /**
  133407. * Gets the current class name
  133408. * @returns the class name
  133409. */
  133410. getClassName(): string;
  133411. /**
  133412. * Gets the seed input component
  133413. */
  133414. get seed(): NodeMaterialConnectionPoint;
  133415. /**
  133416. * Gets the jitter input component
  133417. */
  133418. get jitter(): NodeMaterialConnectionPoint;
  133419. /**
  133420. * Gets the output component
  133421. */
  133422. get output(): NodeMaterialConnectionPoint;
  133423. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133424. /**
  133425. * Exposes the properties to the UI?
  133426. */
  133427. protected _dumpPropertiesCode(): string;
  133428. /**
  133429. * Exposes the properties to the Seralize?
  133430. */
  133431. serialize(): any;
  133432. /**
  133433. * Exposes the properties to the deseralize?
  133434. */
  133435. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133436. }
  133437. }
  133438. declare module BABYLON {
  133439. /**
  133440. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133441. */
  133442. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133443. /**
  133444. * Creates a new SimplexPerlin3DBlock
  133445. * @param name defines the block name
  133446. */
  133447. constructor(name: string);
  133448. /**
  133449. * Gets the current class name
  133450. * @returns the class name
  133451. */
  133452. getClassName(): string;
  133453. /**
  133454. * Gets the seed operand input component
  133455. */
  133456. get seed(): NodeMaterialConnectionPoint;
  133457. /**
  133458. * Gets the output component
  133459. */
  133460. get output(): NodeMaterialConnectionPoint;
  133461. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133462. }
  133463. }
  133464. declare module BABYLON {
  133465. /**
  133466. * Block used to blend normals
  133467. */
  133468. export class NormalBlendBlock extends NodeMaterialBlock {
  133469. /**
  133470. * Creates a new NormalBlendBlock
  133471. * @param name defines the block name
  133472. */
  133473. constructor(name: string);
  133474. /**
  133475. * Gets the current class name
  133476. * @returns the class name
  133477. */
  133478. getClassName(): string;
  133479. /**
  133480. * Gets the first input component
  133481. */
  133482. get normalMap0(): NodeMaterialConnectionPoint;
  133483. /**
  133484. * Gets the second input component
  133485. */
  133486. get normalMap1(): NodeMaterialConnectionPoint;
  133487. /**
  133488. * Gets the output component
  133489. */
  133490. get output(): NodeMaterialConnectionPoint;
  133491. protected _buildBlock(state: NodeMaterialBuildState): this;
  133492. }
  133493. }
  133494. declare module BABYLON {
  133495. /**
  133496. * Block used to rotate a 2d vector by a given angle
  133497. */
  133498. export class Rotate2dBlock extends NodeMaterialBlock {
  133499. /**
  133500. * Creates a new Rotate2dBlock
  133501. * @param name defines the block name
  133502. */
  133503. constructor(name: string);
  133504. /**
  133505. * Gets the current class name
  133506. * @returns the class name
  133507. */
  133508. getClassName(): string;
  133509. /**
  133510. * Gets the input vector
  133511. */
  133512. get input(): NodeMaterialConnectionPoint;
  133513. /**
  133514. * Gets the input angle
  133515. */
  133516. get angle(): NodeMaterialConnectionPoint;
  133517. /**
  133518. * Gets the output component
  133519. */
  133520. get output(): NodeMaterialConnectionPoint;
  133521. autoConfigure(material: NodeMaterial): void;
  133522. protected _buildBlock(state: NodeMaterialBuildState): this;
  133523. }
  133524. }
  133525. declare module BABYLON {
  133526. /**
  133527. * Block used to get the reflected vector from a direction and a normal
  133528. */
  133529. export class ReflectBlock extends NodeMaterialBlock {
  133530. /**
  133531. * Creates a new ReflectBlock
  133532. * @param name defines the block name
  133533. */
  133534. constructor(name: string);
  133535. /**
  133536. * Gets the current class name
  133537. * @returns the class name
  133538. */
  133539. getClassName(): string;
  133540. /**
  133541. * Gets the incident component
  133542. */
  133543. get incident(): NodeMaterialConnectionPoint;
  133544. /**
  133545. * Gets the normal component
  133546. */
  133547. get normal(): NodeMaterialConnectionPoint;
  133548. /**
  133549. * Gets the output component
  133550. */
  133551. get output(): NodeMaterialConnectionPoint;
  133552. protected _buildBlock(state: NodeMaterialBuildState): this;
  133553. }
  133554. }
  133555. declare module BABYLON {
  133556. /**
  133557. * Block used to get the refracted vector from a direction and a normal
  133558. */
  133559. export class RefractBlock extends NodeMaterialBlock {
  133560. /**
  133561. * Creates a new RefractBlock
  133562. * @param name defines the block name
  133563. */
  133564. constructor(name: string);
  133565. /**
  133566. * Gets the current class name
  133567. * @returns the class name
  133568. */
  133569. getClassName(): string;
  133570. /**
  133571. * Gets the incident component
  133572. */
  133573. get incident(): NodeMaterialConnectionPoint;
  133574. /**
  133575. * Gets the normal component
  133576. */
  133577. get normal(): NodeMaterialConnectionPoint;
  133578. /**
  133579. * Gets the index of refraction component
  133580. */
  133581. get ior(): NodeMaterialConnectionPoint;
  133582. /**
  133583. * Gets the output component
  133584. */
  133585. get output(): NodeMaterialConnectionPoint;
  133586. protected _buildBlock(state: NodeMaterialBuildState): this;
  133587. }
  133588. }
  133589. declare module BABYLON {
  133590. /**
  133591. * Block used to desaturate a color
  133592. */
  133593. export class DesaturateBlock extends NodeMaterialBlock {
  133594. /**
  133595. * Creates a new DesaturateBlock
  133596. * @param name defines the block name
  133597. */
  133598. constructor(name: string);
  133599. /**
  133600. * Gets the current class name
  133601. * @returns the class name
  133602. */
  133603. getClassName(): string;
  133604. /**
  133605. * Gets the color operand input component
  133606. */
  133607. get color(): NodeMaterialConnectionPoint;
  133608. /**
  133609. * Gets the level operand input component
  133610. */
  133611. get level(): NodeMaterialConnectionPoint;
  133612. /**
  133613. * Gets the output component
  133614. */
  133615. get output(): NodeMaterialConnectionPoint;
  133616. protected _buildBlock(state: NodeMaterialBuildState): this;
  133617. }
  133618. }
  133619. declare module BABYLON {
  133620. /**
  133621. * Effect Render Options
  133622. */
  133623. export interface IEffectRendererOptions {
  133624. /**
  133625. * Defines the vertices positions.
  133626. */
  133627. positions?: number[];
  133628. /**
  133629. * Defines the indices.
  133630. */
  133631. indices?: number[];
  133632. }
  133633. /**
  133634. * Helper class to render one or more effects
  133635. */
  133636. export class EffectRenderer {
  133637. private engine;
  133638. private static _DefaultOptions;
  133639. private _vertexBuffers;
  133640. private _indexBuffer;
  133641. private _ringBufferIndex;
  133642. private _ringScreenBuffer;
  133643. private _fullscreenViewport;
  133644. private _getNextFrameBuffer;
  133645. /**
  133646. * Creates an effect renderer
  133647. * @param engine the engine to use for rendering
  133648. * @param options defines the options of the effect renderer
  133649. */
  133650. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133651. /**
  133652. * Sets the current viewport in normalized coordinates 0-1
  133653. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133654. */
  133655. setViewport(viewport?: Viewport): void;
  133656. /**
  133657. * Binds the embedded attributes buffer to the effect.
  133658. * @param effect Defines the effect to bind the attributes for
  133659. */
  133660. bindBuffers(effect: Effect): void;
  133661. /**
  133662. * Sets the current effect wrapper to use during draw.
  133663. * The effect needs to be ready before calling this api.
  133664. * This also sets the default full screen position attribute.
  133665. * @param effectWrapper Defines the effect to draw with
  133666. */
  133667. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133668. /**
  133669. * Draws a full screen quad.
  133670. */
  133671. draw(): void;
  133672. /**
  133673. * renders one or more effects to a specified texture
  133674. * @param effectWrappers list of effects to renderer
  133675. * @param outputTexture texture to draw to, if null it will render to the screen
  133676. */
  133677. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133678. /**
  133679. * Disposes of the effect renderer
  133680. */
  133681. dispose(): void;
  133682. }
  133683. /**
  133684. * Options to create an EffectWrapper
  133685. */
  133686. interface EffectWrapperCreationOptions {
  133687. /**
  133688. * Engine to use to create the effect
  133689. */
  133690. engine: ThinEngine;
  133691. /**
  133692. * Fragment shader for the effect
  133693. */
  133694. fragmentShader: string;
  133695. /**
  133696. * Vertex shader for the effect
  133697. */
  133698. vertexShader?: string;
  133699. /**
  133700. * Attributes to use in the shader
  133701. */
  133702. attributeNames?: Array<string>;
  133703. /**
  133704. * Uniforms to use in the shader
  133705. */
  133706. uniformNames?: Array<string>;
  133707. /**
  133708. * Texture sampler names to use in the shader
  133709. */
  133710. samplerNames?: Array<string>;
  133711. /**
  133712. * The friendly name of the effect displayed in Spector.
  133713. */
  133714. name?: string;
  133715. }
  133716. /**
  133717. * Wraps an effect to be used for rendering
  133718. */
  133719. export class EffectWrapper {
  133720. /**
  133721. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133722. */
  133723. onApplyObservable: Observable<{}>;
  133724. /**
  133725. * The underlying effect
  133726. */
  133727. effect: Effect;
  133728. /**
  133729. * Creates an effect to be renderer
  133730. * @param creationOptions options to create the effect
  133731. */
  133732. constructor(creationOptions: EffectWrapperCreationOptions);
  133733. /**
  133734. * Disposes of the effect wrapper
  133735. */
  133736. dispose(): void;
  133737. }
  133738. }
  133739. declare module BABYLON {
  133740. /**
  133741. * Helper class to push actions to a pool of workers.
  133742. */
  133743. export class WorkerPool implements IDisposable {
  133744. private _workerInfos;
  133745. private _pendingActions;
  133746. /**
  133747. * Constructor
  133748. * @param workers Array of workers to use for actions
  133749. */
  133750. constructor(workers: Array<Worker>);
  133751. /**
  133752. * Terminates all workers and clears any pending actions.
  133753. */
  133754. dispose(): void;
  133755. /**
  133756. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133757. * pended until a worker has completed its action.
  133758. * @param action The action to perform. Call onComplete when the action is complete.
  133759. */
  133760. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133761. private _execute;
  133762. }
  133763. }
  133764. declare module BABYLON {
  133765. /**
  133766. * Configuration for Draco compression
  133767. */
  133768. export interface IDracoCompressionConfiguration {
  133769. /**
  133770. * Configuration for the decoder.
  133771. */
  133772. decoder: {
  133773. /**
  133774. * The url to the WebAssembly module.
  133775. */
  133776. wasmUrl?: string;
  133777. /**
  133778. * The url to the WebAssembly binary.
  133779. */
  133780. wasmBinaryUrl?: string;
  133781. /**
  133782. * The url to the fallback JavaScript module.
  133783. */
  133784. fallbackUrl?: string;
  133785. };
  133786. }
  133787. /**
  133788. * Draco compression (https://google.github.io/draco/)
  133789. *
  133790. * This class wraps the Draco module.
  133791. *
  133792. * **Encoder**
  133793. *
  133794. * The encoder is not currently implemented.
  133795. *
  133796. * **Decoder**
  133797. *
  133798. * 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.
  133799. *
  133800. * To update the configuration, use the following code:
  133801. * ```javascript
  133802. * DracoCompression.Configuration = {
  133803. * decoder: {
  133804. * wasmUrl: "<url to the WebAssembly library>",
  133805. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133806. * fallbackUrl: "<url to the fallback JavaScript library>",
  133807. * }
  133808. * };
  133809. * ```
  133810. *
  133811. * 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.
  133812. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133813. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133814. *
  133815. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133816. * ```javascript
  133817. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133818. * ```
  133819. *
  133820. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133821. */
  133822. export class DracoCompression implements IDisposable {
  133823. private _workerPoolPromise?;
  133824. private _decoderModulePromise?;
  133825. /**
  133826. * The configuration. Defaults to the following urls:
  133827. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133828. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133829. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133830. */
  133831. static Configuration: IDracoCompressionConfiguration;
  133832. /**
  133833. * Returns true if the decoder configuration is available.
  133834. */
  133835. static get DecoderAvailable(): boolean;
  133836. /**
  133837. * Default number of workers to create when creating the draco compression object.
  133838. */
  133839. static DefaultNumWorkers: number;
  133840. private static GetDefaultNumWorkers;
  133841. private static _Default;
  133842. /**
  133843. * Default instance for the draco compression object.
  133844. */
  133845. static get Default(): DracoCompression;
  133846. /**
  133847. * Constructor
  133848. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133849. */
  133850. constructor(numWorkers?: number);
  133851. /**
  133852. * Stop all async operations and release resources.
  133853. */
  133854. dispose(): void;
  133855. /**
  133856. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133857. * @returns a promise that resolves when ready
  133858. */
  133859. whenReadyAsync(): Promise<void>;
  133860. /**
  133861. * Decode Draco compressed mesh data to vertex data.
  133862. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133863. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133864. * @returns A promise that resolves with the decoded vertex data
  133865. */
  133866. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133867. [kind: string]: number;
  133868. }): Promise<VertexData>;
  133869. }
  133870. }
  133871. declare module BABYLON {
  133872. /**
  133873. * Class for building Constructive Solid Geometry
  133874. */
  133875. export class CSG {
  133876. private polygons;
  133877. /**
  133878. * The world matrix
  133879. */
  133880. matrix: Matrix;
  133881. /**
  133882. * Stores the position
  133883. */
  133884. position: Vector3;
  133885. /**
  133886. * Stores the rotation
  133887. */
  133888. rotation: Vector3;
  133889. /**
  133890. * Stores the rotation quaternion
  133891. */
  133892. rotationQuaternion: Nullable<Quaternion>;
  133893. /**
  133894. * Stores the scaling vector
  133895. */
  133896. scaling: Vector3;
  133897. /**
  133898. * Convert the Mesh to CSG
  133899. * @param mesh The Mesh to convert to CSG
  133900. * @returns A new CSG from the Mesh
  133901. */
  133902. static FromMesh(mesh: Mesh): CSG;
  133903. /**
  133904. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133905. * @param polygons Polygons used to construct a CSG solid
  133906. */
  133907. private static FromPolygons;
  133908. /**
  133909. * Clones, or makes a deep copy, of the CSG
  133910. * @returns A new CSG
  133911. */
  133912. clone(): CSG;
  133913. /**
  133914. * Unions this CSG with another CSG
  133915. * @param csg The CSG to union against this CSG
  133916. * @returns The unioned CSG
  133917. */
  133918. union(csg: CSG): CSG;
  133919. /**
  133920. * Unions this CSG with another CSG in place
  133921. * @param csg The CSG to union against this CSG
  133922. */
  133923. unionInPlace(csg: CSG): void;
  133924. /**
  133925. * Subtracts this CSG with another CSG
  133926. * @param csg The CSG to subtract against this CSG
  133927. * @returns A new CSG
  133928. */
  133929. subtract(csg: CSG): CSG;
  133930. /**
  133931. * Subtracts this CSG with another CSG in place
  133932. * @param csg The CSG to subtact against this CSG
  133933. */
  133934. subtractInPlace(csg: CSG): void;
  133935. /**
  133936. * Intersect this CSG with another CSG
  133937. * @param csg The CSG to intersect against this CSG
  133938. * @returns A new CSG
  133939. */
  133940. intersect(csg: CSG): CSG;
  133941. /**
  133942. * Intersects this CSG with another CSG in place
  133943. * @param csg The CSG to intersect against this CSG
  133944. */
  133945. intersectInPlace(csg: CSG): void;
  133946. /**
  133947. * Return a new CSG solid with solid and empty space switched. This solid is
  133948. * not modified.
  133949. * @returns A new CSG solid with solid and empty space switched
  133950. */
  133951. inverse(): CSG;
  133952. /**
  133953. * Inverses the CSG in place
  133954. */
  133955. inverseInPlace(): void;
  133956. /**
  133957. * This is used to keep meshes transformations so they can be restored
  133958. * when we build back a Babylon Mesh
  133959. * NB : All CSG operations are performed in world coordinates
  133960. * @param csg The CSG to copy the transform attributes from
  133961. * @returns This CSG
  133962. */
  133963. copyTransformAttributes(csg: CSG): CSG;
  133964. /**
  133965. * Build Raw mesh from CSG
  133966. * Coordinates here are in world space
  133967. * @param name The name of the mesh geometry
  133968. * @param scene The Scene
  133969. * @param keepSubMeshes Specifies if the submeshes should be kept
  133970. * @returns A new Mesh
  133971. */
  133972. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133973. /**
  133974. * Build Mesh from CSG taking material and transforms into account
  133975. * @param name The name of the Mesh
  133976. * @param material The material of the Mesh
  133977. * @param scene The Scene
  133978. * @param keepSubMeshes Specifies if submeshes should be kept
  133979. * @returns The new Mesh
  133980. */
  133981. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133982. }
  133983. }
  133984. declare module BABYLON {
  133985. /**
  133986. * Class used to create a trail following a mesh
  133987. */
  133988. export class TrailMesh extends Mesh {
  133989. private _generator;
  133990. private _autoStart;
  133991. private _running;
  133992. private _diameter;
  133993. private _length;
  133994. private _sectionPolygonPointsCount;
  133995. private _sectionVectors;
  133996. private _sectionNormalVectors;
  133997. private _beforeRenderObserver;
  133998. /**
  133999. * @constructor
  134000. * @param name The value used by scene.getMeshByName() to do a lookup.
  134001. * @param generator The mesh or transform node to generate a trail.
  134002. * @param scene The scene to add this mesh to.
  134003. * @param diameter Diameter of trailing mesh. Default is 1.
  134004. * @param length Length of trailing mesh. Default is 60.
  134005. * @param autoStart Automatically start trailing mesh. Default true.
  134006. */
  134007. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  134008. /**
  134009. * "TrailMesh"
  134010. * @returns "TrailMesh"
  134011. */
  134012. getClassName(): string;
  134013. private _createMesh;
  134014. /**
  134015. * Start trailing mesh.
  134016. */
  134017. start(): void;
  134018. /**
  134019. * Stop trailing mesh.
  134020. */
  134021. stop(): void;
  134022. /**
  134023. * Update trailing mesh geometry.
  134024. */
  134025. update(): void;
  134026. /**
  134027. * Returns a new TrailMesh object.
  134028. * @param name is a string, the name given to the new mesh
  134029. * @param newGenerator use new generator object for cloned trail mesh
  134030. * @returns a new mesh
  134031. */
  134032. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  134033. /**
  134034. * Serializes this trail mesh
  134035. * @param serializationObject object to write serialization to
  134036. */
  134037. serialize(serializationObject: any): void;
  134038. /**
  134039. * Parses a serialized trail mesh
  134040. * @param parsedMesh the serialized mesh
  134041. * @param scene the scene to create the trail mesh in
  134042. * @returns the created trail mesh
  134043. */
  134044. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  134045. }
  134046. }
  134047. declare module BABYLON {
  134048. /**
  134049. * Class containing static functions to help procedurally build meshes
  134050. */
  134051. export class TiledBoxBuilder {
  134052. /**
  134053. * Creates a box mesh
  134054. * 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)
  134055. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134059. * @param name defines the name of the mesh
  134060. * @param options defines the options used to create the mesh
  134061. * @param scene defines the hosting scene
  134062. * @returns the box mesh
  134063. */
  134064. static CreateTiledBox(name: string, options: {
  134065. pattern?: number;
  134066. width?: number;
  134067. height?: number;
  134068. depth?: number;
  134069. tileSize?: number;
  134070. tileWidth?: number;
  134071. tileHeight?: number;
  134072. alignHorizontal?: number;
  134073. alignVertical?: number;
  134074. faceUV?: Vector4[];
  134075. faceColors?: Color4[];
  134076. sideOrientation?: number;
  134077. updatable?: boolean;
  134078. }, scene?: Nullable<Scene>): Mesh;
  134079. }
  134080. }
  134081. declare module BABYLON {
  134082. /**
  134083. * Class containing static functions to help procedurally build meshes
  134084. */
  134085. export class TorusKnotBuilder {
  134086. /**
  134087. * Creates a torus knot mesh
  134088. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134089. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134090. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134091. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134092. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134093. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134095. * @param name defines the name of the mesh
  134096. * @param options defines the options used to create the mesh
  134097. * @param scene defines the hosting scene
  134098. * @returns the torus knot mesh
  134099. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134100. */
  134101. static CreateTorusKnot(name: string, options: {
  134102. radius?: number;
  134103. tube?: number;
  134104. radialSegments?: number;
  134105. tubularSegments?: number;
  134106. p?: number;
  134107. q?: number;
  134108. updatable?: boolean;
  134109. sideOrientation?: number;
  134110. frontUVs?: Vector4;
  134111. backUVs?: Vector4;
  134112. }, scene: any): Mesh;
  134113. }
  134114. }
  134115. declare module BABYLON {
  134116. /**
  134117. * Polygon
  134118. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  134119. */
  134120. export class Polygon {
  134121. /**
  134122. * Creates a rectangle
  134123. * @param xmin bottom X coord
  134124. * @param ymin bottom Y coord
  134125. * @param xmax top X coord
  134126. * @param ymax top Y coord
  134127. * @returns points that make the resulting rectation
  134128. */
  134129. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  134130. /**
  134131. * Creates a circle
  134132. * @param radius radius of circle
  134133. * @param cx scale in x
  134134. * @param cy scale in y
  134135. * @param numberOfSides number of sides that make up the circle
  134136. * @returns points that make the resulting circle
  134137. */
  134138. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  134139. /**
  134140. * Creates a polygon from input string
  134141. * @param input Input polygon data
  134142. * @returns the parsed points
  134143. */
  134144. static Parse(input: string): Vector2[];
  134145. /**
  134146. * Starts building a polygon from x and y coordinates
  134147. * @param x x coordinate
  134148. * @param y y coordinate
  134149. * @returns the started path2
  134150. */
  134151. static StartingAt(x: number, y: number): Path2;
  134152. }
  134153. /**
  134154. * Builds a polygon
  134155. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  134156. */
  134157. export class PolygonMeshBuilder {
  134158. private _points;
  134159. private _outlinepoints;
  134160. private _holes;
  134161. private _name;
  134162. private _scene;
  134163. private _epoints;
  134164. private _eholes;
  134165. private _addToepoint;
  134166. /**
  134167. * Babylon reference to the earcut plugin.
  134168. */
  134169. bjsEarcut: any;
  134170. /**
  134171. * Creates a PolygonMeshBuilder
  134172. * @param name name of the builder
  134173. * @param contours Path of the polygon
  134174. * @param scene scene to add to when creating the mesh
  134175. * @param earcutInjection can be used to inject your own earcut reference
  134176. */
  134177. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  134178. /**
  134179. * Adds a whole within the polygon
  134180. * @param hole Array of points defining the hole
  134181. * @returns this
  134182. */
  134183. addHole(hole: Vector2[]): PolygonMeshBuilder;
  134184. /**
  134185. * Creates the polygon
  134186. * @param updatable If the mesh should be updatable
  134187. * @param depth The depth of the mesh created
  134188. * @returns the created mesh
  134189. */
  134190. build(updatable?: boolean, depth?: number): Mesh;
  134191. /**
  134192. * Creates the polygon
  134193. * @param depth The depth of the mesh created
  134194. * @returns the created VertexData
  134195. */
  134196. buildVertexData(depth?: number): VertexData;
  134197. /**
  134198. * Adds a side to the polygon
  134199. * @param positions points that make the polygon
  134200. * @param normals normals of the polygon
  134201. * @param uvs uvs of the polygon
  134202. * @param indices indices of the polygon
  134203. * @param bounds bounds of the polygon
  134204. * @param points points of the polygon
  134205. * @param depth depth of the polygon
  134206. * @param flip flip of the polygon
  134207. */
  134208. private addSide;
  134209. }
  134210. }
  134211. declare module BABYLON {
  134212. /**
  134213. * Class containing static functions to help procedurally build meshes
  134214. */
  134215. export class PolygonBuilder {
  134216. /**
  134217. * Creates a polygon mesh
  134218. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134219. * * 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
  134220. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134223. * * Remember you can only change the shape positions, not their number when updating a polygon
  134224. * @param name defines the name of the mesh
  134225. * @param options defines the options used to create the mesh
  134226. * @param scene defines the hosting scene
  134227. * @param earcutInjection can be used to inject your own earcut reference
  134228. * @returns the polygon mesh
  134229. */
  134230. static CreatePolygon(name: string, options: {
  134231. shape: Vector3[];
  134232. holes?: Vector3[][];
  134233. depth?: number;
  134234. faceUV?: Vector4[];
  134235. faceColors?: Color4[];
  134236. updatable?: boolean;
  134237. sideOrientation?: number;
  134238. frontUVs?: Vector4;
  134239. backUVs?: Vector4;
  134240. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134241. /**
  134242. * Creates an extruded polygon mesh, with depth in the Y direction.
  134243. * * 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)
  134244. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134245. * @param name defines the name of the mesh
  134246. * @param options defines the options used to create the mesh
  134247. * @param scene defines the hosting scene
  134248. * @param earcutInjection can be used to inject your own earcut reference
  134249. * @returns the polygon mesh
  134250. */
  134251. static ExtrudePolygon(name: string, options: {
  134252. shape: Vector3[];
  134253. holes?: Vector3[][];
  134254. depth?: number;
  134255. faceUV?: Vector4[];
  134256. faceColors?: Color4[];
  134257. updatable?: boolean;
  134258. sideOrientation?: number;
  134259. frontUVs?: Vector4;
  134260. backUVs?: Vector4;
  134261. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134262. }
  134263. }
  134264. declare module BABYLON {
  134265. /**
  134266. * Class containing static functions to help procedurally build meshes
  134267. */
  134268. export class LatheBuilder {
  134269. /**
  134270. * Creates lathe mesh.
  134271. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134272. * * 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
  134273. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134274. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134275. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134276. * * 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
  134277. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134278. * * 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
  134279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134280. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134281. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134283. * @param name defines the name of the mesh
  134284. * @param options defines the options used to create the mesh
  134285. * @param scene defines the hosting scene
  134286. * @returns the lathe mesh
  134287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134288. */
  134289. static CreateLathe(name: string, options: {
  134290. shape: Vector3[];
  134291. radius?: number;
  134292. tessellation?: number;
  134293. clip?: number;
  134294. arc?: number;
  134295. closed?: boolean;
  134296. updatable?: boolean;
  134297. sideOrientation?: number;
  134298. frontUVs?: Vector4;
  134299. backUVs?: Vector4;
  134300. cap?: number;
  134301. invertUV?: boolean;
  134302. }, scene?: Nullable<Scene>): Mesh;
  134303. }
  134304. }
  134305. declare module BABYLON {
  134306. /**
  134307. * Class containing static functions to help procedurally build meshes
  134308. */
  134309. export class TiledPlaneBuilder {
  134310. /**
  134311. * Creates a tiled plane mesh
  134312. * * The parameter `pattern` will, depending on value, do nothing or
  134313. * * * flip (reflect about central vertical) alternate tiles across and up
  134314. * * * flip every tile on alternate rows
  134315. * * * rotate (180 degs) alternate tiles across and up
  134316. * * * rotate every tile on alternate rows
  134317. * * * flip and rotate alternate tiles across and up
  134318. * * * flip and rotate every tile on alternate rows
  134319. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134320. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134321. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134322. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134323. * * 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)
  134324. * * 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)
  134325. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134326. * @param name defines the name of the mesh
  134327. * @param options defines the options used to create the mesh
  134328. * @param scene defines the hosting scene
  134329. * @returns the box mesh
  134330. */
  134331. static CreateTiledPlane(name: string, options: {
  134332. pattern?: number;
  134333. tileSize?: number;
  134334. tileWidth?: number;
  134335. tileHeight?: number;
  134336. size?: number;
  134337. width?: number;
  134338. height?: number;
  134339. alignHorizontal?: number;
  134340. alignVertical?: number;
  134341. sideOrientation?: number;
  134342. frontUVs?: Vector4;
  134343. backUVs?: Vector4;
  134344. updatable?: boolean;
  134345. }, scene?: Nullable<Scene>): Mesh;
  134346. }
  134347. }
  134348. declare module BABYLON {
  134349. /**
  134350. * Class containing static functions to help procedurally build meshes
  134351. */
  134352. export class TubeBuilder {
  134353. /**
  134354. * Creates a tube mesh.
  134355. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134356. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134357. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134358. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134359. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134360. * * 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)
  134361. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134362. * * 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
  134363. * * 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
  134364. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134365. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134366. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134368. * @param name defines the name of the mesh
  134369. * @param options defines the options used to create the mesh
  134370. * @param scene defines the hosting scene
  134371. * @returns the tube mesh
  134372. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134373. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134374. */
  134375. static CreateTube(name: string, options: {
  134376. path: Vector3[];
  134377. radius?: number;
  134378. tessellation?: number;
  134379. radiusFunction?: {
  134380. (i: number, distance: number): number;
  134381. };
  134382. cap?: number;
  134383. arc?: number;
  134384. updatable?: boolean;
  134385. sideOrientation?: number;
  134386. frontUVs?: Vector4;
  134387. backUVs?: Vector4;
  134388. instance?: Mesh;
  134389. invertUV?: boolean;
  134390. }, scene?: Nullable<Scene>): Mesh;
  134391. }
  134392. }
  134393. declare module BABYLON {
  134394. /**
  134395. * Class containing static functions to help procedurally build meshes
  134396. */
  134397. export class IcoSphereBuilder {
  134398. /**
  134399. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134400. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134401. * * 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`)
  134402. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134403. * * 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
  134404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134407. * @param name defines the name of the mesh
  134408. * @param options defines the options used to create the mesh
  134409. * @param scene defines the hosting scene
  134410. * @returns the icosahedron mesh
  134411. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134412. */
  134413. static CreateIcoSphere(name: string, options: {
  134414. radius?: number;
  134415. radiusX?: number;
  134416. radiusY?: number;
  134417. radiusZ?: number;
  134418. flat?: boolean;
  134419. subdivisions?: number;
  134420. sideOrientation?: number;
  134421. frontUVs?: Vector4;
  134422. backUVs?: Vector4;
  134423. updatable?: boolean;
  134424. }, scene?: Nullable<Scene>): Mesh;
  134425. }
  134426. }
  134427. declare module BABYLON {
  134428. /**
  134429. * Class containing static functions to help procedurally build meshes
  134430. */
  134431. export class DecalBuilder {
  134432. /**
  134433. * Creates a decal mesh.
  134434. * 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
  134435. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134436. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134437. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134438. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134439. * @param name defines the name of the mesh
  134440. * @param sourceMesh defines the mesh where the decal must be applied
  134441. * @param options defines the options used to create the mesh
  134442. * @param scene defines the hosting scene
  134443. * @returns the decal mesh
  134444. * @see https://doc.babylonjs.com/how_to/decals
  134445. */
  134446. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134447. position?: Vector3;
  134448. normal?: Vector3;
  134449. size?: Vector3;
  134450. angle?: number;
  134451. }): Mesh;
  134452. }
  134453. }
  134454. declare module BABYLON {
  134455. /**
  134456. * Class containing static functions to help procedurally build meshes
  134457. */
  134458. export class MeshBuilder {
  134459. /**
  134460. * Creates a box mesh
  134461. * * The parameter `size` sets the size (float) of each box side (default 1)
  134462. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134463. * * 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)
  134464. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134466. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134468. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  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 box mesh
  134473. */
  134474. static CreateBox(name: string, options: {
  134475. size?: number;
  134476. width?: number;
  134477. height?: number;
  134478. depth?: number;
  134479. faceUV?: Vector4[];
  134480. faceColors?: Color4[];
  134481. sideOrientation?: number;
  134482. frontUVs?: Vector4;
  134483. backUVs?: Vector4;
  134484. updatable?: boolean;
  134485. }, scene?: Nullable<Scene>): Mesh;
  134486. /**
  134487. * Creates a tiled box mesh
  134488. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134490. * @param name defines the name of the mesh
  134491. * @param options defines the options used to create the mesh
  134492. * @param scene defines the hosting scene
  134493. * @returns the tiled box mesh
  134494. */
  134495. static CreateTiledBox(name: string, options: {
  134496. pattern?: number;
  134497. size?: number;
  134498. width?: number;
  134499. height?: number;
  134500. depth: number;
  134501. tileSize?: number;
  134502. tileWidth?: number;
  134503. tileHeight?: number;
  134504. faceUV?: Vector4[];
  134505. faceColors?: Color4[];
  134506. alignHorizontal?: number;
  134507. alignVertical?: number;
  134508. sideOrientation?: number;
  134509. updatable?: boolean;
  134510. }, scene?: Nullable<Scene>): Mesh;
  134511. /**
  134512. * Creates a sphere mesh
  134513. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134514. * * 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`)
  134515. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134516. * * 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
  134517. * * 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)
  134518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134521. * @param name defines the name of the mesh
  134522. * @param options defines the options used to create the mesh
  134523. * @param scene defines the hosting scene
  134524. * @returns the sphere mesh
  134525. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134526. */
  134527. static CreateSphere(name: string, options: {
  134528. segments?: number;
  134529. diameter?: number;
  134530. diameterX?: number;
  134531. diameterY?: number;
  134532. diameterZ?: number;
  134533. arc?: number;
  134534. slice?: number;
  134535. sideOrientation?: number;
  134536. frontUVs?: Vector4;
  134537. backUVs?: Vector4;
  134538. updatable?: boolean;
  134539. }, scene?: Nullable<Scene>): Mesh;
  134540. /**
  134541. * Creates a plane polygonal mesh. By default, this is a disc
  134542. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134543. * * 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
  134544. * * 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
  134545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134546. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134548. * @param name defines the name of the mesh
  134549. * @param options defines the options used to create the mesh
  134550. * @param scene defines the hosting scene
  134551. * @returns the plane polygonal mesh
  134552. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134553. */
  134554. static CreateDisc(name: string, options: {
  134555. radius?: number;
  134556. tessellation?: number;
  134557. arc?: number;
  134558. updatable?: boolean;
  134559. sideOrientation?: number;
  134560. frontUVs?: Vector4;
  134561. backUVs?: Vector4;
  134562. }, scene?: Nullable<Scene>): Mesh;
  134563. /**
  134564. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134565. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134566. * * 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`)
  134567. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134568. * * 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
  134569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134572. * @param name defines the name of the mesh
  134573. * @param options defines the options used to create the mesh
  134574. * @param scene defines the hosting scene
  134575. * @returns the icosahedron mesh
  134576. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134577. */
  134578. static CreateIcoSphere(name: string, options: {
  134579. radius?: number;
  134580. radiusX?: number;
  134581. radiusY?: number;
  134582. radiusZ?: number;
  134583. flat?: boolean;
  134584. subdivisions?: number;
  134585. sideOrientation?: number;
  134586. frontUVs?: Vector4;
  134587. backUVs?: Vector4;
  134588. updatable?: boolean;
  134589. }, scene?: Nullable<Scene>): Mesh;
  134590. /**
  134591. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134592. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134593. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134594. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134595. * * 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
  134596. * * 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
  134597. * * 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
  134598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134599. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134600. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134601. * * 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
  134602. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134603. * * 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
  134604. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134606. * @param name defines the name of the mesh
  134607. * @param options defines the options used to create the mesh
  134608. * @param scene defines the hosting scene
  134609. * @returns the ribbon mesh
  134610. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134611. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134612. */
  134613. static CreateRibbon(name: string, options: {
  134614. pathArray: Vector3[][];
  134615. closeArray?: boolean;
  134616. closePath?: boolean;
  134617. offset?: number;
  134618. updatable?: boolean;
  134619. sideOrientation?: number;
  134620. frontUVs?: Vector4;
  134621. backUVs?: Vector4;
  134622. instance?: Mesh;
  134623. invertUV?: boolean;
  134624. uvs?: Vector2[];
  134625. colors?: Color4[];
  134626. }, scene?: Nullable<Scene>): Mesh;
  134627. /**
  134628. * Creates a cylinder or a cone mesh
  134629. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134630. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134631. * * 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.
  134632. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134633. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134634. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134635. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134636. * * 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).
  134637. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134638. * * 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).
  134639. * * 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
  134640. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134641. * * 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
  134642. * * 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.
  134643. * * If `enclose` is false, a ring surface is one element.
  134644. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134645. * * 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
  134646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134647. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134649. * @param name defines the name of the mesh
  134650. * @param options defines the options used to create the mesh
  134651. * @param scene defines the hosting scene
  134652. * @returns the cylinder mesh
  134653. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134654. */
  134655. static CreateCylinder(name: string, options: {
  134656. height?: number;
  134657. diameterTop?: number;
  134658. diameterBottom?: number;
  134659. diameter?: number;
  134660. tessellation?: number;
  134661. subdivisions?: number;
  134662. arc?: number;
  134663. faceColors?: Color4[];
  134664. faceUV?: Vector4[];
  134665. updatable?: boolean;
  134666. hasRings?: boolean;
  134667. enclose?: boolean;
  134668. cap?: number;
  134669. sideOrientation?: number;
  134670. frontUVs?: Vector4;
  134671. backUVs?: Vector4;
  134672. }, scene?: Nullable<Scene>): Mesh;
  134673. /**
  134674. * Creates a torus mesh
  134675. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134676. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134677. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134681. * @param name defines the name of the mesh
  134682. * @param options defines the options used to create the mesh
  134683. * @param scene defines the hosting scene
  134684. * @returns the torus mesh
  134685. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134686. */
  134687. static CreateTorus(name: string, options: {
  134688. diameter?: number;
  134689. thickness?: number;
  134690. tessellation?: number;
  134691. updatable?: boolean;
  134692. sideOrientation?: number;
  134693. frontUVs?: Vector4;
  134694. backUVs?: Vector4;
  134695. }, scene?: Nullable<Scene>): Mesh;
  134696. /**
  134697. * Creates a torus knot mesh
  134698. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134699. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134700. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134701. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134702. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134703. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134705. * @param name defines the name of the mesh
  134706. * @param options defines the options used to create the mesh
  134707. * @param scene defines the hosting scene
  134708. * @returns the torus knot mesh
  134709. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134710. */
  134711. static CreateTorusKnot(name: string, options: {
  134712. radius?: number;
  134713. tube?: number;
  134714. radialSegments?: number;
  134715. tubularSegments?: number;
  134716. p?: number;
  134717. q?: number;
  134718. updatable?: boolean;
  134719. sideOrientation?: number;
  134720. frontUVs?: Vector4;
  134721. backUVs?: Vector4;
  134722. }, scene?: Nullable<Scene>): Mesh;
  134723. /**
  134724. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134725. * * 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
  134726. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134727. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134728. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134729. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134730. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134731. * * 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
  134732. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134734. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134735. * @param name defines the name of the new line system
  134736. * @param options defines the options used to create the line system
  134737. * @param scene defines the hosting scene
  134738. * @returns a new line system mesh
  134739. */
  134740. static CreateLineSystem(name: string, options: {
  134741. lines: Vector3[][];
  134742. updatable?: boolean;
  134743. instance?: Nullable<LinesMesh>;
  134744. colors?: Nullable<Color4[][]>;
  134745. useVertexAlpha?: boolean;
  134746. }, scene: Nullable<Scene>): LinesMesh;
  134747. /**
  134748. * Creates a line mesh
  134749. * 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
  134750. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134751. * * The parameter `points` is an array successive Vector3
  134752. * * 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
  134753. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134754. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134755. * * When updating an instance, remember that only point positions can change, not the number of points
  134756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134757. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134758. * @param name defines the name of the new line system
  134759. * @param options defines the options used to create the line system
  134760. * @param scene defines the hosting scene
  134761. * @returns a new line mesh
  134762. */
  134763. static CreateLines(name: string, options: {
  134764. points: Vector3[];
  134765. updatable?: boolean;
  134766. instance?: Nullable<LinesMesh>;
  134767. colors?: Color4[];
  134768. useVertexAlpha?: boolean;
  134769. }, scene?: Nullable<Scene>): LinesMesh;
  134770. /**
  134771. * Creates a dashed line mesh
  134772. * * 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
  134773. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134774. * * The parameter `points` is an array successive Vector3
  134775. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134776. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134777. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134778. * * 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
  134779. * * When updating an instance, remember that only point positions can change, not the number of points
  134780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134781. * @param name defines the name of the mesh
  134782. * @param options defines the options used to create the mesh
  134783. * @param scene defines the hosting scene
  134784. * @returns the dashed line mesh
  134785. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134786. */
  134787. static CreateDashedLines(name: string, options: {
  134788. points: Vector3[];
  134789. dashSize?: number;
  134790. gapSize?: number;
  134791. dashNb?: number;
  134792. updatable?: boolean;
  134793. instance?: LinesMesh;
  134794. }, scene?: Nullable<Scene>): LinesMesh;
  134795. /**
  134796. * 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.
  134797. * * 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.
  134798. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134799. * * 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.
  134800. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134801. * * 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
  134802. * * 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
  134803. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134805. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134806. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134808. * @param name defines the name of the mesh
  134809. * @param options defines the options used to create the mesh
  134810. * @param scene defines the hosting scene
  134811. * @returns the extruded shape mesh
  134812. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134813. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134814. */
  134815. static ExtrudeShape(name: string, options: {
  134816. shape: Vector3[];
  134817. path: Vector3[];
  134818. scale?: number;
  134819. rotation?: number;
  134820. cap?: number;
  134821. updatable?: boolean;
  134822. sideOrientation?: number;
  134823. frontUVs?: Vector4;
  134824. backUVs?: Vector4;
  134825. instance?: Mesh;
  134826. invertUV?: boolean;
  134827. }, scene?: Nullable<Scene>): Mesh;
  134828. /**
  134829. * Creates an custom extruded shape mesh.
  134830. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134831. * * 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.
  134832. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134833. * * 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
  134834. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134835. * * 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
  134836. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134837. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134838. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134839. * * 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
  134840. * * 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
  134841. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134843. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134844. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134846. * @param name defines the name of the mesh
  134847. * @param options defines the options used to create the mesh
  134848. * @param scene defines the hosting scene
  134849. * @returns the custom extruded shape mesh
  134850. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134851. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134852. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134853. */
  134854. static ExtrudeShapeCustom(name: string, options: {
  134855. shape: Vector3[];
  134856. path: Vector3[];
  134857. scaleFunction?: any;
  134858. rotationFunction?: any;
  134859. ribbonCloseArray?: boolean;
  134860. ribbonClosePath?: boolean;
  134861. cap?: number;
  134862. updatable?: boolean;
  134863. sideOrientation?: number;
  134864. frontUVs?: Vector4;
  134865. backUVs?: Vector4;
  134866. instance?: Mesh;
  134867. invertUV?: boolean;
  134868. }, scene?: Nullable<Scene>): Mesh;
  134869. /**
  134870. * Creates lathe mesh.
  134871. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134872. * * 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
  134873. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134874. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134875. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134876. * * 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
  134877. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134878. * * 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
  134879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134881. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134883. * @param name defines the name of the mesh
  134884. * @param options defines the options used to create the mesh
  134885. * @param scene defines the hosting scene
  134886. * @returns the lathe mesh
  134887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134888. */
  134889. static CreateLathe(name: string, options: {
  134890. shape: Vector3[];
  134891. radius?: number;
  134892. tessellation?: number;
  134893. clip?: number;
  134894. arc?: number;
  134895. closed?: boolean;
  134896. updatable?: boolean;
  134897. sideOrientation?: number;
  134898. frontUVs?: Vector4;
  134899. backUVs?: Vector4;
  134900. cap?: number;
  134901. invertUV?: boolean;
  134902. }, scene?: Nullable<Scene>): Mesh;
  134903. /**
  134904. * Creates a tiled plane mesh
  134905. * * You can set a limited pattern arrangement with the tiles
  134906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134907. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134909. * @param name defines the name of the mesh
  134910. * @param options defines the options used to create the mesh
  134911. * @param scene defines the hosting scene
  134912. * @returns the plane mesh
  134913. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134914. */
  134915. static CreateTiledPlane(name: string, options: {
  134916. pattern?: number;
  134917. tileSize?: number;
  134918. tileWidth?: number;
  134919. tileHeight?: number;
  134920. size?: number;
  134921. width?: number;
  134922. height?: number;
  134923. alignHorizontal?: number;
  134924. alignVertical?: number;
  134925. sideOrientation?: number;
  134926. frontUVs?: Vector4;
  134927. backUVs?: Vector4;
  134928. updatable?: boolean;
  134929. }, scene?: Nullable<Scene>): Mesh;
  134930. /**
  134931. * Creates a plane mesh
  134932. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134933. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134934. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134938. * @param name defines the name of the mesh
  134939. * @param options defines the options used to create the mesh
  134940. * @param scene defines the hosting scene
  134941. * @returns the plane mesh
  134942. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134943. */
  134944. static CreatePlane(name: string, options: {
  134945. size?: number;
  134946. width?: number;
  134947. height?: number;
  134948. sideOrientation?: number;
  134949. frontUVs?: Vector4;
  134950. backUVs?: Vector4;
  134951. updatable?: boolean;
  134952. sourcePlane?: Plane;
  134953. }, scene?: Nullable<Scene>): Mesh;
  134954. /**
  134955. * Creates a ground mesh
  134956. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134957. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134959. * @param name defines the name of the mesh
  134960. * @param options defines the options used to create the mesh
  134961. * @param scene defines the hosting scene
  134962. * @returns the ground mesh
  134963. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134964. */
  134965. static CreateGround(name: string, options: {
  134966. width?: number;
  134967. height?: number;
  134968. subdivisions?: number;
  134969. subdivisionsX?: number;
  134970. subdivisionsY?: number;
  134971. updatable?: boolean;
  134972. }, scene?: Nullable<Scene>): Mesh;
  134973. /**
  134974. * Creates a tiled ground mesh
  134975. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134976. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134977. * * 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
  134978. * * 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
  134979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134980. * @param name defines the name of the mesh
  134981. * @param options defines the options used to create the mesh
  134982. * @param scene defines the hosting scene
  134983. * @returns the tiled ground mesh
  134984. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134985. */
  134986. static CreateTiledGround(name: string, options: {
  134987. xmin: number;
  134988. zmin: number;
  134989. xmax: number;
  134990. zmax: number;
  134991. subdivisions?: {
  134992. w: number;
  134993. h: number;
  134994. };
  134995. precision?: {
  134996. w: number;
  134997. h: number;
  134998. };
  134999. updatable?: boolean;
  135000. }, scene?: Nullable<Scene>): Mesh;
  135001. /**
  135002. * Creates a ground mesh from a height map
  135003. * * The parameter `url` sets the URL of the height map image resource.
  135004. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  135005. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  135006. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  135007. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  135008. * * 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.
  135009. * * 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).
  135010. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  135011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135012. * @param name defines the name of the mesh
  135013. * @param url defines the url to the height map
  135014. * @param options defines the options used to create the mesh
  135015. * @param scene defines the hosting scene
  135016. * @returns the ground mesh
  135017. * @see https://doc.babylonjs.com/babylon101/height_map
  135018. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  135019. */
  135020. static CreateGroundFromHeightMap(name: string, url: string, options: {
  135021. width?: number;
  135022. height?: number;
  135023. subdivisions?: number;
  135024. minHeight?: number;
  135025. maxHeight?: number;
  135026. colorFilter?: Color3;
  135027. alphaFilter?: number;
  135028. updatable?: boolean;
  135029. onReady?: (mesh: GroundMesh) => void;
  135030. }, scene?: Nullable<Scene>): GroundMesh;
  135031. /**
  135032. * Creates a polygon mesh
  135033. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  135034. * * 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
  135035. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135037. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  135038. * * Remember you can only change the shape positions, not their number when updating a polygon
  135039. * @param name defines the name of the mesh
  135040. * @param options defines the options used to create the mesh
  135041. * @param scene defines the hosting scene
  135042. * @param earcutInjection can be used to inject your own earcut reference
  135043. * @returns the polygon mesh
  135044. */
  135045. static CreatePolygon(name: string, options: {
  135046. shape: Vector3[];
  135047. holes?: Vector3[][];
  135048. depth?: number;
  135049. faceUV?: Vector4[];
  135050. faceColors?: Color4[];
  135051. updatable?: boolean;
  135052. sideOrientation?: number;
  135053. frontUVs?: Vector4;
  135054. backUVs?: Vector4;
  135055. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135056. /**
  135057. * Creates an extruded polygon mesh, with depth in the Y direction.
  135058. * * 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)
  135059. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135060. * @param name defines the name of the mesh
  135061. * @param options defines the options used to create the mesh
  135062. * @param scene defines the hosting scene
  135063. * @param earcutInjection can be used to inject your own earcut reference
  135064. * @returns the polygon mesh
  135065. */
  135066. static ExtrudePolygon(name: string, options: {
  135067. shape: Vector3[];
  135068. holes?: Vector3[][];
  135069. depth?: number;
  135070. faceUV?: Vector4[];
  135071. faceColors?: Color4[];
  135072. updatable?: boolean;
  135073. sideOrientation?: number;
  135074. frontUVs?: Vector4;
  135075. backUVs?: Vector4;
  135076. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135077. /**
  135078. * Creates a tube mesh.
  135079. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135080. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  135081. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  135082. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  135083. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  135084. * * 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)
  135085. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  135086. * * 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
  135087. * * 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
  135088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135090. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135092. * @param name defines the name of the mesh
  135093. * @param options defines the options used to create the mesh
  135094. * @param scene defines the hosting scene
  135095. * @returns the tube mesh
  135096. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135097. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  135098. */
  135099. static CreateTube(name: string, options: {
  135100. path: Vector3[];
  135101. radius?: number;
  135102. tessellation?: number;
  135103. radiusFunction?: {
  135104. (i: number, distance: number): number;
  135105. };
  135106. cap?: number;
  135107. arc?: number;
  135108. updatable?: boolean;
  135109. sideOrientation?: number;
  135110. frontUVs?: Vector4;
  135111. backUVs?: Vector4;
  135112. instance?: Mesh;
  135113. invertUV?: boolean;
  135114. }, scene?: Nullable<Scene>): Mesh;
  135115. /**
  135116. * Creates a polyhedron mesh
  135117. * * 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
  135118. * * The parameter `size` (positive float, default 1) sets the polygon size
  135119. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  135120. * * 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`
  135121. * * 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
  135122. * * 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)`)
  135123. * * 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
  135124. * * 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
  135125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135128. * @param name defines the name of the mesh
  135129. * @param options defines the options used to create the mesh
  135130. * @param scene defines the hosting scene
  135131. * @returns the polyhedron mesh
  135132. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  135133. */
  135134. static CreatePolyhedron(name: string, options: {
  135135. type?: number;
  135136. size?: number;
  135137. sizeX?: number;
  135138. sizeY?: number;
  135139. sizeZ?: number;
  135140. custom?: any;
  135141. faceUV?: Vector4[];
  135142. faceColors?: Color4[];
  135143. flat?: boolean;
  135144. updatable?: boolean;
  135145. sideOrientation?: number;
  135146. frontUVs?: Vector4;
  135147. backUVs?: Vector4;
  135148. }, scene?: Nullable<Scene>): Mesh;
  135149. /**
  135150. * Creates a decal mesh.
  135151. * 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
  135152. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135153. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135154. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135155. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135156. * @param name defines the name of the mesh
  135157. * @param sourceMesh defines the mesh where the decal must be applied
  135158. * @param options defines the options used to create the mesh
  135159. * @param scene defines the hosting scene
  135160. * @returns the decal mesh
  135161. * @see https://doc.babylonjs.com/how_to/decals
  135162. */
  135163. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135164. position?: Vector3;
  135165. normal?: Vector3;
  135166. size?: Vector3;
  135167. angle?: number;
  135168. }): Mesh;
  135169. }
  135170. }
  135171. declare module BABYLON {
  135172. /**
  135173. * A simplifier interface for future simplification implementations
  135174. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135175. */
  135176. export interface ISimplifier {
  135177. /**
  135178. * Simplification of a given mesh according to the given settings.
  135179. * Since this requires computation, it is assumed that the function runs async.
  135180. * @param settings The settings of the simplification, including quality and distance
  135181. * @param successCallback A callback that will be called after the mesh was simplified.
  135182. * @param errorCallback in case of an error, this callback will be called. optional.
  135183. */
  135184. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  135185. }
  135186. /**
  135187. * Expected simplification settings.
  135188. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  135189. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135190. */
  135191. export interface ISimplificationSettings {
  135192. /**
  135193. * Gets or sets the expected quality
  135194. */
  135195. quality: number;
  135196. /**
  135197. * Gets or sets the distance when this optimized version should be used
  135198. */
  135199. distance: number;
  135200. /**
  135201. * Gets an already optimized mesh
  135202. */
  135203. optimizeMesh?: boolean;
  135204. }
  135205. /**
  135206. * Class used to specify simplification options
  135207. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135208. */
  135209. export class SimplificationSettings implements ISimplificationSettings {
  135210. /** expected quality */
  135211. quality: number;
  135212. /** distance when this optimized version should be used */
  135213. distance: number;
  135214. /** already optimized mesh */
  135215. optimizeMesh?: boolean | undefined;
  135216. /**
  135217. * Creates a SimplificationSettings
  135218. * @param quality expected quality
  135219. * @param distance distance when this optimized version should be used
  135220. * @param optimizeMesh already optimized mesh
  135221. */
  135222. constructor(
  135223. /** expected quality */
  135224. quality: number,
  135225. /** distance when this optimized version should be used */
  135226. distance: number,
  135227. /** already optimized mesh */
  135228. optimizeMesh?: boolean | undefined);
  135229. }
  135230. /**
  135231. * Interface used to define a simplification task
  135232. */
  135233. export interface ISimplificationTask {
  135234. /**
  135235. * Array of settings
  135236. */
  135237. settings: Array<ISimplificationSettings>;
  135238. /**
  135239. * Simplification type
  135240. */
  135241. simplificationType: SimplificationType;
  135242. /**
  135243. * Mesh to simplify
  135244. */
  135245. mesh: Mesh;
  135246. /**
  135247. * Callback called on success
  135248. */
  135249. successCallback?: () => void;
  135250. /**
  135251. * Defines if parallel processing can be used
  135252. */
  135253. parallelProcessing: boolean;
  135254. }
  135255. /**
  135256. * Queue used to order the simplification tasks
  135257. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135258. */
  135259. export class SimplificationQueue {
  135260. private _simplificationArray;
  135261. /**
  135262. * Gets a boolean indicating that the process is still running
  135263. */
  135264. running: boolean;
  135265. /**
  135266. * Creates a new queue
  135267. */
  135268. constructor();
  135269. /**
  135270. * Adds a new simplification task
  135271. * @param task defines a task to add
  135272. */
  135273. addTask(task: ISimplificationTask): void;
  135274. /**
  135275. * Execute next task
  135276. */
  135277. executeNext(): void;
  135278. /**
  135279. * Execute a simplification task
  135280. * @param task defines the task to run
  135281. */
  135282. runSimplification(task: ISimplificationTask): void;
  135283. private getSimplifier;
  135284. }
  135285. /**
  135286. * The implemented types of simplification
  135287. * At the moment only Quadratic Error Decimation is implemented
  135288. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135289. */
  135290. export enum SimplificationType {
  135291. /** Quadratic error decimation */
  135292. QUADRATIC = 0
  135293. }
  135294. /**
  135295. * An implementation of the Quadratic Error simplification algorithm.
  135296. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  135297. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  135298. * @author RaananW
  135299. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135300. */
  135301. export class QuadraticErrorSimplification implements ISimplifier {
  135302. private _mesh;
  135303. private triangles;
  135304. private vertices;
  135305. private references;
  135306. private _reconstructedMesh;
  135307. /** Gets or sets the number pf sync interations */
  135308. syncIterations: number;
  135309. /** Gets or sets the aggressiveness of the simplifier */
  135310. aggressiveness: number;
  135311. /** Gets or sets the number of allowed iterations for decimation */
  135312. decimationIterations: number;
  135313. /** Gets or sets the espilon to use for bounding box computation */
  135314. boundingBoxEpsilon: number;
  135315. /**
  135316. * Creates a new QuadraticErrorSimplification
  135317. * @param _mesh defines the target mesh
  135318. */
  135319. constructor(_mesh: Mesh);
  135320. /**
  135321. * Simplification of a given mesh according to the given settings.
  135322. * Since this requires computation, it is assumed that the function runs async.
  135323. * @param settings The settings of the simplification, including quality and distance
  135324. * @param successCallback A callback that will be called after the mesh was simplified.
  135325. */
  135326. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  135327. private runDecimation;
  135328. private initWithMesh;
  135329. private init;
  135330. private reconstructMesh;
  135331. private initDecimatedMesh;
  135332. private isFlipped;
  135333. private updateTriangles;
  135334. private identifyBorder;
  135335. private updateMesh;
  135336. private vertexError;
  135337. private calculateError;
  135338. }
  135339. }
  135340. declare module BABYLON {
  135341. interface Scene {
  135342. /** @hidden (Backing field) */
  135343. _simplificationQueue: SimplificationQueue;
  135344. /**
  135345. * Gets or sets the simplification queue attached to the scene
  135346. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135347. */
  135348. simplificationQueue: SimplificationQueue;
  135349. }
  135350. interface Mesh {
  135351. /**
  135352. * Simplify the mesh according to the given array of settings.
  135353. * Function will return immediately and will simplify async
  135354. * @param settings a collection of simplification settings
  135355. * @param parallelProcessing should all levels calculate parallel or one after the other
  135356. * @param simplificationType the type of simplification to run
  135357. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135358. * @returns the current mesh
  135359. */
  135360. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135361. }
  135362. /**
  135363. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135364. * created in a scene
  135365. */
  135366. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135367. /**
  135368. * The component name helpfull to identify the component in the list of scene components.
  135369. */
  135370. readonly name: string;
  135371. /**
  135372. * The scene the component belongs to.
  135373. */
  135374. scene: Scene;
  135375. /**
  135376. * Creates a new instance of the component for the given scene
  135377. * @param scene Defines the scene to register the component in
  135378. */
  135379. constructor(scene: Scene);
  135380. /**
  135381. * Registers the component in a given scene
  135382. */
  135383. register(): void;
  135384. /**
  135385. * Rebuilds the elements related to this component in case of
  135386. * context lost for instance.
  135387. */
  135388. rebuild(): void;
  135389. /**
  135390. * Disposes the component and the associated ressources
  135391. */
  135392. dispose(): void;
  135393. private _beforeCameraUpdate;
  135394. }
  135395. }
  135396. declare module BABYLON {
  135397. /**
  135398. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135399. */
  135400. export interface INavigationEnginePlugin {
  135401. /**
  135402. * plugin name
  135403. */
  135404. name: string;
  135405. /**
  135406. * Creates a navigation mesh
  135407. * @param meshes array of all the geometry used to compute the navigatio mesh
  135408. * @param parameters bunch of parameters used to filter geometry
  135409. */
  135410. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135411. /**
  135412. * Create a navigation mesh debug mesh
  135413. * @param scene is where the mesh will be added
  135414. * @returns debug display mesh
  135415. */
  135416. createDebugNavMesh(scene: Scene): Mesh;
  135417. /**
  135418. * Get a navigation mesh constrained position, closest to the parameter position
  135419. * @param position world position
  135420. * @returns the closest point to position constrained by the navigation mesh
  135421. */
  135422. getClosestPoint(position: Vector3): Vector3;
  135423. /**
  135424. * Get a navigation mesh constrained position, within a particular radius
  135425. * @param position world position
  135426. * @param maxRadius the maximum distance to the constrained world position
  135427. * @returns the closest point to position constrained by the navigation mesh
  135428. */
  135429. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135430. /**
  135431. * Compute the final position from a segment made of destination-position
  135432. * @param position world position
  135433. * @param destination world position
  135434. * @returns the resulting point along the navmesh
  135435. */
  135436. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135437. /**
  135438. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135439. * @param start world position
  135440. * @param end world position
  135441. * @returns array containing world position composing the path
  135442. */
  135443. computePath(start: Vector3, end: Vector3): Vector3[];
  135444. /**
  135445. * If this plugin is supported
  135446. * @returns true if plugin is supported
  135447. */
  135448. isSupported(): boolean;
  135449. /**
  135450. * Create a new Crowd so you can add agents
  135451. * @param maxAgents the maximum agent count in the crowd
  135452. * @param maxAgentRadius the maximum radius an agent can have
  135453. * @param scene to attach the crowd to
  135454. * @returns the crowd you can add agents to
  135455. */
  135456. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135457. /**
  135458. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135459. * The queries will try to find a solution within those bounds
  135460. * default is (1,1,1)
  135461. * @param extent x,y,z value that define the extent around the queries point of reference
  135462. */
  135463. setDefaultQueryExtent(extent: Vector3): void;
  135464. /**
  135465. * Get the Bounding box extent specified by setDefaultQueryExtent
  135466. * @returns the box extent values
  135467. */
  135468. getDefaultQueryExtent(): Vector3;
  135469. /**
  135470. * Release all resources
  135471. */
  135472. dispose(): void;
  135473. }
  135474. /**
  135475. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135476. */
  135477. export interface ICrowd {
  135478. /**
  135479. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135480. * You can attach anything to that node. The node position is updated in the scene update tick.
  135481. * @param pos world position that will be constrained by the navigation mesh
  135482. * @param parameters agent parameters
  135483. * @param transform hooked to the agent that will be update by the scene
  135484. * @returns agent index
  135485. */
  135486. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135487. /**
  135488. * Returns the agent position in world space
  135489. * @param index agent index returned by addAgent
  135490. * @returns world space position
  135491. */
  135492. getAgentPosition(index: number): Vector3;
  135493. /**
  135494. * Gets the agent velocity in world space
  135495. * @param index agent index returned by addAgent
  135496. * @returns world space velocity
  135497. */
  135498. getAgentVelocity(index: number): Vector3;
  135499. /**
  135500. * remove a particular agent previously created
  135501. * @param index agent index returned by addAgent
  135502. */
  135503. removeAgent(index: number): void;
  135504. /**
  135505. * get the list of all agents attached to this crowd
  135506. * @returns list of agent indices
  135507. */
  135508. getAgents(): number[];
  135509. /**
  135510. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135511. * @param deltaTime in seconds
  135512. */
  135513. update(deltaTime: number): void;
  135514. /**
  135515. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135516. * @param index agent index returned by addAgent
  135517. * @param destination targeted world position
  135518. */
  135519. agentGoto(index: number, destination: Vector3): void;
  135520. /**
  135521. * Teleport the agent to a new position
  135522. * @param index agent index returned by addAgent
  135523. * @param destination targeted world position
  135524. */
  135525. agentTeleport(index: number, destination: Vector3): void;
  135526. /**
  135527. * Update agent parameters
  135528. * @param index agent index returned by addAgent
  135529. * @param parameters agent parameters
  135530. */
  135531. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135532. /**
  135533. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135534. * The queries will try to find a solution within those bounds
  135535. * default is (1,1,1)
  135536. * @param extent x,y,z value that define the extent around the queries point of reference
  135537. */
  135538. setDefaultQueryExtent(extent: Vector3): void;
  135539. /**
  135540. * Get the Bounding box extent specified by setDefaultQueryExtent
  135541. * @returns the box extent values
  135542. */
  135543. getDefaultQueryExtent(): Vector3;
  135544. /**
  135545. * Release all resources
  135546. */
  135547. dispose(): void;
  135548. }
  135549. /**
  135550. * Configures an agent
  135551. */
  135552. export interface IAgentParameters {
  135553. /**
  135554. * Agent radius. [Limit: >= 0]
  135555. */
  135556. radius: number;
  135557. /**
  135558. * Agent height. [Limit: > 0]
  135559. */
  135560. height: number;
  135561. /**
  135562. * Maximum allowed acceleration. [Limit: >= 0]
  135563. */
  135564. maxAcceleration: number;
  135565. /**
  135566. * Maximum allowed speed. [Limit: >= 0]
  135567. */
  135568. maxSpeed: number;
  135569. /**
  135570. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135571. */
  135572. collisionQueryRange: number;
  135573. /**
  135574. * The path visibility optimization range. [Limit: > 0]
  135575. */
  135576. pathOptimizationRange: number;
  135577. /**
  135578. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135579. */
  135580. separationWeight: number;
  135581. }
  135582. /**
  135583. * Configures the navigation mesh creation
  135584. */
  135585. export interface INavMeshParameters {
  135586. /**
  135587. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135588. */
  135589. cs: number;
  135590. /**
  135591. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135592. */
  135593. ch: number;
  135594. /**
  135595. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135596. */
  135597. walkableSlopeAngle: number;
  135598. /**
  135599. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135600. * be considered walkable. [Limit: >= 3] [Units: vx]
  135601. */
  135602. walkableHeight: number;
  135603. /**
  135604. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135605. */
  135606. walkableClimb: number;
  135607. /**
  135608. * The distance to erode/shrink the walkable area of the heightfield away from
  135609. * obstructions. [Limit: >=0] [Units: vx]
  135610. */
  135611. walkableRadius: number;
  135612. /**
  135613. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135614. */
  135615. maxEdgeLen: number;
  135616. /**
  135617. * The maximum distance a simplfied contour's border edges should deviate
  135618. * the original raw contour. [Limit: >=0] [Units: vx]
  135619. */
  135620. maxSimplificationError: number;
  135621. /**
  135622. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135623. */
  135624. minRegionArea: number;
  135625. /**
  135626. * Any regions with a span count smaller than this value will, if possible,
  135627. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135628. */
  135629. mergeRegionArea: number;
  135630. /**
  135631. * The maximum number of vertices allowed for polygons generated during the
  135632. * contour to polygon conversion process. [Limit: >= 3]
  135633. */
  135634. maxVertsPerPoly: number;
  135635. /**
  135636. * Sets the sampling distance to use when generating the detail mesh.
  135637. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135638. */
  135639. detailSampleDist: number;
  135640. /**
  135641. * The maximum distance the detail mesh surface should deviate from heightfield
  135642. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135643. */
  135644. detailSampleMaxError: number;
  135645. }
  135646. }
  135647. declare module BABYLON {
  135648. /**
  135649. * RecastJS navigation plugin
  135650. */
  135651. export class RecastJSPlugin implements INavigationEnginePlugin {
  135652. /**
  135653. * Reference to the Recast library
  135654. */
  135655. bjsRECAST: any;
  135656. /**
  135657. * plugin name
  135658. */
  135659. name: string;
  135660. /**
  135661. * the first navmesh created. We might extend this to support multiple navmeshes
  135662. */
  135663. navMesh: any;
  135664. /**
  135665. * Initializes the recastJS plugin
  135666. * @param recastInjection can be used to inject your own recast reference
  135667. */
  135668. constructor(recastInjection?: any);
  135669. /**
  135670. * Creates a navigation mesh
  135671. * @param meshes array of all the geometry used to compute the navigatio mesh
  135672. * @param parameters bunch of parameters used to filter geometry
  135673. */
  135674. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135675. /**
  135676. * Create a navigation mesh debug mesh
  135677. * @param scene is where the mesh will be added
  135678. * @returns debug display mesh
  135679. */
  135680. createDebugNavMesh(scene: Scene): Mesh;
  135681. /**
  135682. * Get a navigation mesh constrained position, closest to the parameter position
  135683. * @param position world position
  135684. * @returns the closest point to position constrained by the navigation mesh
  135685. */
  135686. getClosestPoint(position: Vector3): Vector3;
  135687. /**
  135688. * Get a navigation mesh constrained position, within a particular radius
  135689. * @param position world position
  135690. * @param maxRadius the maximum distance to the constrained world position
  135691. * @returns the closest point to position constrained by the navigation mesh
  135692. */
  135693. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135694. /**
  135695. * Compute the final position from a segment made of destination-position
  135696. * @param position world position
  135697. * @param destination world position
  135698. * @returns the resulting point along the navmesh
  135699. */
  135700. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135701. /**
  135702. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135703. * @param start world position
  135704. * @param end world position
  135705. * @returns array containing world position composing the path
  135706. */
  135707. computePath(start: Vector3, end: Vector3): Vector3[];
  135708. /**
  135709. * Create a new Crowd so you can add agents
  135710. * @param maxAgents the maximum agent count in the crowd
  135711. * @param maxAgentRadius the maximum radius an agent can have
  135712. * @param scene to attach the crowd to
  135713. * @returns the crowd you can add agents to
  135714. */
  135715. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135716. /**
  135717. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135718. * The queries will try to find a solution within those bounds
  135719. * default is (1,1,1)
  135720. * @param extent x,y,z value that define the extent around the queries point of reference
  135721. */
  135722. setDefaultQueryExtent(extent: Vector3): void;
  135723. /**
  135724. * Get the Bounding box extent specified by setDefaultQueryExtent
  135725. * @returns the box extent values
  135726. */
  135727. getDefaultQueryExtent(): Vector3;
  135728. /**
  135729. * Disposes
  135730. */
  135731. dispose(): void;
  135732. /**
  135733. * If this plugin is supported
  135734. * @returns true if plugin is supported
  135735. */
  135736. isSupported(): boolean;
  135737. }
  135738. /**
  135739. * Recast detour crowd implementation
  135740. */
  135741. export class RecastJSCrowd implements ICrowd {
  135742. /**
  135743. * Recast/detour plugin
  135744. */
  135745. bjsRECASTPlugin: RecastJSPlugin;
  135746. /**
  135747. * Link to the detour crowd
  135748. */
  135749. recastCrowd: any;
  135750. /**
  135751. * One transform per agent
  135752. */
  135753. transforms: TransformNode[];
  135754. /**
  135755. * All agents created
  135756. */
  135757. agents: number[];
  135758. /**
  135759. * Link to the scene is kept to unregister the crowd from the scene
  135760. */
  135761. private _scene;
  135762. /**
  135763. * Observer for crowd updates
  135764. */
  135765. private _onBeforeAnimationsObserver;
  135766. /**
  135767. * Constructor
  135768. * @param plugin recastJS plugin
  135769. * @param maxAgents the maximum agent count in the crowd
  135770. * @param maxAgentRadius the maximum radius an agent can have
  135771. * @param scene to attach the crowd to
  135772. * @returns the crowd you can add agents to
  135773. */
  135774. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135775. /**
  135776. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135777. * You can attach anything to that node. The node position is updated in the scene update tick.
  135778. * @param pos world position that will be constrained by the navigation mesh
  135779. * @param parameters agent parameters
  135780. * @param transform hooked to the agent that will be update by the scene
  135781. * @returns agent index
  135782. */
  135783. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135784. /**
  135785. * Returns the agent position in world space
  135786. * @param index agent index returned by addAgent
  135787. * @returns world space position
  135788. */
  135789. getAgentPosition(index: number): Vector3;
  135790. /**
  135791. * Returns the agent velocity in world space
  135792. * @param index agent index returned by addAgent
  135793. * @returns world space velocity
  135794. */
  135795. getAgentVelocity(index: number): Vector3;
  135796. /**
  135797. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135798. * @param index agent index returned by addAgent
  135799. * @param destination targeted world position
  135800. */
  135801. agentGoto(index: number, destination: Vector3): void;
  135802. /**
  135803. * Teleport the agent to a new position
  135804. * @param index agent index returned by addAgent
  135805. * @param destination targeted world position
  135806. */
  135807. agentTeleport(index: number, destination: Vector3): void;
  135808. /**
  135809. * Update agent parameters
  135810. * @param index agent index returned by addAgent
  135811. * @param parameters agent parameters
  135812. */
  135813. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135814. /**
  135815. * remove a particular agent previously created
  135816. * @param index agent index returned by addAgent
  135817. */
  135818. removeAgent(index: number): void;
  135819. /**
  135820. * get the list of all agents attached to this crowd
  135821. * @returns list of agent indices
  135822. */
  135823. getAgents(): number[];
  135824. /**
  135825. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135826. * @param deltaTime in seconds
  135827. */
  135828. update(deltaTime: number): void;
  135829. /**
  135830. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135831. * The queries will try to find a solution within those bounds
  135832. * default is (1,1,1)
  135833. * @param extent x,y,z value that define the extent around the queries point of reference
  135834. */
  135835. setDefaultQueryExtent(extent: Vector3): void;
  135836. /**
  135837. * Get the Bounding box extent specified by setDefaultQueryExtent
  135838. * @returns the box extent values
  135839. */
  135840. getDefaultQueryExtent(): Vector3;
  135841. /**
  135842. * Release all resources
  135843. */
  135844. dispose(): void;
  135845. }
  135846. }
  135847. declare module BABYLON {
  135848. /**
  135849. * Class used to enable access to IndexedDB
  135850. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135851. */
  135852. export class Database implements IOfflineProvider {
  135853. private _callbackManifestChecked;
  135854. private _currentSceneUrl;
  135855. private _db;
  135856. private _enableSceneOffline;
  135857. private _enableTexturesOffline;
  135858. private _manifestVersionFound;
  135859. private _mustUpdateRessources;
  135860. private _hasReachedQuota;
  135861. private _isSupported;
  135862. private _idbFactory;
  135863. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135864. private static IsUASupportingBlobStorage;
  135865. /**
  135866. * Gets a boolean indicating if Database storate is enabled (off by default)
  135867. */
  135868. static IDBStorageEnabled: boolean;
  135869. /**
  135870. * Gets a boolean indicating if scene must be saved in the database
  135871. */
  135872. get enableSceneOffline(): boolean;
  135873. /**
  135874. * Gets a boolean indicating if textures must be saved in the database
  135875. */
  135876. get enableTexturesOffline(): boolean;
  135877. /**
  135878. * Creates a new Database
  135879. * @param urlToScene defines the url to load the scene
  135880. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135881. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135882. */
  135883. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135884. private static _ParseURL;
  135885. private static _ReturnFullUrlLocation;
  135886. private _checkManifestFile;
  135887. /**
  135888. * Open the database and make it available
  135889. * @param successCallback defines the callback to call on success
  135890. * @param errorCallback defines the callback to call on error
  135891. */
  135892. open(successCallback: () => void, errorCallback: () => void): void;
  135893. /**
  135894. * Loads an image from the database
  135895. * @param url defines the url to load from
  135896. * @param image defines the target DOM image
  135897. */
  135898. loadImage(url: string, image: HTMLImageElement): void;
  135899. private _loadImageFromDBAsync;
  135900. private _saveImageIntoDBAsync;
  135901. private _checkVersionFromDB;
  135902. private _loadVersionFromDBAsync;
  135903. private _saveVersionIntoDBAsync;
  135904. /**
  135905. * Loads a file from database
  135906. * @param url defines the URL to load from
  135907. * @param sceneLoaded defines a callback to call on success
  135908. * @param progressCallBack defines a callback to call when progress changed
  135909. * @param errorCallback defines a callback to call on error
  135910. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135911. */
  135912. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135913. private _loadFileAsync;
  135914. private _saveFileAsync;
  135915. /**
  135916. * Validates if xhr data is correct
  135917. * @param xhr defines the request to validate
  135918. * @param dataType defines the expected data type
  135919. * @returns true if data is correct
  135920. */
  135921. private static _ValidateXHRData;
  135922. }
  135923. }
  135924. declare module BABYLON {
  135925. /** @hidden */
  135926. export var gpuUpdateParticlesPixelShader: {
  135927. name: string;
  135928. shader: string;
  135929. };
  135930. }
  135931. declare module BABYLON {
  135932. /** @hidden */
  135933. export var gpuUpdateParticlesVertexShader: {
  135934. name: string;
  135935. shader: string;
  135936. };
  135937. }
  135938. declare module BABYLON {
  135939. /** @hidden */
  135940. export var clipPlaneFragmentDeclaration2: {
  135941. name: string;
  135942. shader: string;
  135943. };
  135944. }
  135945. declare module BABYLON {
  135946. /** @hidden */
  135947. export var gpuRenderParticlesPixelShader: {
  135948. name: string;
  135949. shader: string;
  135950. };
  135951. }
  135952. declare module BABYLON {
  135953. /** @hidden */
  135954. export var clipPlaneVertexDeclaration2: {
  135955. name: string;
  135956. shader: string;
  135957. };
  135958. }
  135959. declare module BABYLON {
  135960. /** @hidden */
  135961. export var gpuRenderParticlesVertexShader: {
  135962. name: string;
  135963. shader: string;
  135964. };
  135965. }
  135966. declare module BABYLON {
  135967. /**
  135968. * This represents a GPU particle system in Babylon
  135969. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135970. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135971. */
  135972. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135973. /**
  135974. * The layer mask we are rendering the particles through.
  135975. */
  135976. layerMask: number;
  135977. private _capacity;
  135978. private _activeCount;
  135979. private _currentActiveCount;
  135980. private _accumulatedCount;
  135981. private _renderEffect;
  135982. private _updateEffect;
  135983. private _buffer0;
  135984. private _buffer1;
  135985. private _spriteBuffer;
  135986. private _updateVAO;
  135987. private _renderVAO;
  135988. private _targetIndex;
  135989. private _sourceBuffer;
  135990. private _targetBuffer;
  135991. private _engine;
  135992. private _currentRenderId;
  135993. private _started;
  135994. private _stopped;
  135995. private _timeDelta;
  135996. private _randomTexture;
  135997. private _randomTexture2;
  135998. private _attributesStrideSize;
  135999. private _updateEffectOptions;
  136000. private _randomTextureSize;
  136001. private _actualFrame;
  136002. private readonly _rawTextureWidth;
  136003. /**
  136004. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  136005. */
  136006. static get IsSupported(): boolean;
  136007. /**
  136008. * An event triggered when the system is disposed.
  136009. */
  136010. onDisposeObservable: Observable<GPUParticleSystem>;
  136011. /**
  136012. * Gets the maximum number of particles active at the same time.
  136013. * @returns The max number of active particles.
  136014. */
  136015. getCapacity(): number;
  136016. /**
  136017. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  136018. * to override the particles.
  136019. */
  136020. forceDepthWrite: boolean;
  136021. /**
  136022. * Gets or set the number of active particles
  136023. */
  136024. get activeParticleCount(): number;
  136025. set activeParticleCount(value: number);
  136026. private _preWarmDone;
  136027. /**
  136028. * Specifies if the particles are updated in emitter local space or world space.
  136029. * This is always false for GPU particles
  136030. */
  136031. get isLocal(): boolean;
  136032. set isLocal(value: boolean);
  136033. /**
  136034. * Is this system ready to be used/rendered
  136035. * @return true if the system is ready
  136036. */
  136037. isReady(): boolean;
  136038. /**
  136039. * Gets if the system has been started. (Note: this will still be true after stop is called)
  136040. * @returns True if it has been started, otherwise false.
  136041. */
  136042. isStarted(): boolean;
  136043. /**
  136044. * Starts the particle system and begins to emit
  136045. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  136046. */
  136047. start(delay?: number): void;
  136048. /**
  136049. * Stops the particle system.
  136050. */
  136051. stop(): void;
  136052. /**
  136053. * Remove all active particles
  136054. */
  136055. reset(): void;
  136056. /**
  136057. * Returns the string "GPUParticleSystem"
  136058. * @returns a string containing the class name
  136059. */
  136060. getClassName(): string;
  136061. private _colorGradientsTexture;
  136062. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  136063. /**
  136064. * Adds a new color gradient
  136065. * @param gradient defines the gradient to use (between 0 and 1)
  136066. * @param color1 defines the color to affect to the specified gradient
  136067. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  136068. * @returns the current particle system
  136069. */
  136070. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  136071. /**
  136072. * Remove a specific color gradient
  136073. * @param gradient defines the gradient to remove
  136074. * @returns the current particle system
  136075. */
  136076. removeColorGradient(gradient: number): GPUParticleSystem;
  136077. private _angularSpeedGradientsTexture;
  136078. private _sizeGradientsTexture;
  136079. private _velocityGradientsTexture;
  136080. private _limitVelocityGradientsTexture;
  136081. private _dragGradientsTexture;
  136082. private _addFactorGradient;
  136083. /**
  136084. * Adds a new size gradient
  136085. * @param gradient defines the gradient to use (between 0 and 1)
  136086. * @param factor defines the size factor to affect to the specified gradient
  136087. * @returns the current particle system
  136088. */
  136089. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  136090. /**
  136091. * Remove a specific size gradient
  136092. * @param gradient defines the gradient to remove
  136093. * @returns the current particle system
  136094. */
  136095. removeSizeGradient(gradient: number): GPUParticleSystem;
  136096. /**
  136097. * Adds a new angular speed gradient
  136098. * @param gradient defines the gradient to use (between 0 and 1)
  136099. * @param factor defines the angular speed to affect to the specified gradient
  136100. * @returns the current particle system
  136101. */
  136102. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  136103. /**
  136104. * Remove a specific angular speed gradient
  136105. * @param gradient defines the gradient to remove
  136106. * @returns the current particle system
  136107. */
  136108. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  136109. /**
  136110. * Adds a new velocity gradient
  136111. * @param gradient defines the gradient to use (between 0 and 1)
  136112. * @param factor defines the velocity to affect to the specified gradient
  136113. * @returns the current particle system
  136114. */
  136115. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  136116. /**
  136117. * Remove a specific velocity gradient
  136118. * @param gradient defines the gradient to remove
  136119. * @returns the current particle system
  136120. */
  136121. removeVelocityGradient(gradient: number): GPUParticleSystem;
  136122. /**
  136123. * Adds a new limit velocity gradient
  136124. * @param gradient defines the gradient to use (between 0 and 1)
  136125. * @param factor defines the limit velocity value to affect to the specified gradient
  136126. * @returns the current particle system
  136127. */
  136128. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  136129. /**
  136130. * Remove a specific limit velocity gradient
  136131. * @param gradient defines the gradient to remove
  136132. * @returns the current particle system
  136133. */
  136134. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  136135. /**
  136136. * Adds a new drag gradient
  136137. * @param gradient defines the gradient to use (between 0 and 1)
  136138. * @param factor defines the drag value to affect to the specified gradient
  136139. * @returns the current particle system
  136140. */
  136141. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  136142. /**
  136143. * Remove a specific drag gradient
  136144. * @param gradient defines the gradient to remove
  136145. * @returns the current particle system
  136146. */
  136147. removeDragGradient(gradient: number): GPUParticleSystem;
  136148. /**
  136149. * Not supported by GPUParticleSystem
  136150. * @param gradient defines the gradient to use (between 0 and 1)
  136151. * @param factor defines the emit rate value to affect to the specified gradient
  136152. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136153. * @returns the current particle system
  136154. */
  136155. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136156. /**
  136157. * Not supported by GPUParticleSystem
  136158. * @param gradient defines the gradient to remove
  136159. * @returns the current particle system
  136160. */
  136161. removeEmitRateGradient(gradient: number): IParticleSystem;
  136162. /**
  136163. * Not supported by GPUParticleSystem
  136164. * @param gradient defines the gradient to use (between 0 and 1)
  136165. * @param factor defines the start size value to affect to the specified gradient
  136166. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136167. * @returns the current particle system
  136168. */
  136169. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136170. /**
  136171. * Not supported by GPUParticleSystem
  136172. * @param gradient defines the gradient to remove
  136173. * @returns the current particle system
  136174. */
  136175. removeStartSizeGradient(gradient: number): IParticleSystem;
  136176. /**
  136177. * Not supported by GPUParticleSystem
  136178. * @param gradient defines the gradient to use (between 0 and 1)
  136179. * @param min defines the color remap minimal range
  136180. * @param max defines the color remap maximal range
  136181. * @returns the current particle system
  136182. */
  136183. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136184. /**
  136185. * Not supported by GPUParticleSystem
  136186. * @param gradient defines the gradient to remove
  136187. * @returns the current particle system
  136188. */
  136189. removeColorRemapGradient(): IParticleSystem;
  136190. /**
  136191. * Not supported by GPUParticleSystem
  136192. * @param gradient defines the gradient to use (between 0 and 1)
  136193. * @param min defines the alpha remap minimal range
  136194. * @param max defines the alpha remap maximal range
  136195. * @returns the current particle system
  136196. */
  136197. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136198. /**
  136199. * Not supported by GPUParticleSystem
  136200. * @param gradient defines the gradient to remove
  136201. * @returns the current particle system
  136202. */
  136203. removeAlphaRemapGradient(): IParticleSystem;
  136204. /**
  136205. * Not supported by GPUParticleSystem
  136206. * @param gradient defines the gradient to use (between 0 and 1)
  136207. * @param color defines the color to affect to the specified gradient
  136208. * @returns the current particle system
  136209. */
  136210. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  136211. /**
  136212. * Not supported by GPUParticleSystem
  136213. * @param gradient defines the gradient to remove
  136214. * @returns the current particle system
  136215. */
  136216. removeRampGradient(): IParticleSystem;
  136217. /**
  136218. * Not supported by GPUParticleSystem
  136219. * @returns the list of ramp gradients
  136220. */
  136221. getRampGradients(): Nullable<Array<Color3Gradient>>;
  136222. /**
  136223. * Not supported by GPUParticleSystem
  136224. * Gets or sets a boolean indicating that ramp gradients must be used
  136225. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  136226. */
  136227. get useRampGradients(): boolean;
  136228. set useRampGradients(value: boolean);
  136229. /**
  136230. * Not supported by GPUParticleSystem
  136231. * @param gradient defines the gradient to use (between 0 and 1)
  136232. * @param factor defines the life time factor to affect to the specified gradient
  136233. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136234. * @returns the current particle system
  136235. */
  136236. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136237. /**
  136238. * Not supported by GPUParticleSystem
  136239. * @param gradient defines the gradient to remove
  136240. * @returns the current particle system
  136241. */
  136242. removeLifeTimeGradient(gradient: number): IParticleSystem;
  136243. /**
  136244. * Instantiates a GPU particle system.
  136245. * 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.
  136246. * @param name The name of the particle system
  136247. * @param options The options used to create the system
  136248. * @param scene The scene the particle system belongs to
  136249. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  136250. */
  136251. constructor(name: string, options: Partial<{
  136252. capacity: number;
  136253. randomTextureSize: number;
  136254. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  136255. protected _reset(): void;
  136256. private _createUpdateVAO;
  136257. private _createRenderVAO;
  136258. private _initialize;
  136259. /** @hidden */
  136260. _recreateUpdateEffect(): void;
  136261. /** @hidden */
  136262. _recreateRenderEffect(): void;
  136263. /**
  136264. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  136265. * @param preWarm defines if we are in the pre-warmimg phase
  136266. */
  136267. animate(preWarm?: boolean): void;
  136268. private _createFactorGradientTexture;
  136269. private _createSizeGradientTexture;
  136270. private _createAngularSpeedGradientTexture;
  136271. private _createVelocityGradientTexture;
  136272. private _createLimitVelocityGradientTexture;
  136273. private _createDragGradientTexture;
  136274. private _createColorGradientTexture;
  136275. /**
  136276. * Renders the particle system in its current state
  136277. * @param preWarm defines if the system should only update the particles but not render them
  136278. * @returns the current number of particles
  136279. */
  136280. render(preWarm?: boolean): number;
  136281. /**
  136282. * Rebuilds the particle system
  136283. */
  136284. rebuild(): void;
  136285. private _releaseBuffers;
  136286. private _releaseVAOs;
  136287. /**
  136288. * Disposes the particle system and free the associated resources
  136289. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  136290. */
  136291. dispose(disposeTexture?: boolean): void;
  136292. /**
  136293. * Clones the particle system.
  136294. * @param name The name of the cloned object
  136295. * @param newEmitter The new emitter to use
  136296. * @returns the cloned particle system
  136297. */
  136298. clone(name: string, newEmitter: any): GPUParticleSystem;
  136299. /**
  136300. * Serializes the particle system to a JSON object.
  136301. * @returns the JSON object
  136302. */
  136303. serialize(): any;
  136304. /**
  136305. * Parses a JSON object to create a GPU particle system.
  136306. * @param parsedParticleSystem The JSON object to parse
  136307. * @param scene The scene to create the particle system in
  136308. * @param rootUrl The root url to use to load external dependencies like texture
  136309. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  136310. * @returns the parsed GPU particle system
  136311. */
  136312. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  136313. }
  136314. }
  136315. declare module BABYLON {
  136316. /**
  136317. * Represents a set of particle systems working together to create a specific effect
  136318. */
  136319. export class ParticleSystemSet implements IDisposable {
  136320. /**
  136321. * Gets or sets base Assets URL
  136322. */
  136323. static BaseAssetsUrl: string;
  136324. private _emitterCreationOptions;
  136325. private _emitterNode;
  136326. /**
  136327. * Gets the particle system list
  136328. */
  136329. systems: IParticleSystem[];
  136330. /**
  136331. * Gets the emitter node used with this set
  136332. */
  136333. get emitterNode(): Nullable<TransformNode>;
  136334. /**
  136335. * Creates a new emitter mesh as a sphere
  136336. * @param options defines the options used to create the sphere
  136337. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  136338. * @param scene defines the hosting scene
  136339. */
  136340. setEmitterAsSphere(options: {
  136341. diameter: number;
  136342. segments: number;
  136343. color: Color3;
  136344. }, renderingGroupId: number, scene: Scene): void;
  136345. /**
  136346. * Starts all particle systems of the set
  136347. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136348. */
  136349. start(emitter?: AbstractMesh): void;
  136350. /**
  136351. * Release all associated resources
  136352. */
  136353. dispose(): void;
  136354. /**
  136355. * Serialize the set into a JSON compatible object
  136356. * @returns a JSON compatible representation of the set
  136357. */
  136358. serialize(): any;
  136359. /**
  136360. * Parse a new ParticleSystemSet from a serialized source
  136361. * @param data defines a JSON compatible representation of the set
  136362. * @param scene defines the hosting scene
  136363. * @param gpu defines if we want GPU particles or CPU particles
  136364. * @returns a new ParticleSystemSet
  136365. */
  136366. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136367. }
  136368. }
  136369. declare module BABYLON {
  136370. /**
  136371. * This class is made for on one-liner static method to help creating particle system set.
  136372. */
  136373. export class ParticleHelper {
  136374. /**
  136375. * Gets or sets base Assets URL
  136376. */
  136377. static BaseAssetsUrl: string;
  136378. /**
  136379. * Create a default particle system that you can tweak
  136380. * @param emitter defines the emitter to use
  136381. * @param capacity defines the system capacity (default is 500 particles)
  136382. * @param scene defines the hosting scene
  136383. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136384. * @returns the new Particle system
  136385. */
  136386. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136387. /**
  136388. * This is the main static method (one-liner) of this helper to create different particle systems
  136389. * @param type This string represents the type to the particle system to create
  136390. * @param scene The scene where the particle system should live
  136391. * @param gpu If the system will use gpu
  136392. * @returns the ParticleSystemSet created
  136393. */
  136394. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136395. /**
  136396. * Static function used to export a particle system to a ParticleSystemSet variable.
  136397. * Please note that the emitter shape is not exported
  136398. * @param systems defines the particle systems to export
  136399. * @returns the created particle system set
  136400. */
  136401. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136402. }
  136403. }
  136404. declare module BABYLON {
  136405. interface Engine {
  136406. /**
  136407. * Create an effect to use with particle systems.
  136408. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136409. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136410. * @param uniformsNames defines a list of attribute names
  136411. * @param samplers defines an array of string used to represent textures
  136412. * @param defines defines the string containing the defines to use to compile the shaders
  136413. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136414. * @param onCompiled defines a function to call when the effect creation is successful
  136415. * @param onError defines a function to call when the effect creation has failed
  136416. * @returns the new Effect
  136417. */
  136418. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136419. }
  136420. interface Mesh {
  136421. /**
  136422. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136423. * @returns an array of IParticleSystem
  136424. */
  136425. getEmittedParticleSystems(): IParticleSystem[];
  136426. /**
  136427. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136428. * @returns an array of IParticleSystem
  136429. */
  136430. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136431. }
  136432. /**
  136433. * @hidden
  136434. */
  136435. export var _IDoNeedToBeInTheBuild: number;
  136436. }
  136437. declare module BABYLON {
  136438. /** Defines the 4 color options */
  136439. export enum PointColor {
  136440. /** color value */
  136441. Color = 2,
  136442. /** uv value */
  136443. UV = 1,
  136444. /** random value */
  136445. Random = 0,
  136446. /** stated value */
  136447. Stated = 3
  136448. }
  136449. /**
  136450. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136451. * 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.
  136452. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136453. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136454. *
  136455. * Full documentation here : TO BE ENTERED
  136456. */
  136457. export class PointsCloudSystem implements IDisposable {
  136458. /**
  136459. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136460. * Example : var p = SPS.particles[i];
  136461. */
  136462. particles: CloudPoint[];
  136463. /**
  136464. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136465. */
  136466. nbParticles: number;
  136467. /**
  136468. * This a counter for your own usage. It's not set by any SPS functions.
  136469. */
  136470. counter: number;
  136471. /**
  136472. * The PCS name. This name is also given to the underlying mesh.
  136473. */
  136474. name: string;
  136475. /**
  136476. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136477. */
  136478. mesh: Mesh;
  136479. /**
  136480. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136481. * Please read :
  136482. */
  136483. vars: any;
  136484. /**
  136485. * @hidden
  136486. */
  136487. _size: number;
  136488. private _scene;
  136489. private _promises;
  136490. private _positions;
  136491. private _indices;
  136492. private _normals;
  136493. private _colors;
  136494. private _uvs;
  136495. private _indices32;
  136496. private _positions32;
  136497. private _colors32;
  136498. private _uvs32;
  136499. private _updatable;
  136500. private _isVisibilityBoxLocked;
  136501. private _alwaysVisible;
  136502. private _groups;
  136503. private _groupCounter;
  136504. private _computeParticleColor;
  136505. private _computeParticleTexture;
  136506. private _computeParticleRotation;
  136507. private _computeBoundingBox;
  136508. private _isReady;
  136509. /**
  136510. * Creates a PCS (Points Cloud System) object
  136511. * @param name (String) is the PCS name, this will be the underlying mesh name
  136512. * @param pointSize (number) is the size for each point
  136513. * @param scene (Scene) is the scene in which the PCS is added
  136514. * @param options defines the options of the PCS e.g.
  136515. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136516. */
  136517. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136518. updatable?: boolean;
  136519. });
  136520. /**
  136521. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136522. * If no points were added to the PCS, the returned mesh is just a single point.
  136523. * @returns a promise for the created mesh
  136524. */
  136525. buildMeshAsync(): Promise<Mesh>;
  136526. /**
  136527. * @hidden
  136528. */
  136529. private _buildMesh;
  136530. private _addParticle;
  136531. private _randomUnitVector;
  136532. private _getColorIndicesForCoord;
  136533. private _setPointsColorOrUV;
  136534. private _colorFromTexture;
  136535. private _calculateDensity;
  136536. /**
  136537. * Adds points to the PCS in random positions within a unit sphere
  136538. * @param nb (positive integer) the number of particles to be created from this model
  136539. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136540. * @returns the number of groups in the system
  136541. */
  136542. addPoints(nb: number, pointFunction?: any): number;
  136543. /**
  136544. * Adds points to the PCS from the surface of the model shape
  136545. * @param mesh is any Mesh object that will be used as a surface model for the points
  136546. * @param nb (positive integer) the number of particles to be created from this model
  136547. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136548. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136549. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136550. * @returns the number of groups in the system
  136551. */
  136552. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136553. /**
  136554. * Adds points to the PCS inside the model shape
  136555. * @param mesh is any Mesh object that will be used as a surface model for the points
  136556. * @param nb (positive integer) the number of particles to be created from this model
  136557. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136558. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136559. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136560. * @returns the number of groups in the system
  136561. */
  136562. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136563. /**
  136564. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136565. * This method calls `updateParticle()` for each particle of the SPS.
  136566. * For an animated SPS, it is usually called within the render loop.
  136567. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136568. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136569. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136570. * @returns the PCS.
  136571. */
  136572. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136573. /**
  136574. * Disposes the PCS.
  136575. */
  136576. dispose(): void;
  136577. /**
  136578. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136579. * doc :
  136580. * @returns the PCS.
  136581. */
  136582. refreshVisibleSize(): PointsCloudSystem;
  136583. /**
  136584. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136585. * @param size the size (float) of the visibility box
  136586. * note : this doesn't lock the PCS mesh bounding box.
  136587. * doc :
  136588. */
  136589. setVisibilityBox(size: number): void;
  136590. /**
  136591. * Gets whether the PCS is always visible or not
  136592. * doc :
  136593. */
  136594. get isAlwaysVisible(): boolean;
  136595. /**
  136596. * Sets the PCS as always visible or not
  136597. * doc :
  136598. */
  136599. set isAlwaysVisible(val: boolean);
  136600. /**
  136601. * Tells to `setParticles()` to compute the particle rotations or not
  136602. * Default value : false. The PCS is faster when it's set to false
  136603. * Note : particle rotations are only applied to parent particles
  136604. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136605. */
  136606. set computeParticleRotation(val: boolean);
  136607. /**
  136608. * Tells to `setParticles()` to compute the particle colors or not.
  136609. * Default value : true. The PCS is faster when it's set to false.
  136610. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136611. */
  136612. set computeParticleColor(val: boolean);
  136613. set computeParticleTexture(val: boolean);
  136614. /**
  136615. * Gets if `setParticles()` computes the particle colors or not.
  136616. * Default value : false. The PCS is faster when it's set to false.
  136617. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136618. */
  136619. get computeParticleColor(): boolean;
  136620. /**
  136621. * Gets if `setParticles()` computes the particle textures or not.
  136622. * Default value : false. The PCS is faster when it's set to false.
  136623. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136624. */
  136625. get computeParticleTexture(): boolean;
  136626. /**
  136627. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136628. */
  136629. set computeBoundingBox(val: boolean);
  136630. /**
  136631. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136632. */
  136633. get computeBoundingBox(): boolean;
  136634. /**
  136635. * This function does nothing. It may be overwritten to set all the particle first values.
  136636. * The PCS doesn't call this function, you may have to call it by your own.
  136637. * doc :
  136638. */
  136639. initParticles(): void;
  136640. /**
  136641. * This function does nothing. It may be overwritten to recycle a particle
  136642. * The PCS doesn't call this function, you can to call it
  136643. * doc :
  136644. * @param particle The particle to recycle
  136645. * @returns the recycled particle
  136646. */
  136647. recycleParticle(particle: CloudPoint): CloudPoint;
  136648. /**
  136649. * Updates a particle : this function should be overwritten by the user.
  136650. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136651. * doc :
  136652. * @example : just set a particle position or velocity and recycle conditions
  136653. * @param particle The particle to update
  136654. * @returns the updated particle
  136655. */
  136656. updateParticle(particle: CloudPoint): CloudPoint;
  136657. /**
  136658. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136659. * This does nothing and may be overwritten by the user.
  136660. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136661. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136662. * @param update the boolean update value actually passed to setParticles()
  136663. */
  136664. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136665. /**
  136666. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136667. * This will be passed three parameters.
  136668. * This does nothing and may be overwritten by the user.
  136669. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136670. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136671. * @param update the boolean update value actually passed to setParticles()
  136672. */
  136673. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136674. }
  136675. }
  136676. declare module BABYLON {
  136677. /**
  136678. * Represents one particle of a points cloud system.
  136679. */
  136680. export class CloudPoint {
  136681. /**
  136682. * particle global index
  136683. */
  136684. idx: number;
  136685. /**
  136686. * The color of the particle
  136687. */
  136688. color: Nullable<Color4>;
  136689. /**
  136690. * The world space position of the particle.
  136691. */
  136692. position: Vector3;
  136693. /**
  136694. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136695. */
  136696. rotation: Vector3;
  136697. /**
  136698. * The world space rotation quaternion of the particle.
  136699. */
  136700. rotationQuaternion: Nullable<Quaternion>;
  136701. /**
  136702. * The uv of the particle.
  136703. */
  136704. uv: Nullable<Vector2>;
  136705. /**
  136706. * The current speed of the particle.
  136707. */
  136708. velocity: Vector3;
  136709. /**
  136710. * The pivot point in the particle local space.
  136711. */
  136712. pivot: Vector3;
  136713. /**
  136714. * Must the particle be translated from its pivot point in its local space ?
  136715. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136716. * Default : false
  136717. */
  136718. translateFromPivot: boolean;
  136719. /**
  136720. * Index of this particle in the global "positions" array (Internal use)
  136721. * @hidden
  136722. */
  136723. _pos: number;
  136724. /**
  136725. * @hidden Index of this particle in the global "indices" array (Internal use)
  136726. */
  136727. _ind: number;
  136728. /**
  136729. * Group this particle belongs to
  136730. */
  136731. _group: PointsGroup;
  136732. /**
  136733. * Group id of this particle
  136734. */
  136735. groupId: number;
  136736. /**
  136737. * Index of the particle in its group id (Internal use)
  136738. */
  136739. idxInGroup: number;
  136740. /**
  136741. * @hidden Particle BoundingInfo object (Internal use)
  136742. */
  136743. _boundingInfo: BoundingInfo;
  136744. /**
  136745. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136746. */
  136747. _pcs: PointsCloudSystem;
  136748. /**
  136749. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136750. */
  136751. _stillInvisible: boolean;
  136752. /**
  136753. * @hidden Last computed particle rotation matrix
  136754. */
  136755. _rotationMatrix: number[];
  136756. /**
  136757. * Parent particle Id, if any.
  136758. * Default null.
  136759. */
  136760. parentId: Nullable<number>;
  136761. /**
  136762. * @hidden Internal global position in the PCS.
  136763. */
  136764. _globalPosition: Vector3;
  136765. /**
  136766. * Creates a Point Cloud object.
  136767. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136768. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136769. * @param group (PointsGroup) is the group the particle belongs to
  136770. * @param groupId (integer) is the group identifier in the PCS.
  136771. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136772. * @param pcs defines the PCS it is associated to
  136773. */
  136774. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136775. /**
  136776. * get point size
  136777. */
  136778. get size(): Vector3;
  136779. /**
  136780. * Set point size
  136781. */
  136782. set size(scale: Vector3);
  136783. /**
  136784. * Legacy support, changed quaternion to rotationQuaternion
  136785. */
  136786. get quaternion(): Nullable<Quaternion>;
  136787. /**
  136788. * Legacy support, changed quaternion to rotationQuaternion
  136789. */
  136790. set quaternion(q: Nullable<Quaternion>);
  136791. /**
  136792. * Returns a boolean. True if the particle intersects a mesh, else false
  136793. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136794. * @param target is the object (point or mesh) what the intersection is computed against
  136795. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136796. * @returns true if it intersects
  136797. */
  136798. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136799. /**
  136800. * get the rotation matrix of the particle
  136801. * @hidden
  136802. */
  136803. getRotationMatrix(m: Matrix): void;
  136804. }
  136805. /**
  136806. * Represents a group of points in a points cloud system
  136807. * * PCS internal tool, don't use it manually.
  136808. */
  136809. export class PointsGroup {
  136810. /**
  136811. * The group id
  136812. * @hidden
  136813. */
  136814. groupID: number;
  136815. /**
  136816. * image data for group (internal use)
  136817. * @hidden
  136818. */
  136819. _groupImageData: Nullable<ArrayBufferView>;
  136820. /**
  136821. * Image Width (internal use)
  136822. * @hidden
  136823. */
  136824. _groupImgWidth: number;
  136825. /**
  136826. * Image Height (internal use)
  136827. * @hidden
  136828. */
  136829. _groupImgHeight: number;
  136830. /**
  136831. * Custom position function (internal use)
  136832. * @hidden
  136833. */
  136834. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136835. /**
  136836. * density per facet for surface points
  136837. * @hidden
  136838. */
  136839. _groupDensity: number[];
  136840. /**
  136841. * Only when points are colored by texture carries pointer to texture list array
  136842. * @hidden
  136843. */
  136844. _textureNb: number;
  136845. /**
  136846. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136847. * PCS internal tool, don't use it manually.
  136848. * @hidden
  136849. */
  136850. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136851. }
  136852. }
  136853. declare module BABYLON {
  136854. interface Scene {
  136855. /** @hidden (Backing field) */
  136856. _physicsEngine: Nullable<IPhysicsEngine>;
  136857. /** @hidden */
  136858. _physicsTimeAccumulator: number;
  136859. /**
  136860. * Gets the current physics engine
  136861. * @returns a IPhysicsEngine or null if none attached
  136862. */
  136863. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136864. /**
  136865. * Enables physics to the current scene
  136866. * @param gravity defines the scene's gravity for the physics engine
  136867. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136868. * @return a boolean indicating if the physics engine was initialized
  136869. */
  136870. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136871. /**
  136872. * Disables and disposes the physics engine associated with the scene
  136873. */
  136874. disablePhysicsEngine(): void;
  136875. /**
  136876. * Gets a boolean indicating if there is an active physics engine
  136877. * @returns a boolean indicating if there is an active physics engine
  136878. */
  136879. isPhysicsEnabled(): boolean;
  136880. /**
  136881. * Deletes a physics compound impostor
  136882. * @param compound defines the compound to delete
  136883. */
  136884. deleteCompoundImpostor(compound: any): void;
  136885. /**
  136886. * An event triggered when physic simulation is about to be run
  136887. */
  136888. onBeforePhysicsObservable: Observable<Scene>;
  136889. /**
  136890. * An event triggered when physic simulation has been done
  136891. */
  136892. onAfterPhysicsObservable: Observable<Scene>;
  136893. }
  136894. interface AbstractMesh {
  136895. /** @hidden */
  136896. _physicsImpostor: Nullable<PhysicsImpostor>;
  136897. /**
  136898. * Gets or sets impostor used for physic simulation
  136899. * @see http://doc.babylonjs.com/features/physics_engine
  136900. */
  136901. physicsImpostor: Nullable<PhysicsImpostor>;
  136902. /**
  136903. * Gets the current physics impostor
  136904. * @see http://doc.babylonjs.com/features/physics_engine
  136905. * @returns a physics impostor or null
  136906. */
  136907. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136908. /** Apply a physic impulse to the mesh
  136909. * @param force defines the force to apply
  136910. * @param contactPoint defines where to apply the force
  136911. * @returns the current mesh
  136912. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136913. */
  136914. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136915. /**
  136916. * Creates a physic joint between two meshes
  136917. * @param otherMesh defines the other mesh to use
  136918. * @param pivot1 defines the pivot to use on this mesh
  136919. * @param pivot2 defines the pivot to use on the other mesh
  136920. * @param options defines additional options (can be plugin dependent)
  136921. * @returns the current mesh
  136922. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136923. */
  136924. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136925. /** @hidden */
  136926. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136927. }
  136928. /**
  136929. * Defines the physics engine scene component responsible to manage a physics engine
  136930. */
  136931. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136932. /**
  136933. * The component name helpful to identify the component in the list of scene components.
  136934. */
  136935. readonly name: string;
  136936. /**
  136937. * The scene the component belongs to.
  136938. */
  136939. scene: Scene;
  136940. /**
  136941. * Creates a new instance of the component for the given scene
  136942. * @param scene Defines the scene to register the component in
  136943. */
  136944. constructor(scene: Scene);
  136945. /**
  136946. * Registers the component in a given scene
  136947. */
  136948. register(): void;
  136949. /**
  136950. * Rebuilds the elements related to this component in case of
  136951. * context lost for instance.
  136952. */
  136953. rebuild(): void;
  136954. /**
  136955. * Disposes the component and the associated ressources
  136956. */
  136957. dispose(): void;
  136958. }
  136959. }
  136960. declare module BABYLON {
  136961. /**
  136962. * A helper for physics simulations
  136963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136964. */
  136965. export class PhysicsHelper {
  136966. private _scene;
  136967. private _physicsEngine;
  136968. /**
  136969. * Initializes the Physics helper
  136970. * @param scene Babylon.js scene
  136971. */
  136972. constructor(scene: Scene);
  136973. /**
  136974. * Applies a radial explosion impulse
  136975. * @param origin the origin of the explosion
  136976. * @param radiusOrEventOptions the radius or the options of radial explosion
  136977. * @param strength the explosion strength
  136978. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136979. * @returns A physics radial explosion event, or null
  136980. */
  136981. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136982. /**
  136983. * Applies a radial explosion force
  136984. * @param origin the origin of the explosion
  136985. * @param radiusOrEventOptions the radius or the options of radial explosion
  136986. * @param strength the explosion strength
  136987. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136988. * @returns A physics radial explosion event, or null
  136989. */
  136990. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136991. /**
  136992. * Creates a gravitational field
  136993. * @param origin the origin of the explosion
  136994. * @param radiusOrEventOptions the radius or the options of radial explosion
  136995. * @param strength the explosion strength
  136996. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136997. * @returns A physics gravitational field event, or null
  136998. */
  136999. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  137000. /**
  137001. * Creates a physics updraft event
  137002. * @param origin the origin of the updraft
  137003. * @param radiusOrEventOptions the radius or the options of the updraft
  137004. * @param strength the strength of the updraft
  137005. * @param height the height of the updraft
  137006. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  137007. * @returns A physics updraft event, or null
  137008. */
  137009. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  137010. /**
  137011. * Creates a physics vortex event
  137012. * @param origin the of the vortex
  137013. * @param radiusOrEventOptions the radius or the options of the vortex
  137014. * @param strength the strength of the vortex
  137015. * @param height the height of the vortex
  137016. * @returns a Physics vortex event, or null
  137017. * A physics vortex event or null
  137018. */
  137019. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  137020. }
  137021. /**
  137022. * Represents a physics radial explosion event
  137023. */
  137024. class PhysicsRadialExplosionEvent {
  137025. private _scene;
  137026. private _options;
  137027. private _sphere;
  137028. private _dataFetched;
  137029. /**
  137030. * Initializes a radial explosioin event
  137031. * @param _scene BabylonJS scene
  137032. * @param _options The options for the vortex event
  137033. */
  137034. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  137035. /**
  137036. * Returns the data related to the radial explosion event (sphere).
  137037. * @returns The radial explosion event data
  137038. */
  137039. getData(): PhysicsRadialExplosionEventData;
  137040. /**
  137041. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  137042. * @param impostor A physics imposter
  137043. * @param origin the origin of the explosion
  137044. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  137045. */
  137046. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  137047. /**
  137048. * Triggers affecterd impostors callbacks
  137049. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  137050. */
  137051. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  137052. /**
  137053. * Disposes the sphere.
  137054. * @param force Specifies if the sphere should be disposed by force
  137055. */
  137056. dispose(force?: boolean): void;
  137057. /*** Helpers ***/
  137058. private _prepareSphere;
  137059. private _intersectsWithSphere;
  137060. }
  137061. /**
  137062. * Represents a gravitational field event
  137063. */
  137064. class PhysicsGravitationalFieldEvent {
  137065. private _physicsHelper;
  137066. private _scene;
  137067. private _origin;
  137068. private _options;
  137069. private _tickCallback;
  137070. private _sphere;
  137071. private _dataFetched;
  137072. /**
  137073. * Initializes the physics gravitational field event
  137074. * @param _physicsHelper A physics helper
  137075. * @param _scene BabylonJS scene
  137076. * @param _origin The origin position of the gravitational field event
  137077. * @param _options The options for the vortex event
  137078. */
  137079. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  137080. /**
  137081. * Returns the data related to the gravitational field event (sphere).
  137082. * @returns A gravitational field event
  137083. */
  137084. getData(): PhysicsGravitationalFieldEventData;
  137085. /**
  137086. * Enables the gravitational field.
  137087. */
  137088. enable(): void;
  137089. /**
  137090. * Disables the gravitational field.
  137091. */
  137092. disable(): void;
  137093. /**
  137094. * Disposes the sphere.
  137095. * @param force The force to dispose from the gravitational field event
  137096. */
  137097. dispose(force?: boolean): void;
  137098. private _tick;
  137099. }
  137100. /**
  137101. * Represents a physics updraft event
  137102. */
  137103. class PhysicsUpdraftEvent {
  137104. private _scene;
  137105. private _origin;
  137106. private _options;
  137107. private _physicsEngine;
  137108. private _originTop;
  137109. private _originDirection;
  137110. private _tickCallback;
  137111. private _cylinder;
  137112. private _cylinderPosition;
  137113. private _dataFetched;
  137114. /**
  137115. * Initializes the physics updraft event
  137116. * @param _scene BabylonJS scene
  137117. * @param _origin The origin position of the updraft
  137118. * @param _options The options for the updraft event
  137119. */
  137120. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  137121. /**
  137122. * Returns the data related to the updraft event (cylinder).
  137123. * @returns A physics updraft event
  137124. */
  137125. getData(): PhysicsUpdraftEventData;
  137126. /**
  137127. * Enables the updraft.
  137128. */
  137129. enable(): void;
  137130. /**
  137131. * Disables the updraft.
  137132. */
  137133. disable(): void;
  137134. /**
  137135. * Disposes the cylinder.
  137136. * @param force Specifies if the updraft should be disposed by force
  137137. */
  137138. dispose(force?: boolean): void;
  137139. private getImpostorHitData;
  137140. private _tick;
  137141. /*** Helpers ***/
  137142. private _prepareCylinder;
  137143. private _intersectsWithCylinder;
  137144. }
  137145. /**
  137146. * Represents a physics vortex event
  137147. */
  137148. class PhysicsVortexEvent {
  137149. private _scene;
  137150. private _origin;
  137151. private _options;
  137152. private _physicsEngine;
  137153. private _originTop;
  137154. private _tickCallback;
  137155. private _cylinder;
  137156. private _cylinderPosition;
  137157. private _dataFetched;
  137158. /**
  137159. * Initializes the physics vortex event
  137160. * @param _scene The BabylonJS scene
  137161. * @param _origin The origin position of the vortex
  137162. * @param _options The options for the vortex event
  137163. */
  137164. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  137165. /**
  137166. * Returns the data related to the vortex event (cylinder).
  137167. * @returns The physics vortex event data
  137168. */
  137169. getData(): PhysicsVortexEventData;
  137170. /**
  137171. * Enables the vortex.
  137172. */
  137173. enable(): void;
  137174. /**
  137175. * Disables the cortex.
  137176. */
  137177. disable(): void;
  137178. /**
  137179. * Disposes the sphere.
  137180. * @param force
  137181. */
  137182. dispose(force?: boolean): void;
  137183. private getImpostorHitData;
  137184. private _tick;
  137185. /*** Helpers ***/
  137186. private _prepareCylinder;
  137187. private _intersectsWithCylinder;
  137188. }
  137189. /**
  137190. * Options fot the radial explosion event
  137191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137192. */
  137193. export class PhysicsRadialExplosionEventOptions {
  137194. /**
  137195. * The radius of the sphere for the radial explosion.
  137196. */
  137197. radius: number;
  137198. /**
  137199. * The strenth of the explosion.
  137200. */
  137201. strength: number;
  137202. /**
  137203. * The strenght of the force in correspondence to the distance of the affected object
  137204. */
  137205. falloff: PhysicsRadialImpulseFalloff;
  137206. /**
  137207. * Sphere options for the radial explosion.
  137208. */
  137209. sphere: {
  137210. segments: number;
  137211. diameter: number;
  137212. };
  137213. /**
  137214. * Sphere options for the radial explosion.
  137215. */
  137216. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  137217. }
  137218. /**
  137219. * Options fot the updraft event
  137220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137221. */
  137222. export class PhysicsUpdraftEventOptions {
  137223. /**
  137224. * The radius of the cylinder for the vortex
  137225. */
  137226. radius: number;
  137227. /**
  137228. * The strenth of the updraft.
  137229. */
  137230. strength: number;
  137231. /**
  137232. * The height of the cylinder for the updraft.
  137233. */
  137234. height: number;
  137235. /**
  137236. * The mode for the the updraft.
  137237. */
  137238. updraftMode: PhysicsUpdraftMode;
  137239. }
  137240. /**
  137241. * Options fot the vortex event
  137242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137243. */
  137244. export class PhysicsVortexEventOptions {
  137245. /**
  137246. * The radius of the cylinder for the vortex
  137247. */
  137248. radius: number;
  137249. /**
  137250. * The strenth of the vortex.
  137251. */
  137252. strength: number;
  137253. /**
  137254. * The height of the cylinder for the vortex.
  137255. */
  137256. height: number;
  137257. /**
  137258. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  137259. */
  137260. centripetalForceThreshold: number;
  137261. /**
  137262. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  137263. */
  137264. centripetalForceMultiplier: number;
  137265. /**
  137266. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  137267. */
  137268. centrifugalForceMultiplier: number;
  137269. /**
  137270. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  137271. */
  137272. updraftForceMultiplier: number;
  137273. }
  137274. /**
  137275. * The strenght of the force in correspondence to the distance of the affected object
  137276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137277. */
  137278. export enum PhysicsRadialImpulseFalloff {
  137279. /** Defines that impulse is constant in strength across it's whole radius */
  137280. Constant = 0,
  137281. /** Defines that impulse gets weaker if it's further from the origin */
  137282. Linear = 1
  137283. }
  137284. /**
  137285. * The strength of the force in correspondence to the distance of the affected object
  137286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137287. */
  137288. export enum PhysicsUpdraftMode {
  137289. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  137290. Center = 0,
  137291. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  137292. Perpendicular = 1
  137293. }
  137294. /**
  137295. * Interface for a physics hit data
  137296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137297. */
  137298. export interface PhysicsHitData {
  137299. /**
  137300. * The force applied at the contact point
  137301. */
  137302. force: Vector3;
  137303. /**
  137304. * The contact point
  137305. */
  137306. contactPoint: Vector3;
  137307. /**
  137308. * The distance from the origin to the contact point
  137309. */
  137310. distanceFromOrigin: number;
  137311. }
  137312. /**
  137313. * Interface for radial explosion event data
  137314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137315. */
  137316. export interface PhysicsRadialExplosionEventData {
  137317. /**
  137318. * A sphere used for the radial explosion event
  137319. */
  137320. sphere: Mesh;
  137321. }
  137322. /**
  137323. * Interface for gravitational field event data
  137324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137325. */
  137326. export interface PhysicsGravitationalFieldEventData {
  137327. /**
  137328. * A sphere mesh used for the gravitational field event
  137329. */
  137330. sphere: Mesh;
  137331. }
  137332. /**
  137333. * Interface for updraft event data
  137334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137335. */
  137336. export interface PhysicsUpdraftEventData {
  137337. /**
  137338. * A cylinder used for the updraft event
  137339. */
  137340. cylinder: Mesh;
  137341. }
  137342. /**
  137343. * Interface for vortex event data
  137344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137345. */
  137346. export interface PhysicsVortexEventData {
  137347. /**
  137348. * A cylinder used for the vortex event
  137349. */
  137350. cylinder: Mesh;
  137351. }
  137352. /**
  137353. * Interface for an affected physics impostor
  137354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137355. */
  137356. export interface PhysicsAffectedImpostorWithData {
  137357. /**
  137358. * The impostor affected by the effect
  137359. */
  137360. impostor: PhysicsImpostor;
  137361. /**
  137362. * The data about the hit/horce from the explosion
  137363. */
  137364. hitData: PhysicsHitData;
  137365. }
  137366. }
  137367. declare module BABYLON {
  137368. /** @hidden */
  137369. export var blackAndWhitePixelShader: {
  137370. name: string;
  137371. shader: string;
  137372. };
  137373. }
  137374. declare module BABYLON {
  137375. /**
  137376. * Post process used to render in black and white
  137377. */
  137378. export class BlackAndWhitePostProcess extends PostProcess {
  137379. /**
  137380. * Linear about to convert he result to black and white (default: 1)
  137381. */
  137382. degree: number;
  137383. /**
  137384. * Creates a black and white post process
  137385. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137386. * @param name The name of the effect.
  137387. * @param options The required width/height ratio to downsize to before computing the render pass.
  137388. * @param camera The camera to apply the render pass to.
  137389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137390. * @param engine The engine which the post process will be applied. (default: current engine)
  137391. * @param reusable If the post process can be reused on the same frame. (default: false)
  137392. */
  137393. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137394. }
  137395. }
  137396. declare module BABYLON {
  137397. /**
  137398. * This represents a set of one or more post processes in Babylon.
  137399. * A post process can be used to apply a shader to a texture after it is rendered.
  137400. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137401. */
  137402. export class PostProcessRenderEffect {
  137403. private _postProcesses;
  137404. private _getPostProcesses;
  137405. private _singleInstance;
  137406. private _cameras;
  137407. private _indicesForCamera;
  137408. /**
  137409. * Name of the effect
  137410. * @hidden
  137411. */
  137412. _name: string;
  137413. /**
  137414. * Instantiates a post process render effect.
  137415. * A post process can be used to apply a shader to a texture after it is rendered.
  137416. * @param engine The engine the effect is tied to
  137417. * @param name The name of the effect
  137418. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137419. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137420. */
  137421. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137422. /**
  137423. * Checks if all the post processes in the effect are supported.
  137424. */
  137425. get isSupported(): boolean;
  137426. /**
  137427. * Updates the current state of the effect
  137428. * @hidden
  137429. */
  137430. _update(): void;
  137431. /**
  137432. * Attaches the effect on cameras
  137433. * @param cameras The camera to attach to.
  137434. * @hidden
  137435. */
  137436. _attachCameras(cameras: Camera): void;
  137437. /**
  137438. * Attaches the effect on cameras
  137439. * @param cameras The camera to attach to.
  137440. * @hidden
  137441. */
  137442. _attachCameras(cameras: Camera[]): void;
  137443. /**
  137444. * Detaches the effect on cameras
  137445. * @param cameras The camera to detatch from.
  137446. * @hidden
  137447. */
  137448. _detachCameras(cameras: Camera): void;
  137449. /**
  137450. * Detatches the effect on cameras
  137451. * @param cameras The camera to detatch from.
  137452. * @hidden
  137453. */
  137454. _detachCameras(cameras: Camera[]): void;
  137455. /**
  137456. * Enables the effect on given cameras
  137457. * @param cameras The camera to enable.
  137458. * @hidden
  137459. */
  137460. _enable(cameras: Camera): void;
  137461. /**
  137462. * Enables the effect on given cameras
  137463. * @param cameras The camera to enable.
  137464. * @hidden
  137465. */
  137466. _enable(cameras: Nullable<Camera[]>): void;
  137467. /**
  137468. * Disables the effect on the given cameras
  137469. * @param cameras The camera to disable.
  137470. * @hidden
  137471. */
  137472. _disable(cameras: Camera): void;
  137473. /**
  137474. * Disables the effect on the given cameras
  137475. * @param cameras The camera to disable.
  137476. * @hidden
  137477. */
  137478. _disable(cameras: Nullable<Camera[]>): void;
  137479. /**
  137480. * Gets a list of the post processes contained in the effect.
  137481. * @param camera The camera to get the post processes on.
  137482. * @returns The list of the post processes in the effect.
  137483. */
  137484. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137485. }
  137486. }
  137487. declare module BABYLON {
  137488. /** @hidden */
  137489. export var extractHighlightsPixelShader: {
  137490. name: string;
  137491. shader: string;
  137492. };
  137493. }
  137494. declare module BABYLON {
  137495. /**
  137496. * 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.
  137497. */
  137498. export class ExtractHighlightsPostProcess extends PostProcess {
  137499. /**
  137500. * The luminance threshold, pixels below this value will be set to black.
  137501. */
  137502. threshold: number;
  137503. /** @hidden */
  137504. _exposure: number;
  137505. /**
  137506. * Post process which has the input texture to be used when performing highlight extraction
  137507. * @hidden
  137508. */
  137509. _inputPostProcess: Nullable<PostProcess>;
  137510. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137511. }
  137512. }
  137513. declare module BABYLON {
  137514. /** @hidden */
  137515. export var bloomMergePixelShader: {
  137516. name: string;
  137517. shader: string;
  137518. };
  137519. }
  137520. declare module BABYLON {
  137521. /**
  137522. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137523. */
  137524. export class BloomMergePostProcess extends PostProcess {
  137525. /** Weight of the bloom to be added to the original input. */
  137526. weight: number;
  137527. /**
  137528. * Creates a new instance of @see BloomMergePostProcess
  137529. * @param name The name of the effect.
  137530. * @param originalFromInput Post process which's input will be used for the merge.
  137531. * @param blurred Blurred highlights post process which's output will be used.
  137532. * @param weight Weight of the bloom to be added to the original input.
  137533. * @param options The required width/height ratio to downsize to before computing the render pass.
  137534. * @param camera The camera to apply the render pass to.
  137535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137536. * @param engine The engine which the post process will be applied. (default: current engine)
  137537. * @param reusable If the post process can be reused on the same frame. (default: false)
  137538. * @param textureType Type of textures used when performing the post process. (default: 0)
  137539. * @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)
  137540. */
  137541. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137542. /** Weight of the bloom to be added to the original input. */
  137543. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137544. }
  137545. }
  137546. declare module BABYLON {
  137547. /**
  137548. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137549. */
  137550. export class BloomEffect extends PostProcessRenderEffect {
  137551. private bloomScale;
  137552. /**
  137553. * @hidden Internal
  137554. */
  137555. _effects: Array<PostProcess>;
  137556. /**
  137557. * @hidden Internal
  137558. */
  137559. _downscale: ExtractHighlightsPostProcess;
  137560. private _blurX;
  137561. private _blurY;
  137562. private _merge;
  137563. /**
  137564. * The luminance threshold to find bright areas of the image to bloom.
  137565. */
  137566. get threshold(): number;
  137567. set threshold(value: number);
  137568. /**
  137569. * The strength of the bloom.
  137570. */
  137571. get weight(): number;
  137572. set weight(value: number);
  137573. /**
  137574. * Specifies the size of the bloom blur kernel, relative to the final output size
  137575. */
  137576. get kernel(): number;
  137577. set kernel(value: number);
  137578. /**
  137579. * Creates a new instance of @see BloomEffect
  137580. * @param scene The scene the effect belongs to.
  137581. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137582. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137583. * @param bloomWeight The the strength of bloom.
  137584. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137585. * @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)
  137586. */
  137587. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137588. /**
  137589. * Disposes each of the internal effects for a given camera.
  137590. * @param camera The camera to dispose the effect on.
  137591. */
  137592. disposeEffects(camera: Camera): void;
  137593. /**
  137594. * @hidden Internal
  137595. */
  137596. _updateEffects(): void;
  137597. /**
  137598. * Internal
  137599. * @returns if all the contained post processes are ready.
  137600. * @hidden
  137601. */
  137602. _isReady(): boolean;
  137603. }
  137604. }
  137605. declare module BABYLON {
  137606. /** @hidden */
  137607. export var chromaticAberrationPixelShader: {
  137608. name: string;
  137609. shader: string;
  137610. };
  137611. }
  137612. declare module BABYLON {
  137613. /**
  137614. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137615. */
  137616. export class ChromaticAberrationPostProcess extends PostProcess {
  137617. /**
  137618. * The amount of seperation of rgb channels (default: 30)
  137619. */
  137620. aberrationAmount: number;
  137621. /**
  137622. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137623. */
  137624. radialIntensity: number;
  137625. /**
  137626. * 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))
  137627. */
  137628. direction: Vector2;
  137629. /**
  137630. * 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))
  137631. */
  137632. centerPosition: Vector2;
  137633. /**
  137634. * Creates a new instance ChromaticAberrationPostProcess
  137635. * @param name The name of the effect.
  137636. * @param screenWidth The width of the screen to apply the effect on.
  137637. * @param screenHeight The height of the screen to apply the effect on.
  137638. * @param options The required width/height ratio to downsize to before computing the render pass.
  137639. * @param camera The camera to apply the render pass to.
  137640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137641. * @param engine The engine which the post process will be applied. (default: current engine)
  137642. * @param reusable If the post process can be reused on the same frame. (default: false)
  137643. * @param textureType Type of textures used when performing the post process. (default: 0)
  137644. * @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)
  137645. */
  137646. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137647. }
  137648. }
  137649. declare module BABYLON {
  137650. /** @hidden */
  137651. export var circleOfConfusionPixelShader: {
  137652. name: string;
  137653. shader: string;
  137654. };
  137655. }
  137656. declare module BABYLON {
  137657. /**
  137658. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137659. */
  137660. export class CircleOfConfusionPostProcess extends PostProcess {
  137661. /**
  137662. * 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.
  137663. */
  137664. lensSize: number;
  137665. /**
  137666. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137667. */
  137668. fStop: number;
  137669. /**
  137670. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137671. */
  137672. focusDistance: number;
  137673. /**
  137674. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137675. */
  137676. focalLength: number;
  137677. private _depthTexture;
  137678. /**
  137679. * Creates a new instance CircleOfConfusionPostProcess
  137680. * @param name The name of the effect.
  137681. * @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.
  137682. * @param options The required width/height ratio to downsize to before computing the render pass.
  137683. * @param camera The camera to apply the render pass to.
  137684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137685. * @param engine The engine which the post process will be applied. (default: current engine)
  137686. * @param reusable If the post process can be reused on the same frame. (default: false)
  137687. * @param textureType Type of textures used when performing the post process. (default: 0)
  137688. * @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)
  137689. */
  137690. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137691. /**
  137692. * 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.
  137693. */
  137694. set depthTexture(value: RenderTargetTexture);
  137695. }
  137696. }
  137697. declare module BABYLON {
  137698. /** @hidden */
  137699. export var colorCorrectionPixelShader: {
  137700. name: string;
  137701. shader: string;
  137702. };
  137703. }
  137704. declare module BABYLON {
  137705. /**
  137706. *
  137707. * This post-process allows the modification of rendered colors by using
  137708. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137709. *
  137710. * The object needs to be provided an url to a texture containing the color
  137711. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137712. * Use an image editing software to tweak the LUT to match your needs.
  137713. *
  137714. * For an example of a color LUT, see here:
  137715. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137716. * For explanations on color grading, see here:
  137717. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137718. *
  137719. */
  137720. export class ColorCorrectionPostProcess extends PostProcess {
  137721. private _colorTableTexture;
  137722. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137723. }
  137724. }
  137725. declare module BABYLON {
  137726. /** @hidden */
  137727. export var convolutionPixelShader: {
  137728. name: string;
  137729. shader: string;
  137730. };
  137731. }
  137732. declare module BABYLON {
  137733. /**
  137734. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137735. * input texture to perform effects such as edge detection or sharpening
  137736. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137737. */
  137738. export class ConvolutionPostProcess extends PostProcess {
  137739. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137740. kernel: number[];
  137741. /**
  137742. * Creates a new instance ConvolutionPostProcess
  137743. * @param name The name of the effect.
  137744. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137745. * @param options The required width/height ratio to downsize to before computing the render pass.
  137746. * @param camera The camera to apply the render pass to.
  137747. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137748. * @param engine The engine which the post process will be applied. (default: current engine)
  137749. * @param reusable If the post process can be reused on the same frame. (default: false)
  137750. * @param textureType Type of textures used when performing the post process. (default: 0)
  137751. */
  137752. constructor(name: string,
  137753. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137754. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137755. /**
  137756. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137757. */
  137758. static EdgeDetect0Kernel: number[];
  137759. /**
  137760. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137761. */
  137762. static EdgeDetect1Kernel: number[];
  137763. /**
  137764. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137765. */
  137766. static EdgeDetect2Kernel: number[];
  137767. /**
  137768. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137769. */
  137770. static SharpenKernel: number[];
  137771. /**
  137772. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137773. */
  137774. static EmbossKernel: number[];
  137775. /**
  137776. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137777. */
  137778. static GaussianKernel: number[];
  137779. }
  137780. }
  137781. declare module BABYLON {
  137782. /**
  137783. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137784. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137785. * based on samples that have a large difference in distance than the center pixel.
  137786. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137787. */
  137788. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137789. direction: Vector2;
  137790. /**
  137791. * Creates a new instance CircleOfConfusionPostProcess
  137792. * @param name The name of the effect.
  137793. * @param scene The scene the effect belongs to.
  137794. * @param direction The direction the blur should be applied.
  137795. * @param kernel The size of the kernel used to blur.
  137796. * @param options The required width/height ratio to downsize to before computing the render pass.
  137797. * @param camera The camera to apply the render pass to.
  137798. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137799. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137801. * @param engine The engine which the post process will be applied. (default: current engine)
  137802. * @param reusable If the post process can be reused on the same frame. (default: false)
  137803. * @param textureType Type of textures used when performing the post process. (default: 0)
  137804. * @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)
  137805. */
  137806. 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);
  137807. }
  137808. }
  137809. declare module BABYLON {
  137810. /** @hidden */
  137811. export var depthOfFieldMergePixelShader: {
  137812. name: string;
  137813. shader: string;
  137814. };
  137815. }
  137816. declare module BABYLON {
  137817. /**
  137818. * Options to be set when merging outputs from the default pipeline.
  137819. */
  137820. export class DepthOfFieldMergePostProcessOptions {
  137821. /**
  137822. * The original image to merge on top of
  137823. */
  137824. originalFromInput: PostProcess;
  137825. /**
  137826. * Parameters to perform the merge of the depth of field effect
  137827. */
  137828. depthOfField?: {
  137829. circleOfConfusion: PostProcess;
  137830. blurSteps: Array<PostProcess>;
  137831. };
  137832. /**
  137833. * Parameters to perform the merge of bloom effect
  137834. */
  137835. bloom?: {
  137836. blurred: PostProcess;
  137837. weight: number;
  137838. };
  137839. }
  137840. /**
  137841. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137842. */
  137843. export class DepthOfFieldMergePostProcess extends PostProcess {
  137844. private blurSteps;
  137845. /**
  137846. * Creates a new instance of DepthOfFieldMergePostProcess
  137847. * @param name The name of the effect.
  137848. * @param originalFromInput Post process which's input will be used for the merge.
  137849. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137850. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137851. * @param options The required width/height ratio to downsize to before computing the render pass.
  137852. * @param camera The camera to apply the render pass to.
  137853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137854. * @param engine The engine which the post process will be applied. (default: current engine)
  137855. * @param reusable If the post process can be reused on the same frame. (default: false)
  137856. * @param textureType Type of textures used when performing the post process. (default: 0)
  137857. * @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)
  137858. */
  137859. 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);
  137860. /**
  137861. * Updates the effect with the current post process compile time values and recompiles the shader.
  137862. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137863. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137864. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137865. * @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
  137866. * @param onCompiled Called when the shader has been compiled.
  137867. * @param onError Called if there is an error when compiling a shader.
  137868. */
  137869. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137870. }
  137871. }
  137872. declare module BABYLON {
  137873. /**
  137874. * Specifies the level of max blur that should be applied when using the depth of field effect
  137875. */
  137876. export enum DepthOfFieldEffectBlurLevel {
  137877. /**
  137878. * Subtle blur
  137879. */
  137880. Low = 0,
  137881. /**
  137882. * Medium blur
  137883. */
  137884. Medium = 1,
  137885. /**
  137886. * Large blur
  137887. */
  137888. High = 2
  137889. }
  137890. /**
  137891. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137892. */
  137893. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137894. private _circleOfConfusion;
  137895. /**
  137896. * @hidden Internal, blurs from high to low
  137897. */
  137898. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137899. private _depthOfFieldBlurY;
  137900. private _dofMerge;
  137901. /**
  137902. * @hidden Internal post processes in depth of field effect
  137903. */
  137904. _effects: Array<PostProcess>;
  137905. /**
  137906. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137907. */
  137908. set focalLength(value: number);
  137909. get focalLength(): number;
  137910. /**
  137911. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137912. */
  137913. set fStop(value: number);
  137914. get fStop(): number;
  137915. /**
  137916. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137917. */
  137918. set focusDistance(value: number);
  137919. get focusDistance(): number;
  137920. /**
  137921. * 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.
  137922. */
  137923. set lensSize(value: number);
  137924. get lensSize(): number;
  137925. /**
  137926. * Creates a new instance DepthOfFieldEffect
  137927. * @param scene The scene the effect belongs to.
  137928. * @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.
  137929. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137930. * @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)
  137931. */
  137932. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137933. /**
  137934. * Get the current class name of the current effet
  137935. * @returns "DepthOfFieldEffect"
  137936. */
  137937. getClassName(): string;
  137938. /**
  137939. * 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.
  137940. */
  137941. set depthTexture(value: RenderTargetTexture);
  137942. /**
  137943. * Disposes each of the internal effects for a given camera.
  137944. * @param camera The camera to dispose the effect on.
  137945. */
  137946. disposeEffects(camera: Camera): void;
  137947. /**
  137948. * @hidden Internal
  137949. */
  137950. _updateEffects(): void;
  137951. /**
  137952. * Internal
  137953. * @returns if all the contained post processes are ready.
  137954. * @hidden
  137955. */
  137956. _isReady(): boolean;
  137957. }
  137958. }
  137959. declare module BABYLON {
  137960. /** @hidden */
  137961. export var displayPassPixelShader: {
  137962. name: string;
  137963. shader: string;
  137964. };
  137965. }
  137966. declare module BABYLON {
  137967. /**
  137968. * DisplayPassPostProcess which produces an output the same as it's input
  137969. */
  137970. export class DisplayPassPostProcess extends PostProcess {
  137971. /**
  137972. * Creates the DisplayPassPostProcess
  137973. * @param name The name of the effect.
  137974. * @param options The required width/height ratio to downsize to before computing the render pass.
  137975. * @param camera The camera to apply the render pass to.
  137976. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137977. * @param engine The engine which the post process will be applied. (default: current engine)
  137978. * @param reusable If the post process can be reused on the same frame. (default: false)
  137979. */
  137980. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137981. }
  137982. }
  137983. declare module BABYLON {
  137984. /** @hidden */
  137985. export var filterPixelShader: {
  137986. name: string;
  137987. shader: string;
  137988. };
  137989. }
  137990. declare module BABYLON {
  137991. /**
  137992. * Applies a kernel filter to the image
  137993. */
  137994. export class FilterPostProcess extends PostProcess {
  137995. /** The matrix to be applied to the image */
  137996. kernelMatrix: Matrix;
  137997. /**
  137998. *
  137999. * @param name The name of the effect.
  138000. * @param kernelMatrix The matrix to be applied to the image
  138001. * @param options The required width/height ratio to downsize to before computing the render pass.
  138002. * @param camera The camera to apply the render pass to.
  138003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138004. * @param engine The engine which the post process will be applied. (default: current engine)
  138005. * @param reusable If the post process can be reused on the same frame. (default: false)
  138006. */
  138007. constructor(name: string,
  138008. /** The matrix to be applied to the image */
  138009. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138010. }
  138011. }
  138012. declare module BABYLON {
  138013. /** @hidden */
  138014. export var fxaaPixelShader: {
  138015. name: string;
  138016. shader: string;
  138017. };
  138018. }
  138019. declare module BABYLON {
  138020. /** @hidden */
  138021. export var fxaaVertexShader: {
  138022. name: string;
  138023. shader: string;
  138024. };
  138025. }
  138026. declare module BABYLON {
  138027. /**
  138028. * Fxaa post process
  138029. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  138030. */
  138031. export class FxaaPostProcess extends PostProcess {
  138032. /** @hidden */
  138033. texelWidth: number;
  138034. /** @hidden */
  138035. texelHeight: number;
  138036. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  138037. private _getDefines;
  138038. }
  138039. }
  138040. declare module BABYLON {
  138041. /** @hidden */
  138042. export var grainPixelShader: {
  138043. name: string;
  138044. shader: string;
  138045. };
  138046. }
  138047. declare module BABYLON {
  138048. /**
  138049. * The GrainPostProcess adds noise to the image at mid luminance levels
  138050. */
  138051. export class GrainPostProcess extends PostProcess {
  138052. /**
  138053. * The intensity of the grain added (default: 30)
  138054. */
  138055. intensity: number;
  138056. /**
  138057. * If the grain should be randomized on every frame
  138058. */
  138059. animated: boolean;
  138060. /**
  138061. * Creates a new instance of @see GrainPostProcess
  138062. * @param name The name of the effect.
  138063. * @param options The required width/height ratio to downsize to before computing the render pass.
  138064. * @param camera The camera to apply the render pass to.
  138065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138066. * @param engine The engine which the post process will be applied. (default: current engine)
  138067. * @param reusable If the post process can be reused on the same frame. (default: false)
  138068. * @param textureType Type of textures used when performing the post process. (default: 0)
  138069. * @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)
  138070. */
  138071. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138072. }
  138073. }
  138074. declare module BABYLON {
  138075. /** @hidden */
  138076. export var highlightsPixelShader: {
  138077. name: string;
  138078. shader: string;
  138079. };
  138080. }
  138081. declare module BABYLON {
  138082. /**
  138083. * Extracts highlights from the image
  138084. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  138085. */
  138086. export class HighlightsPostProcess extends PostProcess {
  138087. /**
  138088. * Extracts highlights from the image
  138089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  138090. * @param name The name of the effect.
  138091. * @param options The required width/height ratio to downsize to before computing the render pass.
  138092. * @param camera The camera to apply the render pass to.
  138093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138094. * @param engine The engine which the post process will be applied. (default: current engine)
  138095. * @param reusable If the post process can be reused on the same frame. (default: false)
  138096. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  138097. */
  138098. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  138099. }
  138100. }
  138101. declare module BABYLON {
  138102. /** @hidden */
  138103. export var mrtFragmentDeclaration: {
  138104. name: string;
  138105. shader: string;
  138106. };
  138107. }
  138108. declare module BABYLON {
  138109. /** @hidden */
  138110. export var geometryPixelShader: {
  138111. name: string;
  138112. shader: string;
  138113. };
  138114. }
  138115. declare module BABYLON {
  138116. /** @hidden */
  138117. export var geometryVertexShader: {
  138118. name: string;
  138119. shader: string;
  138120. };
  138121. }
  138122. declare module BABYLON {
  138123. /** @hidden */
  138124. interface ISavedTransformationMatrix {
  138125. world: Matrix;
  138126. viewProjection: Matrix;
  138127. }
  138128. /**
  138129. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  138130. */
  138131. export class GeometryBufferRenderer {
  138132. /**
  138133. * Constant used to retrieve the position texture index in the G-Buffer textures array
  138134. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  138135. */
  138136. static readonly POSITION_TEXTURE_TYPE: number;
  138137. /**
  138138. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  138139. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  138140. */
  138141. static readonly VELOCITY_TEXTURE_TYPE: number;
  138142. /**
  138143. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  138144. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  138145. */
  138146. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  138147. /**
  138148. * Dictionary used to store the previous transformation matrices of each rendered mesh
  138149. * in order to compute objects velocities when enableVelocity is set to "true"
  138150. * @hidden
  138151. */
  138152. _previousTransformationMatrices: {
  138153. [index: number]: ISavedTransformationMatrix;
  138154. };
  138155. /**
  138156. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  138157. * in order to compute objects velocities when enableVelocity is set to "true"
  138158. * @hidden
  138159. */
  138160. _previousBonesTransformationMatrices: {
  138161. [index: number]: Float32Array;
  138162. };
  138163. /**
  138164. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  138165. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  138166. */
  138167. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  138168. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  138169. renderTransparentMeshes: boolean;
  138170. private _scene;
  138171. private _multiRenderTarget;
  138172. private _ratio;
  138173. private _enablePosition;
  138174. private _enableVelocity;
  138175. private _enableReflectivity;
  138176. private _positionIndex;
  138177. private _velocityIndex;
  138178. private _reflectivityIndex;
  138179. protected _effect: Effect;
  138180. protected _cachedDefines: string;
  138181. /**
  138182. * Set the render list (meshes to be rendered) used in the G buffer.
  138183. */
  138184. set renderList(meshes: Mesh[]);
  138185. /**
  138186. * Gets wether or not G buffer are supported by the running hardware.
  138187. * This requires draw buffer supports
  138188. */
  138189. get isSupported(): boolean;
  138190. /**
  138191. * Returns the index of the given texture type in the G-Buffer textures array
  138192. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  138193. * @returns the index of the given texture type in the G-Buffer textures array
  138194. */
  138195. getTextureIndex(textureType: number): number;
  138196. /**
  138197. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  138198. */
  138199. get enablePosition(): boolean;
  138200. /**
  138201. * Sets whether or not objects positions are enabled for the G buffer.
  138202. */
  138203. set enablePosition(enable: boolean);
  138204. /**
  138205. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  138206. */
  138207. get enableVelocity(): boolean;
  138208. /**
  138209. * Sets wether or not objects velocities are enabled for the G buffer.
  138210. */
  138211. set enableVelocity(enable: boolean);
  138212. /**
  138213. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  138214. */
  138215. get enableReflectivity(): boolean;
  138216. /**
  138217. * Sets wether or not objects roughness are enabled for the G buffer.
  138218. */
  138219. set enableReflectivity(enable: boolean);
  138220. /**
  138221. * Gets the scene associated with the buffer.
  138222. */
  138223. get scene(): Scene;
  138224. /**
  138225. * Gets the ratio used by the buffer during its creation.
  138226. * How big is the buffer related to the main canvas.
  138227. */
  138228. get ratio(): number;
  138229. /** @hidden */
  138230. static _SceneComponentInitialization: (scene: Scene) => void;
  138231. /**
  138232. * Creates a new G Buffer for the scene
  138233. * @param scene The scene the buffer belongs to
  138234. * @param ratio How big is the buffer related to the main canvas.
  138235. */
  138236. constructor(scene: Scene, ratio?: number);
  138237. /**
  138238. * Checks wether everything is ready to render a submesh to the G buffer.
  138239. * @param subMesh the submesh to check readiness for
  138240. * @param useInstances is the mesh drawn using instance or not
  138241. * @returns true if ready otherwise false
  138242. */
  138243. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138244. /**
  138245. * Gets the current underlying G Buffer.
  138246. * @returns the buffer
  138247. */
  138248. getGBuffer(): MultiRenderTarget;
  138249. /**
  138250. * Gets the number of samples used to render the buffer (anti aliasing).
  138251. */
  138252. get samples(): number;
  138253. /**
  138254. * Sets the number of samples used to render the buffer (anti aliasing).
  138255. */
  138256. set samples(value: number);
  138257. /**
  138258. * Disposes the renderer and frees up associated resources.
  138259. */
  138260. dispose(): void;
  138261. protected _createRenderTargets(): void;
  138262. private _copyBonesTransformationMatrices;
  138263. }
  138264. }
  138265. declare module BABYLON {
  138266. interface Scene {
  138267. /** @hidden (Backing field) */
  138268. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138269. /**
  138270. * Gets or Sets the current geometry buffer associated to the scene.
  138271. */
  138272. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138273. /**
  138274. * Enables a GeometryBufferRender and associates it with the scene
  138275. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  138276. * @returns the GeometryBufferRenderer
  138277. */
  138278. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  138279. /**
  138280. * Disables the GeometryBufferRender associated with the scene
  138281. */
  138282. disableGeometryBufferRenderer(): void;
  138283. }
  138284. /**
  138285. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  138286. * in several rendering techniques.
  138287. */
  138288. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  138289. /**
  138290. * The component name helpful to identify the component in the list of scene components.
  138291. */
  138292. readonly name: string;
  138293. /**
  138294. * The scene the component belongs to.
  138295. */
  138296. scene: Scene;
  138297. /**
  138298. * Creates a new instance of the component for the given scene
  138299. * @param scene Defines the scene to register the component in
  138300. */
  138301. constructor(scene: Scene);
  138302. /**
  138303. * Registers the component in a given scene
  138304. */
  138305. register(): void;
  138306. /**
  138307. * Rebuilds the elements related to this component in case of
  138308. * context lost for instance.
  138309. */
  138310. rebuild(): void;
  138311. /**
  138312. * Disposes the component and the associated ressources
  138313. */
  138314. dispose(): void;
  138315. private _gatherRenderTargets;
  138316. }
  138317. }
  138318. declare module BABYLON {
  138319. /** @hidden */
  138320. export var motionBlurPixelShader: {
  138321. name: string;
  138322. shader: string;
  138323. };
  138324. }
  138325. declare module BABYLON {
  138326. /**
  138327. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  138328. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  138329. * As an example, all you have to do is to create the post-process:
  138330. * var mb = new BABYLON.MotionBlurPostProcess(
  138331. * 'mb', // The name of the effect.
  138332. * scene, // The scene containing the objects to blur according to their velocity.
  138333. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  138334. * camera // The camera to apply the render pass to.
  138335. * );
  138336. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  138337. */
  138338. export class MotionBlurPostProcess extends PostProcess {
  138339. /**
  138340. * Defines how much the image is blurred by the movement. Default value is equal to 1
  138341. */
  138342. motionStrength: number;
  138343. /**
  138344. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138345. */
  138346. get motionBlurSamples(): number;
  138347. /**
  138348. * Sets the number of iterations to be used for motion blur quality
  138349. */
  138350. set motionBlurSamples(samples: number);
  138351. private _motionBlurSamples;
  138352. private _geometryBufferRenderer;
  138353. /**
  138354. * Creates a new instance MotionBlurPostProcess
  138355. * @param name The name of the effect.
  138356. * @param scene The scene containing the objects to blur according to their velocity.
  138357. * @param options The required width/height ratio to downsize to before computing the render pass.
  138358. * @param camera The camera to apply the render pass to.
  138359. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138360. * @param engine The engine which the post process will be applied. (default: current engine)
  138361. * @param reusable If the post process can be reused on the same frame. (default: false)
  138362. * @param textureType Type of textures used when performing the post process. (default: 0)
  138363. * @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)
  138364. */
  138365. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138366. /**
  138367. * Excludes the given skinned mesh from computing bones velocities.
  138368. * 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.
  138369. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138370. */
  138371. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138372. /**
  138373. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138374. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138375. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138376. */
  138377. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138378. /**
  138379. * Disposes the post process.
  138380. * @param camera The camera to dispose the post process on.
  138381. */
  138382. dispose(camera?: Camera): void;
  138383. }
  138384. }
  138385. declare module BABYLON {
  138386. /** @hidden */
  138387. export var refractionPixelShader: {
  138388. name: string;
  138389. shader: string;
  138390. };
  138391. }
  138392. declare module BABYLON {
  138393. /**
  138394. * Post process which applies a refractin texture
  138395. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138396. */
  138397. export class RefractionPostProcess extends PostProcess {
  138398. /** the base color of the refraction (used to taint the rendering) */
  138399. color: Color3;
  138400. /** simulated refraction depth */
  138401. depth: number;
  138402. /** the coefficient of the base color (0 to remove base color tainting) */
  138403. colorLevel: number;
  138404. private _refTexture;
  138405. private _ownRefractionTexture;
  138406. /**
  138407. * Gets or sets the refraction texture
  138408. * Please note that you are responsible for disposing the texture if you set it manually
  138409. */
  138410. get refractionTexture(): Texture;
  138411. set refractionTexture(value: Texture);
  138412. /**
  138413. * Initializes the RefractionPostProcess
  138414. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138415. * @param name The name of the effect.
  138416. * @param refractionTextureUrl Url of the refraction texture to use
  138417. * @param color the base color of the refraction (used to taint the rendering)
  138418. * @param depth simulated refraction depth
  138419. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138420. * @param camera The camera to apply the render pass to.
  138421. * @param options The required width/height ratio to downsize to before computing the render pass.
  138422. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138423. * @param engine The engine which the post process will be applied. (default: current engine)
  138424. * @param reusable If the post process can be reused on the same frame. (default: false)
  138425. */
  138426. constructor(name: string, refractionTextureUrl: string,
  138427. /** the base color of the refraction (used to taint the rendering) */
  138428. color: Color3,
  138429. /** simulated refraction depth */
  138430. depth: number,
  138431. /** the coefficient of the base color (0 to remove base color tainting) */
  138432. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138433. /**
  138434. * Disposes of the post process
  138435. * @param camera Camera to dispose post process on
  138436. */
  138437. dispose(camera: Camera): void;
  138438. }
  138439. }
  138440. declare module BABYLON {
  138441. /** @hidden */
  138442. export var sharpenPixelShader: {
  138443. name: string;
  138444. shader: string;
  138445. };
  138446. }
  138447. declare module BABYLON {
  138448. /**
  138449. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138450. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138451. */
  138452. export class SharpenPostProcess extends PostProcess {
  138453. /**
  138454. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138455. */
  138456. colorAmount: number;
  138457. /**
  138458. * How much sharpness should be applied (default: 0.3)
  138459. */
  138460. edgeAmount: number;
  138461. /**
  138462. * Creates a new instance ConvolutionPostProcess
  138463. * @param name The name of the effect.
  138464. * @param options The required width/height ratio to downsize to before computing the render pass.
  138465. * @param camera The camera to apply the render pass to.
  138466. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138467. * @param engine The engine which the post process will be applied. (default: current engine)
  138468. * @param reusable If the post process can be reused on the same frame. (default: false)
  138469. * @param textureType Type of textures used when performing the post process. (default: 0)
  138470. * @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)
  138471. */
  138472. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138473. }
  138474. }
  138475. declare module BABYLON {
  138476. /**
  138477. * PostProcessRenderPipeline
  138478. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138479. */
  138480. export class PostProcessRenderPipeline {
  138481. private engine;
  138482. private _renderEffects;
  138483. private _renderEffectsForIsolatedPass;
  138484. /**
  138485. * List of inspectable custom properties (used by the Inspector)
  138486. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138487. */
  138488. inspectableCustomProperties: IInspectable[];
  138489. /**
  138490. * @hidden
  138491. */
  138492. protected _cameras: Camera[];
  138493. /** @hidden */
  138494. _name: string;
  138495. /**
  138496. * Gets pipeline name
  138497. */
  138498. get name(): string;
  138499. /** Gets the list of attached cameras */
  138500. get cameras(): Camera[];
  138501. /**
  138502. * Initializes a PostProcessRenderPipeline
  138503. * @param engine engine to add the pipeline to
  138504. * @param name name of the pipeline
  138505. */
  138506. constructor(engine: Engine, name: string);
  138507. /**
  138508. * Gets the class name
  138509. * @returns "PostProcessRenderPipeline"
  138510. */
  138511. getClassName(): string;
  138512. /**
  138513. * If all the render effects in the pipeline are supported
  138514. */
  138515. get isSupported(): boolean;
  138516. /**
  138517. * Adds an effect to the pipeline
  138518. * @param renderEffect the effect to add
  138519. */
  138520. addEffect(renderEffect: PostProcessRenderEffect): void;
  138521. /** @hidden */
  138522. _rebuild(): void;
  138523. /** @hidden */
  138524. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138525. /** @hidden */
  138526. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138527. /** @hidden */
  138528. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138529. /** @hidden */
  138530. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138531. /** @hidden */
  138532. _attachCameras(cameras: Camera, unique: boolean): void;
  138533. /** @hidden */
  138534. _attachCameras(cameras: Camera[], unique: boolean): void;
  138535. /** @hidden */
  138536. _detachCameras(cameras: Camera): void;
  138537. /** @hidden */
  138538. _detachCameras(cameras: Nullable<Camera[]>): void;
  138539. /** @hidden */
  138540. _update(): void;
  138541. /** @hidden */
  138542. _reset(): void;
  138543. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138544. /**
  138545. * Disposes of the pipeline
  138546. */
  138547. dispose(): void;
  138548. }
  138549. }
  138550. declare module BABYLON {
  138551. /**
  138552. * PostProcessRenderPipelineManager class
  138553. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138554. */
  138555. export class PostProcessRenderPipelineManager {
  138556. private _renderPipelines;
  138557. /**
  138558. * Initializes a PostProcessRenderPipelineManager
  138559. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138560. */
  138561. constructor();
  138562. /**
  138563. * Gets the list of supported render pipelines
  138564. */
  138565. get supportedPipelines(): PostProcessRenderPipeline[];
  138566. /**
  138567. * Adds a pipeline to the manager
  138568. * @param renderPipeline The pipeline to add
  138569. */
  138570. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138571. /**
  138572. * Attaches a camera to the pipeline
  138573. * @param renderPipelineName The name of the pipeline to attach to
  138574. * @param cameras the camera to attach
  138575. * @param unique if the camera can be attached multiple times to the pipeline
  138576. */
  138577. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138578. /**
  138579. * Detaches a camera from the pipeline
  138580. * @param renderPipelineName The name of the pipeline to detach from
  138581. * @param cameras the camera to detach
  138582. */
  138583. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138584. /**
  138585. * Enables an effect by name on a pipeline
  138586. * @param renderPipelineName the name of the pipeline to enable the effect in
  138587. * @param renderEffectName the name of the effect to enable
  138588. * @param cameras the cameras that the effect should be enabled on
  138589. */
  138590. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138591. /**
  138592. * Disables an effect by name on a pipeline
  138593. * @param renderPipelineName the name of the pipeline to disable the effect in
  138594. * @param renderEffectName the name of the effect to disable
  138595. * @param cameras the cameras that the effect should be disabled on
  138596. */
  138597. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138598. /**
  138599. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138600. */
  138601. update(): void;
  138602. /** @hidden */
  138603. _rebuild(): void;
  138604. /**
  138605. * Disposes of the manager and pipelines
  138606. */
  138607. dispose(): void;
  138608. }
  138609. }
  138610. declare module BABYLON {
  138611. interface Scene {
  138612. /** @hidden (Backing field) */
  138613. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138614. /**
  138615. * Gets the postprocess render pipeline manager
  138616. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138617. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138618. */
  138619. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138620. }
  138621. /**
  138622. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138623. */
  138624. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138625. /**
  138626. * The component name helpfull to identify the component in the list of scene components.
  138627. */
  138628. readonly name: string;
  138629. /**
  138630. * The scene the component belongs to.
  138631. */
  138632. scene: Scene;
  138633. /**
  138634. * Creates a new instance of the component for the given scene
  138635. * @param scene Defines the scene to register the component in
  138636. */
  138637. constructor(scene: Scene);
  138638. /**
  138639. * Registers the component in a given scene
  138640. */
  138641. register(): void;
  138642. /**
  138643. * Rebuilds the elements related to this component in case of
  138644. * context lost for instance.
  138645. */
  138646. rebuild(): void;
  138647. /**
  138648. * Disposes the component and the associated ressources
  138649. */
  138650. dispose(): void;
  138651. private _gatherRenderTargets;
  138652. }
  138653. }
  138654. declare module BABYLON {
  138655. /**
  138656. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138657. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138658. */
  138659. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138660. private _scene;
  138661. private _camerasToBeAttached;
  138662. /**
  138663. * ID of the sharpen post process,
  138664. */
  138665. private readonly SharpenPostProcessId;
  138666. /**
  138667. * @ignore
  138668. * ID of the image processing post process;
  138669. */
  138670. readonly ImageProcessingPostProcessId: string;
  138671. /**
  138672. * @ignore
  138673. * ID of the Fast Approximate Anti-Aliasing post process;
  138674. */
  138675. readonly FxaaPostProcessId: string;
  138676. /**
  138677. * ID of the chromatic aberration post process,
  138678. */
  138679. private readonly ChromaticAberrationPostProcessId;
  138680. /**
  138681. * ID of the grain post process
  138682. */
  138683. private readonly GrainPostProcessId;
  138684. /**
  138685. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138686. */
  138687. sharpen: SharpenPostProcess;
  138688. private _sharpenEffect;
  138689. private bloom;
  138690. /**
  138691. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138692. */
  138693. depthOfField: DepthOfFieldEffect;
  138694. /**
  138695. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138696. */
  138697. fxaa: FxaaPostProcess;
  138698. /**
  138699. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138700. */
  138701. imageProcessing: ImageProcessingPostProcess;
  138702. /**
  138703. * Chromatic aberration post process which will shift rgb colors in the image
  138704. */
  138705. chromaticAberration: ChromaticAberrationPostProcess;
  138706. private _chromaticAberrationEffect;
  138707. /**
  138708. * Grain post process which add noise to the image
  138709. */
  138710. grain: GrainPostProcess;
  138711. private _grainEffect;
  138712. /**
  138713. * Glow post process which adds a glow to emissive areas of the image
  138714. */
  138715. private _glowLayer;
  138716. /**
  138717. * Animations which can be used to tweak settings over a period of time
  138718. */
  138719. animations: Animation[];
  138720. private _imageProcessingConfigurationObserver;
  138721. private _sharpenEnabled;
  138722. private _bloomEnabled;
  138723. private _depthOfFieldEnabled;
  138724. private _depthOfFieldBlurLevel;
  138725. private _fxaaEnabled;
  138726. private _imageProcessingEnabled;
  138727. private _defaultPipelineTextureType;
  138728. private _bloomScale;
  138729. private _chromaticAberrationEnabled;
  138730. private _grainEnabled;
  138731. private _buildAllowed;
  138732. /**
  138733. * Gets active scene
  138734. */
  138735. get scene(): Scene;
  138736. /**
  138737. * Enable or disable the sharpen process from the pipeline
  138738. */
  138739. set sharpenEnabled(enabled: boolean);
  138740. get sharpenEnabled(): boolean;
  138741. private _resizeObserver;
  138742. private _hardwareScaleLevel;
  138743. private _bloomKernel;
  138744. /**
  138745. * Specifies the size of the bloom blur kernel, relative to the final output size
  138746. */
  138747. get bloomKernel(): number;
  138748. set bloomKernel(value: number);
  138749. /**
  138750. * Specifies the weight of the bloom in the final rendering
  138751. */
  138752. private _bloomWeight;
  138753. /**
  138754. * Specifies the luma threshold for the area that will be blurred by the bloom
  138755. */
  138756. private _bloomThreshold;
  138757. private _hdr;
  138758. /**
  138759. * The strength of the bloom.
  138760. */
  138761. set bloomWeight(value: number);
  138762. get bloomWeight(): number;
  138763. /**
  138764. * The strength of the bloom.
  138765. */
  138766. set bloomThreshold(value: number);
  138767. get bloomThreshold(): number;
  138768. /**
  138769. * The scale of the bloom, lower value will provide better performance.
  138770. */
  138771. set bloomScale(value: number);
  138772. get bloomScale(): number;
  138773. /**
  138774. * Enable or disable the bloom from the pipeline
  138775. */
  138776. set bloomEnabled(enabled: boolean);
  138777. get bloomEnabled(): boolean;
  138778. private _rebuildBloom;
  138779. /**
  138780. * If the depth of field is enabled.
  138781. */
  138782. get depthOfFieldEnabled(): boolean;
  138783. set depthOfFieldEnabled(enabled: boolean);
  138784. /**
  138785. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138786. */
  138787. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138788. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138789. /**
  138790. * If the anti aliasing is enabled.
  138791. */
  138792. set fxaaEnabled(enabled: boolean);
  138793. get fxaaEnabled(): boolean;
  138794. private _samples;
  138795. /**
  138796. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138797. */
  138798. set samples(sampleCount: number);
  138799. get samples(): number;
  138800. /**
  138801. * If image processing is enabled.
  138802. */
  138803. set imageProcessingEnabled(enabled: boolean);
  138804. get imageProcessingEnabled(): boolean;
  138805. /**
  138806. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138807. */
  138808. set glowLayerEnabled(enabled: boolean);
  138809. get glowLayerEnabled(): boolean;
  138810. /**
  138811. * Gets the glow layer (or null if not defined)
  138812. */
  138813. get glowLayer(): Nullable<GlowLayer>;
  138814. /**
  138815. * Enable or disable the chromaticAberration process from the pipeline
  138816. */
  138817. set chromaticAberrationEnabled(enabled: boolean);
  138818. get chromaticAberrationEnabled(): boolean;
  138819. /**
  138820. * Enable or disable the grain process from the pipeline
  138821. */
  138822. set grainEnabled(enabled: boolean);
  138823. get grainEnabled(): boolean;
  138824. /**
  138825. * @constructor
  138826. * @param name - The rendering pipeline name (default: "")
  138827. * @param hdr - If high dynamic range textures should be used (default: true)
  138828. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138829. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138830. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138831. */
  138832. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138833. /**
  138834. * Get the class name
  138835. * @returns "DefaultRenderingPipeline"
  138836. */
  138837. getClassName(): string;
  138838. /**
  138839. * Force the compilation of the entire pipeline.
  138840. */
  138841. prepare(): void;
  138842. private _hasCleared;
  138843. private _prevPostProcess;
  138844. private _prevPrevPostProcess;
  138845. private _setAutoClearAndTextureSharing;
  138846. private _depthOfFieldSceneObserver;
  138847. private _buildPipeline;
  138848. private _disposePostProcesses;
  138849. /**
  138850. * Adds a camera to the pipeline
  138851. * @param camera the camera to be added
  138852. */
  138853. addCamera(camera: Camera): void;
  138854. /**
  138855. * Removes a camera from the pipeline
  138856. * @param camera the camera to remove
  138857. */
  138858. removeCamera(camera: Camera): void;
  138859. /**
  138860. * Dispose of the pipeline and stop all post processes
  138861. */
  138862. dispose(): void;
  138863. /**
  138864. * Serialize the rendering pipeline (Used when exporting)
  138865. * @returns the serialized object
  138866. */
  138867. serialize(): any;
  138868. /**
  138869. * Parse the serialized pipeline
  138870. * @param source Source pipeline.
  138871. * @param scene The scene to load the pipeline to.
  138872. * @param rootUrl The URL of the serialized pipeline.
  138873. * @returns An instantiated pipeline from the serialized object.
  138874. */
  138875. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138876. }
  138877. }
  138878. declare module BABYLON {
  138879. /** @hidden */
  138880. export var lensHighlightsPixelShader: {
  138881. name: string;
  138882. shader: string;
  138883. };
  138884. }
  138885. declare module BABYLON {
  138886. /** @hidden */
  138887. export var depthOfFieldPixelShader: {
  138888. name: string;
  138889. shader: string;
  138890. };
  138891. }
  138892. declare module BABYLON {
  138893. /**
  138894. * BABYLON.JS Chromatic Aberration GLSL Shader
  138895. * Author: Olivier Guyot
  138896. * Separates very slightly R, G and B colors on the edges of the screen
  138897. * Inspired by Francois Tarlier & Martins Upitis
  138898. */
  138899. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138900. /**
  138901. * @ignore
  138902. * The chromatic aberration PostProcess id in the pipeline
  138903. */
  138904. LensChromaticAberrationEffect: string;
  138905. /**
  138906. * @ignore
  138907. * The highlights enhancing PostProcess id in the pipeline
  138908. */
  138909. HighlightsEnhancingEffect: string;
  138910. /**
  138911. * @ignore
  138912. * The depth-of-field PostProcess id in the pipeline
  138913. */
  138914. LensDepthOfFieldEffect: string;
  138915. private _scene;
  138916. private _depthTexture;
  138917. private _grainTexture;
  138918. private _chromaticAberrationPostProcess;
  138919. private _highlightsPostProcess;
  138920. private _depthOfFieldPostProcess;
  138921. private _edgeBlur;
  138922. private _grainAmount;
  138923. private _chromaticAberration;
  138924. private _distortion;
  138925. private _highlightsGain;
  138926. private _highlightsThreshold;
  138927. private _dofDistance;
  138928. private _dofAperture;
  138929. private _dofDarken;
  138930. private _dofPentagon;
  138931. private _blurNoise;
  138932. /**
  138933. * @constructor
  138934. *
  138935. * Effect parameters are as follow:
  138936. * {
  138937. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138938. * edge_blur: number; // from 0 to x (1 for realism)
  138939. * distortion: number; // from 0 to x (1 for realism)
  138940. * grain_amount: number; // from 0 to 1
  138941. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138942. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138943. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138944. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138945. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138946. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138947. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138948. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138949. * }
  138950. * Note: if an effect parameter is unset, effect is disabled
  138951. *
  138952. * @param name The rendering pipeline name
  138953. * @param parameters - An object containing all parameters (see above)
  138954. * @param scene The scene linked to this pipeline
  138955. * @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)
  138956. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138957. */
  138958. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138959. /**
  138960. * Get the class name
  138961. * @returns "LensRenderingPipeline"
  138962. */
  138963. getClassName(): string;
  138964. /**
  138965. * Gets associated scene
  138966. */
  138967. get scene(): Scene;
  138968. /**
  138969. * Gets or sets the edge blur
  138970. */
  138971. get edgeBlur(): number;
  138972. set edgeBlur(value: number);
  138973. /**
  138974. * Gets or sets the grain amount
  138975. */
  138976. get grainAmount(): number;
  138977. set grainAmount(value: number);
  138978. /**
  138979. * Gets or sets the chromatic aberration amount
  138980. */
  138981. get chromaticAberration(): number;
  138982. set chromaticAberration(value: number);
  138983. /**
  138984. * Gets or sets the depth of field aperture
  138985. */
  138986. get dofAperture(): number;
  138987. set dofAperture(value: number);
  138988. /**
  138989. * Gets or sets the edge distortion
  138990. */
  138991. get edgeDistortion(): number;
  138992. set edgeDistortion(value: number);
  138993. /**
  138994. * Gets or sets the depth of field distortion
  138995. */
  138996. get dofDistortion(): number;
  138997. set dofDistortion(value: number);
  138998. /**
  138999. * Gets or sets the darken out of focus amount
  139000. */
  139001. get darkenOutOfFocus(): number;
  139002. set darkenOutOfFocus(value: number);
  139003. /**
  139004. * Gets or sets a boolean indicating if blur noise is enabled
  139005. */
  139006. get blurNoise(): boolean;
  139007. set blurNoise(value: boolean);
  139008. /**
  139009. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  139010. */
  139011. get pentagonBokeh(): boolean;
  139012. set pentagonBokeh(value: boolean);
  139013. /**
  139014. * Gets or sets the highlight grain amount
  139015. */
  139016. get highlightsGain(): number;
  139017. set highlightsGain(value: number);
  139018. /**
  139019. * Gets or sets the highlight threshold
  139020. */
  139021. get highlightsThreshold(): number;
  139022. set highlightsThreshold(value: number);
  139023. /**
  139024. * Sets the amount of blur at the edges
  139025. * @param amount blur amount
  139026. */
  139027. setEdgeBlur(amount: number): void;
  139028. /**
  139029. * Sets edge blur to 0
  139030. */
  139031. disableEdgeBlur(): void;
  139032. /**
  139033. * Sets the amout of grain
  139034. * @param amount Amount of grain
  139035. */
  139036. setGrainAmount(amount: number): void;
  139037. /**
  139038. * Set grain amount to 0
  139039. */
  139040. disableGrain(): void;
  139041. /**
  139042. * Sets the chromatic aberration amount
  139043. * @param amount amount of chromatic aberration
  139044. */
  139045. setChromaticAberration(amount: number): void;
  139046. /**
  139047. * Sets chromatic aberration amount to 0
  139048. */
  139049. disableChromaticAberration(): void;
  139050. /**
  139051. * Sets the EdgeDistortion amount
  139052. * @param amount amount of EdgeDistortion
  139053. */
  139054. setEdgeDistortion(amount: number): void;
  139055. /**
  139056. * Sets edge distortion to 0
  139057. */
  139058. disableEdgeDistortion(): void;
  139059. /**
  139060. * Sets the FocusDistance amount
  139061. * @param amount amount of FocusDistance
  139062. */
  139063. setFocusDistance(amount: number): void;
  139064. /**
  139065. * Disables depth of field
  139066. */
  139067. disableDepthOfField(): void;
  139068. /**
  139069. * Sets the Aperture amount
  139070. * @param amount amount of Aperture
  139071. */
  139072. setAperture(amount: number): void;
  139073. /**
  139074. * Sets the DarkenOutOfFocus amount
  139075. * @param amount amount of DarkenOutOfFocus
  139076. */
  139077. setDarkenOutOfFocus(amount: number): void;
  139078. private _pentagonBokehIsEnabled;
  139079. /**
  139080. * Creates a pentagon bokeh effect
  139081. */
  139082. enablePentagonBokeh(): void;
  139083. /**
  139084. * Disables the pentagon bokeh effect
  139085. */
  139086. disablePentagonBokeh(): void;
  139087. /**
  139088. * Enables noise blur
  139089. */
  139090. enableNoiseBlur(): void;
  139091. /**
  139092. * Disables noise blur
  139093. */
  139094. disableNoiseBlur(): void;
  139095. /**
  139096. * Sets the HighlightsGain amount
  139097. * @param amount amount of HighlightsGain
  139098. */
  139099. setHighlightsGain(amount: number): void;
  139100. /**
  139101. * Sets the HighlightsThreshold amount
  139102. * @param amount amount of HighlightsThreshold
  139103. */
  139104. setHighlightsThreshold(amount: number): void;
  139105. /**
  139106. * Disables highlights
  139107. */
  139108. disableHighlights(): void;
  139109. /**
  139110. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  139111. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  139112. */
  139113. dispose(disableDepthRender?: boolean): void;
  139114. private _createChromaticAberrationPostProcess;
  139115. private _createHighlightsPostProcess;
  139116. private _createDepthOfFieldPostProcess;
  139117. private _createGrainTexture;
  139118. }
  139119. }
  139120. declare module BABYLON {
  139121. /** @hidden */
  139122. export var ssao2PixelShader: {
  139123. name: string;
  139124. shader: string;
  139125. };
  139126. }
  139127. declare module BABYLON {
  139128. /** @hidden */
  139129. export var ssaoCombinePixelShader: {
  139130. name: string;
  139131. shader: string;
  139132. };
  139133. }
  139134. declare module BABYLON {
  139135. /**
  139136. * Render pipeline to produce ssao effect
  139137. */
  139138. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  139139. /**
  139140. * @ignore
  139141. * The PassPostProcess id in the pipeline that contains the original scene color
  139142. */
  139143. SSAOOriginalSceneColorEffect: string;
  139144. /**
  139145. * @ignore
  139146. * The SSAO PostProcess id in the pipeline
  139147. */
  139148. SSAORenderEffect: string;
  139149. /**
  139150. * @ignore
  139151. * The horizontal blur PostProcess id in the pipeline
  139152. */
  139153. SSAOBlurHRenderEffect: string;
  139154. /**
  139155. * @ignore
  139156. * The vertical blur PostProcess id in the pipeline
  139157. */
  139158. SSAOBlurVRenderEffect: string;
  139159. /**
  139160. * @ignore
  139161. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139162. */
  139163. SSAOCombineRenderEffect: string;
  139164. /**
  139165. * The output strength of the SSAO post-process. Default value is 1.0.
  139166. */
  139167. totalStrength: number;
  139168. /**
  139169. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  139170. */
  139171. maxZ: number;
  139172. /**
  139173. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  139174. */
  139175. minZAspect: number;
  139176. private _samples;
  139177. /**
  139178. * Number of samples used for the SSAO calculations. Default value is 8
  139179. */
  139180. set samples(n: number);
  139181. get samples(): number;
  139182. private _textureSamples;
  139183. /**
  139184. * Number of samples to use for antialiasing
  139185. */
  139186. set textureSamples(n: number);
  139187. get textureSamples(): number;
  139188. /**
  139189. * Ratio object used for SSAO ratio and blur ratio
  139190. */
  139191. private _ratio;
  139192. /**
  139193. * Dynamically generated sphere sampler.
  139194. */
  139195. private _sampleSphere;
  139196. /**
  139197. * Blur filter offsets
  139198. */
  139199. private _samplerOffsets;
  139200. private _expensiveBlur;
  139201. /**
  139202. * If bilateral blur should be used
  139203. */
  139204. set expensiveBlur(b: boolean);
  139205. get expensiveBlur(): boolean;
  139206. /**
  139207. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  139208. */
  139209. radius: number;
  139210. /**
  139211. * The base color of the SSAO post-process
  139212. * The final result is "base + ssao" between [0, 1]
  139213. */
  139214. base: number;
  139215. /**
  139216. * Support test.
  139217. */
  139218. static get IsSupported(): boolean;
  139219. private _scene;
  139220. private _depthTexture;
  139221. private _normalTexture;
  139222. private _randomTexture;
  139223. private _originalColorPostProcess;
  139224. private _ssaoPostProcess;
  139225. private _blurHPostProcess;
  139226. private _blurVPostProcess;
  139227. private _ssaoCombinePostProcess;
  139228. /**
  139229. * Gets active scene
  139230. */
  139231. get scene(): Scene;
  139232. /**
  139233. * @constructor
  139234. * @param name The rendering pipeline name
  139235. * @param scene The scene linked to this pipeline
  139236. * @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 }
  139237. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139238. */
  139239. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139240. /**
  139241. * Get the class name
  139242. * @returns "SSAO2RenderingPipeline"
  139243. */
  139244. getClassName(): string;
  139245. /**
  139246. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139247. */
  139248. dispose(disableGeometryBufferRenderer?: boolean): void;
  139249. private _createBlurPostProcess;
  139250. /** @hidden */
  139251. _rebuild(): void;
  139252. private _bits;
  139253. private _radicalInverse_VdC;
  139254. private _hammersley;
  139255. private _hemisphereSample_uniform;
  139256. private _generateHemisphere;
  139257. private _createSSAOPostProcess;
  139258. private _createSSAOCombinePostProcess;
  139259. private _createRandomTexture;
  139260. /**
  139261. * Serialize the rendering pipeline (Used when exporting)
  139262. * @returns the serialized object
  139263. */
  139264. serialize(): any;
  139265. /**
  139266. * Parse the serialized pipeline
  139267. * @param source Source pipeline.
  139268. * @param scene The scene to load the pipeline to.
  139269. * @param rootUrl The URL of the serialized pipeline.
  139270. * @returns An instantiated pipeline from the serialized object.
  139271. */
  139272. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  139273. }
  139274. }
  139275. declare module BABYLON {
  139276. /** @hidden */
  139277. export var ssaoPixelShader: {
  139278. name: string;
  139279. shader: string;
  139280. };
  139281. }
  139282. declare module BABYLON {
  139283. /**
  139284. * Render pipeline to produce ssao effect
  139285. */
  139286. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  139287. /**
  139288. * @ignore
  139289. * The PassPostProcess id in the pipeline that contains the original scene color
  139290. */
  139291. SSAOOriginalSceneColorEffect: string;
  139292. /**
  139293. * @ignore
  139294. * The SSAO PostProcess id in the pipeline
  139295. */
  139296. SSAORenderEffect: string;
  139297. /**
  139298. * @ignore
  139299. * The horizontal blur PostProcess id in the pipeline
  139300. */
  139301. SSAOBlurHRenderEffect: string;
  139302. /**
  139303. * @ignore
  139304. * The vertical blur PostProcess id in the pipeline
  139305. */
  139306. SSAOBlurVRenderEffect: string;
  139307. /**
  139308. * @ignore
  139309. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139310. */
  139311. SSAOCombineRenderEffect: string;
  139312. /**
  139313. * The output strength of the SSAO post-process. Default value is 1.0.
  139314. */
  139315. totalStrength: number;
  139316. /**
  139317. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  139318. */
  139319. radius: number;
  139320. /**
  139321. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  139322. * Must not be equal to fallOff and superior to fallOff.
  139323. * Default value is 0.0075
  139324. */
  139325. area: number;
  139326. /**
  139327. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  139328. * Must not be equal to area and inferior to area.
  139329. * Default value is 0.000001
  139330. */
  139331. fallOff: number;
  139332. /**
  139333. * The base color of the SSAO post-process
  139334. * The final result is "base + ssao" between [0, 1]
  139335. */
  139336. base: number;
  139337. private _scene;
  139338. private _depthTexture;
  139339. private _randomTexture;
  139340. private _originalColorPostProcess;
  139341. private _ssaoPostProcess;
  139342. private _blurHPostProcess;
  139343. private _blurVPostProcess;
  139344. private _ssaoCombinePostProcess;
  139345. private _firstUpdate;
  139346. /**
  139347. * Gets active scene
  139348. */
  139349. get scene(): Scene;
  139350. /**
  139351. * @constructor
  139352. * @param name - The rendering pipeline name
  139353. * @param scene - The scene linked to this pipeline
  139354. * @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 }
  139355. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139356. */
  139357. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139358. /**
  139359. * Get the class name
  139360. * @returns "SSAORenderingPipeline"
  139361. */
  139362. getClassName(): string;
  139363. /**
  139364. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139365. */
  139366. dispose(disableDepthRender?: boolean): void;
  139367. private _createBlurPostProcess;
  139368. /** @hidden */
  139369. _rebuild(): void;
  139370. private _createSSAOPostProcess;
  139371. private _createSSAOCombinePostProcess;
  139372. private _createRandomTexture;
  139373. }
  139374. }
  139375. declare module BABYLON {
  139376. /** @hidden */
  139377. export var screenSpaceReflectionPixelShader: {
  139378. name: string;
  139379. shader: string;
  139380. };
  139381. }
  139382. declare module BABYLON {
  139383. /**
  139384. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139385. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139386. */
  139387. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139388. /**
  139389. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139390. */
  139391. threshold: number;
  139392. /**
  139393. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139394. */
  139395. strength: number;
  139396. /**
  139397. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139398. */
  139399. reflectionSpecularFalloffExponent: number;
  139400. /**
  139401. * 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]
  139402. */
  139403. step: number;
  139404. /**
  139405. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139406. */
  139407. roughnessFactor: number;
  139408. private _geometryBufferRenderer;
  139409. private _enableSmoothReflections;
  139410. private _reflectionSamples;
  139411. private _smoothSteps;
  139412. /**
  139413. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139414. * @param name The name of the effect.
  139415. * @param scene The scene containing the objects to calculate reflections.
  139416. * @param options The required width/height ratio to downsize to before computing the render pass.
  139417. * @param camera The camera to apply the render pass to.
  139418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139419. * @param engine The engine which the post process will be applied. (default: current engine)
  139420. * @param reusable If the post process can be reused on the same frame. (default: false)
  139421. * @param textureType Type of textures used when performing the post process. (default: 0)
  139422. * @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)
  139423. */
  139424. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139425. /**
  139426. * Gets wether or not smoothing reflections is enabled.
  139427. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139428. */
  139429. get enableSmoothReflections(): boolean;
  139430. /**
  139431. * Sets wether or not smoothing reflections is enabled.
  139432. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139433. */
  139434. set enableSmoothReflections(enabled: boolean);
  139435. /**
  139436. * Gets the number of samples taken while computing reflections. More samples count is high,
  139437. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139438. */
  139439. get reflectionSamples(): number;
  139440. /**
  139441. * Sets the number of samples taken while computing reflections. More samples count is high,
  139442. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139443. */
  139444. set reflectionSamples(samples: number);
  139445. /**
  139446. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139447. * more the post-process will require GPU power and can generate a drop in FPS.
  139448. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139449. */
  139450. get smoothSteps(): number;
  139451. set smoothSteps(steps: number);
  139452. private _updateEffectDefines;
  139453. }
  139454. }
  139455. declare module BABYLON {
  139456. /** @hidden */
  139457. export var standardPixelShader: {
  139458. name: string;
  139459. shader: string;
  139460. };
  139461. }
  139462. declare module BABYLON {
  139463. /**
  139464. * Standard rendering pipeline
  139465. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139466. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139467. */
  139468. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139469. /**
  139470. * Public members
  139471. */
  139472. /**
  139473. * Post-process which contains the original scene color before the pipeline applies all the effects
  139474. */
  139475. originalPostProcess: Nullable<PostProcess>;
  139476. /**
  139477. * Post-process used to down scale an image x4
  139478. */
  139479. downSampleX4PostProcess: Nullable<PostProcess>;
  139480. /**
  139481. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139482. */
  139483. brightPassPostProcess: Nullable<PostProcess>;
  139484. /**
  139485. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139486. */
  139487. blurHPostProcesses: PostProcess[];
  139488. /**
  139489. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139490. */
  139491. blurVPostProcesses: PostProcess[];
  139492. /**
  139493. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139494. */
  139495. textureAdderPostProcess: Nullable<PostProcess>;
  139496. /**
  139497. * Post-process used to create volumetric lighting effect
  139498. */
  139499. volumetricLightPostProcess: Nullable<PostProcess>;
  139500. /**
  139501. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139502. */
  139503. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139504. /**
  139505. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139506. */
  139507. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139508. /**
  139509. * Post-process used to merge the volumetric light effect and the real scene color
  139510. */
  139511. volumetricLightMergePostProces: Nullable<PostProcess>;
  139512. /**
  139513. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139514. */
  139515. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139516. /**
  139517. * Base post-process used to calculate the average luminance of the final image for HDR
  139518. */
  139519. luminancePostProcess: Nullable<PostProcess>;
  139520. /**
  139521. * Post-processes used to create down sample post-processes in order to get
  139522. * the average luminance of the final image for HDR
  139523. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139524. */
  139525. luminanceDownSamplePostProcesses: PostProcess[];
  139526. /**
  139527. * Post-process used to create a HDR effect (light adaptation)
  139528. */
  139529. hdrPostProcess: Nullable<PostProcess>;
  139530. /**
  139531. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139532. */
  139533. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139534. /**
  139535. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139536. */
  139537. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139538. /**
  139539. * Post-process used to merge the final HDR post-process and the real scene color
  139540. */
  139541. hdrFinalPostProcess: Nullable<PostProcess>;
  139542. /**
  139543. * Post-process used to create a lens flare effect
  139544. */
  139545. lensFlarePostProcess: Nullable<PostProcess>;
  139546. /**
  139547. * Post-process that merges the result of the lens flare post-process and the real scene color
  139548. */
  139549. lensFlareComposePostProcess: Nullable<PostProcess>;
  139550. /**
  139551. * Post-process used to create a motion blur effect
  139552. */
  139553. motionBlurPostProcess: Nullable<PostProcess>;
  139554. /**
  139555. * Post-process used to create a depth of field effect
  139556. */
  139557. depthOfFieldPostProcess: Nullable<PostProcess>;
  139558. /**
  139559. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139560. */
  139561. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139562. /**
  139563. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139564. */
  139565. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139566. /**
  139567. * Represents the brightness threshold in order to configure the illuminated surfaces
  139568. */
  139569. brightThreshold: number;
  139570. /**
  139571. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139572. */
  139573. blurWidth: number;
  139574. /**
  139575. * Sets if the blur for highlighted surfaces must be only horizontal
  139576. */
  139577. horizontalBlur: boolean;
  139578. /**
  139579. * Gets the overall exposure used by the pipeline
  139580. */
  139581. get exposure(): number;
  139582. /**
  139583. * Sets the overall exposure used by the pipeline
  139584. */
  139585. set exposure(value: number);
  139586. /**
  139587. * Texture used typically to simulate "dirty" on camera lens
  139588. */
  139589. lensTexture: Nullable<Texture>;
  139590. /**
  139591. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139592. */
  139593. volumetricLightCoefficient: number;
  139594. /**
  139595. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139596. */
  139597. volumetricLightPower: number;
  139598. /**
  139599. * Used the set the blur intensity to smooth the volumetric lights
  139600. */
  139601. volumetricLightBlurScale: number;
  139602. /**
  139603. * Light (spot or directional) used to generate the volumetric lights rays
  139604. * The source light must have a shadow generate so the pipeline can get its
  139605. * depth map
  139606. */
  139607. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139608. /**
  139609. * For eye adaptation, represents the minimum luminance the eye can see
  139610. */
  139611. hdrMinimumLuminance: number;
  139612. /**
  139613. * For eye adaptation, represents the decrease luminance speed
  139614. */
  139615. hdrDecreaseRate: number;
  139616. /**
  139617. * For eye adaptation, represents the increase luminance speed
  139618. */
  139619. hdrIncreaseRate: number;
  139620. /**
  139621. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139622. */
  139623. get hdrAutoExposure(): boolean;
  139624. /**
  139625. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139626. */
  139627. set hdrAutoExposure(value: boolean);
  139628. /**
  139629. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139630. */
  139631. lensColorTexture: Nullable<Texture>;
  139632. /**
  139633. * The overall strengh for the lens flare effect
  139634. */
  139635. lensFlareStrength: number;
  139636. /**
  139637. * Dispersion coefficient for lens flare ghosts
  139638. */
  139639. lensFlareGhostDispersal: number;
  139640. /**
  139641. * Main lens flare halo width
  139642. */
  139643. lensFlareHaloWidth: number;
  139644. /**
  139645. * Based on the lens distortion effect, defines how much the lens flare result
  139646. * is distorted
  139647. */
  139648. lensFlareDistortionStrength: number;
  139649. /**
  139650. * Configures the blur intensity used for for lens flare (halo)
  139651. */
  139652. lensFlareBlurWidth: number;
  139653. /**
  139654. * Lens star texture must be used to simulate rays on the flares and is available
  139655. * in the documentation
  139656. */
  139657. lensStarTexture: Nullable<Texture>;
  139658. /**
  139659. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139660. * flare effect by taking account of the dirt texture
  139661. */
  139662. lensFlareDirtTexture: Nullable<Texture>;
  139663. /**
  139664. * Represents the focal length for the depth of field effect
  139665. */
  139666. depthOfFieldDistance: number;
  139667. /**
  139668. * Represents the blur intensity for the blurred part of the depth of field effect
  139669. */
  139670. depthOfFieldBlurWidth: number;
  139671. /**
  139672. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139673. */
  139674. get motionStrength(): number;
  139675. /**
  139676. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139677. */
  139678. set motionStrength(strength: number);
  139679. /**
  139680. * Gets wether or not the motion blur post-process is object based or screen based.
  139681. */
  139682. get objectBasedMotionBlur(): boolean;
  139683. /**
  139684. * Sets wether or not the motion blur post-process should be object based or screen based
  139685. */
  139686. set objectBasedMotionBlur(value: boolean);
  139687. /**
  139688. * List of animations for the pipeline (IAnimatable implementation)
  139689. */
  139690. animations: Animation[];
  139691. /**
  139692. * Private members
  139693. */
  139694. private _scene;
  139695. private _currentDepthOfFieldSource;
  139696. private _basePostProcess;
  139697. private _fixedExposure;
  139698. private _currentExposure;
  139699. private _hdrAutoExposure;
  139700. private _hdrCurrentLuminance;
  139701. private _motionStrength;
  139702. private _isObjectBasedMotionBlur;
  139703. private _floatTextureType;
  139704. private _camerasToBeAttached;
  139705. private _ratio;
  139706. private _bloomEnabled;
  139707. private _depthOfFieldEnabled;
  139708. private _vlsEnabled;
  139709. private _lensFlareEnabled;
  139710. private _hdrEnabled;
  139711. private _motionBlurEnabled;
  139712. private _fxaaEnabled;
  139713. private _screenSpaceReflectionsEnabled;
  139714. private _motionBlurSamples;
  139715. private _volumetricLightStepsCount;
  139716. private _samples;
  139717. /**
  139718. * @ignore
  139719. * Specifies if the bloom pipeline is enabled
  139720. */
  139721. get BloomEnabled(): boolean;
  139722. set BloomEnabled(enabled: boolean);
  139723. /**
  139724. * @ignore
  139725. * Specifies if the depth of field pipeline is enabed
  139726. */
  139727. get DepthOfFieldEnabled(): boolean;
  139728. set DepthOfFieldEnabled(enabled: boolean);
  139729. /**
  139730. * @ignore
  139731. * Specifies if the lens flare pipeline is enabed
  139732. */
  139733. get LensFlareEnabled(): boolean;
  139734. set LensFlareEnabled(enabled: boolean);
  139735. /**
  139736. * @ignore
  139737. * Specifies if the HDR pipeline is enabled
  139738. */
  139739. get HDREnabled(): boolean;
  139740. set HDREnabled(enabled: boolean);
  139741. /**
  139742. * @ignore
  139743. * Specifies if the volumetric lights scattering effect is enabled
  139744. */
  139745. get VLSEnabled(): boolean;
  139746. set VLSEnabled(enabled: boolean);
  139747. /**
  139748. * @ignore
  139749. * Specifies if the motion blur effect is enabled
  139750. */
  139751. get MotionBlurEnabled(): boolean;
  139752. set MotionBlurEnabled(enabled: boolean);
  139753. /**
  139754. * Specifies if anti-aliasing is enabled
  139755. */
  139756. get fxaaEnabled(): boolean;
  139757. set fxaaEnabled(enabled: boolean);
  139758. /**
  139759. * Specifies if screen space reflections are enabled.
  139760. */
  139761. get screenSpaceReflectionsEnabled(): boolean;
  139762. set screenSpaceReflectionsEnabled(enabled: boolean);
  139763. /**
  139764. * Specifies the number of steps used to calculate the volumetric lights
  139765. * Typically in interval [50, 200]
  139766. */
  139767. get volumetricLightStepsCount(): number;
  139768. set volumetricLightStepsCount(count: number);
  139769. /**
  139770. * Specifies the number of samples used for the motion blur effect
  139771. * Typically in interval [16, 64]
  139772. */
  139773. get motionBlurSamples(): number;
  139774. set motionBlurSamples(samples: number);
  139775. /**
  139776. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139777. */
  139778. get samples(): number;
  139779. set samples(sampleCount: number);
  139780. /**
  139781. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139782. * @constructor
  139783. * @param name The rendering pipeline name
  139784. * @param scene The scene linked to this pipeline
  139785. * @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)
  139786. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139787. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139788. */
  139789. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139790. private _buildPipeline;
  139791. private _createDownSampleX4PostProcess;
  139792. private _createBrightPassPostProcess;
  139793. private _createBlurPostProcesses;
  139794. private _createTextureAdderPostProcess;
  139795. private _createVolumetricLightPostProcess;
  139796. private _createLuminancePostProcesses;
  139797. private _createHdrPostProcess;
  139798. private _createLensFlarePostProcess;
  139799. private _createDepthOfFieldPostProcess;
  139800. private _createMotionBlurPostProcess;
  139801. private _getDepthTexture;
  139802. private _disposePostProcesses;
  139803. /**
  139804. * Dispose of the pipeline and stop all post processes
  139805. */
  139806. dispose(): void;
  139807. /**
  139808. * Serialize the rendering pipeline (Used when exporting)
  139809. * @returns the serialized object
  139810. */
  139811. serialize(): any;
  139812. /**
  139813. * Parse the serialized pipeline
  139814. * @param source Source pipeline.
  139815. * @param scene The scene to load the pipeline to.
  139816. * @param rootUrl The URL of the serialized pipeline.
  139817. * @returns An instantiated pipeline from the serialized object.
  139818. */
  139819. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139820. /**
  139821. * Luminance steps
  139822. */
  139823. static LuminanceSteps: number;
  139824. }
  139825. }
  139826. declare module BABYLON {
  139827. /** @hidden */
  139828. export var tonemapPixelShader: {
  139829. name: string;
  139830. shader: string;
  139831. };
  139832. }
  139833. declare module BABYLON {
  139834. /** Defines operator used for tonemapping */
  139835. export enum TonemappingOperator {
  139836. /** Hable */
  139837. Hable = 0,
  139838. /** Reinhard */
  139839. Reinhard = 1,
  139840. /** HejiDawson */
  139841. HejiDawson = 2,
  139842. /** Photographic */
  139843. Photographic = 3
  139844. }
  139845. /**
  139846. * Defines a post process to apply tone mapping
  139847. */
  139848. export class TonemapPostProcess extends PostProcess {
  139849. private _operator;
  139850. /** Defines the required exposure adjustement */
  139851. exposureAdjustment: number;
  139852. /**
  139853. * Creates a new TonemapPostProcess
  139854. * @param name defines the name of the postprocess
  139855. * @param _operator defines the operator to use
  139856. * @param exposureAdjustment defines the required exposure adjustement
  139857. * @param camera defines the camera to use (can be null)
  139858. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139859. * @param engine defines the hosting engine (can be ignore if camera is set)
  139860. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139861. */
  139862. constructor(name: string, _operator: TonemappingOperator,
  139863. /** Defines the required exposure adjustement */
  139864. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139865. }
  139866. }
  139867. declare module BABYLON {
  139868. /** @hidden */
  139869. export var volumetricLightScatteringPixelShader: {
  139870. name: string;
  139871. shader: string;
  139872. };
  139873. }
  139874. declare module BABYLON {
  139875. /** @hidden */
  139876. export var volumetricLightScatteringPassVertexShader: {
  139877. name: string;
  139878. shader: string;
  139879. };
  139880. }
  139881. declare module BABYLON {
  139882. /** @hidden */
  139883. export var volumetricLightScatteringPassPixelShader: {
  139884. name: string;
  139885. shader: string;
  139886. };
  139887. }
  139888. declare module BABYLON {
  139889. /**
  139890. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139891. */
  139892. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139893. private _volumetricLightScatteringPass;
  139894. private _volumetricLightScatteringRTT;
  139895. private _viewPort;
  139896. private _screenCoordinates;
  139897. private _cachedDefines;
  139898. /**
  139899. * If not undefined, the mesh position is computed from the attached node position
  139900. */
  139901. attachedNode: {
  139902. position: Vector3;
  139903. };
  139904. /**
  139905. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139906. */
  139907. customMeshPosition: Vector3;
  139908. /**
  139909. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139910. */
  139911. useCustomMeshPosition: boolean;
  139912. /**
  139913. * If the post-process should inverse the light scattering direction
  139914. */
  139915. invert: boolean;
  139916. /**
  139917. * The internal mesh used by the post-process
  139918. */
  139919. mesh: Mesh;
  139920. /**
  139921. * @hidden
  139922. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139923. */
  139924. get useDiffuseColor(): boolean;
  139925. set useDiffuseColor(useDiffuseColor: boolean);
  139926. /**
  139927. * Array containing the excluded meshes not rendered in the internal pass
  139928. */
  139929. excludedMeshes: AbstractMesh[];
  139930. /**
  139931. * Controls the overall intensity of the post-process
  139932. */
  139933. exposure: number;
  139934. /**
  139935. * Dissipates each sample's contribution in range [0, 1]
  139936. */
  139937. decay: number;
  139938. /**
  139939. * Controls the overall intensity of each sample
  139940. */
  139941. weight: number;
  139942. /**
  139943. * Controls the density of each sample
  139944. */
  139945. density: number;
  139946. /**
  139947. * @constructor
  139948. * @param name The post-process name
  139949. * @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)
  139950. * @param camera The camera that the post-process will be attached to
  139951. * @param mesh The mesh used to create the light scattering
  139952. * @param samples The post-process quality, default 100
  139953. * @param samplingModeThe post-process filtering mode
  139954. * @param engine The babylon engine
  139955. * @param reusable If the post-process is reusable
  139956. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139957. */
  139958. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139959. /**
  139960. * Returns the string "VolumetricLightScatteringPostProcess"
  139961. * @returns "VolumetricLightScatteringPostProcess"
  139962. */
  139963. getClassName(): string;
  139964. private _isReady;
  139965. /**
  139966. * Sets the new light position for light scattering effect
  139967. * @param position The new custom light position
  139968. */
  139969. setCustomMeshPosition(position: Vector3): void;
  139970. /**
  139971. * Returns the light position for light scattering effect
  139972. * @return Vector3 The custom light position
  139973. */
  139974. getCustomMeshPosition(): Vector3;
  139975. /**
  139976. * Disposes the internal assets and detaches the post-process from the camera
  139977. */
  139978. dispose(camera: Camera): void;
  139979. /**
  139980. * Returns the render target texture used by the post-process
  139981. * @return the render target texture used by the post-process
  139982. */
  139983. getPass(): RenderTargetTexture;
  139984. private _meshExcluded;
  139985. private _createPass;
  139986. private _updateMeshScreenCoordinates;
  139987. /**
  139988. * Creates a default mesh for the Volumeric Light Scattering post-process
  139989. * @param name The mesh name
  139990. * @param scene The scene where to create the mesh
  139991. * @return the default mesh
  139992. */
  139993. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139994. }
  139995. }
  139996. declare module BABYLON {
  139997. interface Scene {
  139998. /** @hidden (Backing field) */
  139999. _boundingBoxRenderer: BoundingBoxRenderer;
  140000. /** @hidden (Backing field) */
  140001. _forceShowBoundingBoxes: boolean;
  140002. /**
  140003. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  140004. */
  140005. forceShowBoundingBoxes: boolean;
  140006. /**
  140007. * Gets the bounding box renderer associated with the scene
  140008. * @returns a BoundingBoxRenderer
  140009. */
  140010. getBoundingBoxRenderer(): BoundingBoxRenderer;
  140011. }
  140012. interface AbstractMesh {
  140013. /** @hidden (Backing field) */
  140014. _showBoundingBox: boolean;
  140015. /**
  140016. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  140017. */
  140018. showBoundingBox: boolean;
  140019. }
  140020. /**
  140021. * Component responsible of rendering the bounding box of the meshes in a scene.
  140022. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  140023. */
  140024. export class BoundingBoxRenderer implements ISceneComponent {
  140025. /**
  140026. * The component name helpfull to identify the component in the list of scene components.
  140027. */
  140028. readonly name: string;
  140029. /**
  140030. * The scene the component belongs to.
  140031. */
  140032. scene: Scene;
  140033. /**
  140034. * Color of the bounding box lines placed in front of an object
  140035. */
  140036. frontColor: Color3;
  140037. /**
  140038. * Color of the bounding box lines placed behind an object
  140039. */
  140040. backColor: Color3;
  140041. /**
  140042. * Defines if the renderer should show the back lines or not
  140043. */
  140044. showBackLines: boolean;
  140045. /**
  140046. * @hidden
  140047. */
  140048. renderList: SmartArray<BoundingBox>;
  140049. private _colorShader;
  140050. private _vertexBuffers;
  140051. private _indexBuffer;
  140052. private _fillIndexBuffer;
  140053. private _fillIndexData;
  140054. /**
  140055. * Instantiates a new bounding box renderer in a scene.
  140056. * @param scene the scene the renderer renders in
  140057. */
  140058. constructor(scene: Scene);
  140059. /**
  140060. * Registers the component in a given scene
  140061. */
  140062. register(): void;
  140063. private _evaluateSubMesh;
  140064. private _activeMesh;
  140065. private _prepareRessources;
  140066. private _createIndexBuffer;
  140067. /**
  140068. * Rebuilds the elements related to this component in case of
  140069. * context lost for instance.
  140070. */
  140071. rebuild(): void;
  140072. /**
  140073. * @hidden
  140074. */
  140075. reset(): void;
  140076. /**
  140077. * Render the bounding boxes of a specific rendering group
  140078. * @param renderingGroupId defines the rendering group to render
  140079. */
  140080. render(renderingGroupId: number): void;
  140081. /**
  140082. * In case of occlusion queries, we can render the occlusion bounding box through this method
  140083. * @param mesh Define the mesh to render the occlusion bounding box for
  140084. */
  140085. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  140086. /**
  140087. * Dispose and release the resources attached to this renderer.
  140088. */
  140089. dispose(): void;
  140090. }
  140091. }
  140092. declare module BABYLON {
  140093. interface Scene {
  140094. /** @hidden (Backing field) */
  140095. _depthRenderer: {
  140096. [id: string]: DepthRenderer;
  140097. };
  140098. /**
  140099. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  140100. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  140101. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140102. * @returns the created depth renderer
  140103. */
  140104. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  140105. /**
  140106. * Disables a depth renderer for a given camera
  140107. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  140108. */
  140109. disableDepthRenderer(camera?: Nullable<Camera>): void;
  140110. }
  140111. /**
  140112. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  140113. * in several rendering techniques.
  140114. */
  140115. export class DepthRendererSceneComponent implements ISceneComponent {
  140116. /**
  140117. * The component name helpfull to identify the component in the list of scene components.
  140118. */
  140119. readonly name: string;
  140120. /**
  140121. * The scene the component belongs to.
  140122. */
  140123. scene: Scene;
  140124. /**
  140125. * Creates a new instance of the component for the given scene
  140126. * @param scene Defines the scene to register the component in
  140127. */
  140128. constructor(scene: Scene);
  140129. /**
  140130. * Registers the component in a given scene
  140131. */
  140132. register(): void;
  140133. /**
  140134. * Rebuilds the elements related to this component in case of
  140135. * context lost for instance.
  140136. */
  140137. rebuild(): void;
  140138. /**
  140139. * Disposes the component and the associated ressources
  140140. */
  140141. dispose(): void;
  140142. private _gatherRenderTargets;
  140143. private _gatherActiveCameraRenderTargets;
  140144. }
  140145. }
  140146. declare module BABYLON {
  140147. /** @hidden */
  140148. export var outlinePixelShader: {
  140149. name: string;
  140150. shader: string;
  140151. };
  140152. }
  140153. declare module BABYLON {
  140154. /** @hidden */
  140155. export var outlineVertexShader: {
  140156. name: string;
  140157. shader: string;
  140158. };
  140159. }
  140160. declare module BABYLON {
  140161. interface Scene {
  140162. /** @hidden */
  140163. _outlineRenderer: OutlineRenderer;
  140164. /**
  140165. * Gets the outline renderer associated with the scene
  140166. * @returns a OutlineRenderer
  140167. */
  140168. getOutlineRenderer(): OutlineRenderer;
  140169. }
  140170. interface AbstractMesh {
  140171. /** @hidden (Backing field) */
  140172. _renderOutline: boolean;
  140173. /**
  140174. * Gets or sets a boolean indicating if the outline must be rendered as well
  140175. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  140176. */
  140177. renderOutline: boolean;
  140178. /** @hidden (Backing field) */
  140179. _renderOverlay: boolean;
  140180. /**
  140181. * Gets or sets a boolean indicating if the overlay must be rendered as well
  140182. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  140183. */
  140184. renderOverlay: boolean;
  140185. }
  140186. /**
  140187. * This class is responsible to draw bothe outline/overlay of meshes.
  140188. * It should not be used directly but through the available method on mesh.
  140189. */
  140190. export class OutlineRenderer implements ISceneComponent {
  140191. /**
  140192. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  140193. */
  140194. private static _StencilReference;
  140195. /**
  140196. * The name of the component. Each component must have a unique name.
  140197. */
  140198. name: string;
  140199. /**
  140200. * The scene the component belongs to.
  140201. */
  140202. scene: Scene;
  140203. /**
  140204. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  140205. */
  140206. zOffset: number;
  140207. private _engine;
  140208. private _effect;
  140209. private _cachedDefines;
  140210. private _savedDepthWrite;
  140211. /**
  140212. * Instantiates a new outline renderer. (There could be only one per scene).
  140213. * @param scene Defines the scene it belongs to
  140214. */
  140215. constructor(scene: Scene);
  140216. /**
  140217. * Register the component to one instance of a scene.
  140218. */
  140219. register(): void;
  140220. /**
  140221. * Rebuilds the elements related to this component in case of
  140222. * context lost for instance.
  140223. */
  140224. rebuild(): void;
  140225. /**
  140226. * Disposes the component and the associated ressources.
  140227. */
  140228. dispose(): void;
  140229. /**
  140230. * Renders the outline in the canvas.
  140231. * @param subMesh Defines the sumesh to render
  140232. * @param batch Defines the batch of meshes in case of instances
  140233. * @param useOverlay Defines if the rendering is for the overlay or the outline
  140234. */
  140235. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  140236. /**
  140237. * Returns whether or not the outline renderer is ready for a given submesh.
  140238. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  140239. * @param subMesh Defines the submesh to check readyness for
  140240. * @param useInstances Defines wheter wee are trying to render instances or not
  140241. * @returns true if ready otherwise false
  140242. */
  140243. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140244. private _beforeRenderingMesh;
  140245. private _afterRenderingMesh;
  140246. }
  140247. }
  140248. declare module BABYLON {
  140249. /**
  140250. * Defines the basic options interface of a Sprite Frame Source Size.
  140251. */
  140252. export interface ISpriteJSONSpriteSourceSize {
  140253. /**
  140254. * number of the original width of the Frame
  140255. */
  140256. w: number;
  140257. /**
  140258. * number of the original height of the Frame
  140259. */
  140260. h: number;
  140261. }
  140262. /**
  140263. * Defines the basic options interface of a Sprite Frame Data.
  140264. */
  140265. export interface ISpriteJSONSpriteFrameData {
  140266. /**
  140267. * number of the x offset of the Frame
  140268. */
  140269. x: number;
  140270. /**
  140271. * number of the y offset of the Frame
  140272. */
  140273. y: number;
  140274. /**
  140275. * number of the width of the Frame
  140276. */
  140277. w: number;
  140278. /**
  140279. * number of the height of the Frame
  140280. */
  140281. h: number;
  140282. }
  140283. /**
  140284. * Defines the basic options interface of a JSON Sprite.
  140285. */
  140286. export interface ISpriteJSONSprite {
  140287. /**
  140288. * string name of the Frame
  140289. */
  140290. filename: string;
  140291. /**
  140292. * ISpriteJSONSpriteFrame basic object of the frame data
  140293. */
  140294. frame: ISpriteJSONSpriteFrameData;
  140295. /**
  140296. * boolean to flag is the frame was rotated.
  140297. */
  140298. rotated: boolean;
  140299. /**
  140300. * boolean to flag is the frame was trimmed.
  140301. */
  140302. trimmed: boolean;
  140303. /**
  140304. * ISpriteJSONSpriteFrame basic object of the source data
  140305. */
  140306. spriteSourceSize: ISpriteJSONSpriteFrameData;
  140307. /**
  140308. * ISpriteJSONSpriteFrame basic object of the source data
  140309. */
  140310. sourceSize: ISpriteJSONSpriteSourceSize;
  140311. }
  140312. /**
  140313. * Defines the basic options interface of a JSON atlas.
  140314. */
  140315. export interface ISpriteJSONAtlas {
  140316. /**
  140317. * Array of objects that contain the frame data.
  140318. */
  140319. frames: Array<ISpriteJSONSprite>;
  140320. /**
  140321. * object basic object containing the sprite meta data.
  140322. */
  140323. meta?: object;
  140324. }
  140325. }
  140326. declare module BABYLON {
  140327. /** @hidden */
  140328. export var spriteMapPixelShader: {
  140329. name: string;
  140330. shader: string;
  140331. };
  140332. }
  140333. declare module BABYLON {
  140334. /** @hidden */
  140335. export var spriteMapVertexShader: {
  140336. name: string;
  140337. shader: string;
  140338. };
  140339. }
  140340. declare module BABYLON {
  140341. /**
  140342. * Defines the basic options interface of a SpriteMap
  140343. */
  140344. export interface ISpriteMapOptions {
  140345. /**
  140346. * Vector2 of the number of cells in the grid.
  140347. */
  140348. stageSize?: Vector2;
  140349. /**
  140350. * Vector2 of the size of the output plane in World Units.
  140351. */
  140352. outputSize?: Vector2;
  140353. /**
  140354. * Vector3 of the position of the output plane in World Units.
  140355. */
  140356. outputPosition?: Vector3;
  140357. /**
  140358. * Vector3 of the rotation of the output plane.
  140359. */
  140360. outputRotation?: Vector3;
  140361. /**
  140362. * number of layers that the system will reserve in resources.
  140363. */
  140364. layerCount?: number;
  140365. /**
  140366. * number of max animation frames a single cell will reserve in resources.
  140367. */
  140368. maxAnimationFrames?: number;
  140369. /**
  140370. * number cell index of the base tile when the system compiles.
  140371. */
  140372. baseTile?: number;
  140373. /**
  140374. * boolean flip the sprite after its been repositioned by the framing data.
  140375. */
  140376. flipU?: boolean;
  140377. /**
  140378. * Vector3 scalar of the global RGB values of the SpriteMap.
  140379. */
  140380. colorMultiply?: Vector3;
  140381. }
  140382. /**
  140383. * Defines the IDisposable interface in order to be cleanable from resources.
  140384. */
  140385. export interface ISpriteMap extends IDisposable {
  140386. /**
  140387. * String name of the SpriteMap.
  140388. */
  140389. name: string;
  140390. /**
  140391. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140392. */
  140393. atlasJSON: ISpriteJSONAtlas;
  140394. /**
  140395. * Texture of the SpriteMap.
  140396. */
  140397. spriteSheet: Texture;
  140398. /**
  140399. * The parameters to initialize the SpriteMap with.
  140400. */
  140401. options: ISpriteMapOptions;
  140402. }
  140403. /**
  140404. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140405. */
  140406. export class SpriteMap implements ISpriteMap {
  140407. /** The Name of the spriteMap */
  140408. name: string;
  140409. /** The JSON file with the frame and meta data */
  140410. atlasJSON: ISpriteJSONAtlas;
  140411. /** The systems Sprite Sheet Texture */
  140412. spriteSheet: Texture;
  140413. /** Arguments passed with the Constructor */
  140414. options: ISpriteMapOptions;
  140415. /** Public Sprite Storage array, parsed from atlasJSON */
  140416. sprites: Array<ISpriteJSONSprite>;
  140417. /** Returns the Number of Sprites in the System */
  140418. get spriteCount(): number;
  140419. /** Returns the Position of Output Plane*/
  140420. get position(): Vector3;
  140421. /** Returns the Position of Output Plane*/
  140422. set position(v: Vector3);
  140423. /** Returns the Rotation of Output Plane*/
  140424. get rotation(): Vector3;
  140425. /** Returns the Rotation of Output Plane*/
  140426. set rotation(v: Vector3);
  140427. /** Sets the AnimationMap*/
  140428. get animationMap(): RawTexture;
  140429. /** Sets the AnimationMap*/
  140430. set animationMap(v: RawTexture);
  140431. /** Scene that the SpriteMap was created in */
  140432. private _scene;
  140433. /** Texture Buffer of Float32 that holds tile frame data*/
  140434. private _frameMap;
  140435. /** Texture Buffers of Float32 that holds tileMap data*/
  140436. private _tileMaps;
  140437. /** Texture Buffer of Float32 that holds Animation Data*/
  140438. private _animationMap;
  140439. /** Custom ShaderMaterial Central to the System*/
  140440. private _material;
  140441. /** Custom ShaderMaterial Central to the System*/
  140442. private _output;
  140443. /** Systems Time Ticker*/
  140444. private _time;
  140445. /**
  140446. * Creates a new SpriteMap
  140447. * @param name defines the SpriteMaps Name
  140448. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140449. * @param spriteSheet is the Texture that the Sprites are on.
  140450. * @param options a basic deployment configuration
  140451. * @param scene The Scene that the map is deployed on
  140452. */
  140453. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140454. /**
  140455. * Returns tileID location
  140456. * @returns Vector2 the cell position ID
  140457. */
  140458. getTileID(): Vector2;
  140459. /**
  140460. * Gets the UV location of the mouse over the SpriteMap.
  140461. * @returns Vector2 the UV position of the mouse interaction
  140462. */
  140463. getMousePosition(): Vector2;
  140464. /**
  140465. * Creates the "frame" texture Buffer
  140466. * -------------------------------------
  140467. * Structure of frames
  140468. * "filename": "Falling-Water-2.png",
  140469. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140470. * "rotated": true,
  140471. * "trimmed": true,
  140472. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140473. * "sourceSize": {"w":32,"h":32}
  140474. * @returns RawTexture of the frameMap
  140475. */
  140476. private _createFrameBuffer;
  140477. /**
  140478. * Creates the tileMap texture Buffer
  140479. * @param buffer normally and array of numbers, or a false to generate from scratch
  140480. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140481. * @returns RawTexture of the tileMap
  140482. */
  140483. private _createTileBuffer;
  140484. /**
  140485. * Modifies the data of the tileMaps
  140486. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140487. * @param pos is the iVector2 Coordinates of the Tile
  140488. * @param tile The SpriteIndex of the new Tile
  140489. */
  140490. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140491. /**
  140492. * Creates the animationMap texture Buffer
  140493. * @param buffer normally and array of numbers, or a false to generate from scratch
  140494. * @returns RawTexture of the animationMap
  140495. */
  140496. private _createTileAnimationBuffer;
  140497. /**
  140498. * Modifies the data of the animationMap
  140499. * @param cellID is the Index of the Sprite
  140500. * @param _frame is the target Animation frame
  140501. * @param toCell is the Target Index of the next frame of the animation
  140502. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140503. * @param speed is a global scalar of the time variable on the map.
  140504. */
  140505. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140506. /**
  140507. * Exports the .tilemaps file
  140508. */
  140509. saveTileMaps(): void;
  140510. /**
  140511. * Imports the .tilemaps file
  140512. * @param url of the .tilemaps file
  140513. */
  140514. loadTileMaps(url: string): void;
  140515. /**
  140516. * Release associated resources
  140517. */
  140518. dispose(): void;
  140519. }
  140520. }
  140521. declare module BABYLON {
  140522. /**
  140523. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140524. * @see http://doc.babylonjs.com/babylon101/sprites
  140525. */
  140526. export class SpritePackedManager extends SpriteManager {
  140527. /** defines the packed manager's name */
  140528. name: string;
  140529. /**
  140530. * Creates a new sprite manager from a packed sprite sheet
  140531. * @param name defines the manager's name
  140532. * @param imgUrl defines the sprite sheet url
  140533. * @param capacity defines the maximum allowed number of sprites
  140534. * @param scene defines the hosting scene
  140535. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140536. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140537. * @param samplingMode defines the smapling mode to use with spritesheet
  140538. * @param fromPacked set to true; do not alter
  140539. */
  140540. constructor(
  140541. /** defines the packed manager's name */
  140542. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140543. }
  140544. }
  140545. declare module BABYLON {
  140546. /**
  140547. * Defines the list of states available for a task inside a AssetsManager
  140548. */
  140549. export enum AssetTaskState {
  140550. /**
  140551. * Initialization
  140552. */
  140553. INIT = 0,
  140554. /**
  140555. * Running
  140556. */
  140557. RUNNING = 1,
  140558. /**
  140559. * Done
  140560. */
  140561. DONE = 2,
  140562. /**
  140563. * Error
  140564. */
  140565. ERROR = 3
  140566. }
  140567. /**
  140568. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140569. */
  140570. export abstract class AbstractAssetTask {
  140571. /**
  140572. * Task name
  140573. */ name: string;
  140574. /**
  140575. * Callback called when the task is successful
  140576. */
  140577. onSuccess: (task: any) => void;
  140578. /**
  140579. * Callback called when the task is not successful
  140580. */
  140581. onError: (task: any, message?: string, exception?: any) => void;
  140582. /**
  140583. * Creates a new AssetsManager
  140584. * @param name defines the name of the task
  140585. */
  140586. constructor(
  140587. /**
  140588. * Task name
  140589. */ name: string);
  140590. private _isCompleted;
  140591. private _taskState;
  140592. private _errorObject;
  140593. /**
  140594. * Get if the task is completed
  140595. */
  140596. get isCompleted(): boolean;
  140597. /**
  140598. * Gets the current state of the task
  140599. */
  140600. get taskState(): AssetTaskState;
  140601. /**
  140602. * Gets the current error object (if task is in error)
  140603. */
  140604. get errorObject(): {
  140605. message?: string;
  140606. exception?: any;
  140607. };
  140608. /**
  140609. * Internal only
  140610. * @hidden
  140611. */
  140612. _setErrorObject(message?: string, exception?: any): void;
  140613. /**
  140614. * Execute the current task
  140615. * @param scene defines the scene where you want your assets to be loaded
  140616. * @param onSuccess is a callback called when the task is successfully executed
  140617. * @param onError is a callback called if an error occurs
  140618. */
  140619. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140620. /**
  140621. * Execute the current task
  140622. * @param scene defines the scene where you want your assets to be loaded
  140623. * @param onSuccess is a callback called when the task is successfully executed
  140624. * @param onError is a callback called if an error occurs
  140625. */
  140626. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140627. /**
  140628. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140629. * This can be used with failed tasks that have the reason for failure fixed.
  140630. */
  140631. reset(): void;
  140632. private onErrorCallback;
  140633. private onDoneCallback;
  140634. }
  140635. /**
  140636. * Define the interface used by progress events raised during assets loading
  140637. */
  140638. export interface IAssetsProgressEvent {
  140639. /**
  140640. * Defines the number of remaining tasks to process
  140641. */
  140642. remainingCount: number;
  140643. /**
  140644. * Defines the total number of tasks
  140645. */
  140646. totalCount: number;
  140647. /**
  140648. * Defines the task that was just processed
  140649. */
  140650. task: AbstractAssetTask;
  140651. }
  140652. /**
  140653. * Class used to share progress information about assets loading
  140654. */
  140655. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140656. /**
  140657. * Defines the number of remaining tasks to process
  140658. */
  140659. remainingCount: number;
  140660. /**
  140661. * Defines the total number of tasks
  140662. */
  140663. totalCount: number;
  140664. /**
  140665. * Defines the task that was just processed
  140666. */
  140667. task: AbstractAssetTask;
  140668. /**
  140669. * Creates a AssetsProgressEvent
  140670. * @param remainingCount defines the number of remaining tasks to process
  140671. * @param totalCount defines the total number of tasks
  140672. * @param task defines the task that was just processed
  140673. */
  140674. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140675. }
  140676. /**
  140677. * Define a task used by AssetsManager to load meshes
  140678. */
  140679. export class MeshAssetTask extends AbstractAssetTask {
  140680. /**
  140681. * Defines the name of the task
  140682. */
  140683. name: string;
  140684. /**
  140685. * Defines the list of mesh's names you want to load
  140686. */
  140687. meshesNames: any;
  140688. /**
  140689. * Defines the root url to use as a base to load your meshes and associated resources
  140690. */
  140691. rootUrl: string;
  140692. /**
  140693. * Defines the filename of the scene to load from
  140694. */
  140695. sceneFilename: string;
  140696. /**
  140697. * Gets the list of loaded meshes
  140698. */
  140699. loadedMeshes: Array<AbstractMesh>;
  140700. /**
  140701. * Gets the list of loaded particle systems
  140702. */
  140703. loadedParticleSystems: Array<IParticleSystem>;
  140704. /**
  140705. * Gets the list of loaded skeletons
  140706. */
  140707. loadedSkeletons: Array<Skeleton>;
  140708. /**
  140709. * Gets the list of loaded animation groups
  140710. */
  140711. loadedAnimationGroups: Array<AnimationGroup>;
  140712. /**
  140713. * Callback called when the task is successful
  140714. */
  140715. onSuccess: (task: MeshAssetTask) => void;
  140716. /**
  140717. * Callback called when the task is successful
  140718. */
  140719. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140720. /**
  140721. * Creates a new MeshAssetTask
  140722. * @param name defines the name of the task
  140723. * @param meshesNames defines the list of mesh's names you want to load
  140724. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140725. * @param sceneFilename defines the filename of the scene to load from
  140726. */
  140727. constructor(
  140728. /**
  140729. * Defines the name of the task
  140730. */
  140731. name: string,
  140732. /**
  140733. * Defines the list of mesh's names you want to load
  140734. */
  140735. meshesNames: any,
  140736. /**
  140737. * Defines the root url to use as a base to load your meshes and associated resources
  140738. */
  140739. rootUrl: string,
  140740. /**
  140741. * Defines the filename of the scene to load from
  140742. */
  140743. sceneFilename: string);
  140744. /**
  140745. * Execute the current task
  140746. * @param scene defines the scene where you want your assets to be loaded
  140747. * @param onSuccess is a callback called when the task is successfully executed
  140748. * @param onError is a callback called if an error occurs
  140749. */
  140750. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140751. }
  140752. /**
  140753. * Define a task used by AssetsManager to load text content
  140754. */
  140755. export class TextFileAssetTask extends AbstractAssetTask {
  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. * Gets the loaded text string
  140766. */
  140767. text: string;
  140768. /**
  140769. * Callback called when the task is successful
  140770. */
  140771. onSuccess: (task: TextFileAssetTask) => void;
  140772. /**
  140773. * Callback called when the task is successful
  140774. */
  140775. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140776. /**
  140777. * Creates a new TextFileAssetTask object
  140778. * @param name defines the name of the task
  140779. * @param url defines the location of the file to load
  140780. */
  140781. constructor(
  140782. /**
  140783. * Defines the name of the task
  140784. */
  140785. name: string,
  140786. /**
  140787. * Defines the location of the file to load
  140788. */
  140789. url: string);
  140790. /**
  140791. * Execute the current task
  140792. * @param scene defines the scene where you want your assets to be loaded
  140793. * @param onSuccess is a callback called when the task is successfully executed
  140794. * @param onError is a callback called if an error occurs
  140795. */
  140796. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140797. }
  140798. /**
  140799. * Define a task used by AssetsManager to load binary data
  140800. */
  140801. export class BinaryFileAssetTask extends AbstractAssetTask {
  140802. /**
  140803. * Defines the name of the task
  140804. */
  140805. name: string;
  140806. /**
  140807. * Defines the location of the file to load
  140808. */
  140809. url: string;
  140810. /**
  140811. * Gets the lodaded data (as an array buffer)
  140812. */
  140813. data: ArrayBuffer;
  140814. /**
  140815. * Callback called when the task is successful
  140816. */
  140817. onSuccess: (task: BinaryFileAssetTask) => void;
  140818. /**
  140819. * Callback called when the task is successful
  140820. */
  140821. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140822. /**
  140823. * Creates a new BinaryFileAssetTask object
  140824. * @param name defines the name of the new task
  140825. * @param url defines the location of the file to load
  140826. */
  140827. constructor(
  140828. /**
  140829. * Defines the name of the task
  140830. */
  140831. name: string,
  140832. /**
  140833. * Defines the location of the file to load
  140834. */
  140835. url: string);
  140836. /**
  140837. * Execute the current task
  140838. * @param scene defines the scene where you want your assets to be loaded
  140839. * @param onSuccess is a callback called when the task is successfully executed
  140840. * @param onError is a callback called if an error occurs
  140841. */
  140842. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140843. }
  140844. /**
  140845. * Define a task used by AssetsManager to load images
  140846. */
  140847. export class ImageAssetTask extends AbstractAssetTask {
  140848. /**
  140849. * Defines the name of the task
  140850. */
  140851. name: string;
  140852. /**
  140853. * Defines the location of the image to load
  140854. */
  140855. url: string;
  140856. /**
  140857. * Gets the loaded images
  140858. */
  140859. image: HTMLImageElement;
  140860. /**
  140861. * Callback called when the task is successful
  140862. */
  140863. onSuccess: (task: ImageAssetTask) => void;
  140864. /**
  140865. * Callback called when the task is successful
  140866. */
  140867. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140868. /**
  140869. * Creates a new ImageAssetTask
  140870. * @param name defines the name of the task
  140871. * @param url defines the location of the image to load
  140872. */
  140873. constructor(
  140874. /**
  140875. * Defines the name of the task
  140876. */
  140877. name: string,
  140878. /**
  140879. * Defines the location of the image to load
  140880. */
  140881. url: string);
  140882. /**
  140883. * Execute the current task
  140884. * @param scene defines the scene where you want your assets to be loaded
  140885. * @param onSuccess is a callback called when the task is successfully executed
  140886. * @param onError is a callback called if an error occurs
  140887. */
  140888. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140889. }
  140890. /**
  140891. * Defines the interface used by texture loading tasks
  140892. */
  140893. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140894. /**
  140895. * Gets the loaded texture
  140896. */
  140897. texture: TEX;
  140898. }
  140899. /**
  140900. * Define a task used by AssetsManager to load 2D textures
  140901. */
  140902. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140903. /**
  140904. * Defines the name of the task
  140905. */
  140906. name: string;
  140907. /**
  140908. * Defines the location of the file to load
  140909. */
  140910. url: string;
  140911. /**
  140912. * Defines if mipmap should not be generated (default is false)
  140913. */
  140914. noMipmap?: boolean | undefined;
  140915. /**
  140916. * Defines if texture must be inverted on Y axis (default is false)
  140917. */
  140918. invertY?: boolean | undefined;
  140919. /**
  140920. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140921. */
  140922. samplingMode: number;
  140923. /**
  140924. * Gets the loaded texture
  140925. */
  140926. texture: Texture;
  140927. /**
  140928. * Callback called when the task is successful
  140929. */
  140930. onSuccess: (task: TextureAssetTask) => void;
  140931. /**
  140932. * Callback called when the task is successful
  140933. */
  140934. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140935. /**
  140936. * Creates a new TextureAssetTask object
  140937. * @param name defines the name of the task
  140938. * @param url defines the location of the file to load
  140939. * @param noMipmap defines if mipmap should not be generated (default is false)
  140940. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140941. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140942. */
  140943. constructor(
  140944. /**
  140945. * Defines the name of the task
  140946. */
  140947. name: string,
  140948. /**
  140949. * Defines the location of the file to load
  140950. */
  140951. url: string,
  140952. /**
  140953. * Defines if mipmap should not be generated (default is false)
  140954. */
  140955. noMipmap?: boolean | undefined,
  140956. /**
  140957. * Defines if texture must be inverted on Y axis (default is false)
  140958. */
  140959. invertY?: boolean | undefined,
  140960. /**
  140961. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140962. */
  140963. samplingMode?: number);
  140964. /**
  140965. * Execute the current task
  140966. * @param scene defines the scene where you want your assets to be loaded
  140967. * @param onSuccess is a callback called when the task is successfully executed
  140968. * @param onError is a callback called if an error occurs
  140969. */
  140970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140971. }
  140972. /**
  140973. * Define a task used by AssetsManager to load cube textures
  140974. */
  140975. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140976. /**
  140977. * Defines the name of the task
  140978. */
  140979. name: string;
  140980. /**
  140981. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140982. */
  140983. url: string;
  140984. /**
  140985. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140986. */
  140987. extensions?: string[] | undefined;
  140988. /**
  140989. * Defines if mipmaps should not be generated (default is false)
  140990. */
  140991. noMipmap?: boolean | undefined;
  140992. /**
  140993. * Defines the explicit list of files (undefined by default)
  140994. */
  140995. files?: string[] | undefined;
  140996. /**
  140997. * Gets the loaded texture
  140998. */
  140999. texture: CubeTexture;
  141000. /**
  141001. * Callback called when the task is successful
  141002. */
  141003. onSuccess: (task: CubeTextureAssetTask) => void;
  141004. /**
  141005. * Callback called when the task is successful
  141006. */
  141007. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  141008. /**
  141009. * Creates a new CubeTextureAssetTask
  141010. * @param name defines the name of the task
  141011. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  141012. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  141013. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141014. * @param files defines the explicit list of files (undefined by default)
  141015. */
  141016. constructor(
  141017. /**
  141018. * Defines the name of the task
  141019. */
  141020. name: string,
  141021. /**
  141022. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  141023. */
  141024. url: string,
  141025. /**
  141026. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  141027. */
  141028. extensions?: string[] | undefined,
  141029. /**
  141030. * Defines if mipmaps should not be generated (default is false)
  141031. */
  141032. noMipmap?: boolean | undefined,
  141033. /**
  141034. * Defines the explicit list of files (undefined by default)
  141035. */
  141036. files?: string[] | undefined);
  141037. /**
  141038. * Execute the current task
  141039. * @param scene defines the scene where you want your assets to be loaded
  141040. * @param onSuccess is a callback called when the task is successfully executed
  141041. * @param onError is a callback called if an error occurs
  141042. */
  141043. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141044. }
  141045. /**
  141046. * Define a task used by AssetsManager to load HDR cube textures
  141047. */
  141048. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  141049. /**
  141050. * Defines the name of the task
  141051. */
  141052. name: string;
  141053. /**
  141054. * Defines the location of the file to load
  141055. */
  141056. url: string;
  141057. /**
  141058. * Defines the desired size (the more it increases the longer the generation will be)
  141059. */
  141060. size: number;
  141061. /**
  141062. * Defines if mipmaps should not be generated (default is false)
  141063. */
  141064. noMipmap: boolean;
  141065. /**
  141066. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141067. */
  141068. generateHarmonics: boolean;
  141069. /**
  141070. * 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)
  141071. */
  141072. gammaSpace: boolean;
  141073. /**
  141074. * Internal Use Only
  141075. */
  141076. reserved: boolean;
  141077. /**
  141078. * Gets the loaded texture
  141079. */
  141080. texture: HDRCubeTexture;
  141081. /**
  141082. * Callback called when the task is successful
  141083. */
  141084. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  141085. /**
  141086. * Callback called when the task is successful
  141087. */
  141088. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  141089. /**
  141090. * Creates a new HDRCubeTextureAssetTask object
  141091. * @param name defines the name of the task
  141092. * @param url defines the location of the file to load
  141093. * @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.
  141094. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141095. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141096. * @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)
  141097. * @param reserved Internal use only
  141098. */
  141099. constructor(
  141100. /**
  141101. * Defines the name of the task
  141102. */
  141103. name: string,
  141104. /**
  141105. * Defines the location of the file to load
  141106. */
  141107. url: string,
  141108. /**
  141109. * Defines the desired size (the more it increases the longer the generation will be)
  141110. */
  141111. size: number,
  141112. /**
  141113. * Defines if mipmaps should not be generated (default is false)
  141114. */
  141115. noMipmap?: boolean,
  141116. /**
  141117. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141118. */
  141119. generateHarmonics?: boolean,
  141120. /**
  141121. * 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)
  141122. */
  141123. gammaSpace?: boolean,
  141124. /**
  141125. * Internal Use Only
  141126. */
  141127. reserved?: boolean);
  141128. /**
  141129. * Execute the current task
  141130. * @param scene defines the scene where you want your assets to be loaded
  141131. * @param onSuccess is a callback called when the task is successfully executed
  141132. * @param onError is a callback called if an error occurs
  141133. */
  141134. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141135. }
  141136. /**
  141137. * Define a task used by AssetsManager to load Equirectangular cube textures
  141138. */
  141139. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  141140. /**
  141141. * Defines the name of the task
  141142. */
  141143. name: string;
  141144. /**
  141145. * Defines the location of the file to load
  141146. */
  141147. url: string;
  141148. /**
  141149. * Defines the desired size (the more it increases the longer the generation will be)
  141150. */
  141151. size: number;
  141152. /**
  141153. * Defines if mipmaps should not be generated (default is false)
  141154. */
  141155. noMipmap: boolean;
  141156. /**
  141157. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141158. * but the standard material would require them in Gamma space) (default is true)
  141159. */
  141160. gammaSpace: boolean;
  141161. /**
  141162. * Gets the loaded texture
  141163. */
  141164. texture: EquiRectangularCubeTexture;
  141165. /**
  141166. * Callback called when the task is successful
  141167. */
  141168. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  141169. /**
  141170. * Callback called when the task is successful
  141171. */
  141172. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  141173. /**
  141174. * Creates a new EquiRectangularCubeTextureAssetTask object
  141175. * @param name defines the name of the task
  141176. * @param url defines the location of the file to load
  141177. * @param size defines the desired size (the more it increases the longer the generation will be)
  141178. * If the size is omitted this implies you are using a preprocessed cubemap.
  141179. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141180. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  141181. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  141182. * (default is true)
  141183. */
  141184. constructor(
  141185. /**
  141186. * Defines the name of the task
  141187. */
  141188. name: string,
  141189. /**
  141190. * Defines the location of the file to load
  141191. */
  141192. url: string,
  141193. /**
  141194. * Defines the desired size (the more it increases the longer the generation will be)
  141195. */
  141196. size: number,
  141197. /**
  141198. * Defines if mipmaps should not be generated (default is false)
  141199. */
  141200. noMipmap?: boolean,
  141201. /**
  141202. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141203. * but the standard material would require them in Gamma space) (default is true)
  141204. */
  141205. gammaSpace?: boolean);
  141206. /**
  141207. * Execute the current task
  141208. * @param scene defines the scene where you want your assets to be loaded
  141209. * @param onSuccess is a callback called when the task is successfully executed
  141210. * @param onError is a callback called if an error occurs
  141211. */
  141212. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141213. }
  141214. /**
  141215. * This class can be used to easily import assets into a scene
  141216. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  141217. */
  141218. export class AssetsManager {
  141219. private _scene;
  141220. private _isLoading;
  141221. protected _tasks: AbstractAssetTask[];
  141222. protected _waitingTasksCount: number;
  141223. protected _totalTasksCount: number;
  141224. /**
  141225. * Callback called when all tasks are processed
  141226. */
  141227. onFinish: (tasks: AbstractAssetTask[]) => void;
  141228. /**
  141229. * Callback called when a task is successful
  141230. */
  141231. onTaskSuccess: (task: AbstractAssetTask) => void;
  141232. /**
  141233. * Callback called when a task had an error
  141234. */
  141235. onTaskError: (task: AbstractAssetTask) => void;
  141236. /**
  141237. * Callback called when a task is done (whatever the result is)
  141238. */
  141239. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  141240. /**
  141241. * Observable called when all tasks are processed
  141242. */
  141243. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  141244. /**
  141245. * Observable called when a task had an error
  141246. */
  141247. onTaskErrorObservable: Observable<AbstractAssetTask>;
  141248. /**
  141249. * Observable called when all tasks were executed
  141250. */
  141251. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  141252. /**
  141253. * Observable called when a task is done (whatever the result is)
  141254. */
  141255. onProgressObservable: Observable<IAssetsProgressEvent>;
  141256. /**
  141257. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  141258. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  141259. */
  141260. useDefaultLoadingScreen: boolean;
  141261. /**
  141262. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  141263. * when all assets have been downloaded.
  141264. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  141265. */
  141266. autoHideLoadingUI: boolean;
  141267. /**
  141268. * Creates a new AssetsManager
  141269. * @param scene defines the scene to work on
  141270. */
  141271. constructor(scene: Scene);
  141272. /**
  141273. * Add a MeshAssetTask to the list of active tasks
  141274. * @param taskName defines the name of the new task
  141275. * @param meshesNames defines the name of meshes to load
  141276. * @param rootUrl defines the root url to use to locate files
  141277. * @param sceneFilename defines the filename of the scene file
  141278. * @returns a new MeshAssetTask object
  141279. */
  141280. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  141281. /**
  141282. * Add a TextFileAssetTask to the list of active tasks
  141283. * @param taskName defines the name of the new task
  141284. * @param url defines the url of the file to load
  141285. * @returns a new TextFileAssetTask object
  141286. */
  141287. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  141288. /**
  141289. * Add a BinaryFileAssetTask to the list of active tasks
  141290. * @param taskName defines the name of the new task
  141291. * @param url defines the url of the file to load
  141292. * @returns a new BinaryFileAssetTask object
  141293. */
  141294. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  141295. /**
  141296. * Add a ImageAssetTask to the list of active tasks
  141297. * @param taskName defines the name of the new task
  141298. * @param url defines the url of the file to load
  141299. * @returns a new ImageAssetTask object
  141300. */
  141301. addImageTask(taskName: string, url: string): ImageAssetTask;
  141302. /**
  141303. * Add a TextureAssetTask to the list of active tasks
  141304. * @param taskName defines the name of the new task
  141305. * @param url defines the url of the file to load
  141306. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141307. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  141308. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141309. * @returns a new TextureAssetTask object
  141310. */
  141311. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  141312. /**
  141313. * Add a CubeTextureAssetTask to the list of active tasks
  141314. * @param taskName defines the name of the new task
  141315. * @param url defines the url of the file to load
  141316. * @param extensions defines the extension to use to load the cube map (can be null)
  141317. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141318. * @param files defines the list of files to load (can be null)
  141319. * @returns a new CubeTextureAssetTask object
  141320. */
  141321. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  141322. /**
  141323. *
  141324. * Add a HDRCubeTextureAssetTask to the list of active tasks
  141325. * @param taskName defines the name of the new task
  141326. * @param url defines the url of the file to load
  141327. * @param size defines the size you want for the cubemap (can be null)
  141328. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141329. * @param generateHarmonics defines if you want to automatically generate (true by default)
  141330. * @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)
  141331. * @param reserved Internal use only
  141332. * @returns a new HDRCubeTextureAssetTask object
  141333. */
  141334. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  141335. /**
  141336. *
  141337. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  141338. * @param taskName defines the name of the new task
  141339. * @param url defines the url of the file to load
  141340. * @param size defines the size you want for the cubemap (can be null)
  141341. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141342. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141343. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141344. * @returns a new EquiRectangularCubeTextureAssetTask object
  141345. */
  141346. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141347. /**
  141348. * Remove a task from the assets manager.
  141349. * @param task the task to remove
  141350. */
  141351. removeTask(task: AbstractAssetTask): void;
  141352. private _decreaseWaitingTasksCount;
  141353. private _runTask;
  141354. /**
  141355. * Reset the AssetsManager and remove all tasks
  141356. * @return the current instance of the AssetsManager
  141357. */
  141358. reset(): AssetsManager;
  141359. /**
  141360. * Start the loading process
  141361. * @return the current instance of the AssetsManager
  141362. */
  141363. load(): AssetsManager;
  141364. /**
  141365. * Start the loading process as an async operation
  141366. * @return a promise returning the list of failed tasks
  141367. */
  141368. loadAsync(): Promise<void>;
  141369. }
  141370. }
  141371. declare module BABYLON {
  141372. /**
  141373. * Wrapper class for promise with external resolve and reject.
  141374. */
  141375. export class Deferred<T> {
  141376. /**
  141377. * The promise associated with this deferred object.
  141378. */
  141379. readonly promise: Promise<T>;
  141380. private _resolve;
  141381. private _reject;
  141382. /**
  141383. * The resolve method of the promise associated with this deferred object.
  141384. */
  141385. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141386. /**
  141387. * The reject method of the promise associated with this deferred object.
  141388. */
  141389. get reject(): (reason?: any) => void;
  141390. /**
  141391. * Constructor for this deferred object.
  141392. */
  141393. constructor();
  141394. }
  141395. }
  141396. declare module BABYLON {
  141397. /**
  141398. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141399. */
  141400. export class MeshExploder {
  141401. private _centerMesh;
  141402. private _meshes;
  141403. private _meshesOrigins;
  141404. private _toCenterVectors;
  141405. private _scaledDirection;
  141406. private _newPosition;
  141407. private _centerPosition;
  141408. /**
  141409. * Explodes meshes from a center mesh.
  141410. * @param meshes The meshes to explode.
  141411. * @param centerMesh The mesh to be center of explosion.
  141412. */
  141413. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141414. private _setCenterMesh;
  141415. /**
  141416. * Get class name
  141417. * @returns "MeshExploder"
  141418. */
  141419. getClassName(): string;
  141420. /**
  141421. * "Exploded meshes"
  141422. * @returns Array of meshes with the centerMesh at index 0.
  141423. */
  141424. getMeshes(): Array<Mesh>;
  141425. /**
  141426. * Explodes meshes giving a specific direction
  141427. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141428. */
  141429. explode(direction?: number): void;
  141430. }
  141431. }
  141432. declare module BABYLON {
  141433. /**
  141434. * Class used to help managing file picking and drag'n'drop
  141435. */
  141436. export class FilesInput {
  141437. /**
  141438. * List of files ready to be loaded
  141439. */
  141440. static get FilesToLoad(): {
  141441. [key: string]: File;
  141442. };
  141443. /**
  141444. * Callback called when a file is processed
  141445. */
  141446. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141447. private _engine;
  141448. private _currentScene;
  141449. private _sceneLoadedCallback;
  141450. private _progressCallback;
  141451. private _additionalRenderLoopLogicCallback;
  141452. private _textureLoadingCallback;
  141453. private _startingProcessingFilesCallback;
  141454. private _onReloadCallback;
  141455. private _errorCallback;
  141456. private _elementToMonitor;
  141457. private _sceneFileToLoad;
  141458. private _filesToLoad;
  141459. /**
  141460. * Creates a new FilesInput
  141461. * @param engine defines the rendering engine
  141462. * @param scene defines the hosting scene
  141463. * @param sceneLoadedCallback callback called when scene is loaded
  141464. * @param progressCallback callback called to track progress
  141465. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141466. * @param textureLoadingCallback callback called when a texture is loading
  141467. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141468. * @param onReloadCallback callback called when a reload is requested
  141469. * @param errorCallback callback call if an error occurs
  141470. */
  141471. 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);
  141472. private _dragEnterHandler;
  141473. private _dragOverHandler;
  141474. private _dropHandler;
  141475. /**
  141476. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141477. * @param elementToMonitor defines the DOM element to track
  141478. */
  141479. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141480. /**
  141481. * Release all associated resources
  141482. */
  141483. dispose(): void;
  141484. private renderFunction;
  141485. private drag;
  141486. private drop;
  141487. private _traverseFolder;
  141488. private _processFiles;
  141489. /**
  141490. * Load files from a drop event
  141491. * @param event defines the drop event to use as source
  141492. */
  141493. loadFiles(event: any): void;
  141494. private _processReload;
  141495. /**
  141496. * Reload the current scene from the loaded files
  141497. */
  141498. reload(): void;
  141499. }
  141500. }
  141501. declare module BABYLON {
  141502. /**
  141503. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141504. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141505. */
  141506. export class SceneOptimization {
  141507. /**
  141508. * Defines the priority of this optimization (0 by default which means first in the list)
  141509. */
  141510. priority: number;
  141511. /**
  141512. * Gets a string describing the action executed by the current optimization
  141513. * @returns description string
  141514. */
  141515. getDescription(): string;
  141516. /**
  141517. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141518. * @param scene defines the current scene where to apply this optimization
  141519. * @param optimizer defines the current optimizer
  141520. * @returns true if everything that can be done was applied
  141521. */
  141522. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141523. /**
  141524. * Creates the SceneOptimization object
  141525. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141526. * @param desc defines the description associated with the optimization
  141527. */
  141528. constructor(
  141529. /**
  141530. * Defines the priority of this optimization (0 by default which means first in the list)
  141531. */
  141532. priority?: number);
  141533. }
  141534. /**
  141535. * Defines an optimization used to reduce the size of render target textures
  141536. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141537. */
  141538. export class TextureOptimization extends SceneOptimization {
  141539. /**
  141540. * Defines the priority of this optimization (0 by default which means first in the list)
  141541. */
  141542. priority: number;
  141543. /**
  141544. * 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
  141545. */
  141546. maximumSize: number;
  141547. /**
  141548. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141549. */
  141550. step: number;
  141551. /**
  141552. * Gets a string describing the action executed by the current optimization
  141553. * @returns description string
  141554. */
  141555. getDescription(): string;
  141556. /**
  141557. * Creates the TextureOptimization object
  141558. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141559. * @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
  141560. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141561. */
  141562. constructor(
  141563. /**
  141564. * Defines the priority of this optimization (0 by default which means first in the list)
  141565. */
  141566. priority?: number,
  141567. /**
  141568. * 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
  141569. */
  141570. maximumSize?: number,
  141571. /**
  141572. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141573. */
  141574. step?: number);
  141575. /**
  141576. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141577. * @param scene defines the current scene where to apply this optimization
  141578. * @param optimizer defines the current optimizer
  141579. * @returns true if everything that can be done was applied
  141580. */
  141581. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141582. }
  141583. /**
  141584. * Defines an optimization used to increase or decrease the rendering resolution
  141585. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141586. */
  141587. export class HardwareScalingOptimization extends SceneOptimization {
  141588. /**
  141589. * Defines the priority of this optimization (0 by default which means first in the list)
  141590. */
  141591. priority: number;
  141592. /**
  141593. * Defines the maximum scale to use (2 by default)
  141594. */
  141595. maximumScale: number;
  141596. /**
  141597. * Defines the step to use between two passes (0.5 by default)
  141598. */
  141599. step: number;
  141600. private _currentScale;
  141601. private _directionOffset;
  141602. /**
  141603. * Gets a string describing the action executed by the current optimization
  141604. * @return description string
  141605. */
  141606. getDescription(): string;
  141607. /**
  141608. * Creates the HardwareScalingOptimization object
  141609. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141610. * @param maximumScale defines the maximum scale to use (2 by default)
  141611. * @param step defines the step to use between two passes (0.5 by default)
  141612. */
  141613. constructor(
  141614. /**
  141615. * Defines the priority of this optimization (0 by default which means first in the list)
  141616. */
  141617. priority?: number,
  141618. /**
  141619. * Defines the maximum scale to use (2 by default)
  141620. */
  141621. maximumScale?: number,
  141622. /**
  141623. * Defines the step to use between two passes (0.5 by default)
  141624. */
  141625. step?: number);
  141626. /**
  141627. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141628. * @param scene defines the current scene where to apply this optimization
  141629. * @param optimizer defines the current optimizer
  141630. * @returns true if everything that can be done was applied
  141631. */
  141632. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141633. }
  141634. /**
  141635. * Defines an optimization used to remove shadows
  141636. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141637. */
  141638. export class ShadowsOptimization extends SceneOptimization {
  141639. /**
  141640. * Gets a string describing the action executed by the current optimization
  141641. * @return description string
  141642. */
  141643. getDescription(): string;
  141644. /**
  141645. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141646. * @param scene defines the current scene where to apply this optimization
  141647. * @param optimizer defines the current optimizer
  141648. * @returns true if everything that can be done was applied
  141649. */
  141650. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141651. }
  141652. /**
  141653. * Defines an optimization used to turn post-processes off
  141654. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141655. */
  141656. export class PostProcessesOptimization extends SceneOptimization {
  141657. /**
  141658. * Gets a string describing the action executed by the current optimization
  141659. * @return description string
  141660. */
  141661. getDescription(): string;
  141662. /**
  141663. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141664. * @param scene defines the current scene where to apply this optimization
  141665. * @param optimizer defines the current optimizer
  141666. * @returns true if everything that can be done was applied
  141667. */
  141668. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141669. }
  141670. /**
  141671. * Defines an optimization used to turn lens flares off
  141672. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141673. */
  141674. export class LensFlaresOptimization extends SceneOptimization {
  141675. /**
  141676. * Gets a string describing the action executed by the current optimization
  141677. * @return description string
  141678. */
  141679. getDescription(): string;
  141680. /**
  141681. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141682. * @param scene defines the current scene where to apply this optimization
  141683. * @param optimizer defines the current optimizer
  141684. * @returns true if everything that can be done was applied
  141685. */
  141686. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141687. }
  141688. /**
  141689. * Defines an optimization based on user defined callback.
  141690. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141691. */
  141692. export class CustomOptimization extends SceneOptimization {
  141693. /**
  141694. * Callback called to apply the custom optimization.
  141695. */
  141696. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141697. /**
  141698. * Callback called to get custom description
  141699. */
  141700. onGetDescription: () => string;
  141701. /**
  141702. * Gets a string describing the action executed by the current optimization
  141703. * @returns description string
  141704. */
  141705. getDescription(): string;
  141706. /**
  141707. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141708. * @param scene defines the current scene where to apply this optimization
  141709. * @param optimizer defines the current optimizer
  141710. * @returns true if everything that can be done was applied
  141711. */
  141712. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141713. }
  141714. /**
  141715. * Defines an optimization used to turn particles off
  141716. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141717. */
  141718. export class ParticlesOptimization extends SceneOptimization {
  141719. /**
  141720. * Gets a string describing the action executed by the current optimization
  141721. * @return description string
  141722. */
  141723. getDescription(): string;
  141724. /**
  141725. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141726. * @param scene defines the current scene where to apply this optimization
  141727. * @param optimizer defines the current optimizer
  141728. * @returns true if everything that can be done was applied
  141729. */
  141730. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141731. }
  141732. /**
  141733. * Defines an optimization used to turn render targets off
  141734. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141735. */
  141736. export class RenderTargetsOptimization extends SceneOptimization {
  141737. /**
  141738. * Gets a string describing the action executed by the current optimization
  141739. * @return description string
  141740. */
  141741. getDescription(): string;
  141742. /**
  141743. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141744. * @param scene defines the current scene where to apply this optimization
  141745. * @param optimizer defines the current optimizer
  141746. * @returns true if everything that can be done was applied
  141747. */
  141748. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141749. }
  141750. /**
  141751. * Defines an optimization used to merge meshes with compatible materials
  141752. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141753. */
  141754. export class MergeMeshesOptimization extends SceneOptimization {
  141755. private static _UpdateSelectionTree;
  141756. /**
  141757. * Gets or sets a boolean which defines if optimization octree has to be updated
  141758. */
  141759. static get UpdateSelectionTree(): boolean;
  141760. /**
  141761. * Gets or sets a boolean which defines if optimization octree has to be updated
  141762. */
  141763. static set UpdateSelectionTree(value: boolean);
  141764. /**
  141765. * Gets a string describing the action executed by the current optimization
  141766. * @return description string
  141767. */
  141768. getDescription(): string;
  141769. private _canBeMerged;
  141770. /**
  141771. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141772. * @param scene defines the current scene where to apply this optimization
  141773. * @param optimizer defines the current optimizer
  141774. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141775. * @returns true if everything that can be done was applied
  141776. */
  141777. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141778. }
  141779. /**
  141780. * Defines a list of options used by SceneOptimizer
  141781. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141782. */
  141783. export class SceneOptimizerOptions {
  141784. /**
  141785. * Defines the target frame rate to reach (60 by default)
  141786. */
  141787. targetFrameRate: number;
  141788. /**
  141789. * Defines the interval between two checkes (2000ms by default)
  141790. */
  141791. trackerDuration: number;
  141792. /**
  141793. * Gets the list of optimizations to apply
  141794. */
  141795. optimizations: SceneOptimization[];
  141796. /**
  141797. * Creates a new list of options used by SceneOptimizer
  141798. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141799. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141800. */
  141801. constructor(
  141802. /**
  141803. * Defines the target frame rate to reach (60 by default)
  141804. */
  141805. targetFrameRate?: number,
  141806. /**
  141807. * Defines the interval between two checkes (2000ms by default)
  141808. */
  141809. trackerDuration?: number);
  141810. /**
  141811. * Add a new optimization
  141812. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141813. * @returns the current SceneOptimizerOptions
  141814. */
  141815. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141816. /**
  141817. * Add a new custom optimization
  141818. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141819. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141820. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141821. * @returns the current SceneOptimizerOptions
  141822. */
  141823. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141824. /**
  141825. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141826. * @param targetFrameRate defines the target frame rate (60 by default)
  141827. * @returns a SceneOptimizerOptions object
  141828. */
  141829. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141830. /**
  141831. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141832. * @param targetFrameRate defines the target frame rate (60 by default)
  141833. * @returns a SceneOptimizerOptions object
  141834. */
  141835. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141836. /**
  141837. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141838. * @param targetFrameRate defines the target frame rate (60 by default)
  141839. * @returns a SceneOptimizerOptions object
  141840. */
  141841. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141842. }
  141843. /**
  141844. * Class used to run optimizations in order to reach a target frame rate
  141845. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141846. */
  141847. export class SceneOptimizer implements IDisposable {
  141848. private _isRunning;
  141849. private _options;
  141850. private _scene;
  141851. private _currentPriorityLevel;
  141852. private _targetFrameRate;
  141853. private _trackerDuration;
  141854. private _currentFrameRate;
  141855. private _sceneDisposeObserver;
  141856. private _improvementMode;
  141857. /**
  141858. * Defines an observable called when the optimizer reaches the target frame rate
  141859. */
  141860. onSuccessObservable: Observable<SceneOptimizer>;
  141861. /**
  141862. * Defines an observable called when the optimizer enables an optimization
  141863. */
  141864. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141865. /**
  141866. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141867. */
  141868. onFailureObservable: Observable<SceneOptimizer>;
  141869. /**
  141870. * Gets a boolean indicating if the optimizer is in improvement mode
  141871. */
  141872. get isInImprovementMode(): boolean;
  141873. /**
  141874. * Gets the current priority level (0 at start)
  141875. */
  141876. get currentPriorityLevel(): number;
  141877. /**
  141878. * Gets the current frame rate checked by the SceneOptimizer
  141879. */
  141880. get currentFrameRate(): number;
  141881. /**
  141882. * Gets or sets the current target frame rate (60 by default)
  141883. */
  141884. get targetFrameRate(): number;
  141885. /**
  141886. * Gets or sets the current target frame rate (60 by default)
  141887. */
  141888. set targetFrameRate(value: number);
  141889. /**
  141890. * Gets or sets the current interval between two checks (every 2000ms by default)
  141891. */
  141892. get trackerDuration(): number;
  141893. /**
  141894. * Gets or sets the current interval between two checks (every 2000ms by default)
  141895. */
  141896. set trackerDuration(value: number);
  141897. /**
  141898. * Gets the list of active optimizations
  141899. */
  141900. get optimizations(): SceneOptimization[];
  141901. /**
  141902. * Creates a new SceneOptimizer
  141903. * @param scene defines the scene to work on
  141904. * @param options defines the options to use with the SceneOptimizer
  141905. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141906. * @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)
  141907. */
  141908. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141909. /**
  141910. * Stops the current optimizer
  141911. */
  141912. stop(): void;
  141913. /**
  141914. * Reset the optimizer to initial step (current priority level = 0)
  141915. */
  141916. reset(): void;
  141917. /**
  141918. * Start the optimizer. By default it will try to reach a specific framerate
  141919. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141920. */
  141921. start(): void;
  141922. private _checkCurrentState;
  141923. /**
  141924. * Release all resources
  141925. */
  141926. dispose(): void;
  141927. /**
  141928. * Helper function to create a SceneOptimizer with one single line of code
  141929. * @param scene defines the scene to work on
  141930. * @param options defines the options to use with the SceneOptimizer
  141931. * @param onSuccess defines a callback to call on success
  141932. * @param onFailure defines a callback to call on failure
  141933. * @returns the new SceneOptimizer object
  141934. */
  141935. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141936. }
  141937. }
  141938. declare module BABYLON {
  141939. /**
  141940. * Class used to serialize a scene into a string
  141941. */
  141942. export class SceneSerializer {
  141943. /**
  141944. * Clear cache used by a previous serialization
  141945. */
  141946. static ClearCache(): void;
  141947. /**
  141948. * Serialize a scene into a JSON compatible object
  141949. * @param scene defines the scene to serialize
  141950. * @returns a JSON compatible object
  141951. */
  141952. static Serialize(scene: Scene): any;
  141953. /**
  141954. * Serialize a mesh into a JSON compatible object
  141955. * @param toSerialize defines the mesh to serialize
  141956. * @param withParents defines if parents must be serialized as well
  141957. * @param withChildren defines if children must be serialized as well
  141958. * @returns a JSON compatible object
  141959. */
  141960. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141961. }
  141962. }
  141963. declare module BABYLON {
  141964. /**
  141965. * Class used to host texture specific utilities
  141966. */
  141967. export class TextureTools {
  141968. /**
  141969. * Uses the GPU to create a copy texture rescaled at a given size
  141970. * @param texture Texture to copy from
  141971. * @param width defines the desired width
  141972. * @param height defines the desired height
  141973. * @param useBilinearMode defines if bilinear mode has to be used
  141974. * @return the generated texture
  141975. */
  141976. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141977. }
  141978. }
  141979. declare module BABYLON {
  141980. /**
  141981. * This represents the different options available for the video capture.
  141982. */
  141983. export interface VideoRecorderOptions {
  141984. /** Defines the mime type of the video. */
  141985. mimeType: string;
  141986. /** Defines the FPS the video should be recorded at. */
  141987. fps: number;
  141988. /** Defines the chunk size for the recording data. */
  141989. recordChunckSize: number;
  141990. /** The audio tracks to attach to the recording. */
  141991. audioTracks?: MediaStreamTrack[];
  141992. }
  141993. /**
  141994. * This can help with recording videos from BabylonJS.
  141995. * This is based on the available WebRTC functionalities of the browser.
  141996. *
  141997. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141998. */
  141999. export class VideoRecorder {
  142000. private static readonly _defaultOptions;
  142001. /**
  142002. * Returns whether or not the VideoRecorder is available in your browser.
  142003. * @param engine Defines the Babylon Engine.
  142004. * @returns true if supported otherwise false.
  142005. */
  142006. static IsSupported(engine: Engine): boolean;
  142007. private readonly _options;
  142008. private _canvas;
  142009. private _mediaRecorder;
  142010. private _recordedChunks;
  142011. private _fileName;
  142012. private _resolve;
  142013. private _reject;
  142014. /**
  142015. * True when a recording is already in progress.
  142016. */
  142017. get isRecording(): boolean;
  142018. /**
  142019. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  142020. * @param engine Defines the BabylonJS Engine you wish to record.
  142021. * @param options Defines options that can be used to customize the capture.
  142022. */
  142023. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  142024. /**
  142025. * Stops the current recording before the default capture timeout passed in the startRecording function.
  142026. */
  142027. stopRecording(): void;
  142028. /**
  142029. * Starts recording the canvas for a max duration specified in parameters.
  142030. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  142031. * If null no automatic download will start and you can rely on the promise to get the data back.
  142032. * @param maxDuration Defines the maximum recording time in seconds.
  142033. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  142034. * @return A promise callback at the end of the recording with the video data in Blob.
  142035. */
  142036. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  142037. /**
  142038. * Releases internal resources used during the recording.
  142039. */
  142040. dispose(): void;
  142041. private _handleDataAvailable;
  142042. private _handleError;
  142043. private _handleStop;
  142044. }
  142045. }
  142046. declare module BABYLON {
  142047. /**
  142048. * Class containing a set of static utilities functions for screenshots
  142049. */
  142050. export class ScreenshotTools {
  142051. /**
  142052. * Captures a screenshot of the current rendering
  142053. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142054. * @param engine defines the rendering engine
  142055. * @param camera defines the source camera
  142056. * @param size This parameter can be set to a single number or to an object with the
  142057. * following (optional) properties: precision, width, height. If a single number is passed,
  142058. * it will be used for both width and height. If an object is passed, the screenshot size
  142059. * will be derived from the parameters. The precision property is a multiplier allowing
  142060. * rendering at a higher or lower resolution
  142061. * @param successCallback defines the callback receives a single parameter which contains the
  142062. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  142063. * src parameter of an <img> to display it
  142064. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  142065. * Check your browser for supported MIME types
  142066. */
  142067. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  142068. /**
  142069. * Captures a screenshot of the current rendering
  142070. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142071. * @param engine defines the rendering engine
  142072. * @param camera defines the source camera
  142073. * @param size This parameter can be set to a single number or to an object with the
  142074. * following (optional) properties: precision, width, height. If a single number is passed,
  142075. * it will be used for both width and height. If an object is passed, the screenshot size
  142076. * will be derived from the parameters. The precision property is a multiplier allowing
  142077. * rendering at a higher or lower resolution
  142078. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  142079. * Check your browser for supported MIME types
  142080. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  142081. * to the src parameter of an <img> to display it
  142082. */
  142083. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  142084. /**
  142085. * Generates an image screenshot from the specified camera.
  142086. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142087. * @param engine The engine to use for rendering
  142088. * @param camera The camera to use for rendering
  142089. * @param size This parameter can be set to a single number or to an object with the
  142090. * following (optional) properties: precision, width, height. If a single number is passed,
  142091. * it will be used for both width and height. If an object is passed, the screenshot size
  142092. * will be derived from the parameters. The precision property is a multiplier allowing
  142093. * rendering at a higher or lower resolution
  142094. * @param successCallback The callback receives a single parameter which contains the
  142095. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  142096. * src parameter of an <img> to display it
  142097. * @param mimeType The MIME type of the screenshot image (default: image/png).
  142098. * Check your browser for supported MIME types
  142099. * @param samples Texture samples (default: 1)
  142100. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  142101. * @param fileName A name for for the downloaded file.
  142102. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  142103. */
  142104. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  142105. /**
  142106. * Generates an image screenshot from the specified camera.
  142107. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142108. * @param engine The engine to use for rendering
  142109. * @param camera The camera to use for rendering
  142110. * @param size This parameter can be set to a single number or to an object with the
  142111. * following (optional) properties: precision, width, height. If a single number is passed,
  142112. * it will be used for both width and height. If an object is passed, the screenshot size
  142113. * will be derived from the parameters. The precision property is a multiplier allowing
  142114. * rendering at a higher or lower resolution
  142115. * @param mimeType The MIME type of the screenshot image (default: image/png).
  142116. * Check your browser for supported MIME types
  142117. * @param samples Texture samples (default: 1)
  142118. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  142119. * @param fileName A name for for the downloaded file.
  142120. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  142121. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  142122. * to the src parameter of an <img> to display it
  142123. */
  142124. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  142125. /**
  142126. * Gets height and width for screenshot size
  142127. * @private
  142128. */
  142129. private static _getScreenshotSize;
  142130. }
  142131. }
  142132. declare module BABYLON {
  142133. /**
  142134. * Interface for a data buffer
  142135. */
  142136. export interface IDataBuffer {
  142137. /**
  142138. * Reads bytes from the data buffer.
  142139. * @param byteOffset The byte offset to read
  142140. * @param byteLength The byte length to read
  142141. * @returns A promise that resolves when the bytes are read
  142142. */
  142143. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  142144. /**
  142145. * The byte length of the buffer.
  142146. */
  142147. readonly byteLength: number;
  142148. }
  142149. /**
  142150. * Utility class for reading from a data buffer
  142151. */
  142152. export class DataReader {
  142153. /**
  142154. * The data buffer associated with this data reader.
  142155. */
  142156. readonly buffer: IDataBuffer;
  142157. /**
  142158. * The current byte offset from the beginning of the data buffer.
  142159. */
  142160. byteOffset: number;
  142161. private _dataView;
  142162. private _dataByteOffset;
  142163. /**
  142164. * Constructor
  142165. * @param buffer The buffer to read
  142166. */
  142167. constructor(buffer: IDataBuffer);
  142168. /**
  142169. * Loads the given byte length.
  142170. * @param byteLength The byte length to load
  142171. * @returns A promise that resolves when the load is complete
  142172. */
  142173. loadAsync(byteLength: number): Promise<void>;
  142174. /**
  142175. * Read a unsigned 32-bit integer from the currently loaded data range.
  142176. * @returns The 32-bit integer read
  142177. */
  142178. readUint32(): number;
  142179. /**
  142180. * Read a byte array from the currently loaded data range.
  142181. * @param byteLength The byte length to read
  142182. * @returns The byte array read
  142183. */
  142184. readUint8Array(byteLength: number): Uint8Array;
  142185. /**
  142186. * Read a string from the currently loaded data range.
  142187. * @param byteLength The byte length to read
  142188. * @returns The string read
  142189. */
  142190. readString(byteLength: number): string;
  142191. /**
  142192. * Skips the given byte length the currently loaded data range.
  142193. * @param byteLength The byte length to skip
  142194. */
  142195. skipBytes(byteLength: number): void;
  142196. }
  142197. }
  142198. declare module BABYLON {
  142199. /**
  142200. * Class for storing data to local storage if available or in-memory storage otherwise
  142201. */
  142202. export class DataStorage {
  142203. private static _Storage;
  142204. private static _GetStorage;
  142205. /**
  142206. * Reads a string from the data storage
  142207. * @param key The key to read
  142208. * @param defaultValue The value if the key doesn't exist
  142209. * @returns The string value
  142210. */
  142211. static ReadString(key: string, defaultValue: string): string;
  142212. /**
  142213. * Writes a string to the data storage
  142214. * @param key The key to write
  142215. * @param value The value to write
  142216. */
  142217. static WriteString(key: string, value: string): void;
  142218. /**
  142219. * Reads a boolean from the data storage
  142220. * @param key The key to read
  142221. * @param defaultValue The value if the key doesn't exist
  142222. * @returns The boolean value
  142223. */
  142224. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  142225. /**
  142226. * Writes a boolean to the data storage
  142227. * @param key The key to write
  142228. * @param value The value to write
  142229. */
  142230. static WriteBoolean(key: string, value: boolean): void;
  142231. /**
  142232. * Reads a number from the data storage
  142233. * @param key The key to read
  142234. * @param defaultValue The value if the key doesn't exist
  142235. * @returns The number value
  142236. */
  142237. static ReadNumber(key: string, defaultValue: number): number;
  142238. /**
  142239. * Writes a number to the data storage
  142240. * @param key The key to write
  142241. * @param value The value to write
  142242. */
  142243. static WriteNumber(key: string, value: number): void;
  142244. }
  142245. }
  142246. declare module BABYLON {
  142247. /**
  142248. * Options used for hit testing
  142249. */
  142250. export interface IWebXRHitTestOptions {
  142251. /**
  142252. * Only test when user interacted with the scene. Default - hit test every frame
  142253. */
  142254. testOnPointerDownOnly?: boolean;
  142255. /**
  142256. * The node to use to transform the local results to world coordinates
  142257. */
  142258. worldParentNode?: TransformNode;
  142259. }
  142260. /**
  142261. * Interface defining the babylon result of raycasting/hit-test
  142262. */
  142263. export interface IWebXRHitResult {
  142264. /**
  142265. * Transformation matrix that can be applied to a node that will put it in the hit point location
  142266. */
  142267. transformationMatrix: Matrix;
  142268. /**
  142269. * The native hit test result
  142270. */
  142271. xrHitResult: XRHitResult;
  142272. }
  142273. /**
  142274. * The currently-working hit-test module.
  142275. * Hit test (or Ray-casting) is used to interact with the real world.
  142276. * For further information read here - https://github.com/immersive-web/hit-test
  142277. */
  142278. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  142279. /**
  142280. * options to use when constructing this feature
  142281. */
  142282. readonly options: IWebXRHitTestOptions;
  142283. private _direction;
  142284. private _mat;
  142285. private _onSelectEnabled;
  142286. private _origin;
  142287. /**
  142288. * The module's name
  142289. */
  142290. static readonly Name: string;
  142291. /**
  142292. * The (Babylon) version of this module.
  142293. * This is an integer representing the implementation version.
  142294. * This number does not correspond to the WebXR specs version
  142295. */
  142296. static readonly Version: number;
  142297. /**
  142298. * Populated with the last native XR Hit Results
  142299. */
  142300. lastNativeXRHitResults: XRHitResult[];
  142301. /**
  142302. * Triggered when new babylon (transformed) hit test results are available
  142303. */
  142304. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  142305. /**
  142306. * Creates a new instance of the (legacy version) hit test feature
  142307. * @param _xrSessionManager an instance of WebXRSessionManager
  142308. * @param options options to use when constructing this feature
  142309. */
  142310. constructor(_xrSessionManager: WebXRSessionManager,
  142311. /**
  142312. * options to use when constructing this feature
  142313. */
  142314. options?: IWebXRHitTestOptions);
  142315. /**
  142316. * execute a hit test with an XR Ray
  142317. *
  142318. * @param xrSession a native xrSession that will execute this hit test
  142319. * @param xrRay the ray (position and direction) to use for ray-casting
  142320. * @param referenceSpace native XR reference space to use for the hit-test
  142321. * @param filter filter function that will filter the results
  142322. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142323. */
  142324. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  142325. /**
  142326. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  142327. * @param event the (select) event to use to select with
  142328. * @param referenceSpace the reference space to use for this hit test
  142329. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142330. */
  142331. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  142332. /**
  142333. * attach this feature
  142334. * Will usually be called by the features manager
  142335. *
  142336. * @returns true if successful.
  142337. */
  142338. attach(): boolean;
  142339. /**
  142340. * detach this feature.
  142341. * Will usually be called by the features manager
  142342. *
  142343. * @returns true if successful.
  142344. */
  142345. detach(): boolean;
  142346. /**
  142347. * Dispose this feature and all of the resources attached
  142348. */
  142349. dispose(): void;
  142350. protected _onXRFrame(frame: XRFrame): void;
  142351. private _onHitTestResults;
  142352. private _onSelect;
  142353. }
  142354. }
  142355. declare module BABYLON {
  142356. /**
  142357. * Options used in the plane detector module
  142358. */
  142359. export interface IWebXRPlaneDetectorOptions {
  142360. /**
  142361. * The node to use to transform the local results to world coordinates
  142362. */
  142363. worldParentNode?: TransformNode;
  142364. }
  142365. /**
  142366. * A babylon interface for a WebXR plane.
  142367. * A Plane is actually a polygon, built from N points in space
  142368. *
  142369. * Supported in chrome 79, not supported in canary 81 ATM
  142370. */
  142371. export interface IWebXRPlane {
  142372. /**
  142373. * a babylon-assigned ID for this polygon
  142374. */
  142375. id: number;
  142376. /**
  142377. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  142378. */
  142379. polygonDefinition: Array<Vector3>;
  142380. /**
  142381. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  142382. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  142383. */
  142384. transformationMatrix: Matrix;
  142385. /**
  142386. * the native xr-plane object
  142387. */
  142388. xrPlane: XRPlane;
  142389. }
  142390. /**
  142391. * The plane detector is used to detect planes in the real world when in AR
  142392. * For more information see https://github.com/immersive-web/real-world-geometry/
  142393. */
  142394. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142395. private _options;
  142396. private _detectedPlanes;
  142397. private _enabled;
  142398. private _lastFrameDetected;
  142399. /**
  142400. * The module's name
  142401. */
  142402. static readonly Name: string;
  142403. /**
  142404. * The (Babylon) version of this module.
  142405. * This is an integer representing the implementation version.
  142406. * This number does not correspond to the WebXR specs version
  142407. */
  142408. static readonly Version: number;
  142409. /**
  142410. * Observers registered here will be executed when a new plane was added to the session
  142411. */
  142412. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142413. /**
  142414. * Observers registered here will be executed when a plane is no longer detected in the session
  142415. */
  142416. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142417. /**
  142418. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142419. * This can execute N times every frame
  142420. */
  142421. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142422. /**
  142423. * construct a new Plane Detector
  142424. * @param _xrSessionManager an instance of xr Session manager
  142425. * @param _options configuration to use when constructing this feature
  142426. */
  142427. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142428. /**
  142429. * Dispose this feature and all of the resources attached
  142430. */
  142431. dispose(): void;
  142432. protected _onXRFrame(frame: XRFrame): void;
  142433. private _init;
  142434. private _updatePlaneWithXRPlane;
  142435. /**
  142436. * avoiding using Array.find for global support.
  142437. * @param xrPlane the plane to find in the array
  142438. */
  142439. private findIndexInPlaneArray;
  142440. }
  142441. }
  142442. declare module BABYLON {
  142443. /**
  142444. * Configuration options of the anchor system
  142445. */
  142446. export interface IWebXRAnchorSystemOptions {
  142447. /**
  142448. * Should a new anchor be added every time a select event is triggered
  142449. */
  142450. addAnchorOnSelect?: boolean;
  142451. /**
  142452. * should the anchor system use plane detection.
  142453. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142454. */
  142455. usePlaneDetection?: boolean;
  142456. /**
  142457. * a node that will be used to convert local to world coordinates
  142458. */
  142459. worldParentNode?: TransformNode;
  142460. }
  142461. /**
  142462. * A babylon container for an XR Anchor
  142463. */
  142464. export interface IWebXRAnchor {
  142465. /**
  142466. * A babylon-assigned ID for this anchor
  142467. */
  142468. id: number;
  142469. /**
  142470. * Transformation matrix to apply to an object attached to this anchor
  142471. */
  142472. transformationMatrix: Matrix;
  142473. /**
  142474. * The native anchor object
  142475. */
  142476. xrAnchor: XRAnchor;
  142477. }
  142478. /**
  142479. * An implementation of the anchor system of WebXR.
  142480. * Note that the current documented implementation is not available in any browser. Future implementations
  142481. * will use the frame to create an anchor and not the session or a detected plane
  142482. * For further information see https://github.com/immersive-web/anchors/
  142483. */
  142484. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142485. private _options;
  142486. private _enabled;
  142487. private _hitTestModule;
  142488. private _lastFrameDetected;
  142489. private _onSelect;
  142490. private _planeDetector;
  142491. private _trackedAnchors;
  142492. /**
  142493. * The module's name
  142494. */
  142495. static readonly Name: string;
  142496. /**
  142497. * The (Babylon) version of this module.
  142498. * This is an integer representing the implementation version.
  142499. * This number does not correspond to the WebXR specs version
  142500. */
  142501. static readonly Version: number;
  142502. /**
  142503. * Observers registered here will be executed when a new anchor was added to the session
  142504. */
  142505. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142506. /**
  142507. * Observers registered here will be executed when an anchor was removed from the session
  142508. */
  142509. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142510. /**
  142511. * Observers registered here will be executed when an existing anchor updates
  142512. * This can execute N times every frame
  142513. */
  142514. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142515. /**
  142516. * constructs a new anchor system
  142517. * @param _xrSessionManager an instance of WebXRSessionManager
  142518. * @param _options configuration object for this feature
  142519. */
  142520. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142521. /**
  142522. * Add anchor at a specific XR point.
  142523. *
  142524. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142525. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142526. * @returns a promise the fulfills when the anchor was created
  142527. */
  142528. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142529. /**
  142530. * attach this feature
  142531. * Will usually be called by the features manager
  142532. *
  142533. * @returns true if successful.
  142534. */
  142535. attach(): boolean;
  142536. /**
  142537. * detach this feature.
  142538. * Will usually be called by the features manager
  142539. *
  142540. * @returns true if successful.
  142541. */
  142542. detach(): boolean;
  142543. /**
  142544. * Dispose this feature and all of the resources attached
  142545. */
  142546. dispose(): void;
  142547. /**
  142548. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142549. * @param hitTestModule the hit-test module to use.
  142550. */
  142551. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142552. /**
  142553. * set the plane detector to use in order to create anchors from frames
  142554. * @param planeDetector the plane-detector module to use
  142555. * @param enable enable plane-anchors. default is true
  142556. */
  142557. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142558. protected _onXRFrame(frame: XRFrame): void;
  142559. /**
  142560. * avoiding using Array.find for global support.
  142561. * @param xrAnchor the plane to find in the array
  142562. */
  142563. private _findIndexInAnchorArray;
  142564. private _updateAnchorWithXRFrame;
  142565. }
  142566. }
  142567. declare module BABYLON {
  142568. /**
  142569. * Options interface for the background remover plugin
  142570. */
  142571. export interface IWebXRBackgroundRemoverOptions {
  142572. /**
  142573. * Further background meshes to disable when entering AR
  142574. */
  142575. backgroundMeshes?: AbstractMesh[];
  142576. /**
  142577. * flags to configure the removal of the environment helper.
  142578. * If not set, the entire background will be removed. If set, flags should be set as well.
  142579. */
  142580. environmentHelperRemovalFlags?: {
  142581. /**
  142582. * Should the skybox be removed (default false)
  142583. */
  142584. skyBox?: boolean;
  142585. /**
  142586. * Should the ground be removed (default false)
  142587. */
  142588. ground?: boolean;
  142589. };
  142590. /**
  142591. * don't disable the environment helper
  142592. */
  142593. ignoreEnvironmentHelper?: boolean;
  142594. }
  142595. /**
  142596. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142597. */
  142598. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142599. /**
  142600. * read-only options to be used in this module
  142601. */
  142602. readonly options: IWebXRBackgroundRemoverOptions;
  142603. /**
  142604. * The module's name
  142605. */
  142606. static readonly Name: string;
  142607. /**
  142608. * The (Babylon) version of this module.
  142609. * This is an integer representing the implementation version.
  142610. * This number does not correspond to the WebXR specs version
  142611. */
  142612. static readonly Version: number;
  142613. /**
  142614. * registered observers will be triggered when the background state changes
  142615. */
  142616. onBackgroundStateChangedObservable: Observable<boolean>;
  142617. /**
  142618. * constructs a new background remover module
  142619. * @param _xrSessionManager the session manager for this module
  142620. * @param options read-only options to be used in this module
  142621. */
  142622. constructor(_xrSessionManager: WebXRSessionManager,
  142623. /**
  142624. * read-only options to be used in this module
  142625. */
  142626. options?: IWebXRBackgroundRemoverOptions);
  142627. /**
  142628. * attach this feature
  142629. * Will usually be called by the features manager
  142630. *
  142631. * @returns true if successful.
  142632. */
  142633. attach(): boolean;
  142634. /**
  142635. * detach this feature.
  142636. * Will usually be called by the features manager
  142637. *
  142638. * @returns true if successful.
  142639. */
  142640. detach(): boolean;
  142641. /**
  142642. * Dispose this feature and all of the resources attached
  142643. */
  142644. dispose(): void;
  142645. protected _onXRFrame(_xrFrame: XRFrame): void;
  142646. private _setBackgroundState;
  142647. }
  142648. }
  142649. declare module BABYLON {
  142650. /**
  142651. * Options for the controller physics feature
  142652. */
  142653. export class IWebXRControllerPhysicsOptions {
  142654. /**
  142655. * Should the headset get its own impostor
  142656. */
  142657. enableHeadsetImpostor?: boolean;
  142658. /**
  142659. * Optional parameters for the headset impostor
  142660. */
  142661. headsetImpostorParams?: {
  142662. /**
  142663. * The type of impostor to create. Default is sphere
  142664. */
  142665. impostorType: number;
  142666. /**
  142667. * the size of the impostor. Defaults to 10cm
  142668. */
  142669. impostorSize?: number | {
  142670. width: number;
  142671. height: number;
  142672. depth: number;
  142673. };
  142674. /**
  142675. * Friction definitions
  142676. */
  142677. friction?: number;
  142678. /**
  142679. * Restitution
  142680. */
  142681. restitution?: number;
  142682. };
  142683. /**
  142684. * The physics properties of the future impostors
  142685. */
  142686. physicsProperties?: {
  142687. /**
  142688. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142689. * Note that this requires a physics engine that supports mesh impostors!
  142690. */
  142691. useControllerMesh?: boolean;
  142692. /**
  142693. * The type of impostor to create. Default is sphere
  142694. */
  142695. impostorType?: number;
  142696. /**
  142697. * the size of the impostor. Defaults to 10cm
  142698. */
  142699. impostorSize?: number | {
  142700. width: number;
  142701. height: number;
  142702. depth: number;
  142703. };
  142704. /**
  142705. * Friction definitions
  142706. */
  142707. friction?: number;
  142708. /**
  142709. * Restitution
  142710. */
  142711. restitution?: number;
  142712. };
  142713. /**
  142714. * the xr input to use with this pointer selection
  142715. */
  142716. xrInput: WebXRInput;
  142717. }
  142718. /**
  142719. * Add physics impostor to your webxr controllers,
  142720. * including naive calculation of their linear and angular velocity
  142721. */
  142722. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142723. private readonly _options;
  142724. private _attachController;
  142725. private _controllers;
  142726. private _debugMode;
  142727. private _delta;
  142728. private _headsetImpostor?;
  142729. private _headsetMesh?;
  142730. private _lastTimestamp;
  142731. private _tmpQuaternion;
  142732. private _tmpVector;
  142733. /**
  142734. * The module's name
  142735. */
  142736. static readonly Name: string;
  142737. /**
  142738. * The (Babylon) version of this module.
  142739. * This is an integer representing the implementation version.
  142740. * This number does not correspond to the webxr specs version
  142741. */
  142742. static readonly Version: number;
  142743. /**
  142744. * Construct a new Controller Physics Feature
  142745. * @param _xrSessionManager the corresponding xr session manager
  142746. * @param _options options to create this feature with
  142747. */
  142748. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142749. /**
  142750. * @hidden
  142751. * enable debugging - will show console outputs and the impostor mesh
  142752. */
  142753. _enablePhysicsDebug(): void;
  142754. /**
  142755. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142756. * @param xrController the controller to add
  142757. */
  142758. addController(xrController: WebXRInputSource): void;
  142759. /**
  142760. * attach this feature
  142761. * Will usually be called by the features manager
  142762. *
  142763. * @returns true if successful.
  142764. */
  142765. attach(): boolean;
  142766. /**
  142767. * detach this feature.
  142768. * Will usually be called by the features manager
  142769. *
  142770. * @returns true if successful.
  142771. */
  142772. detach(): boolean;
  142773. /**
  142774. * Get the headset impostor, if enabled
  142775. * @returns the impostor
  142776. */
  142777. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142778. /**
  142779. * Get the physics impostor of a specific controller.
  142780. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142781. * @param controller the controller or the controller id of which to get the impostor
  142782. * @returns the impostor or null
  142783. */
  142784. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142785. /**
  142786. * Update the physics properties provided in the constructor
  142787. * @param newProperties the new properties object
  142788. */
  142789. setPhysicsProperties(newProperties: {
  142790. impostorType?: number;
  142791. impostorSize?: number | {
  142792. width: number;
  142793. height: number;
  142794. depth: number;
  142795. };
  142796. friction?: number;
  142797. restitution?: number;
  142798. }): void;
  142799. protected _onXRFrame(_xrFrame: any): void;
  142800. private _detachController;
  142801. }
  142802. }
  142803. declare module BABYLON {
  142804. /**
  142805. * The motion controller class for all microsoft mixed reality controllers
  142806. */
  142807. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142808. protected readonly _mapping: {
  142809. defaultButton: {
  142810. "valueNodeName": string;
  142811. "unpressedNodeName": string;
  142812. "pressedNodeName": string;
  142813. };
  142814. defaultAxis: {
  142815. "valueNodeName": string;
  142816. "minNodeName": string;
  142817. "maxNodeName": string;
  142818. };
  142819. buttons: {
  142820. "xr-standard-trigger": {
  142821. "rootNodeName": string;
  142822. "componentProperty": string;
  142823. "states": string[];
  142824. };
  142825. "xr-standard-squeeze": {
  142826. "rootNodeName": string;
  142827. "componentProperty": string;
  142828. "states": string[];
  142829. };
  142830. "xr-standard-touchpad": {
  142831. "rootNodeName": string;
  142832. "labelAnchorNodeName": string;
  142833. "touchPointNodeName": string;
  142834. };
  142835. "xr-standard-thumbstick": {
  142836. "rootNodeName": string;
  142837. "componentProperty": string;
  142838. "states": string[];
  142839. };
  142840. };
  142841. axes: {
  142842. "xr-standard-touchpad": {
  142843. "x-axis": {
  142844. "rootNodeName": string;
  142845. };
  142846. "y-axis": {
  142847. "rootNodeName": string;
  142848. };
  142849. };
  142850. "xr-standard-thumbstick": {
  142851. "x-axis": {
  142852. "rootNodeName": string;
  142853. };
  142854. "y-axis": {
  142855. "rootNodeName": string;
  142856. };
  142857. };
  142858. };
  142859. };
  142860. /**
  142861. * The base url used to load the left and right controller models
  142862. */
  142863. static MODEL_BASE_URL: string;
  142864. /**
  142865. * The name of the left controller model file
  142866. */
  142867. static MODEL_LEFT_FILENAME: string;
  142868. /**
  142869. * The name of the right controller model file
  142870. */
  142871. static MODEL_RIGHT_FILENAME: string;
  142872. profileId: string;
  142873. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142874. protected _getFilenameAndPath(): {
  142875. filename: string;
  142876. path: string;
  142877. };
  142878. protected _getModelLoadingConstraints(): boolean;
  142879. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142880. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142881. protected _updateModel(): void;
  142882. }
  142883. }
  142884. declare module BABYLON {
  142885. /**
  142886. * The motion controller class for oculus touch (quest, rift).
  142887. * This class supports legacy mapping as well the standard xr mapping
  142888. */
  142889. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142890. private _forceLegacyControllers;
  142891. private _modelRootNode;
  142892. /**
  142893. * The base url used to load the left and right controller models
  142894. */
  142895. static MODEL_BASE_URL: string;
  142896. /**
  142897. * The name of the left controller model file
  142898. */
  142899. static MODEL_LEFT_FILENAME: string;
  142900. /**
  142901. * The name of the right controller model file
  142902. */
  142903. static MODEL_RIGHT_FILENAME: string;
  142904. /**
  142905. * Base Url for the Quest controller model.
  142906. */
  142907. static QUEST_MODEL_BASE_URL: string;
  142908. profileId: string;
  142909. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142910. protected _getFilenameAndPath(): {
  142911. filename: string;
  142912. path: string;
  142913. };
  142914. protected _getModelLoadingConstraints(): boolean;
  142915. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142916. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142917. protected _updateModel(): void;
  142918. /**
  142919. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142920. * between the touch and touch 2.
  142921. */
  142922. private _isQuest;
  142923. }
  142924. }
  142925. declare module BABYLON {
  142926. /**
  142927. * The motion controller class for the standard HTC-Vive controllers
  142928. */
  142929. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142930. private _modelRootNode;
  142931. /**
  142932. * The base url used to load the left and right controller models
  142933. */
  142934. static MODEL_BASE_URL: string;
  142935. /**
  142936. * File name for the controller model.
  142937. */
  142938. static MODEL_FILENAME: string;
  142939. profileId: string;
  142940. /**
  142941. * Create a new Vive motion controller object
  142942. * @param scene the scene to use to create this controller
  142943. * @param gamepadObject the corresponding gamepad object
  142944. * @param handness the handness of the controller
  142945. */
  142946. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142947. protected _getFilenameAndPath(): {
  142948. filename: string;
  142949. path: string;
  142950. };
  142951. protected _getModelLoadingConstraints(): boolean;
  142952. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142953. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142954. protected _updateModel(): void;
  142955. }
  142956. }
  142957. declare module BABYLON {
  142958. /**
  142959. * A cursor which tracks a point on a path
  142960. */
  142961. export class PathCursor {
  142962. private path;
  142963. /**
  142964. * Stores path cursor callbacks for when an onchange event is triggered
  142965. */
  142966. private _onchange;
  142967. /**
  142968. * The value of the path cursor
  142969. */
  142970. value: number;
  142971. /**
  142972. * The animation array of the path cursor
  142973. */
  142974. animations: Animation[];
  142975. /**
  142976. * Initializes the path cursor
  142977. * @param path The path to track
  142978. */
  142979. constructor(path: Path2);
  142980. /**
  142981. * Gets the cursor point on the path
  142982. * @returns A point on the path cursor at the cursor location
  142983. */
  142984. getPoint(): Vector3;
  142985. /**
  142986. * Moves the cursor ahead by the step amount
  142987. * @param step The amount to move the cursor forward
  142988. * @returns This path cursor
  142989. */
  142990. moveAhead(step?: number): PathCursor;
  142991. /**
  142992. * Moves the cursor behind by the step amount
  142993. * @param step The amount to move the cursor back
  142994. * @returns This path cursor
  142995. */
  142996. moveBack(step?: number): PathCursor;
  142997. /**
  142998. * Moves the cursor by the step amount
  142999. * If the step amount is greater than one, an exception is thrown
  143000. * @param step The amount to move the cursor
  143001. * @returns This path cursor
  143002. */
  143003. move(step: number): PathCursor;
  143004. /**
  143005. * Ensures that the value is limited between zero and one
  143006. * @returns This path cursor
  143007. */
  143008. private ensureLimits;
  143009. /**
  143010. * Runs onchange callbacks on change (used by the animation engine)
  143011. * @returns This path cursor
  143012. */
  143013. private raiseOnChange;
  143014. /**
  143015. * Executes a function on change
  143016. * @param f A path cursor onchange callback
  143017. * @returns This path cursor
  143018. */
  143019. onchange(f: (cursor: PathCursor) => void): PathCursor;
  143020. }
  143021. }
  143022. declare module BABYLON {
  143023. /** @hidden */
  143024. export var blurPixelShader: {
  143025. name: string;
  143026. shader: string;
  143027. };
  143028. }
  143029. declare module BABYLON {
  143030. /** @hidden */
  143031. export var pointCloudVertexDeclaration: {
  143032. name: string;
  143033. shader: string;
  143034. };
  143035. }
  143036. // Mixins
  143037. interface Window {
  143038. mozIndexedDB: IDBFactory;
  143039. webkitIndexedDB: IDBFactory;
  143040. msIndexedDB: IDBFactory;
  143041. webkitURL: typeof URL;
  143042. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  143043. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  143044. WebGLRenderingContext: WebGLRenderingContext;
  143045. MSGesture: MSGesture;
  143046. CANNON: any;
  143047. AudioContext: AudioContext;
  143048. webkitAudioContext: AudioContext;
  143049. PointerEvent: any;
  143050. Math: Math;
  143051. Uint8Array: Uint8ArrayConstructor;
  143052. Float32Array: Float32ArrayConstructor;
  143053. mozURL: typeof URL;
  143054. msURL: typeof URL;
  143055. VRFrameData: any; // WebVR, from specs 1.1
  143056. DracoDecoderModule: any;
  143057. setImmediate(handler: (...args: any[]) => void): number;
  143058. }
  143059. interface HTMLCanvasElement {
  143060. requestPointerLock(): void;
  143061. msRequestPointerLock?(): void;
  143062. mozRequestPointerLock?(): void;
  143063. webkitRequestPointerLock?(): void;
  143064. /** Track wether a record is in progress */
  143065. isRecording: boolean;
  143066. /** Capture Stream method defined by some browsers */
  143067. captureStream(fps?: number): MediaStream;
  143068. }
  143069. interface CanvasRenderingContext2D {
  143070. msImageSmoothingEnabled: boolean;
  143071. }
  143072. interface MouseEvent {
  143073. mozMovementX: number;
  143074. mozMovementY: number;
  143075. webkitMovementX: number;
  143076. webkitMovementY: number;
  143077. msMovementX: number;
  143078. msMovementY: number;
  143079. }
  143080. interface Navigator {
  143081. mozGetVRDevices: (any: any) => any;
  143082. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143083. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143084. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143085. webkitGetGamepads(): Gamepad[];
  143086. msGetGamepads(): Gamepad[];
  143087. webkitGamepads(): Gamepad[];
  143088. }
  143089. interface HTMLVideoElement {
  143090. mozSrcObject: any;
  143091. }
  143092. interface Math {
  143093. fround(x: number): number;
  143094. imul(a: number, b: number): number;
  143095. }
  143096. interface WebGLRenderingContext {
  143097. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  143098. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  143099. vertexAttribDivisor(index: number, divisor: number): void;
  143100. createVertexArray(): any;
  143101. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  143102. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  143103. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  143104. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  143105. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  143106. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  143107. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  143108. // Queries
  143109. createQuery(): WebGLQuery;
  143110. deleteQuery(query: WebGLQuery): void;
  143111. beginQuery(target: number, query: WebGLQuery): void;
  143112. endQuery(target: number): void;
  143113. getQueryParameter(query: WebGLQuery, pname: number): any;
  143114. getQuery(target: number, pname: number): any;
  143115. MAX_SAMPLES: number;
  143116. RGBA8: number;
  143117. READ_FRAMEBUFFER: number;
  143118. DRAW_FRAMEBUFFER: number;
  143119. UNIFORM_BUFFER: number;
  143120. HALF_FLOAT_OES: number;
  143121. RGBA16F: number;
  143122. RGBA32F: number;
  143123. R32F: number;
  143124. RG32F: number;
  143125. RGB32F: number;
  143126. R16F: number;
  143127. RG16F: number;
  143128. RGB16F: number;
  143129. RED: number;
  143130. RG: number;
  143131. R8: number;
  143132. RG8: number;
  143133. UNSIGNED_INT_24_8: number;
  143134. DEPTH24_STENCIL8: number;
  143135. MIN: number;
  143136. MAX: number;
  143137. /* Multiple Render Targets */
  143138. drawBuffers(buffers: number[]): void;
  143139. readBuffer(src: number): void;
  143140. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  143141. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  143142. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  143143. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  143144. // Occlusion Query
  143145. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  143146. ANY_SAMPLES_PASSED: number;
  143147. QUERY_RESULT_AVAILABLE: number;
  143148. QUERY_RESULT: number;
  143149. }
  143150. interface WebGLProgram {
  143151. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  143152. }
  143153. interface EXT_disjoint_timer_query {
  143154. QUERY_COUNTER_BITS_EXT: number;
  143155. TIME_ELAPSED_EXT: number;
  143156. TIMESTAMP_EXT: number;
  143157. GPU_DISJOINT_EXT: number;
  143158. QUERY_RESULT_EXT: number;
  143159. QUERY_RESULT_AVAILABLE_EXT: number;
  143160. queryCounterEXT(query: WebGLQuery, target: number): void;
  143161. createQueryEXT(): WebGLQuery;
  143162. beginQueryEXT(target: number, query: WebGLQuery): void;
  143163. endQueryEXT(target: number): void;
  143164. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  143165. deleteQueryEXT(query: WebGLQuery): void;
  143166. }
  143167. interface WebGLUniformLocation {
  143168. _currentState: any;
  143169. }
  143170. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  143171. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  143172. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  143173. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143174. interface WebGLRenderingContext {
  143175. readonly RASTERIZER_DISCARD: number;
  143176. readonly DEPTH_COMPONENT24: number;
  143177. readonly TEXTURE_3D: number;
  143178. readonly TEXTURE_2D_ARRAY: number;
  143179. readonly TEXTURE_COMPARE_FUNC: number;
  143180. readonly TEXTURE_COMPARE_MODE: number;
  143181. readonly COMPARE_REF_TO_TEXTURE: number;
  143182. readonly TEXTURE_WRAP_R: number;
  143183. readonly HALF_FLOAT: number;
  143184. readonly RGB8: number;
  143185. readonly RED_INTEGER: number;
  143186. readonly RG_INTEGER: number;
  143187. readonly RGB_INTEGER: number;
  143188. readonly RGBA_INTEGER: number;
  143189. readonly R8_SNORM: number;
  143190. readonly RG8_SNORM: number;
  143191. readonly RGB8_SNORM: number;
  143192. readonly RGBA8_SNORM: number;
  143193. readonly R8I: number;
  143194. readonly RG8I: number;
  143195. readonly RGB8I: number;
  143196. readonly RGBA8I: number;
  143197. readonly R8UI: number;
  143198. readonly RG8UI: number;
  143199. readonly RGB8UI: number;
  143200. readonly RGBA8UI: number;
  143201. readonly R16I: number;
  143202. readonly RG16I: number;
  143203. readonly RGB16I: number;
  143204. readonly RGBA16I: number;
  143205. readonly R16UI: number;
  143206. readonly RG16UI: number;
  143207. readonly RGB16UI: number;
  143208. readonly RGBA16UI: number;
  143209. readonly R32I: number;
  143210. readonly RG32I: number;
  143211. readonly RGB32I: number;
  143212. readonly RGBA32I: number;
  143213. readonly R32UI: number;
  143214. readonly RG32UI: number;
  143215. readonly RGB32UI: number;
  143216. readonly RGBA32UI: number;
  143217. readonly RGB10_A2UI: number;
  143218. readonly R11F_G11F_B10F: number;
  143219. readonly RGB9_E5: number;
  143220. readonly RGB10_A2: number;
  143221. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  143222. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  143223. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  143224. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  143225. readonly DEPTH_COMPONENT32F: number;
  143226. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  143227. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  143228. 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;
  143229. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  143230. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  143231. readonly TRANSFORM_FEEDBACK: number;
  143232. readonly INTERLEAVED_ATTRIBS: number;
  143233. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  143234. createTransformFeedback(): WebGLTransformFeedback;
  143235. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  143236. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  143237. beginTransformFeedback(primitiveMode: number): void;
  143238. endTransformFeedback(): void;
  143239. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  143240. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143241. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143242. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143243. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  143244. }
  143245. interface ImageBitmap {
  143246. readonly width: number;
  143247. readonly height: number;
  143248. close(): void;
  143249. }
  143250. interface WebGLQuery extends WebGLObject {
  143251. }
  143252. declare var WebGLQuery: {
  143253. prototype: WebGLQuery;
  143254. new(): WebGLQuery;
  143255. };
  143256. interface WebGLSampler extends WebGLObject {
  143257. }
  143258. declare var WebGLSampler: {
  143259. prototype: WebGLSampler;
  143260. new(): WebGLSampler;
  143261. };
  143262. interface WebGLSync extends WebGLObject {
  143263. }
  143264. declare var WebGLSync: {
  143265. prototype: WebGLSync;
  143266. new(): WebGLSync;
  143267. };
  143268. interface WebGLTransformFeedback extends WebGLObject {
  143269. }
  143270. declare var WebGLTransformFeedback: {
  143271. prototype: WebGLTransformFeedback;
  143272. new(): WebGLTransformFeedback;
  143273. };
  143274. interface WebGLVertexArrayObject extends WebGLObject {
  143275. }
  143276. declare var WebGLVertexArrayObject: {
  143277. prototype: WebGLVertexArrayObject;
  143278. new(): WebGLVertexArrayObject;
  143279. };
  143280. // Type definitions for WebVR API
  143281. // Project: https://w3c.github.io/webvr/
  143282. // Definitions by: six a <https://github.com/lostfictions>
  143283. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143284. interface VRDisplay extends EventTarget {
  143285. /**
  143286. * Dictionary of capabilities describing the VRDisplay.
  143287. */
  143288. readonly capabilities: VRDisplayCapabilities;
  143289. /**
  143290. * z-depth defining the far plane of the eye view frustum
  143291. * enables mapping of values in the render target depth
  143292. * attachment to scene coordinates. Initially set to 10000.0.
  143293. */
  143294. depthFar: number;
  143295. /**
  143296. * z-depth defining the near plane of the eye view frustum
  143297. * enables mapping of values in the render target depth
  143298. * attachment to scene coordinates. Initially set to 0.01.
  143299. */
  143300. depthNear: number;
  143301. /**
  143302. * An identifier for this distinct VRDisplay. Used as an
  143303. * association point in the Gamepad API.
  143304. */
  143305. readonly displayId: number;
  143306. /**
  143307. * A display name, a user-readable name identifying it.
  143308. */
  143309. readonly displayName: string;
  143310. readonly isConnected: boolean;
  143311. readonly isPresenting: boolean;
  143312. /**
  143313. * If this VRDisplay supports room-scale experiences, the optional
  143314. * stage attribute contains details on the room-scale parameters.
  143315. */
  143316. readonly stageParameters: VRStageParameters | null;
  143317. /**
  143318. * Passing the value returned by `requestAnimationFrame` to
  143319. * `cancelAnimationFrame` will unregister the callback.
  143320. * @param handle Define the hanle of the request to cancel
  143321. */
  143322. cancelAnimationFrame(handle: number): void;
  143323. /**
  143324. * Stops presenting to the VRDisplay.
  143325. * @returns a promise to know when it stopped
  143326. */
  143327. exitPresent(): Promise<void>;
  143328. /**
  143329. * Return the current VREyeParameters for the given eye.
  143330. * @param whichEye Define the eye we want the parameter for
  143331. * @returns the eye parameters
  143332. */
  143333. getEyeParameters(whichEye: string): VREyeParameters;
  143334. /**
  143335. * Populates the passed VRFrameData with the information required to render
  143336. * the current frame.
  143337. * @param frameData Define the data structure to populate
  143338. * @returns true if ok otherwise false
  143339. */
  143340. getFrameData(frameData: VRFrameData): boolean;
  143341. /**
  143342. * Get the layers currently being presented.
  143343. * @returns the list of VR layers
  143344. */
  143345. getLayers(): VRLayer[];
  143346. /**
  143347. * Return a VRPose containing the future predicted pose of the VRDisplay
  143348. * when the current frame will be presented. The value returned will not
  143349. * change until JavaScript has returned control to the browser.
  143350. *
  143351. * The VRPose will contain the position, orientation, velocity,
  143352. * and acceleration of each of these properties.
  143353. * @returns the pose object
  143354. */
  143355. getPose(): VRPose;
  143356. /**
  143357. * Return the current instantaneous pose of the VRDisplay, with no
  143358. * prediction applied.
  143359. * @returns the current instantaneous pose
  143360. */
  143361. getImmediatePose(): VRPose;
  143362. /**
  143363. * The callback passed to `requestAnimationFrame` will be called
  143364. * any time a new frame should be rendered. When the VRDisplay is
  143365. * presenting the callback will be called at the native refresh
  143366. * rate of the HMD. When not presenting this function acts
  143367. * identically to how window.requestAnimationFrame acts. Content should
  143368. * make no assumptions of frame rate or vsync behavior as the HMD runs
  143369. * asynchronously from other displays and at differing refresh rates.
  143370. * @param callback Define the eaction to run next frame
  143371. * @returns the request handle it
  143372. */
  143373. requestAnimationFrame(callback: FrameRequestCallback): number;
  143374. /**
  143375. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  143376. * Repeat calls while already presenting will update the VRLayers being displayed.
  143377. * @param layers Define the list of layer to present
  143378. * @returns a promise to know when the request has been fulfilled
  143379. */
  143380. requestPresent(layers: VRLayer[]): Promise<void>;
  143381. /**
  143382. * Reset the pose for this display, treating its current position and
  143383. * orientation as the "origin/zero" values. VRPose.position,
  143384. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  143385. * updated when calling resetPose(). This should be called in only
  143386. * sitting-space experiences.
  143387. */
  143388. resetPose(): void;
  143389. /**
  143390. * The VRLayer provided to the VRDisplay will be captured and presented
  143391. * in the HMD. Calling this function has the same effect on the source
  143392. * canvas as any other operation that uses its source image, and canvases
  143393. * created without preserveDrawingBuffer set to true will be cleared.
  143394. * @param pose Define the pose to submit
  143395. */
  143396. submitFrame(pose?: VRPose): void;
  143397. }
  143398. declare var VRDisplay: {
  143399. prototype: VRDisplay;
  143400. new(): VRDisplay;
  143401. };
  143402. interface VRLayer {
  143403. leftBounds?: number[] | Float32Array | null;
  143404. rightBounds?: number[] | Float32Array | null;
  143405. source?: HTMLCanvasElement | null;
  143406. }
  143407. interface VRDisplayCapabilities {
  143408. readonly canPresent: boolean;
  143409. readonly hasExternalDisplay: boolean;
  143410. readonly hasOrientation: boolean;
  143411. readonly hasPosition: boolean;
  143412. readonly maxLayers: number;
  143413. }
  143414. interface VREyeParameters {
  143415. /** @deprecated */
  143416. readonly fieldOfView: VRFieldOfView;
  143417. readonly offset: Float32Array;
  143418. readonly renderHeight: number;
  143419. readonly renderWidth: number;
  143420. }
  143421. interface VRFieldOfView {
  143422. readonly downDegrees: number;
  143423. readonly leftDegrees: number;
  143424. readonly rightDegrees: number;
  143425. readonly upDegrees: number;
  143426. }
  143427. interface VRFrameData {
  143428. readonly leftProjectionMatrix: Float32Array;
  143429. readonly leftViewMatrix: Float32Array;
  143430. readonly pose: VRPose;
  143431. readonly rightProjectionMatrix: Float32Array;
  143432. readonly rightViewMatrix: Float32Array;
  143433. readonly timestamp: number;
  143434. }
  143435. interface VRPose {
  143436. readonly angularAcceleration: Float32Array | null;
  143437. readonly angularVelocity: Float32Array | null;
  143438. readonly linearAcceleration: Float32Array | null;
  143439. readonly linearVelocity: Float32Array | null;
  143440. readonly orientation: Float32Array | null;
  143441. readonly position: Float32Array | null;
  143442. readonly timestamp: number;
  143443. }
  143444. interface VRStageParameters {
  143445. sittingToStandingTransform?: Float32Array;
  143446. sizeX?: number;
  143447. sizeY?: number;
  143448. }
  143449. interface Navigator {
  143450. getVRDisplays(): Promise<VRDisplay[]>;
  143451. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143452. }
  143453. interface Window {
  143454. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143455. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143456. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143457. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143458. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143459. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143460. }
  143461. interface Gamepad {
  143462. readonly displayId: number;
  143463. }
  143464. type XRSessionMode =
  143465. | "inline"
  143466. | "immersive-vr"
  143467. | "immersive-ar";
  143468. type XRReferenceSpaceType =
  143469. | "viewer"
  143470. | "local"
  143471. | "local-floor"
  143472. | "bounded-floor"
  143473. | "unbounded";
  143474. type XREnvironmentBlendMode =
  143475. | "opaque"
  143476. | "additive"
  143477. | "alpha-blend";
  143478. type XRVisibilityState =
  143479. | "visible"
  143480. | "visible-blurred"
  143481. | "hidden";
  143482. type XRHandedness =
  143483. | "none"
  143484. | "left"
  143485. | "right";
  143486. type XRTargetRayMode =
  143487. | "gaze"
  143488. | "tracked-pointer"
  143489. | "screen";
  143490. type XREye =
  143491. | "none"
  143492. | "left"
  143493. | "right";
  143494. interface XRSpace extends EventTarget {
  143495. }
  143496. interface XRRenderState {
  143497. depthNear?: number;
  143498. depthFar?: number;
  143499. inlineVerticalFieldOfView?: number;
  143500. baseLayer?: XRWebGLLayer;
  143501. }
  143502. interface XRInputSource {
  143503. handedness: XRHandedness;
  143504. targetRayMode: XRTargetRayMode;
  143505. targetRaySpace: XRSpace;
  143506. gripSpace: XRSpace | undefined;
  143507. gamepad: Gamepad | undefined;
  143508. profiles: Array<string>;
  143509. }
  143510. interface XRSessionInit {
  143511. optionalFeatures?: XRReferenceSpaceType[];
  143512. requiredFeatures?: XRReferenceSpaceType[];
  143513. }
  143514. interface XRSession extends XRAnchorCreator {
  143515. addEventListener: Function;
  143516. removeEventListener: Function;
  143517. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143518. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143519. requestAnimationFrame: Function;
  143520. end(): Promise<void>;
  143521. renderState: XRRenderState;
  143522. inputSources: Array<XRInputSource>;
  143523. // AR hit test
  143524. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143525. updateWorldTrackingState(options: {
  143526. planeDetectionState?: { enabled: boolean; }
  143527. }): void;
  143528. }
  143529. interface XRReferenceSpace extends XRSpace {
  143530. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143531. onreset: any;
  143532. }
  143533. type XRPlaneSet = Set<XRPlane>;
  143534. type XRAnchorSet = Set<XRAnchor>;
  143535. interface XRFrame {
  143536. session: XRSession;
  143537. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143538. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143539. // Anchors
  143540. trackedAnchors?: XRAnchorSet;
  143541. // Planes
  143542. worldInformation: {
  143543. detectedPlanes?: XRPlaneSet;
  143544. };
  143545. }
  143546. interface XRViewerPose extends XRPose {
  143547. views: Array<XRView>;
  143548. }
  143549. interface XRPose {
  143550. transform: XRRigidTransform;
  143551. emulatedPosition: boolean;
  143552. }
  143553. interface XRWebGLLayerOptions {
  143554. antialias?: boolean;
  143555. depth?: boolean;
  143556. stencil?: boolean;
  143557. alpha?: boolean;
  143558. multiview?: boolean;
  143559. framebufferScaleFactor?: number;
  143560. }
  143561. declare var XRWebGLLayer: {
  143562. prototype: XRWebGLLayer;
  143563. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143564. };
  143565. interface XRWebGLLayer {
  143566. framebuffer: WebGLFramebuffer;
  143567. framebufferWidth: number;
  143568. framebufferHeight: number;
  143569. getViewport: Function;
  143570. }
  143571. declare class XRRigidTransform {
  143572. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143573. position: DOMPointReadOnly;
  143574. orientation: DOMPointReadOnly;
  143575. matrix: Float32Array;
  143576. inverse: XRRigidTransform;
  143577. }
  143578. interface XRView {
  143579. eye: XREye;
  143580. projectionMatrix: Float32Array;
  143581. transform: XRRigidTransform;
  143582. }
  143583. interface XRInputSourceChangeEvent {
  143584. session: XRSession;
  143585. removed: Array<XRInputSource>;
  143586. added: Array<XRInputSource>;
  143587. }
  143588. interface XRInputSourceEvent extends Event {
  143589. readonly frame: XRFrame;
  143590. readonly inputSource: XRInputSource;
  143591. }
  143592. // Experimental(er) features
  143593. declare class XRRay {
  143594. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143595. origin: DOMPointReadOnly;
  143596. direction: DOMPointReadOnly;
  143597. matrix: Float32Array;
  143598. }
  143599. interface XRHitResult {
  143600. hitMatrix: Float32Array;
  143601. }
  143602. interface XRAnchor {
  143603. // remove?
  143604. id?: string;
  143605. anchorSpace: XRSpace;
  143606. lastChangedTime: number;
  143607. detach(): void;
  143608. }
  143609. interface XRPlane extends XRAnchorCreator {
  143610. orientation: "Horizontal" | "Vertical";
  143611. planeSpace: XRSpace;
  143612. polygon: Array<DOMPointReadOnly>;
  143613. lastChangedTime: number;
  143614. }
  143615. interface XRAnchorCreator {
  143616. // AR Anchors
  143617. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143618. }